예제 #1
0
        internal BassTrack(int channelHandle, int mixerHandle, string file)
        {
            this.channelHandle = channelHandle;
            this.mixerHandle   = mixerHandle;
            var trackLength = Bassh.BASS_ChannelGetLength(channelHandle, BASSMode.BASS_POS_BYTES);

            length = TimeSpan.FromSeconds(Bassh.BASS_ChannelBytes2Seconds(channelHandle, trackLength));
            var channelInfo = Bassh.BASS_ChannelGetInfo(channelHandle);

            sampleRate = channelInfo.freq;
            name       = file;
        }
예제 #2
0
파일: BassPlayer.cs 프로젝트: ilynx/lmaml
        /// <summary>
        /// Creates the channel.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <returns></returns>
        public ITrack CreateChannel(string file)
        {
            var channelHandle = Bassh.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE);

            Bassh.BASS_ChannelSetAttribute(channelHandle, BASSAttribute.BASS_ATTRIB_SRC, 2);
            Debug.WriteLine(Bassh.BASS_ChannelGetInfo(channelHandle));
            if (0 == channelHandle)
            {
                throw new InvalidOperationException("Unable to create stream");
            }
            if (!BassMix.BASS_Mixer_StreamAddChannel(mixerHandle, channelHandle, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_MIXER_BUFFER | BASSFlag.BASS_MIXER_NORAMPIN))
            {
                Trace.WriteLine(Bassh.BASS_ErrorGetCode());
                throw new InvalidOperationException("Unable to add channel to mixer.");
            }
            return(new BassTrack(channelHandle, mixerHandle, file));
        }