예제 #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));
        }
예제 #3
0
파일: BassPlayer.cs 프로젝트: ilynx/lmaml
        private void Setup()
        {
            if (!Bassh.BASS_Init(-1, sampleRate.Value, BASSInit.BASS_DEVICE_LATENCY | BASSInit.BASS_DEVICE_FREQ, IntPtr.Zero))
            {
                throw new InvalidOperationException("Could not initialize BASS");
            }
            Bassh.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, 4);
            Bassh.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, bufferSize.Value);
            Bassh.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, bufferSize.Value / 10);
            Trace.WriteLine(Bassh.BASS_GetInfo());
            var plugins = Bassh.BASS_PluginLoadDirectory(Environment.CurrentDirectory);

            mixerHandle = BassMix.BASS_Mixer_StreamCreate(sampleRate.Value, 2, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_NONSTOP);
            Bassh.BASS_ChannelPlay(mixerHandle, true);
            if (null == plugins)
            {
                return;
            }
            foreach (var plugin in plugins)
            {
                pluginHandles.Add(plugin.Key);
                logger.Log(LoggingType.Information, this, string.Format("Plugin Loaded: {0}", plugin.Value));
            }
        }
예제 #4
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     BassMix.BASS_Mixer_ChannelRemove(channelHandle);
     Bassh.BASS_StreamFree(channelHandle);
 }
예제 #5
0
        /// <summary>
        /// Seeks to the specified offset (In milliseconds).
        /// </summary>
        /// <param name="offset">The offset.</param>
        public void Seek(double offset)
        {
            var byteOffset = Bassh.BASS_ChannelSeconds2Bytes(channelHandle, offset / 1000d);

            BassMix.BASS_Mixer_ChannelSetPosition(channelHandle, byteOffset, BASSMode.BASS_POS_BYTES);
        }