示例#1
0
        public void SetRepeatFile(int handle, bool repeat)
        {
            lock (m_Mutex)
            {
                if (!m_NotLoops.ContainsKey(handle))
                {
                    return; // file is looped anyway
                }
                if (m_CueOutRepeats.ContainsKey(handle))
                {
                    m_CueOutRepeats[handle] = repeat;
                    return;
                }

                if (repeat)
                {
                    Bass.BASS_ChannelFlags(handle, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
                    Bass.BASS_ChannelRemoveSync(handle, m_NotLoops[handle]);
                }
                else
                {
                    Bass.BASS_ChannelFlags(handle, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_SAMPLE_LOOP);
                    int sync = Bass.BASS_ChannelSetSync(handle, BASSSync.BASS_SYNC_END, 0, m_EndSync, IntPtr.Zero);
                    m_NotLoops[handle] = sync;
                }
            }
        }
示例#2
0
文件: BASSControl.cs 项目: walney/KMC
        public static void BASSPlayBackEngine(Int64 length, Int64 pos)
        {
            if (MainWindow.Seeking)
            {
                BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_NOTESOFF, 0);
                BassVst.BASS_VST_ProcessEvent(MainWindow.VSTs._VSTiHandle, 0, BASSMIDIEvent.MIDI_EVENT_NOTESOFF, 0);

                Bass.BASS_ChannelSetPosition(MainWindow.KMCGlobals._recHandle, MainWindow.CurrentSeek, BASSMode.BASS_POS_MIDI_TICK);
                MainWindow.Seeking = false;
                return;
            }

            Int32 tempo = BassMidi.BASS_MIDI_StreamGetEvent(MainWindow.KMCGlobals._recHandle, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO);

            MainWindow.KMCGlobals.OriginalTempo = 60000000 / tempo;

            Bass.BASS_ChannelFlags(MainWindow.KMCGlobals._recHandle, Properties.Settings.Default.DisableEffects ? BASSFlag.BASS_MIDI_NOFX : 0, BASSFlag.BASS_MIDI_NOFX);
            Bass.BASS_ChannelFlags(MainWindow.KMCGlobals._recHandle, Properties.Settings.Default.NoteOff1 ? BASSFlag.BASS_MIDI_NOTEOFF1 : 0, BASSFlag.BASS_MIDI_NOTEOFF1);

            for (Int32 i = 0; i <= 15; i++)
            {
                BassMidi.BASS_MIDI_StreamEvent(MainWindow.KMCGlobals._recHandle, i, BASSMIDIEvent.MIDI_EVENT_MIXLEVEL, MainWindow.KMCStatus.ChannelsVolume[i]);
            }

            MainWindow.KMCGlobals._VolFXParam.fCurrent = 1.0f;
            MainWindow.KMCGlobals._VolFXParam.fTarget  = Properties.Settings.Default.Volume;
            MainWindow.KMCGlobals._VolFXParam.fTime    = 0.0f;
            MainWindow.KMCGlobals._VolFXParam.lCurve   = 0;
            Bass.BASS_FXSetParameters(MainWindow.KMCGlobals._VolFX, MainWindow.KMCGlobals._VolFXParam);

            Bass.BASS_ChannelSetAttribute(MainWindow.KMCGlobals._recHandle, BASSAttribute.BASS_ATTRIB_MIDI_VOICES, Properties.Settings.Default.Voices);
        }
示例#3
0
        //-----------------------------------------------------------------------------------------------
        //ファイルを再生する
        //-----------------------------------------------------------------------------------------------
        public bool PlaySound(string fileName, int vol = 255, bool isLoop = false, double second = 0)
        {
            StopSound();
            playHandle = GetHandle(fileName);

            //if ((Bass.BASS_ChannelFlags(playHandle, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_DEFAULT) & BASSFlag.BASS_SAMPLE_LOOP) == BASSFlag.BASS_SAMPLE_LOOP)
            if (isLoop == false)
            {
                // loop flag was set, so remove it
                Bass.BASS_ChannelFlags(playHandle, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_SAMPLE_LOOP);
            }
            else
            {
                // loop flag was not set, so set it
                Bass.BASS_ChannelFlags(playHandle, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
            }

            Bass.BASS_ChannelPlay(playHandle, false);

//			int syncHandle = Bass.BASS_ChannelSetSync(playHandle, BASSSync.BASS_SYNC_END, 0, proc, IntPtr.Zero);
            //		if (syncHandle == 0) throw new InvalidOperationException("cannot set sync");

            Bass.BASS_ChannelSetPosition(playHandle, second);
            SetVolume(vol);
            //ret = Bass.BASS_ChannelGetLength(playHandle);
            m_length = Bass.BASS_ChannelBytes2Seconds(playHandle, Bass.BASS_ChannelGetLength(playHandle));

            return(true);
        }
示例#4
0
文件: BASSControl.cs 项目: walney/KMC
        public static void BASSEffectSettings()
        {
            Bass.BASS_ChannelFlags((MainWindow.VSTs.VSTInfo[0].isInstrument ? MainWindow.VSTs._VSTiHandle : MainWindow.KMCGlobals._recHandle), Properties.Settings.Default.DisableEffects ? BASSFlag.BASS_MIDI_NOFX : 0, BASSFlag.BASS_MIDI_NOFX);
            BASSCheckError();

            Bass.BASS_ChannelFlags((MainWindow.VSTs.VSTInfo[0].isInstrument ? MainWindow.VSTs._VSTiHandle : MainWindow.KMCGlobals._recHandle), Properties.Settings.Default.NoteOff1 ? BASSFlag.BASS_MIDI_NOTEOFF1 : 0, BASSFlag.BASS_MIDI_NOTEOFF1);
            BASSCheckError();
        }
示例#5
0
 public static void loop_channel(int flag) //установить / снять зацикление
 {
     if (flag == 4)
     {
         loop = 4;
         Bass.BASS_ChannelFlags(Stream, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
     }
     if (flag == 0)
     {
         loop = 0;
         Bass.BASS_ChannelFlags(Stream, 0, BASSFlag.BASS_SAMPLE_LOOP);
     }
 }
示例#6
0
        /// <summary>
        /// A method to play the sample.
        /// </summary>
        public void Play()
        {
            int channel = Bass.BASS_SampleGetChannel(handle, false);

            Bass.BASS_ChannelPlay(channel, false);
            channels.Add(channel);

            // Enable auto looping for looped samples without loop tags.
            if ((looped) && (loop_start < 0))
            {
                Bass.BASS_ChannelFlags(channel, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
            }
        }
示例#7
0
 protected void OnLoopUpdated()
 {
     if (this.BassHandle.HasValue)
     {
         if (this.loop)
         {
             Bass.BASS_ChannelFlags(this.basshandle.Value, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
         }
         else
         {
             Bass.BASS_ChannelFlags(this.basshandle.Value, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_SAMPLE_LOOP);
         }
     }
 }
示例#8
0
 private void RvAndChr_CheckedChanged(object sender, EventArgs e)
 {
     new Thread(() =>
     {
         Thread.CurrentThread.IsBackground = true;
         if (RvAndChr.Checked)
         {
             Bass.BASS_ChannelFlags(chan, 0, BASSFlag.BASS_MIDI_NOFX); // enable FX
         }
         else
         {
             Bass.BASS_ChannelFlags(chan, BASSFlag.BASS_MIDI_NOFX, BASSFlag.BASS_MIDI_NOFX); // disable FX
         }
     }).Start();
 }
        /// <summary>
        /// Starts streaming music from a designated file.
        /// </summary>
        /// <param name="Path">The path to the file.</param>
        /// <param name="ID">The ID of the file.</param>
        /// <param name="Loop">Whether or not to loop the playback.</param>
        /// <returns>The music track's channel.</returns>
        public int LoadMusicTrack(string Path, int ID, bool Loop)
        {
            int Channel = Bass.BASS_StreamCreateFile(Path, 0, 0, BASSFlag.BASS_DEFAULT | BASSFlag.BASS_STREAM_AUTOFREE);

            if (Loop)
            {
                Bass.BASS_ChannelFlags(Channel, BASSFlag.BASS_MUSIC_LOOP, BASSFlag.BASS_MUSIC_LOOP);
            }

            MusicTrack Track = new MusicTrack(ID, Channel);

            m_Tracks.Add(Track);

            Bass.BASS_ChannelPlay(Channel, false);

            return(Channel);
        }
示例#10
0
 private void LoopYesNo_Click(object sender, EventArgs e)
 {
     if (!LoopYesNo.Checked)
     {
         LoopYesNo.Checked = true;
         if (Bass.BASS_ChannelIsActive(hStream) == BASSActive.BASS_ACTIVE_PLAYING)
         {
             Bass.BASS_ChannelFlags(hStream, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
         }
     }
     else
     {
         LoopYesNo.Checked = false;
         if (Bass.BASS_ChannelIsActive(hStream) == BASSActive.BASS_ACTIVE_PLAYING)
         {
             Bass.BASS_ChannelFlags(hStream, 0, BASSFlag.BASS_SAMPLE_LOOP);
         }
     }
 }
示例#11
0
        private void SetLoop()
        {
            switch (this.IsLooping)
            {
            case true:
                foreach (Sample sample in Samples)
                {
                    Bass.BASS_ChannelFlags(sample.Channel, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
                }
                break;

            case false:
                foreach (Sample sample in Samples)
                {
                    Bass.BASS_ChannelFlags(sample.Channel, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_SAMPLE_LOOP);
                }
                break;
            }
        }
示例#12
0
        public void SetLoopMode(LOOP_MODE mode)
        {
            int handle = this.Stream;

            switch (mode)
            {
            case LOOP_MODE.TRACK:
                Bass.BASS_ChannelFlags(handle, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
                break;

            case LOOP_MODE.NONE:
            case LOOP_MODE.PLAYLIST:
                if ((Bass.BASS_ChannelFlags(handle, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_DEFAULT) & BASSFlag.BASS_SAMPLE_LOOP) == BASSFlag.BASS_SAMPLE_LOOP)
                {
                    Bass.BASS_ChannelFlags(handle, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_SAMPLE_LOOP);
                }
                break;
            }

            this.LoopMode = mode;
        }
示例#13
0
        public AmbiencePlayer(Ambience amb)
        {
            if (amb.Loop)
            {
                byte[] data = new XAFile(TSO.Content.Content.Get().GetPath(amb.Path)).DecompressedData;

                LoopSound = GCHandle.Alloc(data, GCHandleType.Pinned);

                IntPtr pointer = LoopSound.AddrOfPinnedObject();
                Channel = Bass.BASS_StreamCreateFile(pointer, 0, data.Length, BASSFlag.BASS_DEFAULT | BASSFlag.BASS_STREAM_AUTOFREE);
                //Bass.BASS_ChannelSetAttribute(Channel, BASSAttribute.BASS_ATTRIB_VOL, 0.33f);
                Bass.BASS_ChannelFlags(Channel, BASSFlag.BASS_MUSIC_LOOP, BASSFlag.BASS_MUSIC_LOOP);
                Bass.BASS_ChannelPlay(Channel, false);
                fscMode = false;
            }
            else
            {
                fsc = HITVM.Get().PlayFSC(TSO.Content.Content.Get().GetPath(amb.Path));
                fsc.SetVolume(0.33f); //may need tweaking
                fscMode = true;
            }
        }
示例#14
0
        public int PlayFile(ISoundFile file, int fadeInTime, PlayingFinished callback, bool loop)
        {
            int      channel     = 0;
            BASSFlag speakerFlag = GetSpeakerFlag(file);
            BASSFlag decodeFlag  = BASSFlag.BASS_STREAM_DECODE;

            if (file.SoundFileType == SoundFileType.Music && file.Effects.SpeakerAssignment.Active)
            {
                switch (file.Effects.SpeakerAssignment.Assignment)
                {
                case Data.SpeakerAssignment.AllSpeakers:
                case Data.SpeakerAssignment.BothCenterRears:
                case Data.SpeakerAssignment.BothFronts:
                case Data.SpeakerAssignment.BothRears:
                case Data.SpeakerAssignment.CenterAndSubwoofer:
                case Data.SpeakerAssignment.Default:
                    break;

                default:
                    decodeFlag |= BASSFlag.BASS_SAMPLE_MONO;
                    break;
                }
            }
#if MONO
            System.Runtime.InteropServices.GCHandle gcHandle = new System.Runtime.InteropServices.GCHandle();
#endif
            if (file.SoundFileType == SoundFileType.WebRadio)
            {
                channel = Bass.BASS_StreamCreateURL(file.Path, 0, decodeFlag | BASSFlag.BASS_STREAM_BLOCK, null, IntPtr.Zero);
            }
            else
            {
#if MONO
                byte[] buffer = null;
                long   length = 0;
                try
                {
#if ANDROID
                    if (file.Path.IsSmbFile())
                    {
                        buffer = SambaHelpers.GetFileContent(file.Path);
                        length = buffer.Length;
                    }
                    else
                    {
#endif
                    System.IO.FileStream fs = System.IO.File.OpenRead(file.Path);
                    length = fs.Length;
                    buffer = new byte[length];
                    fs.Read(buffer, 0, (int)length);
                    fs.Close();
#if ANDROID
                }
#endif
                }
                catch (System.IO.IOException e)
                {
                    ErrorHandling.ErrorOccurred(file.Id, e.Message);
                    return(0);
                }
                gcHandle = System.Runtime.InteropServices.GCHandle.Alloc(buffer, System.Runtime.InteropServices.GCHandleType.Pinned);
                channel  = Bass.BASS_StreamCreateFile(gcHandle.AddrOfPinnedObject(), 0L, length, decodeFlag);
#else // #if MONO
                channel = Bass.BASS_StreamCreateFile(file.Path, 0, 0, decodeFlag);
#endif
            }
            if (channel == 0)
            {
#if MONO
                if (gcHandle.IsAllocated)
                {
                    gcHandle.Free();
                }
#endif
                ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                return(0);
            }
            RunningFileInfo info         = new RunningFileInfo();
            bool isStreaming             = BassStreamer.Instance.IsStreaming;
            bool useMultiSpeakerChannels = false;
            int speakers    = 2;
            int origChannel = channel;
            if (!isStreaming && file.Effects != null &&
                file.Effects.SpeakerAssignment.Active && file.Effects.SpeakerAssignment.Assignment == Data.SpeakerAssignment.AllSpeakers &&
                !file.Effects.Balance.Active && !file.Effects.Pitch.Active && !file.Effects.Tempo.Active)
            {
                speakers = Bass.BASS_GetInfo().speakers;
                if (speakers > 2)
                {
                    useMultiSpeakerChannels = true;
                }
            }

            Un4seen.Bass.BASSFlag flags = BASSFlag.BASS_DEFAULT;
            if (isStreaming)
            {
                flags = BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_DECODE;
            }
            else if (useMultiSpeakerChannels)
            {
                flags = BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_DECODE;
            }
            else
            {
                flags = BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_FX_FREESOURCE | speakerFlag;
            }
            channel = Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_TempoCreate(channel, flags);
            if (channel == 0)
            {
#if MONO
                if (gcHandle.IsAllocated)
                {
                    gcHandle.Free();
                }
#endif
                ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                return(0);
            }
            bool result = true;
            if (useMultiSpeakerChannels)
            {
                int splitStream = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Split_StreamCreate(channel, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_SPEAKER_FRONT, null);
                if (splitStream == 0)
                {
                    result = false;
                }
                else
                {
                    int splitStream2 = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Split_StreamCreate(channel, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_SPEAKER_REAR, null);
                    if (splitStream2 == 0)
                    {
                        result = false;
                    }
                    else
                    {
                        Bass.BASS_ChannelSetLink(splitStream, splitStream2);
                        info.LinkedChannels = new List <int>();
                        info.LinkedChannels.Add(splitStream2);
                    }
                    if (result && speakers > 4)
                    {
                        int splitStream3 = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Split_StreamCreate(channel, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_SPEAKER_CENLFE, null);
                        if (splitStream3 == 0)
                        {
                            result = false;
                        }
                        else
                        {
                            Bass.BASS_ChannelSetLink(splitStream, splitStream3);
                            info.LinkedChannels.Add(splitStream3);
                        }
                    }
                    if (result && speakers > 6)
                    {
                        int splitStream4 = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Split_StreamCreate(channel, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_SPEAKER_REAR2, null);
                        if (splitStream4 == 0)
                        {
                            result = false;
                        }
                        else
                        {
                            Bass.BASS_ChannelSetLink(splitStream, splitStream4);
                            info.LinkedChannels.Add(splitStream4);
                        }
                    }
                    if (result)
                    {
                        channel = splitStream;
                    }
                }
            }
            if (result)
            {
                lock (m_Mutex)
                {
                    info.EndAction = new Action(() =>
                    {
                        callback(file.Id, channel);
                    });
                    info.Volume = file.Volume;
                }
                if (!loop)
                {
                    int sync = 0;
                    // If CueOut is active ...
                    if (file.Effects.CueOut.Active)
                    {
                        // Convert the CueOut position (seconds) into a byte offset
                        long cueOutPos = Bass.BASS_ChannelSeconds2Bytes(channel, file.Effects.CueOut.Position);
                        // Set the "end" sync to that position
                        sync = Bass.BASS_ChannelSetSync(channel, BASSSync.BASS_SYNC_POS, cueOutPos, m_CueOutSync, new IntPtr(file.Id));
                    }
                    else
                    {
                        long totalLength = Bass.BASS_ChannelGetLength(channel);
                        long endingTime  = Bass.BASS_ChannelSeconds2Bytes(channel, 0.1);

                        // Default: set the "end" sync to the end of the stream, minus one ms
                        sync = Bass.BASS_ChannelSetSync(channel, BASSSync.BASS_SYNC_POS, totalLength - endingTime, m_StartNextSync, IntPtr.Zero);
                    }

                    if (sync == 0)
                    {
#if MONO
                        if (gcHandle.IsAllocated)
                        {
                            gcHandle.Free();
                        }
#endif
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                        return(0);
                    }
                    else
                    {
                        lock (m_Mutex)
                        {
                            m_NotLoops[channel] = sync;
                        }
                    }
                }
                if (!SetStartVolume(file, fadeInTime, channel, info))
                {
                    return(0);
                }
                info.CrossFade = false;
                if (file.Effects != null && file.Effects.FadeOutTime != 0)
                {
                    long totalLength = Bass.BASS_ChannelGetLength(channel);
                    if (totalLength == -1)
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetVolumeError);
                        return(0);
                    }
                    long fadeOutLength = Bass.BASS_ChannelSeconds2Bytes(channel, 0.001 * file.Effects.FadeOutTime);
                    if (fadeOutLength == -1)
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetVolumeError);
                        return(0);
                    }
                    if (fadeOutLength > totalLength)
                    {
                        fadeOutLength = totalLength;
                    }
                    // If CueOut is active ...
                    if (file.Effects.CueOut.Active)
                    {
                        // Convert the CueOut position (seconds) into a byte offset
                        long cueOutPos = Bass.BASS_ChannelSeconds2Bytes(channel, file.Effects.CueOut.Position);
                        // Set the "end" sync to that position
                        if (Bass.BASS_ChannelSetSync(channel, BASSSync.BASS_SYNC_POS, cueOutPos - fadeOutLength, m_FadeOutSync, new IntPtr(file.Effects.FadeOutTime)) == 0)
                        {
                            ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                            return(0);
                        }
                    }
                    else
                    {
                        if (Bass.BASS_ChannelSetSync(channel, BASSSync.BASS_SYNC_POS, totalLength - fadeOutLength, m_FadeOutSync, new IntPtr(file.Effects.FadeOutTime)) == 0)
                        {
                            ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                            return(0);
                        }
                    }
                    if (loop)
                    {
                        // If CueOut is active ...
                        if (file.Effects.CueOut.Active)
                        {
                            // Convert the CueOut position (seconds) into a byte offset
                            long cueOutPos = Bass.BASS_ChannelSeconds2Bytes(channel, file.Effects.CueOut.Position);
                            // Set the "end" sync to that position
                            if (Bass.BASS_ChannelSetSync(channel, BASSSync.BASS_SYNC_POS, cueOutPos, m_LoopSync, new IntPtr(file.Id)) == 0)
                            {
                                ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                                return(0);
                            }
                        }
                        else
                        {
                            if (Bass.BASS_ChannelSetSync(channel, BASSSync.BASS_SYNC_POS, totalLength, m_LoopSync, new IntPtr(file.Id)) == 0)
                            {
                                ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                                return(0);
                            }
                        }
                    }
                    else
                    {
                        info.CrossFade = file.Effects.CrossFading;
                    }
                }
                if (file.Effects != null && file.Effects.Pitch.Active)
                {
                    float pitchValue = DetermineIntEffectValue(file.Effects.Pitch);
                    if (!Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, pitchValue))
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                        return(0);
                    }
                }
                if (file.Effects != null && file.Effects.Tempo.Active)
                {
                    float tempoValue = DetermineIntEffectValue(file.Effects.Tempo);
                    if (!Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_TEMPO, tempoValue))
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                        return(0);
                    }
                }
                if (file.Effects != null && file.Effects.Balance.Active && !useMultiSpeakerChannels)
                {
                    SetBalanceEffect(channel, file.Id, file.Effects.Balance);
                }
                if (file.Effects != null && file.Effects.VolumeDB.Active)
                {
                    float volumeDB = DetermineIntEffectValue(file.Effects.VolumeDB);
                    float linear   = (float)Math.Pow(10d, volumeDB / 20);
                    int   volFx    = Bass.BASS_ChannelSetFX(channel, BASSFXType.BASS_FX_BFX_VOLUME, 1);
                    if (volFx == 0)
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                        return(0);
                    }
                    Un4seen.Bass.AddOn.Fx.BASS_BFX_VOLUME fxVol = new Un4seen.Bass.AddOn.Fx.BASS_BFX_VOLUME(linear, Un4seen.Bass.AddOn.Fx.BASSFXChan.BASS_BFX_CHANALL);
                    if (!Bass.BASS_FXSetParameters(volFx, fxVol))
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                        return(0);
                    }
                    if (info.LinkedChannels != null)
                    {
                        foreach (int splitStream2 in info.LinkedChannels)
                        {
                            int volFx2 = splitStream2 != 0 ? Bass.BASS_ChannelSetFX(splitStream2, BASSFXType.BASS_FX_BFX_VOLUME, 1) : 0;
                            if (splitStream2 != 0 && volFx2 == 0)
                            {
                                ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                                return(0);
                            }
                            if (volFx2 != 0 && !Bass.BASS_FXSetParameters(volFx2, fxVol))
                            {
                                ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                                return(0);
                            }
                        }
                    }
                }
#pragma warning disable CS0618 // Type or member is obsolete
                if (file.Effects != null && file.Effects.Reverb.Active)
                {
                    float linearLevel = (float)Math.Pow(10d, file.Effects.Reverb.Level / 20);
                    int   reverbFx    = Bass.BASS_ChannelSetFX(channel, BASSFXType.BASS_FX_BFX_REVERB, 1);
                    if (reverbFx == 0)
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                        return(0);
                    }
                    Un4seen.Bass.AddOn.Fx.BASS_BFX_REVERB fxReverb = new Un4seen.Bass.AddOn.Fx.BASS_BFX_REVERB(linearLevel, file.Effects.Reverb.Delay);
                    if (!Bass.BASS_FXSetParameters(reverbFx, fxReverb))
                    {
                        ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                        return(0);
                    }
                    if (info.LinkedChannels != null)
                    {
                        foreach (int splitStream2 in info.LinkedChannels)
                        {
                            int reverbFx2 = splitStream2 != 0 ? Bass.BASS_ChannelSetFX(splitStream2, BASSFXType.BASS_FX_BFX_REVERB, 1) : 0;
                            if (splitStream2 != 0 && reverbFx2 == 0)
                            {
                                ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                                return(0);
                            }
                            if (reverbFx2 != 0 && !Bass.BASS_FXSetParameters(reverbFx2, fxReverb))
                            {
                                ErrorHandling.BassErrorOccurred(file.Id, StringResources.SetEffectError);
                                return(0);
                            }
                        }
                    }
                }
#pragma warning restore CS0618 // Type or member is obsolete
                if (loop)
                {
                    Bass.BASS_ChannelFlags(channel, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
                }
                lock (m_Mutex)
                {
                    m_Loops[file.Id] = file;
                    if (file.Effects != null && file.Effects.CueOut.Active)
                    {
                        m_CueOutRepeats[channel] = loop;
                    }
                }

                if (file.Effects.CueIn.Active)
                {
                    Bass.BASS_ChannelSetPosition(channel, file.Effects.CueIn.Position);
                }

                if (isStreaming)
                {
                    result = BassStreamer.Instance.AddChannel(channel);
                }
                else
                {
                    result = Bass.BASS_ChannelPlay(channel, false);
                }
                if (!result)
                {
                    ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                    Bass.BASS_StreamFree(channel);
#if MONO
                    if (gcHandle.IsAllocated)
                    {
                        gcHandle.Free();
                    }
#endif
                    return(0);
                }
                lock (m_Mutex)
                {
                    m_RunningFiles[channel] = info;
#if MONO
                    if (gcHandle.IsAllocated)
                    {
                        m_GCHandles[channel] = gcHandle;
                    }
#endif
                }
                return(channel);
            }
            else
            {
                ErrorHandling.BassErrorOccurred(file.Id, StringResources.FilePlayingError);
                return(0);
            }
        }