Presents the user with a list of available ACM (Audio Compression Manager) codec output formats to choose from.
The overload implements the Unicode version for the title, so the BASS_UNICODE flag will be added automatically.
Namespace: Un4seen.Bass.AddOn.Enc
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax
public static int BASS_Encode_GetACMFormat( int handle, IntPtr form, int fromlen, string title, BASSACMFormat flags )
Parameters
- handle
- Type: SystemInt32
The channel handle... a HSTREAM, HMUSIC, or HRECORD. - form
- Type: SystemIntPtr
Pointer to the format buffer. - fromlen
- Type: SystemInt32
Size of the format buffer. If this is 0, then a suggested format buffer length is returned (which is the maximum length of all installed codecs), without displaying the codec selector. - title
- Type: SystemString
Window title for the selector... = "Choose the output format". - flags
- Type: Un4seen.Bass.AddOn.EncBASSACMFormat
A combination of these flags BASSACMFormat:The HighWord - use MakeLong(Int16, Int16)(flags,format) - can be used to restrict the choice to a particular format tag (eg. WAVE_FORMAT_ADPCM). This is required with BASS_ACM_SUGGEST, and is optional otherwise. See WAVEFormatTag for a list of typical formats being used.BASS_ACM_DEFAULT Use the format buffer (form) contents as the default choice in the codec selector. BASS_ACM_RATE Only include formats with the same sample rate as the source. BASS_ACM_CHANS Only include formats with the same number of channels (mono/stereo) as the source. BASS_ACM_SUGGEST Suggest a format without letting the user choose. The wanted format tag (eg. WAVE_FORMAT_ADPCM) should be specified in the HIWORD.
Return Value
Type: Int32If successful, the user-selected codec format details are put in the provided buffer and the length of the format details is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code. If formlen is 0, then the suggested format buffer size is returned.
Remarks
The form buffer contents are actually a WAVEFORMATEX or ACMFORMAT structure. If writing the encoder output to a WAVE file, the form buffer contents would be the format chunk ("fmt") of the file.
To not let the user choose a codec, but automatically suggest a codec you might also use the BASS_Encode_GetACMFormatSuggest(Int32, BASSACMFormat, WAVEFormatTag) method.
ERROR CODE | Description |
---|---|
BASS_ERROR_HANDLE | handle is not valid. |
BASS_ERROR_NOTAVAIL | There are no codecs available that will accept the channel's format. |
BASS_ERROR_ACM_CANCEL | The user pressed the "cancel" button. |
BASS_ERROR_UNKNOWN | Some other mystery problem! |
Examples
// get suggested (maximum) format buffer size int formlen = BassEnc.BASS_Encode_GetACMFormat(0, IntPtr.Zero, 0, null, BASSACMFormat.BASS_ACM_NONE); // create a buffer for the codec byte[] buffer = new byte[formlen]; // now create a pinned handle, so that the Garbage Collector will not move this object GCHandle hGC = GCHandle.Alloc( buffer, GCHandleType.Pinned ); // get the pointer to that pinned object IntPtr codec = hGC.AddrOfPinnedObject(); // let the user choose a codec... if ( BassEnc.BASS_Encode_GetACMFormat( channel, codec, formlen, "Choose your format", BASSACMFormat.BASS_ACM_DEFAULT) > 0 ) { // get the generic codec information back ACMFORMAT acm = (ACMFORMAT)Marshal.PtrToStructure(codec, typeof(ACMFORMAT)); // begin encoding using the codec BassEnc.BASS_Encode_StartACMFile( channel, codec, BASSEncode.BASS_ENCODE_DEFAULT, "acm.wav"); } // free the codec format buffer (you might free it even if encoding is still running) hGC.Free();
C#
// get suggested (maximum) format buffer size int formlen = BassEnc.BASS_Encode_GetACMFormat(0, IntPtr.Zero, 0, null, BASSACMFormat.BASS_ACM_NONE); // create a buffer for the codec byte[] buffer = new byte[formlen]; unsafe { fixed (byte* p = buffer) { // let the user choose a codec... if ( BassEnc.BASS_Encode_GetACMFormat( channel, (IntPtr)p, formlen, "Choose your format", BASSACMFormat.BASS_ACM_DEFAULT) > 0 ) { // get the generic codec information back ACMFORMAT acm = (ACMFORMAT)Marshal.PtrToStructure((IntPtr)p, typeof(ACMFORMAT)); // begin encoding using the codec BassEnc.BASS_Encode_StartACMFile( channel, acm, BASSEncode.BASS_ENCODE_DEFAULT, "acm.wav"); } } }
See Also