예제 #1
0
        /// <summary>
        ///     Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plug-in supported file.
        /// </summary>
        /// <param name="file">File name.</param>
        /// <param name="configs">Configure of <see cref="AudioFileStream" />.</param>
        /// <param name="offset">File offset to begin streaming from.</param>
        /// <param name="length">Data length... 0 = use all data up to the end of the file.</param>
        public AudioFileStream(String file, StreamCreateFileConfig configs, uint offset, uint length)
        {
            configs |= StreamCreateFileConfig.Unicode;

            using (var fileNameHandle = InteropHelper.StringToPtr(file))
            {
                Handle = AudioStreamModule.StreamCreateFileFunction.CheckResult(
                    AudioStreamModule.StreamCreateFileFunction.Delegate(false,
                                                                        fileNameHandle.Handle, offset, length, configs));
            }
        }
예제 #2
0
        /// <summary>
        ///     Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plug-in supported file.
        /// </summary>
        /// <param name="file">File name.</param>
        /// <param name="configs">Configure of <see cref="AudioFileStream" />.</param>
        /// <param name="offset">File offset to begin streaming from.</param>
        /// <param name="length">Data length... 0 = use all data up to the end of the file.</param>
        public AudioFileStream(String file, StreamCreateFileConfig configs, uint offset, uint length)
        {
            configs |= StreamCreateFileConfig.Unicode;

            using (var fileNameHandle = InteropHelper.StringToPtr(file))
            {
                Handle = AudioStreamModule.StreamCreateFileFunction.CheckResult(
                    AudioStreamModule.StreamCreateFileFunction.Delegate(false,
                        fileNameHandle.Handle, offset, length, configs));
            }
        }
예제 #3
0
        /// <summary>
        ///     Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plug-in supported memory stream.
        /// </summary>
        /// <param name="stream">Memory stream.</param>
        /// <param name="configs">Configure of <see cref="AudioFileStream" />.</param>
        public AudioFileStream(MemoryStream stream, StreamCreateFileConfig configs)
        {
            ArraySegment<byte> bufferSegment;
            byte[] buffer = null;
            if (stream.TryGetBuffer(out bufferSegment))
            {
                buffer = bufferSegment.Array;
            }
            else
            {
                buffer = stream.ToArray();
            }

            GCHandle bufferHandle = GCHandle.Alloc(buffer);

            Handle = AudioStreamModule.StreamCreateFileFunction.CheckResult(
                AudioStreamModule.StreamCreateFileFunction.Delegate(true,
                    bufferHandle.AddrOfPinnedObject(), 0, (uint) stream.Length, configs));

            bufferHandle.Free();
        }
예제 #4
0
        /// <summary>
        ///     Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plug-in supported memory stream.
        /// </summary>
        /// <param name="stream">Memory stream.</param>
        /// <param name="configs">Configure of <see cref="AudioFileStream" />.</param>
        public AudioFileStream(MemoryStream stream, StreamCreateFileConfig configs)
        {
            ArraySegment <byte> bufferSegment;

            byte[] buffer = null;
            if (stream.TryGetBuffer(out bufferSegment))
            {
                buffer = bufferSegment.Array;
            }
            else
            {
                buffer = stream.ToArray();
            }

            GCHandle bufferHandle = GCHandle.Alloc(buffer);

            Handle = AudioStreamModule.StreamCreateFileFunction.CheckResult(
                AudioStreamModule.StreamCreateFileFunction.Delegate(true,
                                                                    bufferHandle.AddrOfPinnedObject(), 0, (uint)stream.Length, configs));

            bufferHandle.Free();
        }
예제 #5
0
 /// <summary>
 ///     Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plug-in supported file.
 /// </summary>
 /// <param name="file">File name.</param>
 /// <param name="configs">Configure of <see cref="AudioFileStream" />.</param>
 public AudioFileStream(String file, StreamCreateFileConfig configs) : this(file, configs, 0, 0)
 {
 }
예제 #6
0
 /// <summary>
 ///     Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plug-in supported file.
 /// </summary>
 /// <param name="file">File name.</param>
 /// <param name="configs">Configure of <see cref="AudioFileStream" />.</param>
 public AudioFileStream(String file, StreamCreateFileConfig configs) : this(file, configs, 0, 0)
 {
 }