// Get Midi input from PD public void GetPDInput() { // Clear any previous Midi input CMidiInput.Instance().cMidiInfoList.Clear(); try { // Get any PD messages that might have been sent Ventuz.OSC.OscBundle cOSCBundle = mcUDPReader.ReceiveBundle(); // If there are no messages to retrieve if (cOSCBundle == null || cOSCBundle.Elements == null || cOSCBundle.Elements.Count <= 0) { // Exit the function return; } // Read in and Store all of the OSC Bundles contents while (cOSCBundle != null) { // Read in and Store the Contents of the OSC Bundle ReadAndStoreOSCBundleContents(cOSCBundle); // Get the next OSC Bundle from the queue cOSCBundle = mcUDPReader.ReceiveBundle(); } } // Catch all exceptions catch (Exception e) { // Display the error message MessageBox.Show(e.ToString(), "ERROR"); } }
// Get input from the player public void GetPDInput(bool bKeepPitchInRange) { // Clear any previous sound input, but save the Pitch from the last frame float fPreviousPitch = CSoundInput.Instance().fPitch; CSoundInput.Instance().Reset(); CSoundInput.Instance().fPitchLastFrame = fPreviousPitch; try { // Get any PD messages that might have been sent Ventuz.OSC.OscBundle cOSCBundle = mcUDPReader.ReceiveBundle(); // If there are no messages to retrieve if (cOSCBundle == null || cOSCBundle.Elements == null || cOSCBundle.Elements.Count <= 0) { // Exit the function return; } // If valid pitch input was not received yet AND there are more OSC Bundles to read while (cOSCBundle != null && !CSoundInput.mcInstance.bInputReceived) { // Read in and Store this OSC Bundles Contents ReadAndStoreOSCBundleContents(cOSCBundle, bKeepPitchInRange); // Get the next OSC Bundle in the queue cOSCBundle = mcUDPReader.ReceiveBundle(); } // Read in the any remaining Bundles to empty the queue while (cOSCBundle != null) { cOSCBundle = mcUDPReader.ReceiveBundle(); } } // Catch all exceptions catch (Exception e) { // Display the error message MessageBox.Show(e.ToString(), "ERROR"); } // Calculate how much the Pitch changed between frames CSoundInput.Instance().fPitchChange = CSoundInput.Instance().fPitch - CSoundInput.Instance().fPitchLastFrame; }