Example #1
0
 public unsafe void OpenData(ReadOnlySpan <byte> data)
 {
     fixed(byte *ptr = data)
     {
         Check(AdlMidiImports.adl_openData(_device, ptr, (uint)data.Length));
     }
 }
Example #2
0
        public Instrument GetInstrument(uint index)
        {
            var result = AdlMidiImports.adl_getInstrument(_device, ref _bank, index, out var instrument);

            if (result < 0)
            {
                throw new InvalidOperationException();
            }
            return(instrument);
        }
Example #3
0
        public BankId GetBankId()
        {
            var result = AdlMidiImports.adl_getBankId(_device, ref _bank, out var id);

            if (result < 0)
            {
                throw new InvalidOperationException();
            }
            return(id);
        }
Example #4
0
        int Check(int result)
        {
            if (result >= 0)
            {
                return(result);
            }

            var error = AdlMidiImports.adl_errorInfo(_device);

            throw new InvalidOperationException(error);
        }
Example #5
0
        public static MidiPlayer Init(long sampleRate = DefaultChipSampleRate)
        {
            var midiPlayer = AdlMidiImports.adl_init(sampleRate);

            if (midiPlayer == IntPtr.Zero)
            {
                throw new InvalidOperationException(ErrorString());
            }

            return(new MidiPlayer(midiPlayer));
        }
Example #6
0
 public void Reset() => AdlMidiImports.adl_reset(_device);
Example #7
0
 public void Close() => AdlMidiImports.adl_close(_device);
Example #8
0
 public void OpenFile(string filePath) => Check(AdlMidiImports.adl_openFile(_device, filePath));
Example #9
0
 public static string[] GetBankNames() => AdlMidiImports.adl_getBankNames();
Example #10
0
 public static int GetBankCount() => AdlMidiImports.adl_getBanksCount();
Example #11
0
 public static string ErrorString() => AdlMidiImports.adl_errorString();
Example #12
0
        public static Version LinkedVersion()
        {
            var version = AdlMidiImports.adl_linkedVersion();

            return(new Version(version.Major, version.Minor, version.Patch));
        }
Example #13
0
 public static string LinkedLibraryVersion() => AdlMidiImports.adl_linkedLibraryVersion();
Example #14
0
 public int LoadEmbeddedBank(int num)
 {
     return(AdlMidiImports.adl_loadEmbeddedBank(_device, ref _bank, num));
 }
Example #15
0
 public int SetInstrument(uint index, ref Instrument ins)
 {
     return(AdlMidiImports.adl_setInstrument(_device, ref _bank, index, ref ins));
 }
Example #16
0
 public int RemoveBank()
 {
     return(AdlMidiImports.adl_removeBank(_device, ref _bank));
 }