Commit 2f4d247b authored by jcaceres's avatar jcaceres
Browse files

merged with trunk -r114

parent a9c1bac4
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
* audioDevice.cpp * audioDevice.cpp
*/ */
#include "audioDevice.h" #include "AudioDevice.h"
#include <time.h> #include <ctime>
using namespace std; using namespace std;
AudioDevice::AudioDevice (bool testMode) AudioDevice::AudioDevice (bool testMode)
......
...@@ -35,12 +35,12 @@ ...@@ -35,12 +35,12 @@
#define _AUDIO_DEVICE_H #define _AUDIO_DEVICE_H
#include <iostream> #include <iostream>
#include <stdlib.h> #include <cstdlib>
#include <math.h> #include <cmath>
#include "audioInfo.h" #include "audioInfo.h"
#include "JackClient.h" #include "JackClient.h"
#include "qthread.h" #include <QThread>
#include "StreamBD.h" #include "JackTrip.h"
#include <QWaitCondition> #include <QWaitCondition>
#include <QSemaphore> #include <QSemaphore>
......
...@@ -35,14 +35,14 @@ ...@@ -35,14 +35,14 @@
* *
*/ */
#include "audio_input.h" #include "AudioInput.h"
#include "stream.h" #include "Stream.h"
#include <iostream> #include <iostream>
using namespace std; using namespace std;
AudioInput::AudioInput (AudioDevice * audioDevice, AudioInfoT audioInfo): AudioInput::AudioInput (AudioDevice * audioDevice, AudioInfoT audioInfo):
InputPlugin ("Audio Input Plugin"), InputStreamPlugin ("Audio Input StreamPlugin"),
audioDevice (audioDevice), audioInfo (audioInfo) audioDevice (audioDevice), audioInfo (audioInfo)
{ {
dontRun = audioInfo->jack; dontRun = audioInfo->jack;
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#ifndef _AUDIO_INPUT_H #ifndef _AUDIO_INPUT_H
#define _AUDIO_INPUT_H #define _AUDIO_INPUT_H
#include "input_plugin.h" #include "InputStreamPlugin.h"
#include "audioDevice.h" #include "AudioDevice.h"
#include "audioInfo.h" #include "audioInfo.h"
/** /**
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
* on a Stream. * on a Stream.
*/ */
class AudioInput:public InputPlugin class AudioInput:public InputStreamPlugin
{ {
private: private:
AudioDevice * audioDevice; AudioDevice * audioDevice;
......
...@@ -31,16 +31,16 @@ ...@@ -31,16 +31,16 @@
* audio_output.cpp * audio_output.cpp
*/ */
#include "audio_output.h" #include "AudioOutput.h"
#include "stream.h" #include "Stream.h"
//#include "ambisonics/ambisonicsdecoder.h" //#include "ambisonics/ambisonicsdecoder.h"
#include <string.h> #include <cstring>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
AudioOutput::AudioOutput (AudioDevice * audioDevice, AudioInfoT audioInfo): AudioOutput::AudioOutput (AudioDevice * audioDevice, AudioInfoT audioInfo):
OutputPlugin ("Audio Output plugin"), OutputStreamPlugin ("Audio Output plugin"),
audioDevice (audioDevice), audioInfo (audioInfo), decoder (NULL) audioDevice (audioDevice), audioInfo (audioInfo), decoder (NULL)
{ {
dontRun = audioInfo->jack; dontRun = audioInfo->jack;
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#ifndef _AUDIO_OUTPUT_H #ifndef _AUDIO_OUTPUT_H
#define _AUDIO_OUTPUT_H #define _AUDIO_OUTPUT_H
#include "output_plugin.h" #include "OutputStreamPlugin.h"
#include "audioDevice.h" #include "AudioDevice.h"
#include "audioInfo.h" #include "audioInfo.h"
class AmbisonicsDecoder; class AmbisonicsDecoder;
...@@ -44,7 +44,7 @@ class AmbisonicsDecoder; ...@@ -44,7 +44,7 @@ class AmbisonicsDecoder;
* @brief Sends audio buffers from a Stream to the RtAudio (sound) device. * @brief Sends audio buffers from a Stream to the RtAudio (sound) device.
*/ */
class AudioOutput:public OutputPlugin class AudioOutput:public OutputStreamPlugin
{ {
private: private:
AudioDevice * audioDevice; AudioDevice * audioDevice;
......
/*! \mainpage StreamBD Documentation
*
*
* Download streamBD <a
href="http://www-ccrma.stanford.edu/groups/soundwire/software/newstream/newstream1_0b.tar.gz">here</a>.
* \n
* View installation and run <a href="INSTRUCTIONS.TXT">instructions</a>.
* \n
* If you encounter CommonC++ errors (compile-time errors that begin cc_ )
* Download CommonC++1.5.0 (http://cplusplus.sourceforge.net) from here:
* <a
href="http://www-ccrma.stanford.edu/groups/soundwire/software/newstream/commomc++-1.5.0.tar>http://www-ccrma.stanford.edu/groups/soundwire/software/newstream/commonc++-1.5.0.tar</a>.
* \n
*\section intro Introduction
*
* StreamBD provides low-latency uncompressed audio streaming over high quality networks.
* It can be used to route audio streams across a high quality network, or to use the network
* connection as the delay line in a simple string synthesis to "pluck" the network, and generate
* a multi-channel network harp as described in our ICASSP2002 <a href="http://www-ccrma.stanford.edu/%7Ecc/soundwire/icassp02.pdf">paper</a>.
*
* As an audio stream router it consists of the following four nodes:
* \n\n
* audioin, audioout, netin, netout.
* \n\n
* Streambd can be run in any of the following modes to achieve any
* possible connection of input to output.
* \n\n
* <B>Transmit</B>\n
* Run with a remote hostname, this mode establishes a
* connection to a remote host running in RECEIVE mode. It
* patches audio in exactly the same way RECEIVE does:
* audioin to netout, netin to audioout. Use one machine in
* TRANSMIT mode and one machine in RECEIVE mode to establish
* a bidirectional connection.
* \n\n
* <B>Receive</B>\n
* Listen for a connection from another machine running in
* TRANSMIT mode. When contacted, patch audioin to netout and
* netin to audioout. Use one machine in RECEIVE mode and one
* machine in TRANSMIT mode to establish a bidirectional
* connection.
* \n\n
* <B>Netmirror</B>\n
* Patch netin to netout. Do not create audioin or audioout.
* (No audio interface is needed.) The input stream from the
* network is streamed straight to the network output. When run
* the program listens for a connection. When contacted by
* another machine running in TRANSMIT mode, it establishes a
* return connection. Use this mode to test your connection to
* a remote machine.
* \n\n
* <B>Sndmirror</B> \n
* Patch audioin to audioout. Do not create netin or netout.
* (No network interface is needed.) All sound input is streamed
* straight to the sound output. Use this mode to test audio
* hardware.
* \n\n
* <B>HarpT</B>\n
* Run with a hostname, this mode connects to a HARPR receiver
* machine, and adds STK low pass filtering or delay (to
* "tune" the different strings of the Netharp). Coefficients
* for the STK processes are specified at the command line (off
* by default).
* \n\n
* <B>HarpR</B>\n
* Connected to by a HARPT. Can also apply processes so that
* synthesis CPU requirements can be shared between the
* two machines (low-pass filtering on one, delay on the other.)
* \n\n
* Questions or comments: Daniel Walling (<a href="mailto:dwalling@ccrma.stanford.edu">dwalling@ccrma.stanford.edu</a>).
*/
/**********************************************************************
* File: streambd.h
**********************************************************************
* A project of the SoundWIRE research group at CCRMA
* http://www-ccrma.stanford.edu/groups/soundwire/
* --------------------------------------------------------------------
* Coded by Daniel Walling (dwalling@ccrma.stanford.edu)
* Based on Scott Wilson's streambd code (rswilson@ccrma.stanford.edu)
* --------------------------------------------------------------------
*/
#ifndef _STREAM_BD_H
#define _STREAM_BD_H
#endif
...@@ -36,18 +36,18 @@ ...@@ -36,18 +36,18 @@
#ifndef _INPUT_PLUGIN_H #ifndef _INPUT_PLUGIN_H
#define _INPUT_PLUGIN_H #define _INPUT_PLUGIN_H
#include "plugin.h" #include "StreamPlugin.h"
class Stream; class Stream;
class InputPlugin : public Plugin class InputStreamPlugin : public StreamPlugin
{ {
protected: protected:
int key; int key;
Stream *stream; Stream *stream;
public: public:
InputPlugin(const char *name) : key( -1 ) InputStreamPlugin(const char *name) : key( -1 )
{ {
this->setName(name); this->setName(name);
this->dontRun = false; this->dontRun = false;
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
*/ */
#include "JackClient.h" #include "JackClient.h"
#include "math.h" #include <cmath>
#include "string.h" #include <cstring>
#include "audioDevice.h" #include "AudioDevice.h"
//#include "qstring.h" //#include "qstring.h"
#include <QString> #include <QString>
//#include <q3textstream.h> //#include <q3textstream.h>
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
#define _JACKCLIENT_H_ #define _JACKCLIENT_H_
#include <jack/jack.h> #include <jack/jack.h>
#include "stdio.h" #include <cstdio>
#include "stdlib.h" #include <cstdlib>
#include <qstring.h> #include <QString>
class AudioDevice; class AudioDevice;
class JackClient//:public Stk class JackClient//:public Stk
......
...@@ -28,20 +28,23 @@ ...@@ -28,20 +28,23 @@
*/ */
/* /*
* StreamBD.cpp * JackTrip.cpp
*/ */
//#include "StreamBD.h" //#include "JackTrip.h"
#include "audioDevice.h" #include "AudioDevice.h"
using namespace std; using namespace std;
extern QString * extern QString *
IPv4Addr (char *namebuf); IPv4Addr (char *namebuf);
/**
* @brief return fifo priority for streambd. //---------------------------------------------------------------------------------------------
/*! \brief Returns fifo priority for streambd.
*
*/ */
//---------------------------------------------------------------------------------------------
int int
get_fifo_priority (bool half) get_fifo_priority (bool half)
{ {
...@@ -52,13 +55,16 @@ get_fifo_priority (bool half) ...@@ -52,13 +55,16 @@ get_fifo_priority (bool half)
if (half) priority = (max - (max - min) / 2); if (half) priority = (max - (max - min) / 2);
else else
priority = max; priority = max;
// priority=min; //priority=min;
return priority; return priority;
} }
/**
* @brief Set fifo priority (if user has sufficient privileges). //---------------------------------------------------------------------------------------------
/*! \brief Set fifo priority (if user has sufficient privileges).
*
*/ */
//---------------------------------------------------------------------------------------------
int int
set_fifo_priority (bool half) set_fifo_priority (bool half)
{ {
...@@ -94,20 +100,33 @@ set_fifo_priority (bool half) ...@@ -94,20 +100,33 @@ set_fifo_priority (bool half)
} }
StreamBD::StreamBD() //---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
JackTrip::JackTrip()
{ {
args = new cmdLineArgs; args = new cmdLineArgs;
} }
StreamBD::~StreamBD() //---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
JackTrip::~JackTrip()
{ {
// TODO: put destructor code here // TODO: put destructor code here
} }
//---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
int int
StreamBD::cmd (MainDialog *eventThread) JackTrip::cmd (MainDialog *eventThread)
{ {
// Get the local host address // Get the local host address
QString *localhostName = GetLocalHostName (); QString *localhostName = GetLocalHostName ();
...@@ -170,7 +189,7 @@ StreamBD::cmd (MainDialog *eventThread) ...@@ -170,7 +189,7 @@ StreamBD::cmd (MainDialog *eventThread)
t.netin = new UDPInput (netInfo, audioInfo); t.netin = new UDPInput (netInfo, audioInfo);
t.netout = new UDPOutput (netInfo, audioInfo); t.netout = new UDPOutput (netInfo, audioInfo);
ConnectPlugins (t.netin, t.netout, t.streamout); ConnectStreamPlugins (t.netin, t.netout, t.streamout);
break; break;
//remove STK dependency //remove STK dependency
...@@ -182,7 +201,7 @@ StreamBD::cmd (MainDialog *eventThread) ...@@ -182,7 +201,7 @@ StreamBD::cmd (MainDialog *eventThread)
addSTKProcesses (t.streamin); addSTKProcesses (t.streamin);
ConnectPlugins (t.netin, t.netout, t.streamin); ConnectStreamPlugins (t.netin, t.netout, t.streamin);
audioDevice = new AudioDevice (args->audioDeviceID, audioDevice = new AudioDevice (args->audioDeviceID,
args-> args->
...@@ -192,7 +211,7 @@ StreamBD::cmd (MainDialog *eventThread) ...@@ -192,7 +211,7 @@ StreamBD::cmd (MainDialog *eventThread)
t.audioout = new AudioOutput (audioDevice, audioInfo); t.audioout = new AudioOutput (audioDevice, audioInfo);
addPlugin (t.audioout, t.streamin); addStreamPlugin (t.audioout, t.streamin);
// Synchronize network packet transfers to audio device tick rate. // Synchronize network packet transfers to audio device tick rate.
t.streamin->synchronizeOutputsTo (t.audioout); t.streamin->synchronizeOutputsTo (t.audioout);
...@@ -206,7 +225,7 @@ StreamBD::cmd (MainDialog *eventThread) ...@@ -206,7 +225,7 @@ StreamBD::cmd (MainDialog *eventThread)
addSTKProcesses (t.streamout); addSTKProcesses (t.streamout);
ConnectPlugins (t.netin, t.netout, t.streamout); ConnectStreamPlugins (t.netin, t.netout, t.streamout);
break; break;
*/ */
...@@ -221,7 +240,7 @@ StreamBD::cmd (MainDialog *eventThread) ...@@ -221,7 +240,7 @@ StreamBD::cmd (MainDialog *eventThread)
t.audioin = new AudioInput (audioDevice, audioInfo); t.audioin = new AudioInput (audioDevice, audioInfo);
t.audioout = new AudioOutput (audioDevice, audioInfo); t.audioout = new AudioOutput (audioDevice, audioInfo);
ConnectPlugins (t.audioin, t.audioout, t.streamout); ConnectStreamPlugins (t.audioin, t.audioout, t.streamout);
break; break;
default: default:
...@@ -237,12 +256,12 @@ StreamBD::cmd (MainDialog *eventThread) ...@@ -237,12 +256,12 @@ StreamBD::cmd (MainDialog *eventThread)
audioDevice->setThreads(t); audioDevice->setThreads(t);
t.netin = new UDPInput (netInfo, audioInfo); t.netin = new UDPInput (netInfo, audioInfo);
t.netin->setGUI((QObject *)eventThread); //t.netin->setGUI((QObject *)eventThread);
t.netout = new UDPOutput (netInfo, audioInfo); t.netout = new UDPOutput (netInfo, audioInfo);
t.netout->setGUI((QObject *)eventThread); //t.netout->setGUI((QObject *)eventThread);
ConnectPlugins (t.audioin, t.netout, t.streamout); ConnectStreamPlugins (t.audioin, t.netout, t.streamout);
ConnectPlugins (t.netin, t.audioout, t.streamin); ConnectStreamPlugins (t.netin, t.audioout, t.streamin);
} }
...@@ -283,13 +302,22 @@ StreamBD::cmd (MainDialog *eventThread) ...@@ -283,13 +302,22 @@ StreamBD::cmd (MainDialog *eventThread)
} }
//---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
void void
StreamBD::start () JackTrip::start ()
{ {
} }
//---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
void void
StreamBD::finish () JackTrip::finish ()
{ {
cout << "Finishing" << endl; cout << "Finishing" << endl;
if (args->jack) if (args->jack)
...@@ -302,36 +330,52 @@ StreamBD::finish () ...@@ -302,36 +330,52 @@ StreamBD::finish ()
cout << "stopped streamout threads" << endl; cout << "stopped streamout threads" << endl;
} }
//---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
void void
StreamBD::go () JackTrip::go ()
/* cause run loop to start */ /* cause run loop to start */
{ {
start (); start ();
} }
//---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
void void
StreamBD::stop () JackTrip::stop ()
/* cause run loop to finish */ /* cause run loop to finish */
{ {
// loop = false; not a thread // loop = false; not a thread
finish(); finish();
} }
//---------------------------------------------------------------------------------------------
/*! \brief
*/
//---------------------------------------------------------------------------------------------
void void
StreamBD::join () JackTrip::join ()
/* wait for thread to exit */ /* wait for thread to exit */
{ {
// wait (); not a thread // wait (); not a thread
} }
//---------------------------------------------------------------------------------------------
/* PrintUsage(struct cmdLineArgs *args) /*! \brief PrintUsage()
* ------------------------------------ *
* Print all of the command line arguments and their default values * Print all of the command line arguments and their default values
*/ */
//---------------------------------------------------------------------------------------------
void void
StreamBD::PrintUsage () JackTrip::PrintUsage ()
{ {
cout << "===========================================================================" << endl; cout << "===========================================================================" << endl;
cout << " jacktrip A project of the SoundWIRE group at CCRMA, Stanford." << endl; cout << " jacktrip A project of the SoundWIRE group at CCRMA, Stanford." << endl;
...@@ -373,14 +417,16 @@ StreamBD::PrintUsage () ...@@ -373,14 +417,16 @@ StreamBD::PrintUsage ()
endl; endl;