|
John Cleary
Guest
|
 |
« Reply #2 on: 14 Nov '03 - 22:38 » |
Quote
|
Thanks im going to use that. I am trying to write a cut down version of the nBass Record.cs but I keep getting an invalid handle when I try and read the left or right level could somebody take a look please. This is the code I am using.
using System; using System.Runtime.InteropServices;
namespace nBASS { public class Recorder { public bool disposed; public Int32 Handle; [DllImport("bass.dll", EntryPoint = "BASS_RecordInit")] static extern int _Init(int device); [DllImport("bass.dll", EntryPoint = "BASS_RecordStart")] static extern int _Start(int freq, int flags, GetRecordCallBack proc, int user); [DllImport("bass.dll", EntryPoint = "BASS_ChannelStop")] static extern int _Stop(IntPtr handle); [DllImport("bass.dll", EntryPoint = "BASS_ChannelPause")] static extern int _Pause(IntPtr handle);
[DllImport("bass.dll", EntryPoint = "BASS_ChannelResume")] static extern int _Resume(IntPtr handle); [DllImport("bass.dll", EntryPoint = "BASS_ChannelGetLevel")] static extern int _GetLevel(IntPtr handle); [DllImport("bass.dll", EntryPoint = "BASS_RecordFree")] static extern void _Free(); [DllImport("bass.dll", EntryPoint = "BASS_ChannelIsActive")] static extern int _IsActive(IntPtr handle); [DllImport("bass.dll", EntryPoint = "BASS_RecordSetInput")] static extern int _SetInput(int inputn, int setting); public Recorder(int device) : base(new IntPtr(1)) { int i = _Init(device) ; if (i == 0) throw new BASSException(); disposed = false; Handle = new Int32(1); } public void SetInput(int inputn, InputFlags flags) { if (this.disposed) throw new ObjectDisposedException(this.ToString());
if (_SetInput(inputn, (int) flags) == 0) throw new BASSException(); } public void Start(int freq, RecordFlags flags, GetRecordCallBack callback, int user) { if (this.disposed) throw new ObjectDisposedException(this.ToString());
if (_Start(freq, (int) flags, callback, (int) flags) == 0 ) throw new BASSException(); } public void Stop() { if (this.disposed) throw new ObjectDisposedException(this.ToString());
if (_Stop(this.Handle) == 0) throw new BASSException();
}
public void Pause() { if (this.disposed) throw new ObjectDisposedException(this.ToString());
if (_Pause(this.Handle) == 0) throw new BASSException(); }
public void Resume() { if (this.disposed) throw new ObjectDisposedException(this.ToString());
if (_Resume(this.Handle) == 0) throw new BASSException(); } public State ActivityState { get { if (this.disposed) throw new ObjectDisposedException(this.ToString());
return (State)_IsActive(this.Handle); } }
public int LeftLevel { get { if (this.disposed) throw new ObjectDisposedException(this.ToString()); int result = _GetLevel(this.Handle); if(result < 0) throw new BASSException(); return Helper.LoWord(result); } }
public int RightLevel { get { if (this.disposed) throw new ObjectDisposedException(this.ToString());
int result = _GetLevel(this.Handle); if(result < 0) throw new BASSException(); return Helper.HiWord(result); } } public void Dispose() { if (!this.disposed) { _Free(); disposed = true; } }
} }
thanks John
|