public static void LoadAudio(AudioStream audioStream)
        {
            // abort if audio data already loaded
            if (audioStream.IsAudioLoaded())
            {
                return;
            }

            AudioDataHelper.LoadAudioData(audioStream);

            var channel = Bass.BASS_StreamCreateFile(audioStream.AudioData.DataPointer,
                                                     0,
                                                     audioStream.AudioData.Data.Length,
                                                     BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_PRESCAN);

            audioStream.AddChannel(channel);

            if (audioStream.ChannelId == 0)
            {
                throw new Exception("Cannot load " + audioStream.Filename + ". Error code: " + Bass.BASS_ErrorGetCode());
            }

            // DebugHelper.WriteLine("Creating reverse FX stream " + audioStream.Description + "...");
            audioStream.AddChannel(BassFx.BASS_FX_ReverseCreate(audioStream.ChannelId, 1, BASSFlag.BASS_STREAM_DECODE));

            if (audioStream.ChannelId == 0)
            {
                throw new Exception("Cannot load " + audioStream.Filename + ". Error code: " + Bass.BASS_ErrorGetCode());
            }

            Bass.BASS_ChannelSetAttribute(audioStream.ChannelId, BASSAttribute.BASS_ATTRIB_REVERSE_DIR,
                                          (float)BASSFXReverse.BASS_FX_RVS_FORWARD);


            // DebugHelper.WriteLine("Creating tempo FX stream " + audioStream.Description + "...");

            audioStream.AddChannel(BassFx.BASS_FX_TempoCreate(audioStream.ChannelId,
                                                              BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_STREAM_DECODE));

            if (audioStream.ChannelId == 0)
            {
                throw new Exception("Cannot load " + audioStream.Filename + ". Error code: " + Bass.BASS_ErrorGetCode());
            }

            // DebugHelper.WriteLine("Calculating track length " + audioStream.Description + "...");

            audioStream.Length            = Bass.BASS_ChannelGetLength(audioStream.ChannelId);
            audioStream.DefaultSampleRate = GetSampleRate(audioStream.ChannelId);

            SetReplayGain(audioStream);
            SetPosition(audioStream, 0);
        }
        /// <summary>
        ///     Unloads the audio of an audio stream
        /// </summary>
        /// <param name="audioStream">The audio stream.</param>
        public static void UnloadAudio(AudioStream audioStream)
        {
            if (audioStream == null || !audioStream.IsAudioLoaded())
            {
                //throw new Exception("Audio file null or not audio not loaded");
                return;
            }

            // DebugHelper.WriteLine($"UnloadAudio {audioStream.Description}...");

            foreach (var channel in audioStream.ChannelIds)
            {
                Bass.BASS_StreamFree(channel);
            }
            audioStream.ChannelIds.Clear();

            AudioDataHelper.UnloadAudioData(audioStream);

            // DebugHelper.WriteLine("done");
        }