BASS.NET API for the Un4seen BASS Audio Library

EncoderWAV Class

BASS.NET API for the Un4seen BASS Audio Library
Encoder class implementation for the RIFF WAVE format using raw PCM sample data with no real encoder.
Inheritance Hierarchy

SystemObject
  Un4seen.Bass.MiscBaseEncoder
    Un4seen.Bass.MiscEncoderWAV

Namespace:  Un4seen.Bass.Misc
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

[SerializableAttribute]
public sealed class EncoderWAV : BaseEncoder

The EncoderWAV type exposes the following members.

Constructors

  NameDescription
Public methodEncoderWAV
Creates an instance of a RIFF WAVE implementation.
Top
Properties

  NameDescription
Public propertyBWF_AddBEXT
Gets or Sets, if a BWF BEXT chunk should be written to the file (default is )?
Public propertyBWF_AddCART
Gets or Sets, if a BWF CART chunk should be written to the file (default is )?
Public propertyBWF_UseRF64
Gets or Sets, if a BWF RF64 WAVE header should be used instead of a regular WAVE header (default is )?
Public propertyChannelBitwidth
This property returns the actual bitwidth of the sample data of the channel (e.g. 8, 16, 32).
(Inherited from BaseEncoder.)
Public propertyChannelHandle
Gets or Sets the channel handle which is used to create the broadcast encoder class.
(Inherited from BaseEncoder.)
Public propertyChannelInfo
Returns the general channel info.
(Inherited from BaseEncoder.)
Public propertyChannelNumChans
This property returns the actual number of channles of the sample data BASS is using with the channel (e.g. 1=mono, 2=stereo, etc.).
(Inherited from BaseEncoder.)
Public propertyChannelSampleRate
This property returns the actual sample rate in Hz of the sample data BASS is using with the channel (e.g. 44100).
(Inherited from BaseEncoder.)
Public propertyDefaultOutputExtension
This return the default extension of an output file for this encoder (e.g. ".wav"). Here the WAV_DefaultOutputExtension value is returned.
(Overrides BaseEncoderDefaultOutputExtension.)
Public propertyEffectiveBitrate
Returns the effective encoder bitrate (in kbps) of the output.
(Overrides BaseEncoderEffectiveBitrate.)
Public propertyEncoderCommandLine
Returns the OutputFile, since WAV does not use any command-line tool.
(Overrides BaseEncoderEncoderCommandLine.)
Public propertyEncoderDirectory
Gets or Sets the encoder's base directory.
(Inherited from BaseEncoder.)
Public propertyEncoderExists
This property should return , if the encoder exists and is available - else should be returned.
(Inherited from BaseEncoder.)
Public propertyEncoderHandle
Gets or sets the current HENCODE encoder handle.
(Inherited from BaseEncoder.)
Public propertyEncoderType
Gets a value indicating the type of content. Here the WAV_EncoderType value is returned.
(Overrides BaseEncoderEncoderType.)
Public propertyForce16Bit
Always returns false, since this encoder doesn't supports this flag. The target format can be set via the WAV_BitsPerSample property.
Public propertyInputFile
Gets or Sets the input file name to be processed by the encoder (null = STDIN, default).
(Inherited from BaseEncoder.)
Public propertyIsActive
Gets a value indicating if the encoder has been started (see Start(ENCODEPROC, IntPtr, Boolean)) and is active - else will be returned.
(Inherited from BaseEncoder.)
Public propertyIsPaused
Gets a value indicating if the encoder has been paused (see Pause(Boolean)) - else must be returned.
(Inherited from BaseEncoder.)
Public propertyIsStreaming
Is this instance used for streaming? When set to true, some internal encoder options might be set. Default is false.
(Inherited from BaseEncoder.)
Public propertyNoLimit
Gets or Sets if encoding should use the CAST_NOLIMIT flag (which is only needed, if the encoder is used for streaming).
(Inherited from BaseEncoder.)
Public propertyOutputFile
Gets or Sets the output file name to be processed by the encoder (null = STDOUT, default).
(Inherited from BaseEncoder.)
Public propertySupportsSTDOUT
WAV does not implement STDOUT, so is always returned.
(Overrides BaseEncoderSupportsSTDOUT.)
Public propertyTAGs
Gets or Sets the TAG_INFO structure associated with the encoder.
(Inherited from BaseEncoder.)
Public propertyUseAsyncQueue
Gets or Sets if encoding should use an async queue (i.e. the BASS_ENCODE_QUEUE flag).
(Inherited from BaseEncoder.)
Public propertyWAV_AddRiffInfo
Gets or Sets, if a RIFF INFO LIST chunk should be written to the file (default is )?
Public propertyWAV_BitsPerSample
Gets or Sets the target resolution (number of bits per sample) of the Wave file to create - (by default the original resolution will be used).
Public propertyWAV_Use32BitInteger
Gets or Sets, if 32bit integer (instead of 32bit IEEE float) should be used when setting WAV_BitsPerSample to 32 (default is )?
Public propertyWAV_UseAIFF
Gets or Sets, if the AIFF format should be used instead of the WAVE format (default is )?
Top
Methods

  NameDescription
Public methodDispose
Implement IDisposable.
(Inherited from BaseEncoder.)
Protected methodFinalize
Finalization code.
(Inherited from BaseEncoder.)
Public methodPause
Pauses or resumes an encoder.
(Inherited from BaseEncoder.)
Public methodSettingsString
Returns the string representation of the current encoder settings.
(Overrides BaseEncoderSettingsString.)
Public methodStart
This method starts the actual WAV encoder.
(Overrides BaseEncoderStart(ENCODEPROC, IntPtr, Boolean).)
Public methodStop
Stops the encoder immediately (if started).
(Inherited from BaseEncoder.)
Public methodStop(Boolean)
Stops the encoder (if started).
(Inherited from BaseEncoder.)
Public methodToString
Returns the name of the Encoder.
(Overrides ObjectToString.)
Top
Fields

  NameDescription
Public fieldWAV_DefaultOutputExtension
Gets or Sets the default output extension to be used by the encoder (e.g. ".wav").
Public fieldWAV_EncoderType
Gets or Sets the BASSChannelType which will be supported by the encoder.
Top
Remarks

This class uses the BASS_CTYPE_STREAM_WAV encoder type.

This format supports 8-, 16- and 32-bit(IEEE float) sample data as input.

Make sure to set the WAV_xxx and/or BWF_xxx flags before calling Start(ENCODEPROC, IntPtr, Boolean).

TAG writing is supported by saving appropriate RIFF LIST INFO chunks.

This implementation uses the automatic DSP system for encoding. Meaning the sending of sample data to the encoder is done automatically when you play the channel (BASS_ChannelPlay(Int32, Boolean)) or call BASS_ChannelGetData(Int32, IntPtr, Int32) (if it's a decoding channel). So there is no need to call BASS_Encode_Write(Int32, IntPtr, Int32) manually!

If you simply want to encode a physical file please also take a look to the EncodeFile(String, String, BaseEncoder, BaseEncoderENCODEFILEPROC, Boolean, Boolean).

Examples

Manual encoding "File" To "File" in 32-bit:
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, 
                  BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
EncoderWAV w = new EncoderWAV(stream);
w.InputFile = null;
w.OutputFile = "test.wav";  // will be a 32-bit IEEE float WAVE file, since the stream is float
w.Start(null, IntPtr.Zero, false);
// do the encoding
Utils.DecodeAllData(stream, true);
w.Stop();
Manual encoding "File" To "File" in 24-bit:
EncoderWAV w = new EncoderWAV(0);
w.InputFile = "testIn.wav";
w.OutputFile = "testOut.wav";
w.WAV_BitsPerSample = 24;
w.Start(null, IntPtr.Zero, false);
w.Stop();
"Recording" To "File" in 16-bit:
private RECORDPROC _recProc;

// init your recording device (we use the default device)
if ( !Bass.BASS_RecordInit(-1) )
  MessageBox.Show(this, "Bass_RecordInit error!" );
_recProc = new RECORDPROC(RecordingHandler);
// start recording at 44.1kHz, stereo (paused)
int recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, _recProc, IntPtr.Zero);
if (recHandle == Bass.FALSE)
  MessageBox.Show(this, "BASS_RecordStart error!" );

// setup the encoder
EncoderWAV w = new EncoderWAV(recHandle);
w.InputFile = null;
w.OutputFile = "testrec.wav";
w.Start(null, IntPtr.Zero, true); // start encoder paused
...
// now really start recording and encoding
w.Pause(false);
Bass.BASS_ChannelPlay(recHandle, false);
...
// your recording will be encoded until you call
w.Stop();

private bool RecordingHandler(int handle, IntPtr buffer, int length, IntPtr user)
{
  return true;
}
See Also

Reference