Example #1
0
        public Sample LoadSample(bool mem, [NotNull] string filename, int offset,
            int length, int max, SampleInfoFlags flags)
        {
            if (_disposed)
                throw new ObjectDisposedException("BASSEngine");

            int handle = Bass.BASS_SampleLoad(filename, offset, length, max, (BASSFlag) flags);
            if (handle == 0) throw new BASSException();
            return new Sample(handle);
        }
Example #2
0
        /// <summary>
        ///     Create a sample. This function allows you to generate custom samples, or
        ///     load samples that are not in the WAV format. A pointer is returned to the
        ///     memory location at which you should write the sample's data. After writing
        ///     the data, call BASS_SampleCreateDone to get the new sample's handle.
        /// </summary>
        /// <param name="freq">default sample rate</param>
        /// <param name="max">Maximum number of simultaneous playbacks (1-65535)</param>
        /// <param name="flags">SampleInfoFlags</param>
        /// <returns></returns>
        public Sample CreateSample(short[] data, int freq, int max, SampleInfoFlags flags)
        {
            if (_disposed)
                throw new ObjectDisposedException("BASSEngine");

            int sample = Bass.BASS_SampleCreate(data.Length, freq, 2, max, (BASSFlag) flags);
            if(sample == 0) throw new BASSException();

            if(!Bass.BASS_SampleSetData(sample, data))
                throw new BASSException();

            return new Sample(sample);

            //IntPtr memloc = _CreateSample(data.Length, freq, max, (int) flags);
            //Marshal.Copy(data, 0, memloc, data.Length);
            //if (memloc == IntPtr.Zero) throw new BASSException();
            //IntPtr sample = _CreateSampleDone(); /// ???????????
            //if (sample == IntPtr.Zero) throw new BASSException();
            //return new Sample(sample);
        }