コード例 #1
0
        public void LoadUrl(string path, string url, Action <long, long> proc, Action finish)
        {
            try
            {
                ip = new IntPtr(BassdlList.Count);
                var Bassdl = new BASSDL(path);
                BassdlList.Add(Bassdl);
                Bassdl.procChanged     = proc;
                Bassdl.finished        = finish;
                Bassdl.downloadfailed += (e) => {
                };
                decode = Bass.BASS_StreamCreateURL(url + "\r\n"
                                                   + "Host: musichy.tc.qq.com\r\n"
                                                   + "Accept-Encoding: identity;q=1, *;q=0\r\n"
                                                   + "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.66 Safari/537.36 Edg/80.0.361.40\r\n"
                                                   + "Accept: */*\r\n"
                                                   + "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6\r\n"
                                                   + "Cookie:" + Settings.USettings.Cookie
                                                   , 0, BASSFlag.BASS_STREAM_DECODE, Bassdl._myDownloadProc, ip);
                Bassdl.stream = decode;
                stream        = BassFx.BASS_FX_TempoCreate(decode, BASSFlag.BASS_SAMPLE_FLOAT);

                Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, _Vol);
                if (_Pitch != -1024)
                {
                    Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, _Pitch);
                }
                if (_Speed != -1024)
                {
                    Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_TEMPO, _Speed);
                }
            }
            catch { }
        }
コード例 #2
0
 public void Volume(float vol)
 {
     if (ActiveStreamHandle != 0)
     {
         Bass.BASS_ChannelSetAttribute(ActiveStreamHandle, BASSAttribute.BASS_ATTRIB_VOL, vol);
     }
 }
コード例 #3
0
    public override bool Play(float playPoint = 0, bool restart = false)
    {
        base.Play(playPoint, restart);

        int channel = Bass.BASS_SampleGetChannel(audioHandle, false);

        bool isPlaying = Bass.BASS_ChannelIsActive(channel) != BASSActive.BASS_ACTIVE_STOPPED && Bass.BASS_ChannelIsActive(channel) != BASSActive.BASS_ACTIVE_PAUSED;

        if (onlyPlayIfStopped && isPlaying)
        {
            return(false);
        }

        if (channel != 0)
        {
            Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_VOL, volume);
            Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_PAN, pan);

            Bass.BASS_ChannelPlay(channel, restart);
            return(true);
        }
        else
        {
            UnityEngine.Debug.LogError("Error when playing sample stream: " + Bass.BASS_ErrorGetCode() + ", " + audioHandle);
        }

        return(false);
    }
コード例 #4
0
ファイル: Sound.cs プロジェクト: TrollingChar/nupskou-project
        public void Play(float volume = 1)
        {
            int channel = Bass.BASS_SampleGetChannel(_sample, false);

            Bass.BASS_ChannelPlay(channel, false);
            Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_VOL, volume);
        }
コード例 #5
0
        private void GetInfoFromStream_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                while (true)
                {
                    if (chan != 0)
                    {
                        normalpos = Bass.BASS_ChannelGetPosition(chan);
                        normallen = Bass.BASS_ChannelGetLength(chan);
                        tick      = Bass.BASS_ChannelGetPosition(chan, BASSMode.BASS_POS_MIDI_TICK);                       // get position in ticks
                        lentick   = Bass.BASS_ChannelGetLength(chan, BASSMode.BASS_POS_MIDI_TICK);                         // get length in ticks
                        Bass.BASS_ChannelSetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_VOICES, maxvoices);             // apply to current MIDI file too
                        Bass.BASS_ChannelSetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_CPU, Convert.ToSingle(maxcpu)); // apply to current MIDI file too
                        Bass.BASS_ChannelGetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_VOICES_ACTIVE, ref active);     // get active voices
                        Bass.BASS_ChannelGetAttribute(chan, BASSAttribute.BASS_ATTRIB_CPU, ref cpu);                       // get cpu usage
                        PassedTime = TimeSpan.FromSeconds(Bass.BASS_ChannelBytes2Seconds(chan, normalpos));
                        LengthTime = TimeSpan.FromSeconds(Bass.BASS_ChannelBytes2Seconds(chan, normallen));
                    }

                    BASS_MIDI_FONTINFO i = new BASS_MIDI_FONTINFO();
                    BassMidi.BASS_MIDI_FontGetInfo(font, i);
                    sfinfolabel = String.Format("Name: {0}\nLoaded: {1} / {2}", i.name, i.samload, i.samsize);

                    System.Threading.Thread.Sleep(1);
                }
            }
            catch { }
        }
コード例 #6
0
 public void Volume(int volume)
 {
     if (_stream != 0)
     {
         Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, ((float)volume) / 100);
     }
 }
コード例 #7
0
ファイル: Sound.cs プロジェクト: kim-g/StD-Player-3
 /// <summary>
 /// Настройка параметров при открытии
 /// </summary>
 private void SetOpenParameters()
 {
     Bass.BASS_ChannelSetAttribute(Channel, BASSAttribute.BASS_ATTRIB_VOL, Volume / 100f);
     Bass.BASS_ChannelSetAttribute(Channel, BASSAttribute.BASS_ATTRIB_PAN, Balance);
     SetBalance(Balance);
     Length = GetLength();
 }
コード例 #8
0
 //запуск воспроизведения
 public static void Play(string filename, int vol)
 {
     if (Bass.BASS_ChannelIsActive(Stream) != BASSActive.BASS_ACTIVE_PAUSED)
     {
         //чтобы не начало одновременно играть два трека
         Stop();
         //с помощью метода InitBass(HZ) проверяем инициализацию библиотеки
         //если она инициализирована, загружаем трек
         //filename - какой трек будет воспроизводиться
         //0 - воспроизводится с начала
         //0 - длительность (до конца, т.е. оригинальный размер)
         if (InitBass(HZ))
         {
             Stream = Bass.BASS_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_DEFAULT);
             //если файл открыт удачно, то Stream не равен нулю
             if (Stream != 0)
             {
                 //устанавливаем громкость трека
                 Volume = vol;
                 Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, Volume / 100F);
                 //запускаем воспроизведение
                 Bass.BASS_ChannelPlay(Stream, false);
             }
         }
     }
     else
     {
         Bass.BASS_ChannelPlay(Stream, false);
     }
     isStopped = false;
 }
コード例 #9
0
        internal void Update()
        {
            if (!hasChannel)
            {
                return;
            }

            if (inputBalanceWeight > 0)
            {
                if (osu.GameModes.Play.Rulesets.Ruleset.Instance != null)
                {
                    //Use the ruleset position, as this accounts for taiko and CtB specialties.
                    balance = osu.GameModes.Play.Rulesets.Ruleset.Instance.MousePosition.X / 512f - 0.5f;
                }
                else
                {
                    balance = osu.Input.InputManager.CursorPosition.X / GameBase.WindowManager.Ratio / GameBase.WindowManager.WidthScaled - 0.5f;
                }

                balance *= inputBalanceWeight;
            }

            Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_VOL, volume * AudioEngine.VolumeEffectAdjusted / 100f);
            Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_PAN, balance);
            Bass.BASS_ChannelSetAttribute(channel, BASSAttribute.BASS_ATTRIB_FREQ, initialFrequency * playbackRate);
        }
コード例 #10
0
 private void balanceChangeBox()
 {
     model.balanceLevel    = 0;
     view.balanceBar.Value = 0;
     view.balanceBox.Text  = "0";
     Bass.BASS_ChannelSetAttribute(model.stream, BASSAttribute.BASS_ATTRIB_PAN, model.balanceLevel);
 }
コード例 #11
0
        public static async void startBassStream(string files, int vol)
        {
            await Task.Run(() =>
            {
                Bass.BASS_StreamFree(audioStreamBass);

                if (InitBass(HZ))
                {
                    Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_ASYNCFILE_BUFFER, 5000);
                    Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 5000);
                    audioStreamBass = Bass.BASS_StreamCreateURL(files, 0, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_STREAM_STATUS, null, IntPtr.Zero);
                    BassTag.syncStreamTitleUpdates(audioStreamBass);
                }
                if (audioStreamBass != 0 && Bass.BASS_ChannelPlay(audioStreamBass, true))
                {
                    Volume = vol;
                    Bass.BASS_ChannelSetAttribute(audioStreamBass, BASSAttribute.BASS_ATTRIB_VOL, Volume / 100.0F);
                    BassTag.updateTags();
                }
                else
                {
                    MessageBox.Show("Радиостанция в данный момент недоступна.\nПроверьте интернет-соединение.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            });
        }
コード例 #12
0
        public void LoadJumpChannel(string fileName)
        {
            JumpChannelHandle = ChannelFactory.Create(fileName, BASSFlag.BASS_MUSIC_LOOP);

            if (!JumpChannelHandle.Valid)
            {
                throw new Exception("Failed to load the jump channel.");
            }

            Bass.BASS_ChannelSetAttribute(JumpChannelHandle.Handle, BASSAttribute.BASS_ATTRIB_VOL, 0f);

            JumpChannelSyncs.Add(
                new Sync(
                    JumpChannelHandle,
                    BASSSync.BASS_SYNC_SLIDE | BASSSync.BASS_SYNC_MIXTIME,
                    (handle, channel, data, user) =>
            {
                var volume = 0.0f;
                Bass.BASS_ChannelGetAttribute(JumpChannelHandle.Handle, BASSAttribute.BASS_ATTRIB_VOL, ref volume);

                if (volume >= MaximumVolume * 0.45f)
                {
                    Console.WriteLine("Will fade next frame.");
                    _fadeJumpNextFrame = true;
                }
            }
                    )
                );
        }
コード例 #13
0
        public void LoadStartFlightChannel(string fileName)
        {
            StartFlightChannelHandle = ChannelFactory.Create(fileName);

            if (!StartFlightChannelHandle.Valid)
            {
                throw new Exception("Failed to load start boost channel.");
            }

            Bass.BASS_ChannelSetAttribute(StartFlightChannelHandle.Handle, BASSAttribute.BASS_ATTRIB_VOL, 0f);

            StartFlightChannelSyncs.Add(
                new Sync(
                    StartFlightChannelHandle,
                    BASSSync.BASS_SYNC_END,
                    (handle, channel, data, user) =>
            {
                if (FlightChannelHandle != null)
                {
                    var volume = 0.0f;
                    Bass.BASS_ChannelGetAttribute(StartFlightChannelHandle.Handle, BASSAttribute.BASS_ATTRIB_VOL, ref volume);

                    if (volume > 0.0f)
                    {
                        Bass.BASS_ChannelSetAttribute(FlightChannelHandle.Handle, BASSAttribute.BASS_ATTRIB_VOL, MaximumVolume);
                    }

                    Bass.BASS_ChannelPlay(FlightChannelHandle.Handle, true);
                }
            }
                    )
                );
        }
コード例 #14
0
ファイル: BassCore.cs プロジェクト: jcernea/VisualBass
        /// <summary>
        /// Playing the audio (Check if initialized & paused)
        /// </summary>
        /// <param name="file"></param>
        /// <param name="volume"></param>
        public void Play(string file, int volume)
        {
            PlayEvent?.Invoke(null, file);

            if (Bass.BASS_ChannelIsActive(Stream) != BASSActive.BASS_ACTIVE_PAUSED)
            {
                Stop(); //Stopping existing stream
                if (InitBass(HZ))
                {
                    Stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT); //Loading in audio file into stream
                    if (Stream != 0)
                    {
                        Volume = volume;
                        Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, Volume / 100F); //Initializing channel volume attribute
                        Bass.BASS_ChannelPlay(Stream, false);                                                //Start playing the stream
                    }
                }
            }
            else
            {
                Bass.BASS_ChannelPlay(Stream, false);
            }
            EqEnable(_eqEnabled); // Enabling EQ based on _eqEnabled state
            activeState = PlayerState.Playing;
        }
コード例 #15
0
 void Location_MouseDown(object sender, MouseButtonEventArgs e)
 {
     IsLocationChanging = true;
     IsPaused           = true;
     Bass.BASS_ChannelPause(Stream);
     Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, 0f);
 }
コード例 #16
0
        public void Play(string fileName, int vol = 100)
        {
            if (_handle != 0)
            {
                Stop();
                _currentPosition = 0;
                OnTrackPositionProgressChanged(new TrackPositionProgrressChangedEventHandlerArgs()
                {
                    PositionSeconds = _currentPosition
                });
            }

            _handle = Bass.BASS_StreamCreateFile(fileName, 0, 0, BASSFlag.BASS_DEFAULT);
            if (_handle != 0)
            {
                CurrentTrackLength = GetTrackLength();
                TAG_INFO tagInfo = BassTags.BASS_TAG_GetFromFile(fileName);
                OnTrackChanged(new TrackChangedEventHandlerArgs()
                {
                    TrackLength = CurrentTrackLength,
                    Title = tagInfo.title,
                    Album = tagInfo.album,
                    Artist = tagInfo.artist,
                    Image = tagInfo.PictureCount > 0 ? tagInfo.PictureGetImage(0): null,
                    Year = tagInfo.year
                });
                Bass.BASS_ChannelSetAttribute(_handle, BASSAttribute.BASS_ATTRIB_VOL, vol / 100f);
                Bass.BASS_ChannelPlay(_handle, false);
                _timer.Start();
            }
        }
コード例 #17
0
 /// <summary>
 /// Sets the volume attribute of the channel of this stream to the given value.
 /// </summary>
 /// <param name="volume">Volume to set. 0 = silent, 1 = full.</param>
 private void SetVolume(float volume)
 {
     if (!Bass.BASS_ChannelSetAttribute(_handle, BASSAttribute.BASS_ATTRIB_VOL, volume))
     {
         CheckException("BASS_ChannelSetAttribute");
     }
 }
コード例 #18
0
        private void nextBtn_Click(object sender, EventArgs e)
        {
            if (Functions.PlaylistPosition < Functions.playlist.Count - 1)
            {
                if (Functions.playlist.Count > 1)
                {
                    Bass.BASS_ChannelStop(_stream);
                    var data = new string[6];
                    switch (Functions.PlayMode)
                    {
                    case 0:
                        data = Functions.NextTrack();
                        break;

                    case 1:
                        data = Functions.LoopTrack();
                        break;

                    case 2:
                        data = Functions.RandomTrack();
                        break;
                    }
                    SetPlayerData(data);
                    if (playerControl.playerControl.pause)
                    {
                        Bass.BASS_ChannelPlay(_stream, false); Discord.SetData(1);
                    }
                    // Set volume
                    float Volume = (float)volumeTrackBar.Value / 100;
                    Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, Volume);
                    /////////////
                }
            }
        }
コード例 #19
0
        public override void Play()
        {
            if ((Bass.BASS_ChannelIsActive(_stream) != BASSActive.BASS_ACTIVE_PAUSED) || (Bass.BASS_ChannelIsActive(_stream) == BASSActive.BASS_ACTIVE_STOPPED))
            {
                Bass.BASS_StreamFree(_stream);

                _stream = Bass.BASS_StreamCreateFile(_source, 0, 0, BASSFlag.BASS_DEFAULT);
                //_stream = Bass.BASS_StreamCreateFile(_source, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
                if (_stream != 0)
                {
                    //костыли
                    Bass.BASS_ChannelGetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, ref vol);
                    //костыли
                    Volume = vol * 100F;
                    //костыли
                    Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, (float)_volume);
                    Bass.BASS_ChannelPlay(_stream, false); //2й параметр это луп (рестарт)
                    //   MessageBox.Show(vol.ToString());
                }
                else
                {
                    MessageBox.Show("Error= " + Bass.BASS_ErrorGetCode().ToString());
                }
            }
            else
            {
                Bass.BASS_ChannelPlay(_stream, false);
            }

            //       MessageBox.Show(Duration.ToString());
//
            // Position = TimeSpan.Parse("00:01:00");// 40000;
        }
コード例 #20
0
        private void FadeThread_Tick(object sender, EventArgs e)
        {
            if (_startVol + (float)jump < _reachcap)
            {
                _startVol += (float)Math.Pow(jump, .95);
                if (!Config.Muted)
                {
                    Bass.BASS_ChannelSetAttribute(_waveIn.Handle, BASSAttribute.BASS_ATTRIB_VOL, _startVol);
                    Bass.BASS_ChannelSetAttribute(_waveOut.Handle, BASSAttribute.BASS_ATTRIB_VOL, (_reachcap - _startVol));
                    Bass.BASS_ChannelSetAttribute(_waveOut.Handle, BASSAttribute.BASS_ATTRIB_PAN, (_startVol / _reachcap));
                    Bass.BASS_ChannelSetAttribute(_waveIn.Handle, BASSAttribute.BASS_ATTRIB_PAN, -1 + (_startVol / _reachcap));
                }
            }
            else
            {
                Bass.BASS_ChannelSetAttribute(_waveIn.Handle, BASSAttribute.BASS_ATTRIB_PAN, 0);

                RaiseActionCompletedEvent();
                //if ordered to kill wave, dispose it
                if (_kill)
                {
                    _waveOut.Dispose();
                }
                Dispose();
            }
        }
コード例 #21
0
        void SE_Play()
        {
            //選択しているSEを再生
            if (IsClosing)
            {
                return;
            }
            Bass.BASS_ChannelStop(Stream);
            Bass.BASS_StreamFree(Stream);
            string SE_Count     = SE_Change_Window.Preset_List[SE_Change_Window.Preset_Index][SE_Lists.SelectedIndex + 1];
            int    StreamHandle = Bass.BASS_StreamCreateFile(SE_Count.Split('|')[SE_Play_Index - 1], 0, 0, BASSFlag.BASS_STREAM_DECODE);

            Stream = BassFx.BASS_FX_TempoCreate(StreamHandle, BASSFlag.BASS_FX_FREESOURCE);
            Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, 1f);
            Bass.BASS_ChannelSetDevice(Stream, Video_Mode.Sound_Device);
            Bass.BASS_ChannelPlay(Stream, true);
            if (SE_Play_Index < Select_SE_File_Count)
            {
                SE_Play_Index++;
                SE_Play_Number_T.Text = SE_Play_Index + "/" + Select_SE_File_Count;
            }
            else if (Select_SE_File_Count != 1 && SE_Play_Index == Select_SE_File_Count)
            {
                SE_Play_Index         = 1;
                SE_Play_Number_T.Text = SE_Play_Index + "/" + Select_SE_File_Count;
            }
        }
コード例 #22
0
        /// <summary>
        ///     Play stream
        /// </summary>
        public void Play()
        {
            //Check if the song is stopped
            if (Bass.BASS_ChannelIsActive(Handle) == BASSActive.BASS_ACTIVE_PAUSED)
            {
                if (Valid) //Check if the stream handle is valid
                {
                    if (Bass.BASS_ChannelPlay(Handle, false))
                    {
                        StreamStatus = StreamStatus.CanPause;
                    }
                }
            }
            else //song is stopped, load again
            {
                Open(); //Open the file since its stopped
                if (Bass.BASS_ChannelPlay(Handle, false))
                {
                    StreamStatus = StreamStatus.CanPause;
                }
            }
            if (Config.ReactorFade & !ReactorUsageLocked)
            {
                var fader = new Fader(this, FadeMode.Linear, 5, 250, false, Volume);

                fader.Start();
            }
            if (!Muted)
            {
                Bass.BASS_ChannelSetAttribute(Handle, BASSAttribute.BASS_ATTRIB_VOL, _volume);
            }
        }
コード例 #23
0
        public void PlaySound(string file, int volume)
        {
            Log.InfoFormat("Playing sound '{0}' at volume '{1}'", file, volume);
            if (string.IsNullOrEmpty(file))
            {
                return;
            }

            try
            {
                // create a stream channel from a file
                int stream = Bass.BASS_StreamCreateFile(file, 0L, 0L, BASSFlag.BASS_DEFAULT | BASSFlag.BASS_STREAM_AUTOFREE);
                if (stream != 0)
                {
                    Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, (volume / 100f));
                    Bass.BASS_ChannelPlay(stream, false);
                }
                else
                {
                    throw new ApplicationException(string.Format(Resources.BASS_UNABLE_TO_CREATE_STREAM_FROM_FILE, file));
                }
            }
            catch (Exception exception)
            {
                //Don't publish error - the error handler tries to play a sound file which could loop us right back here
                Log.Error("Exception encountered within the AudioService", exception);
            }
        }
コード例 #24
0
ファイル: Audio.cs プロジェクト: mixail167/ProjectsCSharp
 /// <summary>
 /// Воспроизведение треков
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="volume"></param>
 public static bool Play(string filename, int volume)
 {
     if (Bass.BASS_ChannelIsActive(Stream) != BASSActive.BASS_ACTIVE_PAUSED ||
         (Bass.BASS_ChannelIsActive(Stream) == BASSActive.BASS_ACTIVE_PAUSED && !filename.Equals(CurrentTrackName)))
     {
         Stop();
         if (InitAudio(HZ) && SetStream(filename))
         {
             Volume = volume;
             Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, Volume / 100f);
             Bass.BASS_ChannelPlay(Stream, false);
             CurrentTrackName = filename;
             InitEqualizer();
         }
         else
         {
             return(false);
         }
     }
     else
     {
         Bass.BASS_ChannelPlay(Stream, false);
     }
     isStoped = false;
     return(true);
 }
コード例 #25
0
ファイル: App.xaml.cs プロジェクト: wirmachenbunt/tooll
        internal void ToggleMutePlayback()
        {
            float currentVolume = 0;

            Bass.BASS_ChannelGetAttribute(m_SoundStream, BASSAttribute.BASS_ATTRIB_VOL, ref currentVolume);
            Bass.BASS_ChannelSetAttribute(m_SoundStream, BASSAttribute.BASS_ATTRIB_VOL, currentVolume == 0.0f ? 1.0f : 0.0f);
        }
コード例 #26
0
ファイル: BassLib.cs プロジェクト: tynidev/BPM
        public int ChangeSpeed(int chan, string loc, float speed)
        {
            // get position to resume playback at
            long pos = Bass.BASS_ChannelGetPosition(chan, BASSMode.BASS_POS_BYTES);

            if (!Bass.BASS_StreamFree(chan))
            {
                GetBassErrorTrow("Could not free stream: " + chan);
            }

            chan = OpenFile(loc, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);

            chan = BassFx.BASS_FX_TempoCreate(chan, BASSFlag.BASS_SAMPLE_LOOP);
            if (chan == 0)
            {
                GetBassErrorTrow("Could not open file: " + loc);
            }

            if (!Bass.BASS_ChannelSetPosition(chan, pos, BASSMode.BASS_POS_BYTES))
            {
                GetBassErrorTrow("Could not seek to " + pos + " bytes");
            }

            if (!Bass.BASS_ChannelSetAttribute(chan, BASSAttribute.BASS_ATTRIB_TEMPO, CheckTempoRange(speed) - 100))
            {
                GetBassErrorTrow("Could not set attribute: " + BASSAttribute.BASS_ATTRIB_TEMPO);
            }

            return(chan);
        }
コード例 #27
0
        public void MusicUpdate()
        {
            if (m_NewMusic != "")
            {
                float maxVolume = GlobalSettings.Default.MusicVolume / 10.0f;
                m_MusicFade -= 1.0 / 60.0;
                if (m_MusicChannel != -1)
                {
                    Bass.BASS_ChannelSetAttribute(m_MusicChannel, BASSAttribute.BASS_ATTRIB_VOL, maxVolume * (float)Math.Max(0, (m_MusicFade - 0.5) / 1.5));
                }
                if (m_MusicFade <= 0)
                {
                    if (m_MusicChannel != -1)
                    {
                        Bass.BASS_ChannelStop(m_MusicChannel);
                    }
                    if (m_NewMusic != "none")
                    {
                        m_MusicChannel = LoadMusicTrack(m_NewMusic, 1, false);
                        Bass.BASS_ChannelSetAttribute(m_MusicChannel, BASSAttribute.BASS_ATTRIB_VOL, maxVolume);
                        m_EndedEvent = new SYNCPROC(MusicEnded);

                        Bass.BASS_ChannelSetSync(m_MusicChannel, BASSSync.BASS_SYNC_END, 0, m_EndedEvent, (IntPtr)0);
                        m_MusicFade = 2;
                    }
                    m_NewMusic = "";
                }
            }
        }
コード例 #28
0
 //戻る
 private async void Back_B_Click(object sender, RoutedEventArgs e)
 {
     if (!IsClosing && !IsBusy)
     {
         IsClosing = true;
         IsPaused  = true;
         float Volume_Now = 1f;
         Bass.BASS_ChannelGetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, ref Volume_Now);
         float Volume_Minus = Volume_Now / 30f;
         while (Opacity > 0)
         {
             Opacity    -= Sub_Code.Window_Feed_Time;
             Volume_Now -= Volume_Minus;
             if (Volume_Now < 0f)
             {
                 Volume_Now = 0f;
             }
             Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, Volume_Now);
             await Task.Delay(1000 / 60);
         }
         Bass.BASS_ChannelStop(Stream);
         Bass.BASS_StreamFree(Stream);
         Location_S.Value           = 0;
         Location_S.Maximum         = 0;
         Voices_L.SelectedIndex     = -1;
         Voice_Type_L.SelectedIndex = -1;
         BGM_Add_List.SelectedIndex = -1;
         Visibility = Visibility.Hidden;
         IsClosing  = false;
     }
 }
コード例 #29
0
 /// <summary>
 /// Sets the volume to the given value instantly.
 /// </summary>
 /// <param name="volume">0.0f-1.0f -> 0-100%</param>
 protected void SetVolume(float volume)
 {
     if (!Bass.BASS_ChannelSetAttribute(_stream.Handle, BASSAttribute.BASS_ATTRIB_VOL, volume))
     {
         throw new BassLibraryException("BASS_ChannelSetAttribute");
     }
 }
コード例 #30
0
 private void ChangeVolume(object sender, RoutedEventArgs e)
 {
     Bass.BASS_ChannelSetAttribute(
         _channel, BASSAttribute.BASS_ATTRIB_VOL,
         (float)(Volume.Value / Volume.Maximum)
         );
 }