gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

open_default_stream.dox (2760B)


      1 /** @page open_default_stream Opening a Stream Using Defaults
      2 @ingroup tutorial
      3 
      4 The next step is to open a stream, which is similar to opening a file. You can specify whether you want audio input and/or output, how many channels, the data format, sample rate, etc. Opening a ''default'' stream means opening the default input and output devices, which saves you the trouble of getting a list of devices and choosing one from the list. (We'll see how to do that later.)
      5 @code
      6 #define SAMPLE_RATE (44100)
      7 static paTestData data;
      8 
      9 .....
     10 
     11     PaStream *stream;
     12     PaError err;
     13 
     14     /* Open an audio I/O stream. */
     15     err = Pa_OpenDefaultStream( &stream,
     16                                 0,          /* no input channels */
     17                                 2,          /* stereo output */
     18                                 paFloat32,  /* 32 bit floating point output */
     19                                 SAMPLE_RATE,
     20                                 256,        /* frames per buffer, i.e. the number
     21                                                    of sample frames that PortAudio will
     22                                                    request from the callback. Many apps
     23                                                    may want to use
     24                                                    paFramesPerBufferUnspecified, which
     25                                                    tells PortAudio to pick the best,
     26                                                    possibly changing, buffer size.*/
     27                                 patestCallback, /* this is your callback function */
     28                                 &data ); /*This is a pointer that will be passed to
     29                                                    your callback*/
     30     if( err != paNoError ) goto error;
     31 @endcode
     32 
     33 The data structure and callback are described in \ref writing_a_callback.
     34 
     35 The above example opens the stream for writing, which is sufficient for playback. It is also possible to open a stream for reading, to do recording, or both reading and writing, for simultaneous recording and playback or even real-time audio processing. If you plan to do playback and recording at the same time, open only one stream with valid input and output parameters.
     36 
     37 There are some caveats to note about simultaneous read/write:
     38 
     39  - Some platforms can only open a read/write stream using the same device.
     40  - Although multiple streams can be opened, it is difficult to synchronize them.
     41  - Some platforms don't support opening multiple streams on the same device.
     42  - Using multiple streams may not be as well tested as other features.
     43  - The PortAudio library calls must be made from the same thread or synchronized by the user.
     44 
     45 
     46 Previous: \ref initializing_portaudio | Next: \ref start_stop_abort
     47 
     48 */