IEnumerator DoBeep(int i) { midiStreamSynthesizer.NoteOn(0, Beep[i].Note, Beep[i].Volume, Beep[i].Instrument); yield return(new WaitForSeconds(Beep[i].Duration)); midiStreamSynthesizer.NoteOff(0, Beep[i].Note); }
/** * Play one single note * The note can be referenced by constants in class NOTES * When note==-1, just stop the note which we just played using this method */ public void setNote(int note) { midiStreamSynthesizer.NoteOff(0, midiNote); if (note != -1) { this.midiNote = note; midiStreamSynthesizer.NoteOn(0, midiNote, midiNoteVolume, midiInstrument); } }
// Update is called every frame, if the // MonoBehaviour is enabled. void Update() { if (!midiSequencer.isPlaying) { //if (!GetComponent<AudioSource>().isPlaying) if (ShouldPlayFile) { LoadSong(midiFilePath); } } else if (!ShouldPlayFile) { midiSequencer.Stop(true); } if (Input.GetButtonDown("Fire1")) { midiStreamSynthesizer.NoteOn(0, midiNote, midiNoteVolume, midiInstrument); } if (Input.GetButtonUp("Fire1")) { midiStreamSynthesizer.NoteOff(0, midiNote); } }
IEnumerator PlayNote(int note, int vol, int inst, float duration) { midiStreamSynthesizer.NoteOn(1, note, vol, inst); yield return(new WaitForSeconds(duration)); midiStreamSynthesizer.NoteOff(1, note); }
IEnumerator DoBeep(int i) { midiStreamSynthesizer.NoteOn(0, midiNote + i, midiNoteVolume, midiInstrument); yield return(new WaitForSeconds(0.4f)); midiStreamSynthesizer.NoteOff(0, midiNote + i); }
public void PlayNote(int note, int volume, int instrument = -1) { if (instrument == -1) { instrument = midiInstrument; } midiNote = note; midiNoteVolume = volume; midiStreamSynthesizer.NoteOn(0, midiNote, midiNoteVolume, instrument); }
// Update is called every frame, if the // MonoBehaviour is enabled. void Update() { if (Input.GetButtonDown("Fire1")) { midiStreamSynthesizer.NoteOn(0, midiNote, midiNoteVolume, midiInstrument); } if (Input.GetButtonUp("Fire1")) { midiStreamSynthesizer.NoteOff(0, midiNote); } Nuotti.text = _violinFirstPosNotes[Nuottinumero % 55]; }
// Update is called every frame, if the // MonoBehaviour is enabled. void Update() { if (!midiSequencer.isPlaying) { //if (!GetComponent<AudioSource>().isPlaying) if (ShouldPlayFile) { LoadSong(midiFilePath); if (synchTimer > 0 && !hasStartedTrack) { synchTimer -= Time.deltaTime; } else if (!hasStartedTrack) { midiSequencer.Play(); hasStartedTrack = true; } } } else if (!ShouldPlayFile) { midiSequencer.Stop(true); midiSequencerDelayed.Stop(true); } if (Input.GetButtonDown("Fire1")) { midiStreamSynthesizer.NoteOn(0, midiNote, midiNoteVolume, midiInstrument); } if (Input.GetButtonUp("Fire1")) { midiStreamSynthesizer.NoteOff(0, midiNote); } }
public void PlayMidiNote(int midiNote) { InitIfNotDoneYet(); midiStreamSynthesizer.NoteOn(0, midiNote, midiVelocity, midiInstrument); }
public void ProcessMidiEvent(MidiEvent midiEvent) { if (midiEvent.midiChannelEvent != MidiHelper.MidiChannelEvent.None) { switch (midiEvent.midiChannelEvent) { case MidiHelper.MidiChannelEvent.Program_Change: if (midiEvent.channel != 9) { if (midiEvent.parameter1 < synth.SoundBank.InstrumentCount) { currentPrograms[midiEvent.channel] = midiEvent.parameter1; } } else //its the drum channel { if (midiEvent.parameter1 < synth.SoundBank.DrumCount) { currentPrograms[midiEvent.channel] = midiEvent.parameter1; } } break; case MidiHelper.MidiChannelEvent.Note_On: if (blockList.Contains(midiEvent.channel)) { return; } if (this.NoteOnEvent != null) { this.NoteOnEvent(midiEvent.channel, midiEvent.parameter1, midiEvent.parameter2); } synth.NoteOn(midiEvent.channel, midiEvent.parameter1, midiEvent.parameter2, currentPrograms[midiEvent.channel]); break; case MidiHelper.MidiChannelEvent.Note_Off: if (this.NoteOffEvent != null) { this.NoteOffEvent(midiEvent.channel, midiEvent.parameter1); } synth.NoteOff(midiEvent.channel, midiEvent.parameter1); break; case MidiHelper.MidiChannelEvent.Pitch_Bend: //Store PitchBend as the # of semitones higher or lower synth.TunePositions[midiEvent.channel] = (double)midiEvent.Parameters[1] * PitchWheelSemitoneRange; break; case MidiHelper.MidiChannelEvent.Controller: switch (midiEvent.GetControllerType()) { case MidiHelper.ControllerType.AllNotesOff: synth.NoteOffAll(true); break; case MidiHelper.ControllerType.MainVolume: synth.VolPositions[midiEvent.channel] = midiEvent.parameter2 / 127.0f; break; case MidiHelper.ControllerType.Pan: synth.PanPositions[midiEvent.channel] = (midiEvent.parameter2 - 64) == 63 ? 1.00f : (midiEvent.parameter2 - 64) / 64.0f; break; case MidiHelper.ControllerType.ResetControllers: ResetControllers(); break; default: break; } break; default: break; } } else { switch (midiEvent.midiMetaEvent) { case MidiHelper.MidiMetaEvent.Tempo: _MidiFile.BeatsPerMinute = MidiHelper.MicroSecondsPerMinute / System.Convert.ToUInt32(midiEvent.Parameters[0]); break; default: break; } } }
public void StartPlayingKey(int channel, int note, int volume, int instrumentNumber) { //UnityEditor.EditorUtility.DisplayDialog("A", volume.ToString(), "A"); midiStreamSynthesizer.NoteOn(channel, note, volume, instrumentNumber); }
// Update is called every frame, if the // MonoBehaviour is enabled. void Update() { //Demo of direct note output if (Input.GetKeyDown(KeyCode.A)) { midiStreamSynthesizer.NoteOn(1, midiNote, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.A)) { midiStreamSynthesizer.NoteOff(1, midiNote); } if (Input.GetKeyDown(KeyCode.W)) { midiStreamSynthesizer.NoteOn(1, midiNote + 1, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.W)) { midiStreamSynthesizer.NoteOff(1, midiNote + 1); } if (Input.GetKeyDown(KeyCode.S)) { midiStreamSynthesizer.NoteOn(1, midiNote + 2, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.S)) { midiStreamSynthesizer.NoteOff(1, midiNote + 2); } if (Input.GetKeyDown(KeyCode.E)) { midiStreamSynthesizer.NoteOn(1, midiNote + 3, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.E)) { midiStreamSynthesizer.NoteOff(1, midiNote + 3); } if (Input.GetKeyDown(KeyCode.D)) { midiStreamSynthesizer.NoteOn(1, midiNote + 4, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.D)) { midiStreamSynthesizer.NoteOff(1, midiNote + 4); } if (Input.GetKeyDown(KeyCode.F)) { midiStreamSynthesizer.NoteOn(1, midiNote + 5, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.F)) { midiStreamSynthesizer.NoteOff(1, midiNote + 5); } if (Input.GetKeyDown(KeyCode.T)) { midiStreamSynthesizer.NoteOn(1, midiNote + 6, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.T)) { midiStreamSynthesizer.NoteOff(1, midiNote + 6); } if (Input.GetKeyDown(KeyCode.G)) { midiStreamSynthesizer.NoteOn(1, midiNote + 7, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.G)) { midiStreamSynthesizer.NoteOff(1, midiNote + 7); } if (Input.GetKeyDown(KeyCode.Y)) { midiStreamSynthesizer.NoteOn(1, midiNote + 8, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.Y)) { midiStreamSynthesizer.NoteOff(1, midiNote + 8); } if (Input.GetKeyDown(KeyCode.H)) { midiStreamSynthesizer.NoteOn(1, midiNote + 9, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.H)) { midiStreamSynthesizer.NoteOff(1, midiNote + 9); } if (Input.GetKeyDown(KeyCode.U)) { midiStreamSynthesizer.NoteOn(1, midiNote + 10, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.U)) { midiStreamSynthesizer.NoteOff(1, midiNote + 10); } if (Input.GetKeyDown(KeyCode.J)) { midiStreamSynthesizer.NoteOn(1, midiNote + 11, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.J)) { midiStreamSynthesizer.NoteOff(1, midiNote + 11); } if (Input.GetKeyDown(KeyCode.K)) { midiStreamSynthesizer.NoteOn(1, midiNote + 12, midiNoteVolume, midiInstrument); } if (Input.GetKeyUp(KeyCode.K)) { midiStreamSynthesizer.NoteOff(1, midiNote + 12); } }
// note on/off event에 사용되는 함수들 public void MidiNoteOnHandler(int channel, int note, int velocity) { midiStreamSynthesizer.NoteOn(channel, note, velocity, midiInstrument); }
public void PlayNote(int midiNote, float volumeMultiplier) { midiStreamSynthesizer.NoteOn(0, midiNote, (int)(midiNoteVolume * volumeMultiplier), midiInstrument); }
// Keys: // P/S: Play/Stop // N: Normalize matrix // G: Toggle song generation on/off (play and stop combined, for generated) // ` (tilde/backquote): Mute/Unmute all channels // If any channel is not muted, this will mute all. Else it unmutes all. // 1-9,0: Produce the next note on that channel void Update() { frameCount = Time.frameCount; // add some play/stop keys since I'm not using the GUILayout stuff. if (Input.GetKeyDown(KeyCode.P)) { midiSequencer.Play(); } else if (Input.GetKeyDown(KeyCode.S)) { midiSequencer.Stop(true); } if (Input.GetKeyDown(KeyCode.D)) { Debug.Log("MinChannel: " + minChannel); Debug.Log("MaxChannel: " + maxChannel); Debug.Log("MinNote: " + minNote); Debug.Log("MaxNote: " + maxNote); } if (Input.GetKeyDown(KeyCode.R)) { displayNextBlock(); } if (Input.GetKeyDown(KeyCode.G)) { generating = !generating; } if (Input.GetKeyDown(KeyCode.BackQuote)) { if (allMute) { midiSequencer.UnMuteAllChannels(); } else { midiSequencer.MuteAllChannels(); allMute = true; } } for (int key = 0; key < 10; key++) { if (Input.GetKeyUp(key.ToString())) { midiStreamSynthesizer.NoteOff(key, lastNote[key]); } if (Input.GetKeyDown(key.ToString())) { int note = getNote(key, lastNote[key], lastLastNote[key]); Debug.Log("Generated: " + note + " on channel " + key); if (note < 0) { continue; } midiStreamSynthesizer.NoteOn(key, note, 127, 0); lastLastNote[key] = lastNote[key]; lastNote[key] = note; } } }
// Update is called every frame, if the // MonoBehaviour is enabled. public void play(int note, int instrument) { midiStreamSynthesizer.NoteOn(0, note, midiNoteVolume, instrument); }