public void NoteOn(int aBank, Byte aInstrument, Byte aNote, Byte aVelocity, double aSecondLength = 0.0d) { Logger.Debug("Instrument:" + aInstrument); int lBank = aBank; Byte lInstrument = aInstrument; if (soundcluster == null) { Logger.Error("soundcluseter == null "); } else if (soundcluster.BankDictionary == null) { Logger.Error("soundcluster.BankDictionary == null "); } if (soundcluster.BankDictionary.ContainsKey(lBank) == false) { Logger.Error("Not Found Bank:" + lBank.ToString("X4")); lBank = 0; } if (lBank == 0x7F00) { if (lInstrument == 1) { lInstrument = 8; } else if (lInstrument == 2) { lInstrument = 16; } else if (lInstrument == 3) { lInstrument = 24; } else if (lInstrument == 4) { lInstrument = 25; } else if (lInstrument == 5) { lInstrument = 32; } else if (lInstrument == 6) { lInstrument = 40; } else if (lInstrument == 7) { lInstrument = 48; } } if (soundcluster.BankDictionary.ContainsKey(lBank) == true) { InstrumentBase lMidiInstrument = soundcluster.BankDictionary[lBank].instrumentArray[lInstrument]; if (lMidiInstrument == null) { if (lBank == 0x7F00) { Logger.Warning("Change Instrument:" + lBank.ToString("X4") + "/" + lInstrument); lInstrument = 0x0000; } else { Logger.Warning("Change Bank:" + lBank.ToString("X4") + "/" + lInstrument); if (lBank != 0) { Logger.Error("Change Bank:" + lBank.ToString("X4") + "/" + lInstrument); } lBank = 0x0000; lInstrument = 0x0000; } lMidiInstrument = soundcluster.BankDictionary[lBank].instrumentArray[lInstrument]; } if (lMidiInstrument != null) { SoundfontBase lSoundfont = lMidiInstrument.soundfontArray[aNote]; if (lSoundfont != null) { Logger.Warning("Add"); noteOnList.Add(aNote); oscillatorList.Add(new MidiOscillator(aNote, lInstrument, aVelocity, lSoundfont, ref midiVolume, ref midiPitch, aSecondLength)); } else { Logger.Error("Not Found Note:" + lBank.ToString("X4") + "/" + lInstrument + "/" + aNote); } } else { Logger.Error("Not Found Instrument:" + lBank.ToString("X4") + "/" + lInstrument); } } else { Logger.Error("Not Found Bank:" + lBank.ToString("X4")); } }
protected InstrumentBase(SoundfontBase aSoundfont) : this() { AddSoundfont(aSoundfont); }
public MidiOscillator(byte aNote, byte aInstrument, byte aVelocity, SoundfontBase aSoundfont, ref MidiVolume aMidiVolume, ref MidiPitch aMidiPitch, double aSecondsSustain = 0.0d) { generatorEnvelope = new GeneratorEnvelope(aSoundfont, aVelocity, aSecondsSustain); filterVibrato = new FilterVibrato(ref aMidiPitch); generatorPortament = new GeneratorPortament(aNote, aSoundfont.soundinfo.GetPitch()); }
public void Set(SoundfontBase aSoundfont, byte aVelocity, double aSecondsSustain = 0.0d) { soundfont = aSoundfont; volume = ( float )Math.Pow(10.0d, ( double )aSoundfont.soundinfo.volume / 20.0d) * ( float )aVelocity / 8.0f; }