/**** Multi-channel simulator: designed to mimic the acquisition of signals from a digitizer and send them out a socket using the OSC protocol. Creates arbitrary number of channels with arbitrary buffer size at an arbitrary (simulated) digitization rate. The content of each channel is a continuous sine wave. Note: By default, each message contains each channel's buffer, which is sent as soon as it is filled. To bundle the messages (to send all channels at once per buffer), uncomment the appropriate lines. Brian D. Allen MIT Media Lab - Synth Neuro Group http://www.syntheticneurobiology.org 2/26/2010 OSC code (using OSCpack) modified from Ross Bencina's example at http://www.audiomulch.com/~rossb/code/oscpack/ *****/ #include "osc/OscOutboundPacketStream.h" #include "ip/UdpSocket.h" #include #include #include #include #include #include #include "HighResTimer.h" #include #include #define ADDRESS "127.0.0.1" #define PORT 9000 #define PI 3.14159 #define OSC_BUFFER_SIZE 5012 // This buffer size is set to accomodate 1000 floats. S smaller buffer could be used for less floats (use p.Size() to check packet size) #define DAQ_BUFFER_SIZE 100 // Number of floats #define DAQ_RATE 1000.0 #define DAQ_CHANNELS 16 using namespace std; UdpTransmitSocket transmitSocket( IpEndpointName( ADDRESS, PORT ) ); char buffer[OSC_BUFFER_SIZE]; osc::OutboundPacketStream p( buffer, OSC_BUFFER_SIZE ); Timer timer; double t0 = timer.seconds(); double previous_buffer = t0; double current_time; double delta; double loop_time; int counter = 0; vector chan_num_str_vect; int main(int argc, char* argv[]) { // create the channel names for (int chan=0; chan= ((double)DAQ_BUFFER_SIZE / DAQ_RATE)) { previous_buffer = current_time; //cout << current_time << endl; //p << osc::BeginBundleImmediate; ********* If you're bundling the messages, uncomment this for (int chan=0; chan ((double) DAQ_BUFFER_SIZE / (double) DAQ_RATE)) { cout << "The (simulated) acquisition + OSC send loop is not executing fast enough. Try decreasing the DAQ_RATE or increasing the DAQ_BUFFER_SIZE" << endl; } } return 0; }