Ejemplo n.º 1
0
 /// <summary>
 /// Loads a WAV, AIFF, MP3, MP2, MP1, OGG or plugin supported sample.
 /// <para>This overload uses an unmanaged IntPtr and implements loading a sample from memory.</para>
 /// </summary>
 /// <param name="Memory">A byte[] with the sample data to load.</param>
 /// <param name="Offset">File offset to load the sample from.</param>
 /// <param name="Length">Data length. Should be set to the length of the data contained in memory.</param>
 /// <param name="MaxNoOfPlaybacks">Maximum number of simultaneous playbacks... 1 (min) - 65535 (max)... use one of the override flags to choose the override decider, in the case of there being no free channel available for playback (ie. the sample is already playing max times).</param>
 /// <param name="Flags">A combination of <see cref="BassFlags"/> flags.</param>
 /// <returns>If successful, the loaded sample's handle is returned, else 0 is returned. Use <see cref="LastError" /> to get the error code.</returns>
 /// <remarks>
 /// <para>Additional format support is available via the plugin system (see <see cref="PluginLoad" />).</para>
 /// <para>
 /// Unless the BassFlags.SoftwareMixing flag is used, the sample will use hardware mixing if hardware resources are available.
 /// Use <see cref="GetInfo(out BassInfo)" /> to see if there are hardware mixing resources available, and which sample formats are supported by the hardware.
 /// The <see cref="BassFlags.VAM"/> flag allows a sample to be played by both hardware and software, with the decision made when the sample is played rather than when it's loaded.
 /// A sample's VAM options are set via <see cref="SampleSetInfo" />.
 /// </para>
 /// <para>To play a sample, first a channel must be obtained using <see cref="SampleGetChannel" />, which can then be played using <see cref="ChannelPlay" />.</para>
 /// <para>If you want to play a large or one-off sample, then it would probably be better to stream it instead with <see cref="CreateStream(byte[], long, long, BassFlags)" />.</para>
 /// <para>The <paramref name="Memory"/> can be safely discarded after calling this method, as a copy of it is made by Bass.</para>
 /// <para><b>Platform-specific</b></para>
 /// <para>
 /// The <see cref="BassFlags.VAM"/> flag requires DirectX 7 (or above).
 /// </para>
 /// <para>
 /// On Windows and Windows CE, ACM codecs are supported with compressed WAV files.
 /// On iOS and OSX, CoreAudio codecs are supported, adding support for any file formats that have a codec installed.
 /// </para>
 /// </remarks>
 /// <exception cref="Errors.Init"><see cref="Init" /> has not been successfully called.</exception>
 /// <exception cref="Errors.NotAvailable">Sample functions are not available when using the <see cref="NoSoundDevice"/> device.</exception>
 /// <exception cref="Errors.Parameter"><paramref name="MaxNoOfPlaybacks" /> and/or <paramref name="Length" /> is invalid. Specifying <paramref name="Length" /> is mandatory when loading from memory.</exception>
 /// <exception cref="Errors.FileOpen">The <paramref name="Memory" /> could not be opened.</exception>
 /// <exception cref="Errors.FileFormat">The <paramref name="Memory" />'s format is not recognised/supported.</exception>
 /// <exception cref="Errors.Codec">The file uses a codec that's not available/supported. This can apply to WAV and AIFF files, and also MP3 files when using the "MP3-free" BASS version.</exception>
 /// <exception cref="Errors.SampleFormat">The sample format is not supported by the device/drivers. If the sample is more than stereo or the <see cref="BassFlags.Float"/> flag is used, it could be that they are not supported.</exception>
 /// <exception cref="Errors.Memory">There is insufficient memory.</exception>
 /// <exception cref="Errors.No3D">Could not initialize 3D support.</exception>
 /// <exception cref="Errors.Unknown">Some other mystery problem!</exception>
 public static int SampleLoad(byte[] Memory, long Offset, int Length, int MaxNoOfPlaybacks, BassFlags Flags)
 {
     return(GCPin.CreateStreamHelper(Pointer => SampleLoad(Pointer, Offset, Length, MaxNoOfPlaybacks, Flags), Memory));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Loads a MOD music file - MO3 / IT / XM / S3M / MTM / MOD / UMX formats from memory.
 /// </summary>
 /// <param name="Memory">byte[] containing the music data.</param>
 /// <param name="Offset">Memory offset to load the MOD music from.</param>
 /// <param name="Length">Data length.</param>
 /// <param name="Flags">A combination of <see cref="BassFlags"/>.</param>
 /// <param name="Frequency">Sample rate to render/play the MOD music at... 0 = the rate specified in the <see cref="Init" /> call.</param>
 /// <returns>If successful, the loaded music's handle is returned, else 0 is returned. Use <see cref="LastError" /> to get the error code.</returns>
 /// <remarks>
 /// <para>BASS uses the same code as XMPlay for it's MOD music support, giving the most accurate reproduction of MO3 / IT / XM / S3M / MTM / MOD / UMX files available from any sound system.</para>
 /// <para>
 /// MO3s are treated and used in exactly the same way as normal MOD musics.
 /// The advantage of MO3s is that they can be a lot smaller with virtually identical quality.
 /// Playing a MO3 does not use any more CPU power than playing the original MOD version does.
 /// The only difference is a slightly longer load time as the samples are being decoded.
 /// MO3 files are created using the MO3 encoder available at the BASS website.
 /// </para>
 /// <para>
 /// DMO effects (the same as available with <see cref="ChannelSetFX" />) can be used in IT and XM files (and MO3 versions of them) created with Modplug Tracker.
 /// This allows effects to be added to a track without having to resort to an MP3 or OGG version, so it can remain small and still sound fancy.
 /// Of course, the effects require some CPU, so should not be used carelessly if performance is key.
 /// DirectX 8 (or above) is required for the effects to be heard - without that, the music can still be played, but the effects are disabled.
 /// </para>
 /// <para>
 /// "Ramping" does not take a lot of extra processing and improves the sound quality by removing clicks, by ramping/smoothing volume and pan changes.
 /// The start of a sample may also be ramped-in.
 /// That is always the case with XM files (or MOD files in FT2 mode) when using normal ramping, and possibly with all formats when using sensitive ramping; senstitive ramping will only ramp-in when necessary to avoid a click.
 /// Generally, normal ramping is recommended for XM files, and sensitive ramping for the other formats, but some XM files may also sound better using sensitive ramping.
 /// </para>
 /// <para>
 /// When loading a MOD music from memory, Bass does not use the memory after it has loaded the MOD music.
 /// So you can do whatever you want with the memory after calling this function.
 /// </para>
 /// <para><b>Platform-specific</b></para>
 /// <para>
 /// DMO effects are not supported in MOD music on Windows CE, and DirectX 8 (or above) is required on Windows.
 /// They are always available on other platforms, except for the following: Compressor, Gargle, and I3DL2Reverb.
 /// When a DMO effect is unavailable, the MOD music can still be played, but the effect will be disabled.
 /// </para>
 /// </remarks>
 /// <exception cref="Errors.Init"><see cref="Init" /> has not been successfully called.</exception>
 /// <exception cref="Errors.NotAvailable">The <see cref="BassFlags.AutoFree"/> flag is unavailable to decoding channels.</exception>
 /// <exception cref="Errors.FileOpen"><paramref name="Memory"/> could not be opened.</exception>
 /// <exception cref="Errors.FileFormat"><paramref name="Memory"/>'s format is not recognised/supported.</exception>
 /// <exception cref="Errors.SampleFormat">The sample format is not supported by the device/drivers. If the stream is more than stereo or the <see cref="BassFlags.Float"/> flag is used, it could be that they are not supported.</exception>
 /// <exception cref="Errors.Speaker">The specified SPEAKER flags are invalid. The device/drivers do not support them, they are attempting to assign a stereo stream to a mono speaker or 3D functionality is enabled.</exception>
 /// <exception cref="Errors.Memory">There is insufficient memory.</exception>
 /// <exception cref="Errors.No3D">Could not initialize 3D support.</exception>
 /// <exception cref="Errors.Unknown">Some other mystery problem!</exception>
 public static int MusicLoad(byte[] Memory, long Offset, int Length, BassFlags Flags = BassFlags.Default, int Frequency = 0)
 {
     return(GCPin.CreateStreamHelper(Pointer => MusicLoad(Pointer, Offset, Length, Flags), Memory));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieves the parameters of an effect
 /// </summary>
 /// <param name="Handle">The effect handle</param>
 /// <param name="Parameters">The parameters structure to fill. The structure used depends on the effect type.</param>
 /// <returns>
 /// If successful, <see langword="true"/> is returned, else <see langword="false"/> is returned.
 /// Use <see cref="LastError"/> to get the error code.
 /// </returns>
 /// <exception cref="Errors.Handle"><paramref name="Handle"/> is not valid.</exception>
 /// <seealso cref="ChannelSetFX"/>
 /// <seealso cref="FXSetParameters(int,IntPtr)"/>
 public static bool FXGetParameters(int Handle, IEffectParameter Parameters)
 {
     using (var gcp = new GCPin(Parameters))
         return(FXGetParameters(Handle, gcp.Pointer));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file in memory (byte[]).
 /// </summary>
 /// <param name="Memory">A byte[] containing file data.</param>
 /// <param name="Offset">Offset to begin streaming from.</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">Any combination of <see cref="BassFlags"/>.</param>
 /// <returns>If successful, the new stream's handle is returned, else 0 is returned. Use <see cref="LastError" /> to get the error code.</returns>
 /// <remarks>
 /// <para>
 /// BASS has built-in support for MPEG, OGG, WAV and AIFF files.
 /// Support for additional formats is available via add-ons, which can be downloaded from the BASS website: <a href="http://www.un4seen.com">www.un4seen.com</a>.
 /// </para>
 /// <para>
 /// MPEG 1.0, 2.0 and 2.5 layer 3 (MP3) files are supported, layers 1 (MP1) and 2 (MP2) are also supported.
 /// Standard RIFF and RF64 WAV files are supported, with the sample data in a PCM format or compressed with an ACM codec, but the codec is required to be installed on the user's system for the WAV to be decoded.
 /// So you should either distribute the codec with your software, or use a codec that comes with Windows (eg. Microsoft ADPCM).
 /// All PCM formats from 8 to 32-bit are supported in WAV and AIFF files, but the output will be restricted to 16-bit unless the <see cref="BassFlags.Float"/> flag is used.
 /// 64-bit floating-point WAV and AIFF files are also supported, but are rendered in 16-bit or 32-bit floating-point depending on the flags.
 /// The file's original resolution is available via <see cref="ChannelGetInfo(int, out ChannelInfo)" />.
 /// </para>
 /// <para>
 /// Chained OGG files containing multiple logical bitstreams are supported, but seeking within them is only fully supported if the <see cref="BassFlags.Prescan"/> flag is used (or the <see cref="OggPreScan"/> config option is enabled) to have them pre-scanned.
 /// Without pre-scanning, seeking will only be possible back to the start.
 /// The <see cref="PositionFlags.OGG"/> mode can be used with <see cref="ChannelGetLength" /> to get the number of bitstreams and with <see cref="ChannelSetPosition" /> to seek to a particular one.
 /// A <see cref="SyncFlags.OggChange"/> sync can be set via <see cref="ChannelSetSync(int, SyncFlags, long, SyncProcedure, IntPtr)" /> to be informed of when a new bitstream begins during decoding/playback.
 /// </para>
 /// <para>Multi-channel (ie. more than stereo) OGG, WAV and AIFF files are supported.</para>
 /// <para>
 /// Use <see cref="ChannelGetInfo(int, out ChannelInfo)" /> to retrieve information on the format (sample rate, resolution, channels) of the stream.
 /// The playback length of the stream can be retrieved using <see cref="ChannelGetLength" />.
 /// </para>
 /// <para>
 /// If <paramref name="Length"/> = 0 (use all data up to the end of the file), and the file length increases after creating the stream (ie. the file is still being written), then BASS will play the extra data too, but the length returned by <see cref="ChannelGetLength" /> will not be updated until the end is reached.
 /// The <see cref="StreamGetFilePosition" /> return values will be updated during playback of the extra data though.
 /// </para>
 /// <para>
 /// The <paramref name="Memory"/> is pinned by this overload and freed when the stream is freed.
 /// </para>
 /// <para>
 /// To stream a file from the internet, use <see cref="CreateStream(string, int, BassFlags, DownloadProcedure, IntPtr)" />.
 /// To stream from other locations, see <see cref="CreateStream(StreamSystem, BassFlags, FileProcedures, IntPtr)" />.
 /// </para>
 /// <para><b>Platform-specific</b></para>
 /// <para>
 /// On Windows and Windows CE, ACM codecs are supported with compressed WAV files.
 /// Media Foundation codecs are also supported on Windows 7 and updated versions of Vista, including support for AAC/MP4 and WMA.
 /// On iOS and OSX, CoreAudio codecs are supported, adding support for any file formats that have a codec installed.
 /// Media Foundation and CoreAudio codecs are only tried after the built-in decoders and any plugins have rejected the file.
 /// </para>
 /// </remarks>
 /// <exception cref="Errors.Init"><see cref="Init" /> has not been successfully called.</exception>
 /// <exception cref="Errors.NotAvailable">Only decoding channels (<see cref="BassFlags.Decode"/>) are allowed when using the <see cref="NoSoundDevice"/> device. The <see cref="BassFlags.AutoFree"/> flag is also unavailable to decoding channels.</exception>
 /// <exception cref="Errors.Parameter">The <paramref name="Length" /> must be specified when streaming from memory.</exception>
 /// <exception cref="Errors.FileFormat">The file's format is not recognised/supported.</exception>
 /// <exception cref="Errors.Codec">The file uses a codec that's not available/supported. This can apply to WAV and AIFF files, and also MP3 files when using the "MP3-free" BASS version.</exception>
 /// <exception cref="Errors.SampleFormat">The sample format is not supported by the device/drivers. If the stream is more than stereo or the <see cref="BassFlags.Float"/> flag is used, it could be that they are not supported.</exception>
 /// <exception cref="Errors.Speaker">The specified SPEAKER flags are invalid. The device/drivers do not support them, they are attempting to assign a stereo stream to a mono speaker or 3D functionality is enabled.</exception>
 /// <exception cref="Errors.Memory">There is insufficient memory.</exception>
 /// <exception cref="Errors.No3D">Could not initialize 3D support.</exception>
 /// <exception cref="Errors.Unknown">Some other mystery problem!</exception>
 public static int CreateStream(byte[] Memory, long Offset, long Length, BassFlags Flags)
 {
     return(GCPin.CreateStreamHelper(Pointer => CreateStream(Pointer, Offset, Length, Flags), Memory));
 }