/// <summary> /// /// </summary> /// <param name="noteOn"></param> public void AddNote(TaggedNoteOnEvent noteOn) { for (int i = 0; i < orderedNotes.Count; i++) { if (orderedNotes[i].NoteNumber == noteOn.NoteNumber) { orderedNotes[i].Velocity = noteOn.Velocity; return; } } if (orderedNotes.Count == 0) { FirstAddedNote = noteOn; LastPassedNote = null; } orderedNotes.Add(noteOn); calculateArp(); if (RetriggerType == RetriggerType.Note)// || orderedNotes.Count == 1) { Retrigger(); } }
private void PianoControl1_NoteOn(object sender, TaggedNoteOnEvent e) { if (toolStripComboBoxProg.SelectedIndex != 0) { //Program change var pe = new ProgramChangeEvent((SevenBitNumber)(toolStripComboBoxProg.SelectedIndex - 1)); foreach (var i in instruments) { i.NotifyMidiEvent(pe); } foreach (var i in instruments) { i.NotifyMidiEvent(e); } } else { if (timbres != null) { for (int i = 0; i < instruments.Count; i++) { e.Tag = new NoteOnTimbreInfo(timbres[i], TimbreNo); instruments[i].NotifyMidiEvent(e); } } else { foreach (var i in instruments) { i.NotifyMidiEvent(e); } } } }
/// <summary> /// /// </summary> /// <returns></returns> private int searchEmptySlot(TaggedNoteOnEvent note, MT32Timbre timbre) { int emptySlot = -1; emptySlot = SearchEmptySlotAndOff(parentModule, instOnSounds, note, 32); return(emptySlot); }
private void metroButtonPlay_MouseDown(object sender, MouseEventArgs e) { Allophones = metroTextBoxAllophones.Text; ValueChanged?.Invoke(this, EventArgs.Empty); noteOnEvent = new TaggedNoteOnEvent((SevenBitNumber)69, (SevenBitNumber)127); noteOnEvent.Tag = new NoteOnTimbreInfo(timbre, timbreNo); inst.NotifyMidiEvent(noteOnEvent); }
/// <summary> /// /// </summary> /// <param name="note"></param> public override SoundBase[] SoundOn(TaggedNoteOnEvent note) { List <SoundBase> rv = new List <SoundBase>(); var bts = parentModule.GetBaseTimbres(note); var ids = parentModule.GetBaseTimbreIndexes(note); int tindex = 0; for (int i = 0; i < bts.Length; i++) { C140Timbre timbre = (C140Timbre)bts[i]; tindex++; var emptySlot = searchEmptySlot(note); if (emptySlot.slot < 0) { continue; } C140Sound snd = new C140Sound(emptySlot.inst, this, timbre, tindex - 1, note, emptySlot.slot, (byte)ids[i]); instOnSounds.Add(snd); //HACK: store pcm data to local buffer to avoid "thread lock" if (timbre.SoundType == SoundType.INST) { lock (parentModule.tmpPcmDataTable) parentModule.tmpPcmDataTable[ids[i]] = timbre.PcmData; } /* * else if (timbre.SoundType == SoundType.DRUM) * { * var pct = (C140PcmTimbre)parentModule.DrumSoundTable.PcmTimbres[note.NoteNumber]; * lock (parentModule.tmpPcmDataTable) * parentModule.tmpPcmDataTable[note.NoteNumber + 128] = pct.C140PcmData; * } */ FormMain.OutputDebugLog(parentModule, "KeyOn INST ch" + emptySlot + " " + note.ToString()); rv.Add(snd); } for (int i = 0; i < rv.Count; i++) { var snd = rv[i]; if (!snd.IsDisposed) { ProcessKeyOn(snd); } else { rv.Remove(snd); i--; } } return(rv.ToArray()); }
/// <summary> /// /// </summary> /// <returns></returns> public TaggedNoteOnEvent PeekNextNote() { var tmpSrpStep = arpStep; if (SkipNextNote) { tmpSrpStep++; } var tmpArpOctaveCount = arpOctaveCount; if (tmpSrpStep >= arpNotes.Count) { //ステップをループする tmpSrpStep = 0; tmpArpOctaveCount++; if (tmpArpOctaveCount >= Range) { tmpArpOctaveCount = 0; } } //次のノートを取得 TaggedNoteOnEvent an = null; if (StepStyle != ArpStepStyle.Random) { an = arpNotes[tmpSrpStep]; } else { an = arpNotes[random.Next(arpNotes.Count)]; } tmpSrpStep++; var nan = new TaggedNoteOnEvent(an.NoteNumber, an.Velocity) { Channel = an.Channel }; //オクターブを上げる処理 if (tmpArpOctaveCount > 0) { int oc = tmpArpOctaveCount; if (StepStyle == ArpStepStyle.Random) { oc = random.Next(Range - 1); } oc *= 12; if (nan.NoteNumber + oc < 128) { nan.NoteNumber += (SevenBitNumber)oc; } } return(nan); }
private void listBox1_MouseUp(object sender, MouseEventArgs e) { if (noteOnEvent != null) { NoteOffEvent noe = new NoteOffEvent(noteOnEvent.NoteNumber, noteOnEvent.Velocity); inst.NotifyMidiEvent(noe); noteOnEvent = null; } }
/// <summary> /// /// </summary> /// <returns></returns> public TaggedNoteOnEvent NextNote() { if (SkipNextNote) { arpStep++; SkipNextNote = false; } if (arpStep >= arpNotes.Count) { //ステップをループする arpStep = 0; arpOctaveCount++; if (arpOctaveCount >= Range) { arpOctaveCount = 0; } } //次のノートを取得 TaggedNoteOnEvent an = null; if (StepStyle != ArpStepStyle.Random) { an = arpNotes[arpStep]; } else { an = arpNotes[random.Next(arpNotes.Count)]; } arpStep++; var nan = new TaggedNoteOnEvent(an.NoteNumber, an.Velocity) { Channel = an.Channel }; //オクターブを上げる処理 if (arpOctaveCount > 0) { int oc = arpOctaveCount; if (StepStyle == ArpStepStyle.Random) { oc = random.Next(Range - 1); } oc *= 12; if (nan.NoteNumber + oc < 128) { nan.NoteNumber += (SevenBitNumber)oc; } } LastPassedNote = nan; return(nan); }
/// <summary> /// /// </summary> /// <param name="note"></param> public override SoundBase[] SoundOn(TaggedNoteOnEvent note) { List <SoundBase> rv = new List <SoundBase>(); int tindex = 0; foreach (GBAPUTimbre timbre in parentModule.GetBaseTimbres(note)) { tindex++; var emptySlot = searchEmptySlot(note, timbre); if (emptySlot.slot < 0) { continue; } GbSound snd = new GbSound(emptySlot.inst, this, timbre, tindex - 1, note, emptySlot.slot); switch (timbre.SoundType) { case SoundType.SPSG: spsgOnSounds.Add(snd); break; case SoundType.PSG: psgOnSounds.Add(snd); break; case SoundType.WAV: wavOnSounds.Add(snd); break; case SoundType.NOISE: noiseOnSounds.Add(snd); break; } rv.Add(snd); } for (int i = 0; i < rv.Count; i++) { var snd = rv[i]; if (!snd.IsDisposed) { ProcessKeyOn(snd); } else { rv.Remove(snd); i--; } } return(rv.ToArray()); }
private void metroButton2_MouseDown(object sender, MouseEventArgs e) { var mb = (MetroButton)sender; string allophone = mb.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[0]; noteOnEvent = new TaggedNoteOnEvent((SevenBitNumber)69, (SevenBitNumber)127); noteOnEvent.Tag = new NoteOnTimbreInfo(timbre, timbreNo) { Tag = allophone }; inst.NotifyMidiEvent(noteOnEvent); }
/// <summary> /// /// </summary> /// <param name="slot">チップ上の物理的なチャンネル(MIDI chと区別するためスロットとする)</param> protected SoundBase(InstrumentBase parentModule, SoundManagerBase manager, TimbreBase timbre, int baseTimbreIndex, TaggedNoteOnEvent noteOnEvent, int slot) { NoteOnEvent = noteOnEvent; Slot = slot; ParentModule = parentModule; ParentManager = manager; Timbre = timbre; BaseTimbreIndex = baseTimbreIndex; if (ParentModule.ChannelTypes[NoteOnEvent.Channel] == ChannelType.Drum) { DrumTimbre = ParentModule.DrumTimbres[NoteOnEvent.NoteNumber]; } }
private void listBox1_MouseDown(object sender, MouseEventArgs e) { int idx = listBox1.IndexFromPoint(e.Location); PresetVoice pv = (PresetVoice)listBox1.Items[idx]; LpcData = pv.LpcData; ValueChanged?.Invoke(this, EventArgs.Empty); noteOnEvent = new TaggedNoteOnEvent((SevenBitNumber)69, (SevenBitNumber)127); noteOnEvent.Tag = new NoteOnTimbreInfo(timbre, timbreNo); inst.NotifyMidiEvent(noteOnEvent); }
private void PianoControl1_NoteOn(object sender, TaggedNoteOnEvent e) { try { //InstrumentManager.ExclusiveLockObject.EnterUpgradeableReadLock(); e.Tag = new NoteOnTimbreInfo(Timbre, TimbreNo); Instrument.NotifyMidiEvent(e); } finally { //InstrumentManager.ExclusiveLockObject.ExitUpgradeableReadLock(); } }
/// <summary> /// /// </summary> /// <param name="note"></param> public override SoundBase[] SoundOn(TaggedNoteOnEvent note) { List <SoundBase> rv = new List <SoundBase>(); int tindex = 0; foreach (SN76496Timbre timbre in parentModule.GetBaseTimbres(note)) { tindex++; var emptySlot = searchEmptySlot(note, timbre); if (emptySlot.slot < 0) { continue; } SN76496Sound snd = new SN76496Sound(emptySlot.inst, this, timbre, tindex - 1, note, emptySlot.slot); switch (((SN76496Timbre)timbre).SoundType) { case SoundType.PSG: psgOnSounds.Add(snd); FormMain.OutputDebugLog(parentModule, "KeyOn PSG ch" + emptySlot + " " + note.ToString()); break; case SoundType.NOISE: noiseOnSounds.Add(snd); FormMain.OutputDebugLog(parentModule, "KeyOn NOISE ch" + emptySlot + " " + note.ToString()); break; } rv.Add(snd); } for (int i = 0; i < rv.Count; i++) { var snd = rv[i]; if (!snd.IsDisposed) { ProcessKeyOn(snd); } else { rv.Remove(snd); i--; } } return(rv.ToArray()); }
protected override void OnMouseMove(MouseEventArgs e) { if (dataEntryPressed) { InternalEntryDataValue = (SystemInformation.MouseWheelScrollDelta * 127 * (Height - e.Y)) / Height; Invalidate(new Rectangle(0, 0, wKeyW, Height)); } else { for (int keyNum = 0; keyNum < 128; keyNum++) { bool black; GraphicsPath path = getKeyPath(keyNum, out black); var r = new Region(path); if (r.IsVisible(e.Location)) { if (lastKeyOn >= 0) { if (lastKeyOn != keyNum) { lastKeyOff(); lastKeyOn = keyNum; var rect = path.GetBounds(); var velo = (127 * (e.Y - (Height / 6))) / (Height / 3); if (velo < 1) { velo = 1; } if (velo > 127) { velo = 127; } var noe = new TaggedNoteOnEvent((SevenBitNumber)keyNum, (SevenBitNumber)velo); NoteOn?.Invoke(this, noe); } } } } } }
/// <summary> /// /// </summary> /// <returns></returns> private (SN76496 inst, int slot) searchEmptySlot(TaggedNoteOnEvent note, SN76496Timbre timbre) { var emptySlot = (parentModule, -1); switch (timbre.SoundType) { case SoundType.PSG: { emptySlot = SearchEmptySlotAndOffForLeader(parentModule, psgOnSounds, note, 3); break; } case SoundType.NOISE: { emptySlot = SearchEmptySlotAndOffForLeader(parentModule, noiseOnSounds, note, 1); break; } } return(emptySlot); }
/// <summary> /// /// </summary> /// <returns></returns> private (GB_APU inst, int slot) searchEmptySlot(TaggedNoteOnEvent note, GBAPUTimbre timbre) { var emptySlot = (parentModule, -1); switch (timbre.SoundType) { case SoundType.SPSG: { emptySlot = SearchEmptySlotAndOffForLeader(parentModule, spsgOnSounds, note, 1); break; } case SoundType.PSG: { if (timbre.PartialReserveSPSG) { emptySlot = SearchEmptySlotAndOffForLeader(parentModule, psgOnSounds, note, 1); } else { emptySlot = SearchEmptySlotAndOffForLeader(parentModule, psgOnSounds, note, 2); } break; } case SoundType.WAV: { emptySlot = SearchEmptySlotAndOffForLeader(parentModule, wavOnSounds, note, 1); break; } case SoundType.NOISE: { emptySlot = SearchEmptySlotAndOffForLeader(parentModule, noiseOnSounds, note, 1); break; } } return(emptySlot); }
/// <summary> /// /// </summary> /// <param name="midiEvent"></param> protected override void OnNoteOnEvent(TaggedNoteOnEvent midiEvent) { //var its = (HuC6280)InstrumentManager.GetInstruments(16).ElementAt(0); //for (int i = 0; i < its.Timbres.Length; i++) //{ // for (int j = 0; j < 32; j++) // Timbres[i].WsgData[j] = (byte)(its.Timbres[i].WsgData[j] / 2); // if((int)its.Timbres[i].SoundType == 2) // Timbres[i].SoundType = SoundType.NOISE; // else // Timbres[i].SoundType = SoundType.WSG; // Timbres[i].SDS.SerializeData = its.Timbres[i].SDS.SerializeData; //} //for (int i = 0; i < its.DrumTimbres.Length; i++) //{ // DrumTimbres[i].BaseNote = its.DrumTimbres[i].BaseNote; // DrumTimbres[i].GateTime = its.DrumTimbres[i].GateTime; // DrumTimbres[i].TimbreNumber = its.DrumTimbres[i].TimbreNumber; //} soundManager.ProcessKeyOn(midiEvent); }
/// <summary> /// /// </summary> /// <param name="note"></param> public override SoundBase[] SoundOn(TaggedNoteOnEvent note) { List <SoundBase> rv = new List <SoundBase>(); int tindex = 0; foreach (TMS5220Timbre timbre in parentModule.GetBaseTimbres(note)) { tindex++; var emptySlot = searchEmptySlot(note); if (emptySlot.slot < 0) { continue; } TMS5220Sound snd = new TMS5220Sound(emptySlot.inst, this, timbre, tindex - 1, note, emptySlot.slot); psgOnSounds.Add(snd); FormMain.OutputDebugLog(parentModule, "KeyOn SP0256 ch" + emptySlot + " " + note.ToString()); rv.Add(snd); } for (int i = 0; i < rv.Count; i++) { var snd = rv[i]; if (!snd.IsDisposed) { ProcessKeyOn(snd); } else { rv.Remove(snd); i--; } } return(rv.ToArray()); }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public NAMCO_CUS30Sound(NAMCO_CUS30 parentModule, NAMCO_CUS30SoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.timbre = (NAMCO_CUS30Timbre)timbre; }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public C140Sound(C140 parentModule, C140SoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot, byte timbreIndex) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.timbreIndex = timbreIndex; this.timbre = (C140Timbre)timbre; lastSoundType = this.timbre.SoundType; if (lastSoundType == SoundType.INST) { baseFreq = this.timbre.BaseFreqency; sampleRate = this.timbre.SampleRate; loopPoint = this.timbre.LoopPoint; loopEn = this.timbre.LoopEnable; } /* * else if (lastSoundType == SoundType.DRUM) * { * var pct = (C140PcmTimbre)parentModule.DrumSoundTable.PcmTimbres[noteOnEvent.NoteNumber]; * baseFreq = pct.BaseFreqency; * sampleRate = pct.SampleRate; * loopPoint = pct.LoopPoint; * loopEn = pct.LoopEnable; * }*/ }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public BeepSound(Beep parentModule, BeepSoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.timbre = (BeepTimbre)timbre; }
/// <summary> /// /// </summary> /// <returns></returns> private (Beep inst, int slot) searchEmptySlot(TaggedNoteOnEvent note) { return(SearchEmptySlotAndOffForLeader(parentModule, psgOnSounds, note, 1)); }
/// <summary> /// /// </summary> /// <param name="midiEvent"></param> protected override void OnNoteOnEvent(TaggedNoteOnEvent midiEvent) { soundManager.ProcessKeyOn(midiEvent); }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public TMS5220Sound(TMS5220 parentModule, TMS5220SoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.timbre = (TMS5220Timbre)timbre; bw = new BitWriter(parentModule); }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public uPD1771Sound(uPD1771C parentModule, uPD1771SoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.timbre = (uPD1771Timbre)timbre; }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public SP0256Sound(SP0256 parentModule, SP0256SoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.timbre = (SP0256Timbre)timbre; }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public GbSound(GB_APU parentModule, GBSoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.timbre = (GBAPUTimbre)timbre; lastSoundType = this.timbre.SoundType; if (lastSoundType == SoundType.PSG && this.timbre.PartialReserveSPSG) { partialReserveSpsg = 1; } }
/// <summary> /// /// </summary> /// <param name="parentModule"></param> /// <param name="noteOnEvent"></param> /// <param name="programNumber"></param> /// <param name="slot"></param> public MT32Sound(MT32 parentModule, MT32SoundManager manager, TimbreBase timbre, int tindex, TaggedNoteOnEvent noteOnEvent, int slot) : base(parentModule, manager, timbre, tindex, noteOnEvent, slot) { this.parentModule = parentModule; this.programNumber = (SevenBitNumber)parentModule.ProgramNumbers[noteOnEvent.Channel]; this.timbre = (MT32Timbre)timbre; }
/// <summary> /// /// </summary> /// <returns></returns> private (NAMCO_CUS30 inst, int slot) searchEmptySlot(TaggedNoteOnEvent note) { return(SearchEmptySlotAndOffForLeader(parentModule, wsgOnSounds, note, 8)); }