Un4seen.BassWasapiBassWasapiHandler
Namespace: Un4seen.BassWasapi
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
The BassWasapiHandler type exposes the following members.
Name | Description | |
---|---|---|
BassWasapiHandler(Int32, Boolean, Int32, Int32, Single, Single) |
Creates an instance of the WASAPI handler.
| |
BassWasapiHandler(Int32, Boolean, Boolean, Int32, Int32, Single, Single) |
Creates an instance of the WASAPI handler.
|
Name | Description | |
---|---|---|
BufferLength |
Gets the actual buffer length (in seconds) being used with the Device.
| |
BypassFullDuplex |
Gets or Sets the bypass flag for full-duplex WASAPI output processing (default is ).
| |
Device |
Returns the WASAPI device (endpoint) being used by the Wasapi handler.
| |
DeviceMute |
Gets or Sets the mute status of the Device.
| |
DeviceVolume |
Gets or Sets the linear volume of the Device between 0 (silent) and 1 (full).
| |
EventSystem |
Returns , if the WASAPI event-driven system is used - else the standard push system is used.
| |
Exclusive |
Returns , if the WASAPI handler is used in exclusive mode - else shared mode is used.
| |
InputChannel |
Returns an input channel which allows you to retrieve the recorded sample data and/or apply any DSP/FX on Wasapi input.
| |
InternalMixer |
Gets the internal mixer being used with this WASAPI handler (when used with an output device).
| |
InternalWasapiProc |
Gets the WASAPIPROC currently being used by the Wasapi handler.
| |
IsInput |
Returns , if the WASAPI handler is used with a WASAPI input device (capture or loopback endpoint).
| |
IsInputFullDuplex |
Returns , if the WASAPI handler is used with an WASAPI input device and the full-duplex option was set via SetFullDuplex(Int32, BASSFlag, Boolean).
| |
NumChans |
Gets the actual number of channels being used with the Device.
| |
OutputChannel |
Gets the BASS output channel handle which is used with this WASAPI input handler in case of full-duplex monitoring.
| |
Pan |
Gets or Sets the panning of the channels between -1 (left) to +1 (right), 0=centered.
| |
SampleRate |
Gets the actual sample rate in Hz which is being used.
| |
SessionMute |
Gets or Sets the mute status of the session.
| |
SessionVolume |
Gets or Sets the session volume between 0 (silent) and 1 (full).
| |
UpdatePeriod |
Gets the actual update period (in seconds) being used with the Device.
| |
UseInput |
Enables the use of the InputChannel channel with WASAPI input (which is the default for Wasapi input).
| |
Volume |
Gets or Sets the volume of the channels between 0 (silent) and 1 (full).
|
Name | Description | |
---|---|---|
AddOutputSource |
Adds a new source to the WASAPI handler for output.
| |
Dispose |
Disposes an instance of this class also stops and frees the used WASAPI device/driver (endpoint).
| |
Finalize |
Finalization code.
(Overrides ObjectFinalize.) | |
Init | ||
Pause |
Pauses or Unpauses the WASAPI Device being used.
| |
RemoveFullDuplex |
Removes the full-duplex option from WASAPI input.
| |
SetFullDuplex |
Sets the full-duplex option for WASAPI input using the given BASS output device.
| |
Start |
Starts the WASAPI Device.
| |
Stop |
Stops the WASAPI Device.
| |
WasapiInputCallback |
Provides a ready made WASAPIPROC callback procedure which might be used for WASAPI input.
| |
WasapiOutputCallback |
Provides a ready made WASAPIPROC callback procedure which might be used for WASAPI output.
|
Name | Description | |
---|---|---|
Notification |
Event handler used to notify that an Wasapi handler notification event (sync) has occurred.
|
Scenario: | How-To: |
---|---|
Wasapi output | A Bass decoding channel feeding Wasapi output.
Simply create an instance of this class using an output device endpoint and then call the AddOutputSource(Int32, BASSFlag) method to add your decoding channel(s) to be used for output. Now you call the Init(Boolean) and Start methods to actually start the Wasapi output processing. You might also use the InternalMixer property (which returns the internally used Un4seen.Bass.AddOn.Mix mixer channel) to add or remove any decoding channel yourself. |
Wasapi input | Directly record from Wasapi input.
Simply create an instance of this class using an input device endpoint you want to record at (this automatically sets the UseInput property to ). To retrieve the input sample data use the InputChannel channel (e.g. setup an own DSP, use it with the WaveWriter or Encoder Framework). |
Wasapi input, full-duplex to Wasapi | Monitor your Wasapi input on any Wasapi output.
Not supported directly by this class (but you can simply do this yourself, by initializing an output device with a WASAPIPROC and calling from within your input devices WASAPIPROC). |
Wasapi input, full-duplex to BASS | Monitor your Wasapi input on any BASS device.
To enable full-duplex just call the SetFullDuplex(Int32, BASSFlag, Boolean) method (when done call RemoveFullDuplex). Note: You might also specify the "no sound" BASS device (0) and use the BASS_STREAM_DECODE with the SetFullDuplex(Int32, BASSFlag, Boolean) call in order to retrieve a full-duplex decoding Bass stream, which you can now assign to an output instance of this class via AddOutputSource(Int32, BASSFlag) to preform a full-duplex Wasapi input to output monitoring. |
DSP/FX | You can set any DSP/FX on either the input and/or the output (full-duplex).
See InputChannel and InternalMixer for more details. |
You might use the Volume and Pan properties to easily control your Wasapi input/output settings.
Wasapi channels can be paused and resumed at any time by using the Pause(Boolean) method. To physically start the Wasapi device the Init(Boolean) followed by Start methods might be used. Stop will disable and stop the Wasapi device (if really needed).
Caution: Once you created an instance of this class and called the Init(Boolean) method, the respective WASAPI device is enabled and a session is created. The used WASAPI device will be disabled and freed automatically when an instance of this class is being disposed by the .Net Garbage Collector! Call the Dispose method manually to free the WASAPI device, including any full-duplex options.
Note: This class internally uses Un4seen.Bass as well as the Un4seen.Bass.AddOn.Mix add-on, so you need to provide the native bass.dll and the bassmix.dll as well when using this class.
private BassWasapiHandler _wasapi; ... // not playing anything via BASS, so don't need an update thread Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0); // setup BASS - "no sound" device Bass.BASS_Init(0, 48000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); ... int stream = Bass.BASS_StreamCreateFile(fileName, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT); if (stream != 0) { // assign WASAPI output in shared-mode _wasapi = new BassWasapiHandler(-1, false, 48000, 2, 0f, 0f); // add the source channel _wasapi.AddOutputSource(stream, BASSFlag.BASS_DEFAULT) // init and start WASAPI _wasapi.Init(); _wasapi.Start(); }
private BassWasapiHandler _wasapi; ... // not playing anything via BASS, so don't need an update thread Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0); // setup BASS - "no sound" device Bass.BASS_Init(0, 48000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); ... // assign WASAPI input in shared-mode _wasapi = new BassWasapiHandler(-2, false, 48000, 2, 0f, 0f); // init and start WASAPI _wasapi.Init(); int recordStream = _wasapi.InputChannel; // double check, that the device is not muted externally if (_wasapi.DeviceMute) _wasapi.DeviceMute = false; _wasapi.Start(); ... // now you can use recordStream to setup any DSP/FX etc.
// setup a full-duplex stream _wasapiInput.SetFullDuplex(0, BASSFlag.BASS_STREAM_DECODE, false, 2000); int fullDuplexStream = _wasapiInput.OutputChannel; // and assign it to an output _wasapiOutput.AddOutputSource(fullDuplexStream, BASSFlag.BASS_DEFAULT);