Mercurial > hg > beaglert
comparison core/Scope.cpp @ 474:efc9a9f8e63d prerelease
Libpd added scope support and example
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 20 Jun 2016 20:38:46 +0100 |
parents | 421a69d42943 |
children | 506a319c08cf |
comparison
equal
deleted
inserted
replaced
473:2a0b468ce1dd | 474:efc9a9f8e63d |
---|---|
18 | 18 |
19 numChannels = _numChannels; | 19 numChannels = _numChannels; |
20 sampleRate = _sampleRate; | 20 sampleRate = _sampleRate; |
21 | 21 |
22 // setup the OSC server && client | 22 // setup the OSC server && client |
23 // used for sending / recieving settings | 23 // used for sending / receiving settings |
24 // oscClient has it's send task turned off, as we only need to send one handshake message | 24 // oscClient has it's send task turned off, as we only need to send one handshake message |
25 oscServer.setup(OSC_RECIEVE_PORT); | 25 oscServer.setup(OSC_RECEIVE_PORT); |
26 oscClient.setup(OSC_SEND_PORT, "127.0.0.1", false); | 26 oscClient.setup(OSC_SEND_PORT, "127.0.0.1", false); |
27 | 27 |
28 // setup the udp socket | 28 // setup the udp socket |
29 // used for sending raw frame data | 29 // used for sending raw frame data |
30 socket.setServer("127.0.0.1"); | 30 socket.setServer("127.0.0.1"); |
34 scopeTriggerTask = Bela_createAuxiliaryTask(Scope::triggerTask, BELA_AUDIO_PRIORITY-2, "scopeTriggerTask", this, true); | 34 scopeTriggerTask = Bela_createAuxiliaryTask(Scope::triggerTask, BELA_AUDIO_PRIORITY-2, "scopeTriggerTask", this, true); |
35 scopeSendBufferTask = Bela_createAuxiliaryTask(Scope::sendBufferTask, BELA_AUDIO_PRIORITY-1, "scopeSendBufferTask", this); | 35 scopeSendBufferTask = Bela_createAuxiliaryTask(Scope::sendBufferTask, BELA_AUDIO_PRIORITY-1, "scopeSendBufferTask", this); |
36 | 36 |
37 // send an OSC message to address /scope-setup | 37 // send an OSC message to address /scope-setup |
38 // then wait 1 second for a reply on /scope-setup-reply | 38 // then wait 1 second for a reply on /scope-setup-reply |
39 bool handshakeRecieved = false; | 39 bool handshakeReceived = false; |
40 oscClient.sendMessageNow(oscClient.newMessage.to("/scope-setup").add((int)numChannels).add(sampleRate).end()); | 40 oscClient.sendMessageNow(oscClient.newMessage.to("/scope-setup").add((int)numChannels).add(sampleRate).end()); |
41 oscServer.recieveMessageNow(1000); | 41 oscServer.receiveMessageNow(1000); |
42 while (oscServer.messageWaiting()){ | 42 while (oscServer.messageWaiting()){ |
43 if (handshakeRecieved){ | 43 if (handshakeReceived){ |
44 parseMessage(oscServer.popMessage()); | 44 parseMessage(oscServer.popMessage()); |
45 } else if (oscServer.popMessage().match("/scope-setup-reply")){ | 45 } else if (oscServer.popMessage().match("/scope-setup-reply")){ |
46 handshakeRecieved = true; | 46 handshakeReceived = true; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 if (handshakeRecieved && connected) | 50 if (handshakeReceived && connected) |
51 start(); | 51 start(); |
52 | 52 |
53 } | 53 } |
54 | 54 |
55 void Scope::start(){ | 55 void Scope::start(){ |
80 started = false; | 80 started = false; |
81 } | 81 } |
82 | 82 |
83 void Scope::log(float chn1, ...){ | 83 void Scope::log(float chn1, ...){ |
84 | 84 |
85 // check for any recieved OSC messages | 85 // check for any received OSC messages |
86 while (oscServer.messageWaiting()){ | 86 while (oscServer.messageWaiting()){ |
87 parseMessage(oscServer.popMessage()); | 87 parseMessage(oscServer.popMessage()); |
88 } | 88 } |
89 | 89 |
90 if (!started) return; | 90 if (!started) return; |