void ReportOscStart() { // stupid Vector2s: osc_falling_transpRange.Add(aud_falling_transpRange[0]); osc_falling_transpRange.Add(aud_falling_transpRange[1]); osc_falling_delay_timeRange.Add(mx_falling_delay_timeRange[0]); osc_falling_delay_timeRange.Add(mx_falling_delay_timeRange[1]); osc_falling_delay_lineDurRange.Add(mx_falling_delay_lineDurRange[0]); osc_falling_delay_lineDurRange.Add(mx_falling_delay_lineDurRange[1]); osc_curving_casetopRolly_delay_timeRange.Add(mx_curving_casetopRolly_delay_timeRange[0]); osc_curving_casetopRolly_delay_timeRange.Add(mx_curving_casetopRolly_delay_timeRange[1]); osc_curving_casetopRolly_delay_lineDurRange.Add(mx_curving_casetopRolly_delay_lineDurRange[0]); osc_curving_casetopRolly_delay_lineDurRange.Add(mx_curving_casetopRolly_delay_lineDurRange[1]); osc_curving_figure8s_1_transpRange.Add(aud_curving_figure8s_1_transpRange[0]); osc_curving_figure8s_1_transpRange.Add(aud_curving_figure8s_1_transpRange[1]); osc_curving_figure8s_1_delay_timeRange.Add(mx_curving_figure8s_1_delay_timeRange[0]); osc_curving_figure8s_1_delay_timeRange.Add(mx_curving_figure8s_1_delay_timeRange[1]); osc_curving_figure8s_1_delay_lineDurRange.Add(mx_curving_figure8s_1_delay_lineDurRange[0]); osc_curving_figure8s_1_delay_lineDurRange.Add(mx_curving_figure8s_1_delay_lineDurRange[1]); osc_curving_figure8s_2_transpRange.Add(aud_curving_figure8s_2_transpRange[0]); osc_curving_figure8s_2_transpRange.Add(aud_curving_figure8s_2_transpRange[1]); osc_curving_figure8s_2_delay_timeRange.Add(mx_curving_figure8s_2_delay_timeRange[0]); osc_curving_figure8s_2_delay_timeRange.Add(mx_curving_figure8s_2_delay_timeRange[1]); osc_curving_figure8s_2_delay_lineDurRange.Add(mx_curving_figure8s_2_delay_lineDurRange[0]); osc_curving_figure8s_2_delay_lineDurRange.Add(mx_curving_figure8s_2_delay_lineDurRange[1]); oscOutScript.Send("/igniter/" + self_id + "/on", aud_GO_born); oscOutScript.Send("/igniter/" + self_id + "/falling/begin", aud_falling_begin); oscOutScript.Send("/igniter/" + self_id + "/falling/bufferName", mx_falling_bufferName); oscOutScript.Send("/igniter/" + self_id + "/falling/startDur", aud_falling_bufferStartDur); oscOutScript.Send(osc_falling_transpRange); oscOutScript.Send(osc_falling_delay_timeRange); oscOutScript.Send(osc_falling_delay_lineDurRange); oscOutScript.Send("/igniter/" + self_id + "/falling/amp/global", aud_falling_globalAmp); oscOutScript.Send("/igniter/" + self_id + "/curving/casetopRollyPolly/bufferName", mx_curving_casetopRolly_bufferName); oscOutScript.Send("/igniter/" + self_id + "/curving/casetopRollyPolly/startDur", aud_curving_casetopRolly_bufferStartDur); oscOutScript.Send(osc_curving_casetopRolly_delay_timeRange); oscOutScript.Send(osc_curving_casetopRolly_delay_lineDurRange); oscOutScript.Send("/igniter/" + self_id + "/curving/casetopRollyPolly/amp/global", aud_curving_casetopRolly_globalAmp); oscOutScript.Send("/igniter/" + self_id + "/curving/figure8s/1/bufferName", mx_curving_figure8s_1_bufferName); oscOutScript.Send("/igniter/" + self_id + "/curving/figure8s/1/startDur", aud_curving_figure8s_1_bufferStartDur); oscOutScript.Send(osc_curving_figure8s_1_transpRange); oscOutScript.Send(osc_curving_figure8s_1_delay_timeRange); oscOutScript.Send(osc_curving_figure8s_1_delay_lineDurRange); oscOutScript.Send("/igniter/" + self_id + "/curving/figure8s/1/amp/global", aud_curving_figure8s_1_globalAmp); oscOutScript.Send("/igniter/" + self_id + "/curving/figure8s/2/bufferName", mx_curving_figure8s_2_bufferName); oscOutScript.Send("/igniter/" + self_id + "/curving/figure8s/2/startDur", aud_curving_figure8s_2_bufferStartDur); oscOutScript.Send(osc_curving_figure8s_2_transpRange); oscOutScript.Send(osc_curving_figure8s_2_delay_timeRange); oscOutScript.Send(osc_curving_figure8s_2_delay_lineDurRange); oscOutScript.Send("/igniter/" + self_id + "/curving/figure8s/2/amp/global", aud_curving_figure8s_2_globalAmp); aud_GO_born = false; aud_falling_begin = false; }
void Update() { // Send a message with one float argument. oscOut.Send( "/test1", Random.value ); // Send a message with a number of assorted argument types. oscOut.Send( "/test2", Random.value, "Text", false ); // Create a message and send it. OscMessage message = new OscMessage( "/test3" ); message.Add( "Allo" ); message.Add( "World" ); message.args[0] = "Hello"; // Let's say we want overwrite the first argument oscOut.Send( message ); }
void Update() { // Create a messege. OscMessage message = new OscMessage(address); // Create a timetag. Default time is DateTime.Now. OscTimeTag timetag = new OscTimeTag(); // Make it 1 milisecond into the future. timetag.time = timetag.time.AddMilliseconds(1); // Two possible methods for sending timetags ... if (sendTimeTagWithBundle) { // Either create a bundle with the timetag, add the message and send. OscBundle bundle = new OscBundle(timetag); bundle.Add(message); oscOut.Send(bundle); } else { // Or add the timetag to message and send it. message.Add(timetag); oscOut.Send(message); } // Incoming bundles are unpacked automatically and are never exposed. // In the case where we send the timetag with a bundle and want to // access them through incoming messages, we can ask OscIn to add // the timetags from bundles to each of their contained messages. oscIn.addTimeTagsToBundledMessages = sendTimeTagWithBundle; // Update label. sendLabel.text = timetag.time + ":" + timetag.time.Millisecond; }
private void Init() { for (int i = oscEventUiContainer.childCount - 1; i >= 0; --i) { DestroyImmediate(oscEventUiContainer.GetChild(i).gameObject); } timeMachineOscEvents.Clear(); foreach (var c in timeMachineTrackManeger.clipValues) { var oscEventValue = new TimeMachineOscEvent(); oscEventValue.address = $"/{c.name}"; oscEventValue.index = c.index; oscEventValue.name = c.name; timeMachineOscEvents.Add(oscEventValue); oscIn.MapInt(oscEventValue.address, OnReceiveMoveClipEvent); var ui = Instantiate(timeMachineOscEventUI, oscEventUiContainer); ui.oscIn = oscIn; ui.controller = this; ui.oscEvent = oscEventValue; var message = new OscMessage(); message.address = ui.oscAddress; message.Add(c.index); ui.SetTestOscMessage(oscOut, message); } // oscIn }
public void Send(string address, params object[] args) { OscMessage message = OscPool.GetMessage(address); message.Add(args); SendPooled(message); }
void Update() { // Send a message with one float argument. oscOut.Send("/test1", Random.value); // Send a message with a number of assorted argument types. oscOut.Send("/test2", Random.value, "Text", false); // Create a message and send it. OscMessage message = new OscMessage("/test3"); message.Add("Allo"); message.Add("World"); message.args[0] = "Hello"; // Let's say we want overwrite the first argument oscOut.Send(message); }
void UnpackRecursivelyAndDispatch(OscPacket packet) { if (packet is OscBundle) { OscBundle bundle = packet as OscBundle; foreach (OscPacket subPacket in bundle.packets) { if (_addTimeTagsToBundledMessages && subPacket is OscMessage) { OscMessage message = subPacket as OscMessage; message.Add(bundle.timeTag); } UnpackRecursivelyAndDispatch(subPacket); } OscPool.Recycle(bundle); } else { OscMessage message = packet as OscMessage; if (_filterDuplicates) { if (_uniqueAddresses.Contains(message.address)) { OscPool.Recycle(message); return; } _uniqueAddresses.Add(message.address); } Dispatch(packet as OscMessage); _messageCount++; // Influenced by _filterDuplicates. } }
// data[0] must always be the adress ; adress is taken from https://plugins.iem.at/docs/osc/#multiencoder // data[1] must always be the value to send public void SendOSCMessageToClient(string[] data) { OscMessage msg = new OscMessage(data[0]); msg.Add(data[1]); oscOut.Send(msg); //oscOut.Send(data[0], float.Parse(data[1])); }
// TCP // public void setupSocket() // { // try { // mySocket = new TcpClient(Host, Port); // theStream = mySocket.GetStream(); // theWriter = new StreamWriter(theStream); // theReader = new StreamReader(theStream); // socketReady = true; // } // catch (Exception e) { // Debug.Log("Socket error: " + e); // } // } // public void writeSocket(string theLine) // { // if (!socketReady) // return; // String foo = theLine + "\r\n"; // theWriter.Write(foo); // theWriter.Flush(); // } // public String readSocket() // { // if (!socketReady) // return ""; // if (theStream.DataAvailable) // return theReader.ReadLine(); // return ""; // } // public void closeSocket() // { // if (!socketReady) // return; // theWriter.Close(); // theReader.Close(); // mySocket.Close(); // socketReady = false; // } void checkTriggers(int panelNumber, int sensorNumber, float currentTouchValue) { String messageAddress = "/P" + panelNumber + "_" + sensorNumber; OscMessage triggerMessage = new OscMessage(messageAddress); triggerMessage.Add(clip_slot_triggers[panelNumber][sensorNumber]); oscout.Send(triggerMessage); Debug.Log("clip slot trigger message sent: " + messageAddress + "-" + clip_slot_triggers[panelNumber][sensorNumber] + " touch val:" + currentTouchValue); }
// Send some keyboard event such as : F1, F2, ... void SendKeyboardEvent(KeyCode keyCode) { OscMessage message = new OscMessage(oscKeyCodeAddress); message.Add(keyCode.ToString()); oscSend.Send(message); Debug.LogFormat("Sending keyboard event with ToryMessage : {0}", message.ToString()); }
// Send Time.realtimeSinceStartup as vital sign. void SendVital() { OscMessage message = new OscMessage(oscVitalAddress); message.Add(Time.realtimeSinceStartup); oscSend.Send(message); // Debug.Log(message.ToString()); }
public void SendPlayLog(params string[] log) { OscMessage message = new OscMessage(oscPlayLogAddress); foreach (string s in log) { message.Add(s); } oscSend.Send(message); // Debug.Log(message.ToString()); }
public void InitOSCEvent() { var newOscEventValue = new TimeMachineOscEvent(); newOscEventValue.address = oscAddress; newOscEventValue.index = timeMachineOscEvent.index; newOscEventValue.name = timeMachineOscEvent.name; oscIn.MapInt(newOscEventValue.address, controller.OnReceiveMoveClipEvent); oscEvent = newOscEventValue; var message = new OscMessage(); message.address = newOscEventValue.address; message.Add(newOscEventValue.index); testOscMessage = message; }
public void AddNewEvent() { var oscEventValue = new TimeMachineOscEvent(); oscEventValue.address = "/Test"; oscEventValue.index = 0; oscEventValue.name = "Test"; timeMachineOscEvents.Add(oscEventValue); // oscIn.MapInt( oscEventValue.address,OnReceiveMoveClipEvent ); var ui = Instantiate(timeMachinePlainOscEventUI, oscEventUiContainer); ui.oscEvent = oscEventValue; var message = new OscMessage(); message.address = ui.oscAddress; message.Add(oscEventValue.index); ui.SetTestOscMessage(oscOut, message); }
void Start() { // Ensure that we have a OscOut component. if (!_oscOut) { _oscOut = gameObject.AddComponent <OscOut>(); } // Prepare for sending messages locally on this device on port 7000. _oscOut.Open(7000); // ... or, alternatively target a remote devices with an IP Address. //oscOut.Open( 7000, "192.168.1.101" ); // If you want to send a single value then you can use this one-liner. _oscOut.Send(address1, Random.value); // If you want to send a message with multiple values, then you // need to create a message, add your values and send it. // Always cache messages you create, so that you can reuse them. _message2 = new OscMessage(address2); _message2.Add(Time.frameCount).Add(Time.time).Add(Random.value); _oscOut.Send(_message2); }
// UPDATE void Update() { if (Input.GetKey("up") && !manualStart) { calibrateReadings(); } if (Input.GetKeyDown("space")) { manualStart = true; Debug.Log("manual start!!"); } if (firstTime) { Debug.Log("first time"); firstTime = false; oscout.Send("/start", 1); InitialStart(); } if (nowRunning) { AnalyseSound(); updateVisualisation(); } // ***** reading sensors for (int j = 0; j < numberofarduinos; j++) { //readings = allReadings [j]; try{ switch (j) { case 0: strIn = portPanel0.readingsData; break; case 1: strIn = portPanel1.readingsData; break; case 2: strIn = portPanel2.readingsData; break; case 3: strIn = portPanel3.readingsData; break; default: break; } //strIn = ReadFromArduino(j); //Debug.Log("receieved from arduino" + j + ":" + strIn); if (strIn != null) { strIn = strIn.Trim(); string[] readingsText = strIn.Split(' '); if (readingsText.Length == numberBubbles) { for (int i = 0; i < numberBubbles; i++) { readingsText[i] = readingsText[i].Trim(); bool Result; int number; Result = int.TryParse(readingsText[i], out number); if (Result) { //readings[i] = number; allReadings[j][i] = number; //Debug.Log("arduino:" + j + " bubble:" + i + " reading:" + number + " allReadings:" + allReadings[j][i]); } else { Debug.Log("failed"); } } //allReadings [j] = readings; } } } catch (TimeoutException) { Debug.Log("timeout exception"); } } readingsToSend = ""; // **** process readings for (int o = 0; o < numberofarduinos; o++) { for (int p = 0; p < numberBubbles; p++) { // *** creating string for MAX //Debug.Log ("allreadings" + o + ":" + allReadings [o][p]); float currentDiff = restValues[o][p] - allReadings[o][p]; float maxDiff = restValues[o][p] - pressedValues[o][p]; float percentDiff = currentDiff / maxDiff; if (percentDiff < 0) { percentDiff = 0; } if (percentDiff > 1) { percentDiff = 1; } // int valueForMax = Mathf.RoundToInt(percentDiff * 128); // String panelID = "/panel" + o + "_" + p; // Debug.Log(panelID + ":" + valueForMax); // oscout.Send(panelID, valueForMax); // readingsToSend += valueForMax + " "; readingsToSend += percentDiff + " "; // *** send specific triggers to max if (nowRunning) { if (percentDiff > touchThreshold && clip_slot_triggers[o][p] == 0) { Debug.Log("press clip_slot_trigger current value pre:" + clip_slot_triggers[o][p] + "percentDiff:" + percentDiff); clip_slot_triggers[o][p] = 1; Debug.Log("press clip_slot_trigger current value post:" + clip_slot_triggers[o][p] + "percentDiff:" + percentDiff); checkTriggers(o, p, percentDiff); } if (percentDiff < 0.05f && clip_slot_triggers[o][p] == 1) { Debug.Log("not press the clip_slot_trigger for pre panel" + o + "_" + p + " is:" + clip_slot_triggers[o][p] + " should be 0"); clip_slot_triggers[o][p] = 0; Debug.Log("not press the clip_slot_trigger for post panel" + o + "_" + p + " is:" + clip_slot_triggers[o][p] + " should be 0"); } } // *** check for first touch to start everything if (!firstTime && !nowRunning && manualStart) { if (percentDiff > touchThreshold) { firstTime = true; } } } } // Debug.Log(readingsToSend); OscMessage readingsMessage = new OscMessage("/touch"); readingsMessage.Add(readingsToSend); oscout.Send(readingsMessage); //writeSocket(readingsToSend); //sendStringUDP(readingsToSend); updateBubbles(); }
void Beatings_SpinEvent() { // we'll add extra tones to the model list, to create beatings / spin sound // **** we generate the extra frequencies constantly, scaled to the rate of spin so it will sound like its spinning **** // **** an evolving list of F, A, D **** lightSpinEvent_freqs = new List <float>(modelFreqs); // lightSpinEvent_amps = new List<float>( modelAmps ); // lightSpinEvent_decays = new List<float>( modelDecays ); InstantiateOscAddrs_SpinEvent(); foreach (float freq in modelFreqs) { osc_freqsSpin.Add(freq); } foreach (float amp in modelAmps) { osc_ampsSpin.Add(amp); } foreach (float decay in modelDecays) { osc_decaysSpin.Add(decay); } for (int f = 0; f < modelFreqs.Count; f++) { // fundamental if (f == 0) { criticalBand = 24.7f * ((0.00437f * modelFreqs[f]) + 1); half_criticalBand = criticalBand / 2; float lightSpinEvent_spinDeltaClamped = Mathf.Clamp(lightSpinEvent_spinDelta, 0f, .1f); percentOfCriticalBand = Scale(lightSpinEvent_spinDeltaClamped, 0.0f, .1f, mx_lightSpinEvent_fund_percentOfCriticalBandRange[0], mx_lightSpinEvent_fund_percentOfCriticalBandRange[1]); percentOfCriticalBandFreq = modelFreqs[f] + (percentOfCriticalBand * half_criticalBand); osc_freqsSpin.Add(percentOfCriticalBandFreq); osc_ampsSpin.Add(RandomAmp("louder", aud_lightEventType)); osc_decaysSpin.Add(RandomDecay("slower")); // for debug: lightSpinEvent_freqs.Add(percentOfCriticalBandFreq); // lightSpinEvent_amps.Add( RandomAmp( "louder" ) ); // lightSpinEvent_decays.Add( RandomDecay( "slower" ) ); } /* * // upper partials * // too noisy - for now * else * { * criticalBand = 24.7f * ((0.00437f * modelFreqs[f]) + 1); * half_criticalBand = criticalBand / 2; * float lightSpinEvent_spinDeltaClamped = Mathf.Clamp(lightSpinEvent_spinDelta, 0f, .1f); * percentOfCriticalBand = Scale(lightSpinEvent_spinDeltaClamped, 0.0f, .1f, mx_lightSpinEvent_fund_percentOfCriticalBandRange[0], mx_lightSpinEvent_fund_percentOfCriticalBandRange[1]); * percentOfCriticalBandFreq = modelFreqs[f] + (percentOfCriticalBand * half_criticalBand); * * osc_freqsSpin.Add(percentOfCriticalBandFreq); * osc_ampsSpin.Add(RandomAmp("softer", aud_lightEventType)); * osc_decaysSpin.Add(RandomDecay("faster")); * * lightSpinEvent_freqs.Add(percentOfCriticalBandFreq); * }*/ } /* * if (selectedGO != null) * { * if (selectedGO.name == this.transform.name) * { * if( osc_freqsSpin != null ) * { * Debug.Log("not null"); * } * } * }*/ }
void Update() { // If we are going to send 'as bundle', then we would like OSC io // to add the timetag to the messeges contained in the bundle. oscIn.addTimeTagsToBundledMessages = sendAsBundle; // Create a messege OscMessage message = new OscMessage( address ); // Create a timetag. Default time is DateTime.Now. OscTimeTag timetag = new OscTimeTag(); // Make it 1 milisecond into the future. timetag.time = timetag.time.AddMilliseconds( 1 ); // Two possible methods for sending timetags ... if( sendAsBundle ) { // Either create a bundle with the timetag, add the message and send. OscBundle bundle = new OscBundle( timetag ); bundle.Add( message ); oscOut.Send( bundle ); } else { // Or add the timetag to message and send it. message.Add( timetag ); oscOut.Send( message ); } // Update label. sendLabel.text = timetag.time + ":" + timetag.time.Millisecond; }
void Beatings_FlareEvent() { // we'll add extra tones to the model list, to create beatings / interest / shimmer around each fundamental and partial // **** we only generate the extra frequencies once, on event On - this isn't an evolving list of F, A, D **** lightFlareEvent_freqs = new List <float>(modelFreqs); // <-- for troubleshooting InstantiateOscAddrs_FlareEvent(); discModelParams = makeDiscsModel_script.discModelParams; sc_lightFlareEvent_shimmer_percentOfCriticalBandRange = discModelParams.lightFlareEvent_shimmer_percentOfCriticalBandRange; foreach (float freq in modelFreqs) { osc_freqsFlare.Add(freq); } foreach (float amp in modelAmps) { osc_ampsFlare.Add(amp); } foreach (float decay in modelDecays) { osc_decaysFlare.Add(decay); } for (int f = 0; f < modelFreqs.Count; f++) { criticalBand = 24.7f * ((0.00437f * modelFreqs[f]) + 1); half_criticalBand = criticalBand / 2; // fundamental - add three extra tones if (f == 0) { for (int e = 0; e < 3; e++) { percentOfCriticalBand = Random.Range(sc_lightFlareEvent_shimmer_percentOfCriticalBandRange[0], sc_lightFlareEvent_shimmer_percentOfCriticalBandRange[1]); percentOfCriticalBandFreq = modelFreqs[f] + (percentOfCriticalBand * half_criticalBand); osc_freqsFlare.Add(percentOfCriticalBandFreq); osc_ampsFlare.Add(RandomAmp("louder", aud_lightEventType)); osc_decaysFlare.Add(RandomDecay("slower")); // for debug: lightFlareEvent_freqs.Add(percentOfCriticalBandFreq); // lightFlareEvent_amps.Add( RandomAmp( "louder" ) ); // lightFlareEvent_decays.Add( RandomDecay( "slower" ) ); } } // upper partials - add two extra tones each else { for (int e = 0; e < 2; e++) { percentOfCriticalBand = Random.Range(sc_lightFlareEvent_shimmer_percentOfCriticalBandRange[0], sc_lightFlareEvent_shimmer_percentOfCriticalBandRange[1]); percentOfCriticalBandFreq = modelFreqs[f] + (percentOfCriticalBand * half_criticalBand); osc_freqsFlare.Add(percentOfCriticalBandFreq); osc_ampsFlare.Add(RandomAmp("softer", aud_lightEventType)); osc_decaysFlare.Add(RandomDecay("faster")); lightFlareEvent_freqs.Add(percentOfCriticalBandFreq); } } } }