static extern int BASS_Encode_StartUser(int handle, string filename, EncodeFlags flags, EncoderProcedure proc, IntPtr user);
/// <summary> /// Sets up a user-provided encoder on a channel. /// </summary> /// <param name="Handle">The channel handle... a HSTREAM, HMUSIC, or HRECORD.</param> /// <param name="Filename">Output filename... <see langword="null" /> = no output file.</param> /// <param name="Flags">A combination of <see cref="EncodeFlags"/>.</param> /// <param name="Procedure">Callback function to receive the sample data and return the encoded data.</param> /// <param name="User">User instance data to Password to the callback function.</param> /// <returns>The encoder process handle is returned if the encoder is successfully started, else 0 is returned (use <see cref="Bass.LastError" /> to get the error code).</returns> /// <remarks> /// <para> /// This function allows user-provided encoders to be used, which is most useful for platforms where external encoders are unavailable /// for use with <see cref="EncodeStart(int,string,EncodeFlags,EncodeProcedure,IntPtr)" />. /// For example, the LAME library could be used with this function instead of the standalone LAME executable with <see cref="EncodeStart(int,string,EncodeFlags,EncodeProcedure,IntPtr)" />. /// </para> /// <para> /// Internally, the sending of sample data to the encoder is implemented via a DSP callback on the channel. /// That means when the channel is played (or <see cref="Bass.ChannelGetData(int,IntPtr,int)" /> is called if it is a decoding channel), the sample data will be sent to the encoder at the same time. /// It also means that if the <see cref="Bass.FloatingPointDSP"/> option is enabled, the sample data will be 32-bit floating-point, and one of the floating-point flags will be required if the encoder does not support floating-point sample data. /// The <see cref="Bass.FloatingPointDSP"/> setting should not be changed while encoding is in progress. /// </para> /// <para> /// By default, the encoder DSP has a priority setting of -1000, which determines where in the DSP chain the encoding is performed. /// That can be changed via the <see cref="DSPPriority"/> config option. /// </para> /// <para> /// Besides the automatic DSP system, data can also be manually fed to the encoder via the <see cref="EncodeWrite(int,IntPtr,int)" /> function. /// Both methods can be used together, but in general, the 'automatic' system ought to be paused when using the 'manual' system, via the <see cref="EncodeFlags.Pause"/> flag or the <see cref="EncodeSetPaused" /> function. /// Data fed to the encoder manually does not go through the source channel's DSP chain, so any DSP/FX set on the channel will not be applied to the data. /// </para> /// <para> /// When queued encoding is enabled via the <see cref="EncodeFlags.Queue"/> flag, the DSP system or <see cref="EncodeWrite(int,IntPtr,int)" /> call will just buffer the data, and the data will then be fed to the encoder by another thread. /// The buffer will grow as needed to hold the queued data, up to a limit specified by the <see cref="Queue"/> config option. /// If the limit is exceeded (or there is no free memory), data will be lost; /// <see cref="EncodeSetNotify" /> can be used to be notified of that occurrence. /// The amount of data that is currently queued, as well as the queue limit and how much data has been lost, is available from <see cref="EncodeGetCount" />. /// </para> /// <para>When done encoding, use <see cref="EncodeStop(int)" /> or <see cref="EncodeStop(int,bool)" /> to close the encoder.</para> /// <para> /// Multiple encoders can be set on a channel. /// For convenience, most of the encoder functions will accept either an encoder handle or a channel handle. /// When a channel handle is used, the function is applied to all encoders that are set on that channel. /// </para> /// </remarks> /// <exception cref="Errors.Handle"><paramref name="Handle" /> is not valid.</exception> /// <exception cref="Errors.Create">The file could not be created.</exception> /// <exception cref="Errors.Unknown">Some other mystery problem!</exception> public static int EncodeStart(int Handle, string Filename, EncodeFlags Flags, EncoderProcedure Procedure, IntPtr User = default(IntPtr)) { return(BASS_Encode_StartUser(Handle, Filename, Flags | EncodeFlags.Unicode, Procedure, User)); }
public static extern int EncodeStart(int handle, [MarshalAs(UnmanagedType.LPStr)] string filename, BassFlags flags, EncoderProcedure proc, IntPtr user);