int mbrCallback(MbrMessage msg, IntPtr wParam, int lParam) { switch (msg) { case MbrMessage.Init: Console.WriteLine("WM_MBR_INIT"); // fout.Seek(0, SeekOrigin.End); break; case MbrMessage.Read: // fwrite((short*)wParam, sizeof(short), lParam, fout); Console.WriteLine("WM_MBR_READ wParam={0}, lParam={1}", wParam.ToInt32().ToString("X"), lParam); break; case MbrMessage.Write: Console.WriteLine("WM_MBR_WRITE {0} samples", lParam); byte[] buf = new byte[lParam * sizeof(short)]; Marshal.Copy(wParam, buf, 0, lParam * sizeof(short)); // AudioBufferInfo abuf = new AudioBufferInfo(); // abuf.Format // Synth.Emit(abuf); Synth.BufferReady(buf); // fout.Write(buf, 0, buf.Length); break; case MbrMessage.End: Finished = true; Console.WriteLine("WM_MBR_END"); // fout.Close(); break; default: Console.WriteLine("MbrMessage " + msg); break; } return(0); }
int mbrCallback(MbrMessage msg, IntPtr wParam, int lParam) { switch (msg) { case MbrMessage.Init: Synth.Log("Synth initialized"); // fout.Seek(0, SeekOrigin.End); break; // case MbrMessage.Read: // fwrite((short*)wParam, sizeof(short), lParam, fout); // Synth.Log("WM_MBR_READ wParam={0}, lParam={1}", wParam.ToInt32().ToString("X"), lParam); // break; case MbrMessage.Write: Synth.Log("{0} samples received from synth", lParam); byte[] buf = new byte[lParam * sizeof(short)]; Marshal.Copy(wParam, buf, 0, lParam * sizeof(short)); // AudioBufferInfo abuf = new AudioBufferInfo(); // abuf.Format // Synth.Emit(abuf); Synth.BufferReady(buf); // fout.Write(buf, 0, buf.Length); break; case MbrMessage.End: Synth.Log("Synth terminated"); Finished = true; // fout.Close(); break; default: Synth.Log("MbrMessage " + msg); break; } return(0); }