Debian Codegraph @

docs/_sources/examples/04-soundfiles/04-record-perf.rst.txt

raw
1 04-record-perf.py - Recording the performance on disk.
2 ============================================================================================================================================
3
4
5 The Server object allow the recording of the overall playback
6 (that is exactly what your hear). The "Rec Start" button of the
7 Server's window is doing that with default parameters. It'll
8 record a file called "pyo_rec.wav" (16-bit, 44100 Hz) on the
9 user's desktop.
10
11 You can control the recording with the Server's method called
12 `recordOptions`, the arguments are:
13
14 - dur : The duration of the recording, a value of -1 means
15 record forever (recstop() must be called by the user).
16 - filename : Indicates the location of the recorded file.
17 - fileformat : The format of the audio file (see documentation
18 for available formats).
19 - sampletype : The sample type of the audio file (see documentation
20 for available types).
21
22 The recording can be triggered programmatically with the Server's
23 methods `recstart()` and `recstop()`. In order to record multiple files
24 from a unique performance, it is possible to set the filename
25 with an argument to `recstart()`.
26
27 .. code-block:: python
28
29 from pyo import *
30 import os
31
32 s = Server().boot()
33
34 # Path of the recorded sound file.
35 path = os.path.join(os.path.expanduser("~"), "Desktop", "synth.wav")
36 # Record for 10 seconds a 24-bit wav file.
37 s.recordOptions(dur=10, filename=path, fileformat=0, sampletype=1)
38
39 # Creates an amplitude envelope
40 amp = Fader(fadein=1, fadeout=1, dur=10, mul=0.3).play()
41
42 # A Simple synth
43 lfo = Sine(freq=[0.15, 0.16]).range(1.25, 1.5)
44 fm2 = CrossFM(carrier=200, ratio=lfo, ind1=10, ind2=2, mul=amp).out()
45
46 # Starts the recording for 10 seconds...
47 s.recstart()
48
49 s.gui(locals())
50