You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
2.7KB

  1. /*! \page realtime Realtime Audio (blocking)
  2. In this section, we modify the <TT>sineosc.cpp</TT> program in order
  3. to send the output to the default audio playback device on your
  4. computer system. We also make use of the stk::SineWave class as a
  5. sine-wave oscillator. stk::SineWave computes an internal, static sine-wave
  6. table when its first instance is created. Subsequent instances make
  7. use of the same table. The default table length, specified in
  8. SineWave.h, is 2048 samples.
  9. \include rtsine.cpp
  10. The class stk::RtWvOut is a protected subclass of stk::WvOut. A number of
  11. optional constructor arguments can be used to fine tune its
  12. performance for a given system. stk::RtWvOut provides a "single-sample",
  13. blocking interface to the RtAudio class. Note that stk::RtWvOut (as well
  14. as the stk::RtWvIn class described below) makes use of RtAudio's callback
  15. input/output functionality by creating a large ring-buffer into which
  16. data is written. These classes should not be used when low-latency
  17. and robust performance is necessary
  18. Though not used here, an stk::RtWvIn class exists as well that can be used
  19. to read realtime audio data from an input device. See the
  20. <TT>record.cpp</TT> example program in the <TT>examples</TT> project
  21. for more information.
  22. It may be possible to use an instance of stk::RtWvOut and an instance of
  23. stk::RtWvIn to simultaneously read and write realtime audio to and from a
  24. hardware device or devices. However, it is recommended to instead use
  25. a single instance of RtAudio to achieve this behavior, as described in the next section.
  26. See the <TT>effects</TT> project or the <TT>duplex.cpp</TT> example
  27. program in the <TT>examples</TT> project for more information.
  28. When using any realtime STK class (RtAudio, stk::RtWvOut, stk::RtWvIn, RtMidi, stk::InetWvIn, stk::InetWvOut, stk::Socket, stk::UdpSocket, stk::TcpServer, stk::TcpClient, and stk::Thread), it is necessary to specify an audio/MIDI API preprocessor definition and link with the appropriate libraries or frameworks. For example, the above program could be compiled on a Linux system using the GNU g++ compiler and the ALSA audio API as follows (assuming all necessary files exist in the project directory):
  29. \code
  30. g++ -Wall -D__LINUX_ALSA__ -D__LITTLE_ENDIAN__ -o rtsine Stk.cpp Generator.cpp SineWave.cpp WvOut.cpp \
  31. RtWvOut.cpp RtAudio.cpp rtsine.cpp -lpthread -lasound
  32. \endcode
  33. On a Macintosh OS X system, the syntax would be:
  34. \code
  35. g++ -Wall -D__MACOSX_CORE__ -o rtsine Stk.cpp Generator.cpp SineWave.cpp WvOut.cpp RtWvOut.cpp RtAudio.cpp \
  36. rtsine.cpp -lpthread -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
  37. \endcode
  38. [<A HREF="tutorial.html">Main tutorial page</A>] &nbsp; [<A HREF="crealtime.html">Next tutorial</A>]
  39. */