Esempio n. 1
0
        public static void LoadPlugin(string dllFilePath)
        {
            try
            {
                if (string.Equals(Path.GetFileName(dllFilePath), NativeMethods.BASS_DLL))
                {
                    //忽略bass.dll
                    return;
                }

                FreePlugin(dllFilePath);//释放已加载的同名文件
                int handle = NativeMethods.BASS_PluginLoad(dllFilePath, BASSFlag.BASS_UNICODE);
                //If successful, the loaded plugin's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.
                if (handle == 0)
                {
                    int errCode = NativeMethods.BASS_ErrorGetCode();
                    if (errCode == BassErrorCode.BASS_ERROR_FILEFORM || errCode == BassErrorCode.BASS_ERROR_FILEOPEN)
                    {
                        //非bass插件
                        return;
                    }

                    throw new WavException(BassErrorCode.GetErrorInfo());
                }
                _pluginHandleFilePathDic.Add(handle, dllFilePath);
            }
            catch (Exception ex)
            {
                WavLoger.OnRaiseLog(nameof(LoadPlugin), $"加载插件{dllFilePath}失败", ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the device to use for subsequent calls in the current thread
        /// </summary>
        /// <param name="device">The device to use... 0 = no sound, 1 = first real output device</param>
        public static void SetDevice(int device)
        {
            bool result = NativeMethods.BASS_SetDevice(device);

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Frees all resources used by the recording device.
        /// </summary>
        public static void RecordFree()
        {
            bool result = NativeMethods.BASS_RecordFree();

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adjusts the settings of a recording input source.
        /// </summary>
        /// <param name="input">The input to adjust the settings of... 0 = first, -1 = master. </param>
        /// <param name="setting">The new setting... a combination of these flags.
        /// BASS_INPUT_OFF Disable the input.This flag cannot be used when the device supports only one input at a time.
        /// BASS_INPUT_ON Enable the input. If the device only allows one input at a time, then any previously enabled input will be disabled by this
        /// </param>
        /// <param name="volume">The volume level... 0 (silent) to 1 (max), less than 0 = leave current. </param>
        public static void RecordSetInput(int input, BASSInput setting, float volume)
        {
            bool result = NativeMethods.BASS_RecordSetInput(input, setting, volume);

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Stops all musics/samples/streams output.
        /// </summary>
        public static void StopOutput()
        {
            bool result = NativeMethods.BASS_Stop();

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Sets the playback position of a sample, MOD music, or stream
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HSTREAM or HMUSIC</param>
        /// <param name="pos">The position, in units determined by the mode</param>
        /// <param name="mode">How to set the position. One of the following, with optional flags</param>
        public static void ChannelSetPosition(int handle, long pos, BASSMode mode)
        {
            bool result = NativeMethods.BASS_ChannelSetPosition(handle, pos, mode);

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Frees a sample stream's resources, including any sync/DSP/FX it has.
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD</param>
        public static void StreamFree(int handle)
        {
            bool result = NativeMethods.BASS_StreamFree(handle);

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Updates the playback buffer of a stream or MOD music
        /// </summary>
        /// <param name="handle">The channel handle... a HMUSIC or HSTREAM. </param>
        /// <param name="length">The amount of data to render, in milliseconds... 0 = default (2 x update period). This is capped at the space available in the buffer.</param>
        public static void ChannelUpdate(int handle, int length)
        {
            bool result = NativeMethods.BASS_ChannelUpdate(handle, length);

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Stops a sample, stream, MOD music, or recording.
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD</param>
        public static void ChannelStop(int handle)
        {
            bool result = NativeMethods.BASS_ChannelStop(handle);

            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Removes a synchronizer from a MOD music, stream or recording channel.
        /// </summary>
        /// <param name="handle">The channel handle... a HMUSIC, HSTREAM or HRECORD</param>
        /// <param name="sync">Handle of the synchronizer to remove</param>
        public static void BASS_ChannelRemoveSync(int handle, int sync)
        {
            bool result = NativeMethods.BASS_ChannelRemoveSync(handle, sync);

            //If successful, TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code
            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Sets the output master volume.(操作系统音量)
        /// </summary>
        /// <param name="volume">volume The volume level... 0 (silent) to 1 (max).</param>
        public static void SetVolume(float volume)
        {
            bool result = NativeMethods.BASS_SetVolume(volume);

            //If successful, then TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code.
            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Slides a channel's attribute from its current value to a new value
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HSTREAM, HMUSIC, or HRECORD</param>
        /// <param name="attribute">The attribute to slide the value of... one of the following,other attributes may be supported by add-ons, see the documentation</param>
        /// <param name="value">The new attribute value. See the attribute's documentation for details on the possible values. </param>
        /// <param name="time">The length of time (in milliseconds) that it should take for the attribute to reach the value</param>
        public static void ChannelSlideAttribute(int handle, BASSAttribute attribute, float value, int time)
        {
            bool result = NativeMethods.BASS_ChannelSlideAttribute(handle, attribute, value, time);

            //If successful, then TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code
            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Sets the value of a channel's attribute
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD</param>
        /// <param name="attribute">The attribute to set the value of... one of the following.
        /// BASS_ATTRIB_SCANINFO Scanned info. (HSTREAM only)
        /// other attributes may be supported by add-ons, see the documentation</param>
        /// <param name="value">The new attribute data</param>
        /// <param name="size">The size of the attribute data</param>
        public static void ChannelSetAttributeEx(int handle, BASSAttribute attribute, IntPtr value, int size)
        {
            bool result = NativeMethods.BASS_ChannelSetAttributeEx(handle, attribute, value, size);

            //If successful, TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code.
            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Sets the value of a pointer config option
        /// </summary>
        /// <param name="option">The option to set the value of... one of the following</param>
        /// <param name="newvalue">The new option setting. See the option's documentation for details on the possible values. </param>
        public static void BASS_SetConfigPtr(BASSConfig option, IntPtr newvalue)
        {
            bool result = NativeMethods.BASS_SetConfigPtr(option, newvalue);

            //If successful, the value of the requested config option is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code
            if (!result)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Creates a user sample stream.
        /// </summary>
        /// <param name="freq">The default sample rate. The sample rate can be changed using BASS_ChannelSetAttribute. </param>
        /// <param name="chans">The number of channels... 1 = mono, 2 = stereo, 4 = quadraphonic, 6 = 5.1, 8 = 7.1. </param>
        /// <param name="flags">A combination of these flags.</param>
        /// <param name="proc">The user defined stream writing function, or one of the following.
        /// STREAMPROC_DEVICE Create a "dummy" stream for the device's final output mix. This allows DSP/FX to be applied to all channels that are playing on the device,
        /// rather than individual channels. DSP/FX parameter change latency is also reduced because channel playback buffering is avoided. The stream is created with the device's current output sample format;
        /// the freq, chans, and flags parameters are ignored.It will always be floating-point except on platforms/architectures that do not support floating-point (see BASS_CONFIG_FLOAT), where it will be 16-bit instead.
        /// STREAMPROC_DUMMY Create a "dummy" stream. A dummy stream does not have any sample data of its own, but a decoding dummy stream (with BASS_STREAM_DECODE flag) can be used to apply DSP/FX processing to any sample data, by setting DSP/FX on the stream and feeding the data through BASS_ChannelGetData. The dummy stream should have the same sample format as the data being fed through it.
        /// STREAMPROC_PUSH Create a "push" stream.Instead of BASS pulling data from a STREAMPROC function, data is pushed to BASS via BASS_StreamPutData.</param>
        /// <param name="user">User instance data to pass to the callback function. Unused when creating a dummy or push stream. </param>
        /// <returns>If successful, the new stream's handle is returned, else throw WavException</returns>

        public static int StreamCreate(int freq, int chans, BASSFlag flags, BASSStreamProc proc)
        {
            int handle = NativeMethods.BASS_StreamCreatePtr(freq, chans, flags, new IntPtr((int)proc), IntPtr.Zero);

            if (handle == 0)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(handle);
        }
Esempio n. 16
0
        /// <summary>
        /// Retrieves tags/headers from a channel.
        /// </summary>
        /// <param name="handle">The channel handle... a HMUSIC or HSTREAM.</param>
        /// <param name="tags">The tags/headers wanted... one of the following
        /// BASS_TAG_AM_MIME Android media codec MIME type. A single string is returned.
        /// BASS_TAG_AM_NAME Android media codec name.A single string is returned.This in only available on Android 4.3 and above.
        /// BASS_TAG_APE APE (v1 or v2) tags.A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null. Each string is in the form of "key=value", or "key=value1/value2/..." if there are multiple values.
        /// BASS_TAG_APE_BINARY APE binary tag.A pointer to a TAG_APE_BINARY structure is returned.
        /// + tag number (0=first)
        /// BASS_TAG_CA_CODEC CoreAudio codec information.A pointer to a TAG_CA_CODEC structure is returned.
        /// BASS_TAG_HTTP HTTP headers, only available when streaming from a HTTP server. A pointer to a series of null-terminated strings is returned, the final string ending with a double null.
        /// BASS_TAG_ICY ICY (Shoutcast) tags. A pointer to a series of null-terminated strings is returned, the final string ending with a double null.
        /// BASS_TAG_ID3 ID3v1 tags.A pointer to a TAG_ID3 structure is returned.
        /// BASS_TAG_ID3V2 ID3v2 tags.A pointer to a variable length block is returned.ID3v2 tags are supported at both the start and end of the file, and in designated RIFF/AIFF chunks. See www.id3.org for details of the block's structure.
        /// BASS_TAG_LYRICS3 Lyrics3v2 tag.A single string is returned, containing the Lyrics3v2 information. See www.id3.org/Lyrics3v2 for details of its format.
        /// BASS_TAG_META Shoutcast metadata.A single string is returned, containing the current stream title and url (usually omitted). The format of the string is: StreamTitle= 'xxx'; StreamUrl='xxx';
        /// BASS_TAG_MF Media Foundation metadata.A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
        /// BASS_TAG_MP4 MP4/iTunes metadata. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
        /// BASS_TAG_MUSIC_AUTH MOD music author. Only available in files created with the OpenMPT tracker.
        /// BASS_TAG_MUSIC_INST MOD instrument name.Only available with formats that have instruments, eg.IT and XM(and MO3).
        /// + instrument number (0=first)
        /// BASS_TAG_MUSIC_MESSAGE MOD message text.
        /// BASS_TAG_MUSIC_NAME MOD music title.
        /// BASS_TAG_MUSIC_ORDERS MOD music order list.A pointer to a byte array is returned, with each byte being the pattern number played at that order position. Pattern number 254 is "+++" (skip order) and 255 is "---" (end song).
        /// BASS_TAG_MUSIC_SAMPLE MOD sample name.
        /// + sample number (0=first)
        /// BASS_TAG_OGG OGG comments.A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
        /// BASS_TAG_RIFF_BEXT RIFF/BWF "bext" chunk tags.A pointer to a TAG_BEXT structure is returned.
        /// BASS_TAG_RIFF_CART RIFF/BWF "cart" chunk tags. A pointer to a TAG_CART structure is returned.
        /// BASS_TAG_RIFF_CUE RIFF "cue " chunk.A pointer to a TAG_CUE structure is returned.
        /// BASS_TAG_RIFF_DISP RIFF "DISP" chunk text (CF_TEXT) tag. A single string is returned.
        /// BASS_TAG_RIFF_INFO RIFF "INFO" chunk tags. A pointer to a series of null-terminated strings is returned, the final string ending with a double null. The tags are in the form of "XXXX=text", where "XXXX" is the chunk ID.
        /// BASS_TAG_RIFF_SMPL RIFF "smpl" chunk.A pointer to a TAG_SMPL structure is returned.
        /// BASS_TAG_VENDOR OGG encoder.A single UTF-8 string is returned.
        /// BASS_TAG_WAVEFORMAT WAVE "fmt " chunk contents. A pointer to a WAVEFORMATEX structure is returned.As well as WAVE files, this is also provided by Media Foundation codecs.
        /// BASS_TAG_WMA WMA tags.A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
        /// other tags may be supported by add-ons, see the documentation
        /// </param>
        /// <returns>If successful, the requested tags are returned, else NULL is returned. Use BASS_ErrorGetCode to get the error code</returns>
        public static IntPtr BASS_ChannelGetTags(int handle, BASSTag tags)
        {
            IntPtr result = NativeMethods.BASS_ChannelGetTags(handle, tags);

            if (result == IntPtr.Zero)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Esempio n. 17
0
        /// <summary>
        /// Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file.
        /// </summary>
        /// <param name="memory">An unmanaged pointer to the memory location as an IntPtr</param>
        /// <param name="offset">Offset to begin streaming from (unused for memory streams, set to 0). </param>
        /// <param name="length">Data length (needs to be set to the length of the memory stream in bytes which should be played)</param>
        /// <param name="flags">A combination of these flags.</param>
        /// <returns>If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code</returns>
        public static int StreamCreateFile(IntPtr memory, long offset, long length, BASSFlag flags)
        {
            int handle = NativeMethods.BASS_StreamCreateFileMemory(true, memory, offset, length, flags);

            if (handle == 0)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(handle);
        }
Esempio n. 18
0
        /// <summary>
        /// Retrieves the device that a channel is using.
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD. HSAMPLE handles may also be used</param>
        /// <returns>If successful, the device number is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code</returns>
        public static int ChannelGetDevice(int handle)
        {
            int result = NativeMethods.BASS_ChannelGetDevice(handle);

            if (result == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// Translates a time (seconds) position into bytes, based on a channel's format
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD. HSAMPLE handles may also be used</param>
        /// <param name="pos">The position to translate</param>
        /// <returns>If successful, then the translated length is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code</returns>
        public static long ChannelSeconds2Bytes(int handle, double pos)
        {
            long result = NativeMethods.BASS_ChannelSeconds2Bytes(handle, pos);

            if (result < 0d)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Esempio n. 20
0
        /// <summary>
        /// Translates a byte position into time (seconds), based on a channel's format
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD. HSAMPLE handles may also be used</param>
        /// <param name="pos">The position to translate</param>
        /// <returns>If successful, then the translated length is returned, else a negative value is returned. Use BASS_ErrorGetCode to get the error code</returns>
        public static double ChannelBytes2Seconds(int handle, long pos)
        {
            double result = NativeMethods.BASS_ChannelBytes2Seconds(handle, pos);

            if (result < 0d)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Esempio n. 21
0
        /// <summary>
        /// Adds data to a "push buffered" user file stream's buffer.
        /// </summary>
        /// <param name="handle">The stream handle. </param>
        /// <param name="buffer">Pointer to the file data.</param>
        /// <param name="length">The amount of data in bytes, or BASS_FILEDATA_END to end the file. </param>
        /// <returns>If successful, the number of bytes read from buffer is returned, else throw WavException</returns>
        public static int StreamPutFileData(int handle, float[] buffer, int length)
        {
            int count = NativeMethods.BASS_StreamPutFileData(handle, buffer, length);

            if (count == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(count);
        }
Esempio n. 22
0
        /// <summary>
        /// Retrieves the immediate sample data (or an FFT representation of it) of a sample channel, stream, MOD music, or recording channel.
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD. </param>
        /// <param name="buffer">Pointer to a buffer to receive the data... can be NULL when handle is a recording channel (HRECORD),
        /// to discard the requested amount of data from the recording buffer. </param>
        /// <param name="length">Number of bytes wanted (up to 268435455 or 0xFFFFFFF), and/or the following flags.
        /// BASS_DATA_FLOAT Return floating-point sample data.
        /// BASS_DATA_FIXED Return 8.24 fixed-point data.
        /// BASS_DATA_FFT256 256 sample FFT(returns 128 values).
        /// BASS_DATA_FFT512 512 sample FFT(returns 256 values).
        /// BASS_DATA_FFT1024 1024 sample FFT(returns 512 values).
        /// BASS_DATA_FFT2048 2048 sample FFT(returns 1024 values).
        /// BASS_DATA_FFT4096 4096 sample FFT(returns 2048 values).
        /// BASS_DATA_FFT8192 8192 sample FFT(returns 4096 values).
        /// BASS_DATA_FFT16384 16384 sample FFT(returns 8192 values).
        /// BASS_DATA_FFT32768 32768 sample FFT(returns 16384 values).
        /// BASS_DATA_FFT_COMPLEX Return the complex FFT result rather than the magnitudes.This increases the amount of data returned(as listed above) fourfold,
        ///                       as it returns real and imaginary parts and the full FFT result(not only the first half).The real and imaginary parts are interleaved in the returned data.
        /// BASS_DATA_FFT_INDIVIDUAL Perform a separate FFT for each channel, rather than a single combined FFT.The size of the data returned(as listed above) is multiplied by the number of channels.
        /// BASS_DATA_FFT_NOWINDOW Prevent a Hann window being applied to the sample data when performing an FFT.
        /// BASS_DATA_FFT_NYQUIST Return an extra value for the Nyquist frequency magnitude.The Nyquist frequency is always included in a complex FFT result.
        /// BASS_DATA_FFT_REMOVEDC Remove any DC bias from the sample data when performing an FFT.
        /// BASS_DATA_AVAILABLE Query the amount of data the channel has buffered for playback, or from recording.This flag cannot be used with decoding channels as they do not have playback buffers.
        ///                     buffer is ignored when using this flag.</param>
        /// <returns>When requesting FFT data, the number of bytes read from the channel (to perform the FFT) is returned.
        /// When requesting sample data, the number of bytes written to buffer will be returned (not necessarily the same as the number of bytes read when using the BASS_DATA_FLOAT or BASS_DATA_FIXED flag).
        /// When using the BASS_DATA_AVAILABLE flag, the number of bytes in the channel's buffer is returned. </returns>
        public static int ChannelGetData(int handle, IntPtr buffer, int length)
        {
            int result = NativeMethods.BASS_ChannelGetData(handle, buffer, length);

            if (result == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Esempio n. 23
0
        /// <summary>
        /// Adds sample data to a "push" stream.
        /// </summary>
        /// <param name="handle">The stream handle</param>
        /// <param name="buffer">Pointer to the sample data... NULL = allocate space in the queue buffer so that there is at least length bytes of free space. </param>
        /// <param name="length">The amount of data in bytes, optionally using the BASS_STREAMPROC_END flag to signify the end of the stream. 0 can be used to just check how much data is queued. </param>
        /// <returns>If successful, the amount of queued data is returned, else throw WavException.</returns>
        public static int StreamPutData(int handle, IntPtr buffer, int length)
        {
            int amount = NativeMethods.BASS_StreamPutData(handle, buffer, length);

            if (amount == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(amount);
        }
Esempio n. 24
0
        /// <summary>
        /// Modifies and retrieves a channel's flags
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM. </param>
        /// <param name="flags">A combination of these flags.
        /// BASS_SAMPLE_LOOP Loop the channel.
        /// BASS_STREAM_AUTOFREE Automatically free the channel when playback ends.Note that the BASS_MUSIC_AUTOFREE flag is identical to this flag. (HSTREAM/HMUSIC only)
        /// BASS_STREAM_RESTRATE Restrict the download rate. (HSTREAM)
        /// BASS_MUSIC_NONINTER Use non-interpolated sample mixing. (HMUSIC)
        /// BASS_MUSIC_SINCINTER Use sinc interpolated sample mixing. (HMUSIC)
        /// BASS_MUSIC_RAMP Use "normal" ramping. (HMUSIC)
        /// BASS_MUSIC_RAMPS Use "sensitive" ramping. (HMUSIC)
        /// BASS_MUSIC_SURROUND Use surround sound. (HMUSIC)
        /// BASS_MUSIC_SURROUND2 Use surround sound mode 2. (HMUSIC)
        /// BASS_MUSIC_FT2MOD Use FastTracker 2 .MOD playback. (HMUSIC)
        /// BASS_MUSIC_PT1MOD Use ProTracker 1 .MOD playback. (HMUSIC)
        /// BASS_MUSIC_POSRESET Stop all notes when seeking. (HMUSIC)
        /// BASS_MUSIC_POSRESETEX Stop all notes and reset BPM/etc when seeking. (HMUSIC)
        /// BASS_MUSIC_STOPBACK Stop when a backward jump effect is played. (HMUSIC)
        /// BASS_SPEAKER_xxx Speaker assignment flags. (HSTREAM/HMUSIC)
        /// other flags may be supported by add-ons, see the documentation. </param>
        /// <param name="mask">The flags (as above) to modify. Flags that are not included in this are left as they are, so it can be set to 0 in order to just retrieve the current flags. To modify the speaker flags, any of the BASS_SPEAKER_xxx flags can be used in the mask (no need to include all of them). </param>
        /// <returns>If successful, the channel's updated flags are returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code.</returns>
        public static BASSFlag ChannelFlags(int handle, BASSFlag flags, BASSFlag mask)
        {
            int result = NativeMethods.BASS_ChannelFlags(handle, flags, mask);

            if (result == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return((BASSFlag)result);
        }
Esempio n. 25
0
        /// <summary>
        /// Retrieves information on a recording device
        /// </summary>
        /// <param name="device">The device to get the information of... 0 = first.</param>
        /// <param name="info">Pointer to a structure to receive the information. </param>
        /// <returns>returned BASS_DEVICEINFO.</returns>
        public static BASS_DEVICEINFO RecordGetDeviceInfo(int device)
        {
            BASS_DEVICEINFO info = new BASS_DEVICEINFO(device);

            if (NativeMethods.BASS_RecordGetDeviceInfo(device, ref info._internal))
            {
                return(info);
            }

            throw new WavException(BassErrorCode.GetErrorInfo());
        }
Esempio n. 26
0
        /// <summary>
        /// Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file via user callback functions.
        /// </summary>
        /// <param name="system">File system to use, one of the following. </param>
        /// <param name="flags">A combination of these flags.</param>
        /// <param name="procs">The user defined file functions. </param>
        /// <param name="user">User instance data to pass to the callback functions. </param>
        /// <returns>If successful, the new stream's handle is returned, else throw WavException.</returns>
        public static int StreamCreateFileUser(BASSStreamSystem system, BASSFlag flags, BASS_FILEPROCS procs, IntPtr user)
        {
            int handle = NativeMethods.BASS_StreamCreateFileUser(system, flags, procs, user);

            if (handle == 0)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(handle);
        }
Esempio n. 27
0
        /// <summary>
        /// Sets up a synchronizer on a MOD music, stream or recording channel.
        /// </summary>
        /// <param name="handle">The channel handle... a HMUSIC, HSTREAM or HRECORD. </param>
        /// <param name="type">The type of sync (see the table below). The following flags may also be used.
        /// BASS_SYNC_MIXTIME Call the sync function immediately when the sync is triggered, instead of delaying the call until the sync event is actually heard. This is automatic with some sync types (see table below), and always with decoding and recording channels, as they cannot be played/heard.
        /// BASS_SYNC_ONETIME Call the sync only once and then remove it from the channel.
        /// BASS_SYNC_THREAD Call the sync asynchronously in the dedicated sync thread.This only affects mixtime syncs (except BASS_SYNC_FREE syncs) and allows the callback function to safely call BASS_StreamFree or BASS_MusicFree on the same channel handle.</param>
        /// <param name="param">The sync parameter. Depends on the sync type... see the table below. </param>
        /// <param name="proc">The callback function. </param>
        /// <param name="user">User instance data to pass to the callback function. </param>
        /// <returns>If successful, then the new synchronizer's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code. </returns>
        public static int ChannelSetSync(int handle, BASSSync type, long param, SYNCPROC proc, IntPtr user)
        {
            int result = NativeMethods.BASS_ChannelSetSync(handle, type, param, proc, user);

            if (result == 0)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Esempio n. 28
0
        /// <summary>
        /// Retrieves the file position/status of a stream.
        /// </summary>
        /// <param name="handle">The stream handle. </param>
        /// <param name="mode">The file position/status to retrieve. One of the following</param>
        /// <returns> requested file position/status is returned</returns>
        public static long StreamGetFilePosition(int handle, BASSStreamFilePosition mode)
        {
            long pos = NativeMethods.BASS_StreamGetFilePosition(handle, mode);

            if (pos == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(pos);
        }
Esempio n. 29
0
        /// <summary>
        /// Retrieves the playback length of a channel.
        /// </summary>
        /// <param name="handle">The channel handle... a HCHANNEL, HMUSIC, HSTREAM. HSAMPLE handles may also be used</param>
        /// <param name="mode">
        /// How to retrieve the length. One of the following.
        /// BASS_POS_BYTE Get the length in bytes.
        /// BASS_POS_MUSIC_ORDER Get the length in orders. (HMUSIC only)
        /// BASS_POS_OGG Get the number of bitstreams in an OGG file.
        /// other modes may be supported by add-ons, see the documentation
        /// </param>
        /// <returns>If successful, then the channel's length is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code. </returns>
        public static long ChannelGetLength(int handle, BASSMode mode)
        {
            long result = NativeMethods.BASS_ChannelGetLength(handle, mode);

            if (result == -1)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Esempio n. 30
0
        /// <summary>
        /// Creates a user sample stream.
        /// </summary>
        /// <param name="freq">The default sample rate. The sample rate can be changed using BASS_ChannelSetAttribute. </param>
        /// <param name="chans">The number of channels... 1 = mono, 2 = stereo, 4 = quadraphonic, 6 = 5.1, 8 = 7.1. </param>
        /// <param name="flags">A combination of these flags.</param>
        /// <param name="proc">The user defined stream writing function, or one of the following.
        /// STREAMPROC_DEVICE Create a "dummy" stream for the device's final output mix. This allows DSP/FX to be applied to all channels that are playing on the device,
        /// rather than individual channels. DSP/FX parameter change latency is also reduced because channel playback buffering is avoided. The stream is created with the device's current output sample format;
        /// the freq, chans, and flags parameters are ignored.It will always be floating-point except on platforms/architectures that do not support floating-point (see BASS_CONFIG_FLOAT), where it will be 16-bit instead.
        /// STREAMPROC_DUMMY Create a "dummy" stream. A dummy stream does not have any sample data of its own, but a decoding dummy stream (with BASS_STREAM_DECODE flag) can be used to apply DSP/FX processing to any sample data, by setting DSP/FX on the stream and feeding the data through BASS_ChannelGetData. The dummy stream should have the same sample format as the data being fed through it.
        /// STREAMPROC_PUSH Create a "push" stream.Instead of BASS pulling data from a STREAMPROC function, data is pushed to BASS via BASS_StreamPutData.</param>
        /// <param name="user">User instance data to pass to the callback function. Unused when creating a dummy or push stream. </param>
        /// <returns>If successful, the new stream's handle is returned, else throw WavException</returns>
        public static int StreamCreate(int freq, int chans, BASSFlag flags, STREAMPROC proc, IntPtr user)
        {
            int handle = NativeMethods.BASS_StreamCreate(freq, chans, flags, proc, IntPtr.Zero);

            if (handle == 0)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(handle);
        }