// Sends the MIDI control message. IEnumerator sendControl(int beatNumber, float transposeValue) { yield return(new WaitForSeconds(0)); MidiBridge.instance.Warmup(); MidiOut.SendControlChange(channel, macroControllerList [beatNumber], transposeValue); }
public override void VJPerformAction(GameObject go, float value) { if (m_lastValue != value) { MidiOut.SendControlChange(midiChannel, knobNumber, Mathf.Clamp01(value)); m_lastValue = value; } }
public void sendCC(float val) { float adjustedVal = Mathf.Min(1, val * ccScale); currentVal = (adjustedVal * kFilteringFactor) + (currentVal * (1.0f - kFilteringFactor)); MidiOut.SendControlChange(channel, controlNumber, currentVal); //highestVal = Mathf.Max (val, highestVal); //Debug.Log ("CC Val: " + val + ", Highest: " + currentVal); }
// Turns all the drums off, by setting all transposes = -1. IEnumerator Warmup() { yield return(new WaitForSeconds(0.2f)); MidiBridge.instance.Warmup(); MidiOut.SendControlChange(channel, macroControllerList[0], 0); MidiOut.SendControlChange(channel, macroControllerList[1], 0); MidiOut.SendControlChange(channel, macroControllerList[2], 0); MidiOut.SendControlChange(channel, macroControllerList[3], 0); MidiOut.SendControlChange(channel, macroControllerList[4], 0); MidiOut.SendControlChange(channel, macroControllerList[5], 0); MidiOut.SendControlChange(channel, macroControllerList[6], 0); MidiOut.SendControlChange(channel, macroControllerList[7], 0); }
void Update() { if (Input.GetKeyDown(KeyCode.A)) { // source select A-1 MidiOut.SendControlChange(MidiChannel.Ch1, 0, 0); MidiOut.SendControlChange(MidiChannel.Ch1, 32, 0); MidiOut.SendProgramChange(MidiChannel.Ch1, 0, 0); } if (Input.GetKeyDown(KeyCode.S)) { // source select A-2 MidiOut.SendControlChange(MidiChannel.Ch1, 0, 0); MidiOut.SendControlChange(MidiChannel.Ch1, 32, 0); MidiOut.SendProgramChange(MidiChannel.Ch1, 1, 0); } }
public void StayOnSequencer(CircleCollider2D coll) { // Obtain all the variables and objects we need. // References ThalmicMyo thalmicMyo = myo.GetComponent <ThalmicMyo> (); GameObject cur = GameObject.FindGameObjectWithTag("Cursor"); // current gameObject hovered on: the beat object. GameObject currentBeatHovered = coll.gameObject; // Get the difference between the current rotation direction and the direction of rotation when the collider was entered. // Multiply by factor knobRotateScale. Vector3 rotationFromEnteredAngle = new Vector3(0, 0, (cur.transform.rotation.eulerAngles.z - vectorOnEnteringBeat.z) * knobRotateScale); // Calculate the final orientation of the beat - giving a euler z of +/- 360 degrees. Vector3 finalRotationOfBeat = currentVectorOfBeat + rotationFromEnteredAngle; // Clamp the angle of rotation. Calculate the control value percentage to be sent. Vector3 clampedFinalRotationOfBeat = new Vector3(0, 0, ClampAngle(finalRotationOfBeat.z, -127f, 128f)); float controlValueFloat = ((-clampedFinalRotationOfBeat.z + 127f) / 256f); // Route the control value int to the UI as well. int controlValue = Mathf.RoundToInt(controlValueFloat * 16f) - 1; // What is the current beat number? string beatNumberString = coll.gameObject.name.Substring(coll.gameObject.name.Length - 1); int beatNumber = int.Parse(beatNumberString) - 1; // Reference the beat text canvas to access the text fields. GameObject beatTextCanvas = GameObject.FindGameObjectWithTag("Beat text canvas drums"); TextMesh[] beatTextArray = beatTextCanvas.GetComponentsInChildren <TextMesh>(); //listen for a change in gesture if (previousGesture != thalmicMyo.pose) { if (thalmicMyo.pose == Pose.Fist) { // turn on if fist made if (isDrumsOn == false) { isDrumsOn = true; transposeCounter = 1; Sprite fullCircle = Resources.Load <Sprite> ("white_circle_full"); currentBeatHovered.GetComponent <SpriteRenderer> ().sprite = fullCircle; } // else turn off else { isDrumsOn = false; transposeCounter = 0; Sprite emptyCircle = Resources.Load <Sprite> ("white_circle"); currentBeatHovered.GetComponent <SpriteRenderer> ().sprite = emptyCircle; } } } // if previous is fist and current is still fist, listen for rolls. // allows the user to hold fist and rotate arm to change the drum note if (previousGesture == thalmicMyo.pose && thalmicMyo.pose == Pose.Fist) { // Store the beatNumber and controlValueFloat (the percentage) in a global var to be sent to the coroutine. beatNumberToBePassed = beatNumber; controlValueToBePassed = controlValueFloat; // Update the drum note text field beatTextArray[beatNumber].text = getInstrumentName(controlValueFloat).ToString() + ": " + core808[getInstrumentName(controlValueFloat)]; // Update the orientation of the beat object, which is used as an 'invisible' knob. coll.gameObject.transform.localEulerAngles = clampedFinalRotationOfBeat; // Update the previous orientation of the beat object to the current one. previousFinalRotationOfBeat = finalRotationOfBeat; // Start the control coroutine for Midi CC out. if (isDrumsOn == true) { StartCoroutine(sendControl(beatNumberToBePassed, controlValueToBePassed)); } } previousGesture = thalmicMyo.pose; if (isDrumsOn == false) { // If the drums aren't on, set the drums to transpose = -1. MidiBridge.instance.Warmup(); MidiOut.SendControlChange(channel, macroControllerList [beatNumber], 0); } }
IEnumerator controlChange(float value) { MidiBridge.instance.Warmup(); MidiOut.SendControlChange(channel, controlNumber, value); yield return(new WaitForSeconds(0)); }