示例#1
0
 public Boolean YStop()
 {
     return(Bass.BASS_ChannelStop(y));
 }
示例#2
0
 //zatrzymanie puszczanego streama oraz zwolnienie
 public static void Stop()
 {
     Bass.BASS_ChannelStop(Stream);
     Bass.BASS_StreamFree(Stream);
 }
示例#3
0
        private void button2_Click(object sender, EventArgs e) //下一曲
        {
            if (radioButton2.Checked)                          //判断播放模式,如果是随机播放,则执行以下代码
            {
                try
                {
                    Bass.BASS_ChannelStop(stream);
                    listBox1.SelectedIndices.Clear();//清空当前所有选中的索引
                    Random next     = new Random();
                    int    nextsong = next.Next(1, listBox1.Items.Count - 1);
                    listBox1.SelectedIndex = nextsong;
                    string songname = listpath[listBox1.SelectedIndex];
                    stream = Bass.BASS_StreamCreateFile(songname, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT);
                    Bass.BASS_ChannelPlay(stream, true);
                    label1.Text = "   " + songname;
                    暂停ToolStripMenuItem.Text = "暂停";
                    button1.Text             = "暂停";
                    p = true;
                }
                catch { }
            }
            else if (radioButton1.Checked)//如果是按列表顺序模式
            {
                try
                {
                    int index = listBox1.SelectedIndex; //获得当前选中的索引
                    listBox1.SelectedIndices.Clear();   //清空当前所有选中的索引

                    index++;
                    if (index == listBox1.Items.Count)
                    {
                        index = 0;
                    }
                    listBox1.SelectedIndex = index;
                    Bass.BASS_ChannelStop(stream);
                    string songname = listpath[listBox1.SelectedIndex];
                    stream = Bass.BASS_StreamCreateFile(songname, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT);
                    Bass.BASS_ChannelPlay(stream, true);
                    label1.Text              = "   " + songname;
                    button1.Enabled          = true;
                    暂停ToolStripMenuItem.Text = "暂停";
                    button1.Text             = "暂停";
                    p = true;
                }
                catch { }
            }
            else  //单曲循环播放模式
            {
                try {
                    int index = listBox1.SelectedIndex; //获得当前选中的索引
                    listBox1.SelectedIndices.Clear();   //清空当前所有选中的索引

                    // index++;
                    // if (index == listBox1.Items.Count)
                    // { index = 0; }
                    listBox1.SelectedIndex = index;
                    Bass.BASS_ChannelStop(stream);
                    string songname = listpath[listBox1.SelectedIndex];
                    stream = Bass.BASS_StreamCreateFile(songname, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT);
                    Bass.BASS_ChannelPlay(stream, true);
                    label1.Text              = "   " + songname;
                    button1.Enabled          = true;
                    暂停ToolStripMenuItem.Text = "暂停";
                    button1.Text             = "暂停";
                    p = true;
                }
                catch { }
            }
        }
示例#4
0
文件: Form1.cs 项目: xenticorp/Wave
 private void Stop_Click(object sender, EventArgs e)
 {
     Bass.BASS_ChannelStop(chan); //останавливаем музяку
     Bass.BASS_Free();            // выгружаем устройства потоки итд.
 }
示例#5
0
        //PC版WoTの音声ファイルを指定
        private async void Open_File_B_Click(object sender, RoutedEventArgs e)
        {
            if (IsClosing || IsBusy)
            {
                return;
            }
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Title       = "BNKファイルを選択してください。",
                Multiselect = false,
                Filter      = "BNKファイル(*.bnk)|*.bnk"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string PCK_File_Path = Path.GetDirectoryName(ofd.FileName) + "/" + Path.GetFileNameWithoutExtension(ofd.FileName) + ".pck";
                if (PCK_Mode_C.IsChecked.Value && !File.Exists(PCK_File_Path))
                {
                    Message_Feed_Out(Path.GetFileNameWithoutExtension(ofd.FileName) + ".pckが見つかりませんでした。");
                    IsBusy = false;
                    return;
                }
                string XML_File_Path = Path.GetDirectoryName(ofd.FileName) + "/audio_mods.xml";
                if (XML_Mode_C.IsChecked.Value && !File.Exists(XML_File_Path))
                {
                    Message_Feed_Out("audio_mods.xmlが見つかりませんでした。");
                    IsBusy = false;
                    return;
                }
                Bass.BASS_ChannelStop(Stream);
                Bass.BASS_StreamFree(Stream);
                try
                {
                    if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/BNK_WAV"))
                    {
                        Directory.Delete(Voice_Set.Special_Path + "/Wwise/BNK_WAV", true);
                    }
                }
                catch (Exception e1)
                {
                    Sub_Code.Error_Log_Write(e1.Message);
                }
                IsBusy = true;
                try
                {
                    Message_T.Text = ".bnkファイルを解析しています...";
                    await Task.Delay(50);

                    Wwise_Class.BNK_Parse p = new Wwise_Class.BNK_Parse(ofd.FileName);
                    Message_T.Text = "audio_mods.xmlからイベントIDを取得しています...";
                    await Task.Delay(50);

                    if (!p.IsVoiceFile())
                    {
                        Message_Feed_Out("選択されたbnkファイルは音声データではありません。");
                        IsBusy = false;
                        return;
                    }
                    Message_T.Text = "各イベント内の音声IDを取得しています...";
                    await Task.Delay(50);

                    BNK_Voices_Enable.Clear();
                    BNK_Voices = p.Get_Voices(false);
                    if (XML_Mode_C.IsChecked.Value)
                    {
                        p.Get_Event_ID_From_XML(XML_File_Path);
                        List <List <string> > Temp = p.Get_Voices(false);
                        for (int Number = 0; Number < Temp.Count; Number++)
                        {
                            if (BNK_Voices[Number].Count == 0)
                            {
                                BNK_Voices[Number] = Temp[Number];
                            }
                        }
                    }
                    List <string> Need_Files = new List <string>();
                    foreach (List <string> Types in BNK_Voices)
                    {
                        BNK_Voices_Enable.Add(new List <bool>());
                        foreach (string File_Now in Types)
                        {
                            Need_Files.Add(File_Now);
                            BNK_Voices_Enable[BNK_Voices_Enable.Count - 1].Add(true);
                        }
                    }
                    if (Need_Files.Count == 0)
                    {
                        BNK_Voices_Enable.Clear();
                        Message_T.Text = "移植できるファイルが見つからなかったため、特殊な方法で解析しています...";
                        await Task.Delay(50);

                        p.SpecialBNKFileMode = 1;
                        BNK_Voices           = p.Get_Voices(false);
                        foreach (List <string> Types in BNK_Voices)
                        {
                            BNK_Voices_Enable.Add(new List <bool>());
                            foreach (string File_Now in Types)
                            {
                                Need_Files.Add(File_Now);
                                BNK_Voices_Enable[BNK_Voices_Enable.Count - 1].Add(true);
                            }
                        }
                        if (Need_Files.Count == 0)
                        {
                            p.Clear();
                            BNK_Voices.Clear();
                            BNK_Voices_Enable.Clear();
                            Message_Feed_Out("移植できる音声が見つかりませんでした。");
                            IsBusy = false;
                            return;
                        }
                    }
                    p.Clear();
                    Get_Available_Voice_Count();
                    Voices_L.Items.Clear();
                    Voice_Type_L.Items.Clear();
                    for (int Number = 0; Number < BNK_Voices.Count; Number++)
                    {
                        Voices_L.Items.Add(Voice_Set.Get_Voice_Type_Japanese_Name_V2(Number) + " : " + BNK_Voices[Number].Count + "個");
                    }
                    BGM_Count_Change();
                    if (PCK_Mode_C.IsChecked.Value)
                    {
                        Message_T.Text = ".wemファイルに変換しています...";
                        await Task.Delay(50);

                        Wwise_PCK        = new Wwise_File_Extract_V1(PCK_File_Path);
                        Max_Stream_Count = Wwise_PCK.Wwise_Get_File_Count();
                        await Wwise_PCK.Async_Wwise_Extract_To_WEM_Directory(Voice_Set.Special_Path + "/Wwise/BNK_WAV");

                        Message_T.Text = ".wemファイルを.oggに変換しています...";
                        await Task.Delay(50);

                        await Wwise_PCK.Async_Wwise_Extract_To_OGG_Directory(Voice_Set.Special_Path + "/Wwise/BNK_WAV");
                    }
                    else
                    {
                        Message_T.Text = ".wavまたは.oggに変換しています...";
                        await Task.Delay(50);

                        Wwise_BNK        = new Wwise_File_Extract_V2(ofd.FileName);
                        Max_Stream_Count = Wwise_BNK.Wwise_Get_Numbers();
                        Wwise_BNK.Wwise_Extract_To_WEM_Directory_V2(Voice_Set.Special_Path + "/Wwise/BNK_WAV");
                    }
                    string[] Files = Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/BNK_WAV", "*.wem", SearchOption.TopDirectoryOnly);
                    foreach (string File_Now in Files)
                    {
                        Sub_Code.File_Delete_V2(File_Now);
                    }
                    Message_T.Text = "不要な音声ファイルを削除しています...";
                    await Task.Delay(50);

                    string[] All_Files = Directory.GetFiles(Voice_Set.Special_Path + "/Wwise/BNK_WAV", "*", SearchOption.TopDirectoryOnly);
                    foreach (string File_Now in All_Files)
                    {
                        if (!Need_Files.Contains(Path.GetFileNameWithoutExtension(File_Now)))
                        {
                            Sub_Code.File_Delete_V2(File_Now);
                        }
                    }
                    File_Name_T.Text = Path.GetFileName(ofd.FileName);
                    Message_Feed_Out(".bnkファイルをロードしました。");
                }
                catch (Exception e1)
                {
                    Sub_Code.Error_Log_Write(e1.Message);
                    Message_Feed_Out("解析に失敗しました。Error_Log.txtを参照してください。");
                }
                IsBusy = false;
            }
        }
示例#6
0
 private void stopBtn_Click(object sender, EventArgs e)
 {
     Bass.BASS_ChannelStop(_stream);
     playBtn.Image = Properties.Resources._013_play;
 }
示例#7
0
 public void CloseStream()
 {
     Bass.BASS_ChannelStop(_stream);
     Bass.BASS_StreamFree(_stream);
 }
示例#8
0
 public bool stopSong()
 {
     playlist.config.currState = "stop";
     Console.WriteLine(playlist.Count + "---count");
     return(Bass.BASS_ChannelStop(Stream));
 }
        /// <summary>
        /// Resample to new samplerate and in mono
        /// </summary>
        public AudioSamples Resample(float[] inputAudioSamples, int inputSampleRate = 44100, int inputChannels = 2, int outputSamplerate = 5512)
        {
            //create streams for re-sampling
            int stream = Bass.BASS_StreamCreatePush(inputSampleRate, inputChannels, GetDefaultFlags(), IntPtr.Zero);

            ThrowIfStreamIsInvalid(stream);
            int mixerStream = BassMix.BASS_Mixer_StreamCreate(outputSamplerate, 1, GetDefaultFlags());

            ThrowIfStreamIsInvalid(mixerStream);
            if (!bassService.CombineMixerStreams(mixerStream, stream, BASSFlag.BASS_MIXER_FILTER | BASSFlag.BASS_MIXER_DOWNMIX))
            {
                throw new BassException(bassService.GetLastError());
            }
            Bass.BASS_StreamPutData(stream, inputAudioSamples, inputAudioSamples.Length * 4);

            int bufferSize = outputSamplerate * 10 * 4; /*read 10 seconds at each iteration*/

            float[]        buffer = new float[bufferSize];
            List <float[]> chunks = new List <float[]>();
            int            size   = 0;

            int bytesRead;

            do
            {
                // get re-sampled/mono data
                bytesRead = Bass.BASS_ChannelGetData(mixerStream, buffer, bufferSize);
                if (bytesRead == 0)
                {
                    break;
                }
                float[] chunk = new float[bytesRead / 4]; //each float contains 4 bytes
                Array.Copy(buffer, chunk, bytesRead / 4);
                chunks.Add(chunk);
                size += bytesRead / 4; //size of the data
            } while (bytesRead > 0);


            // Do bass cleanup
            Bass.BASS_ChannelStop(mixerStream);
            Bass.BASS_ChannelStop(stream);
            Bass.BASS_StreamFree(mixerStream);
            Bass.BASS_StreamFree(stream);

            float[] data  = new float[size];
            int     index = 0;

            // Concatenate
            foreach (float[] chunk in chunks)
            {
                Array.Copy(chunk, 0, data, index, chunk.Length);
                index += chunk.Length;
            }

            // Create audiosamples object
            AudioSamples audioSamples = new AudioSamples();

            audioSamples.Origin       = "MEMORY";
            audioSamples.Channels     = 1;
            audioSamples.SampleRate   = outputSamplerate;
            audioSamples.StartInMS    = 0;
            audioSamples.DurationInMS = (int)(((float)size / (float)outputSamplerate) * 1000.0f);
            audioSamples.Samples      = data;

            return(audioSamples);
        }
示例#10
0
 public static void FreeChannel(int handle)
 {
     Bass.BASS_ChannelStop(handle);
     Bass.BASS_StreamFree(handle);
 }
示例#11
0
 public void Stop()
 {
     Bass.BASS_ChannelStop(streamHandle);
 }
 public static void Stop(int stream)
 {
     Bass.BASS_ChannelStop(stream);
 }
示例#13
0
 /// <summary>
 /// Stopping and freeing the stream.
 /// </summary>
 public void Stop()
 {
     Bass.BASS_ChannelStop(Stream);
     Bass.BASS_StreamFree(Stream);
     activeState = PlayerState.Stopped;
 }
 private void PlayWindow_OnClosed(object sender, EventArgs e)
 {
     Bass.BASS_ChannelStop(stream);
     Bass.BASS_StreamFree(stream);
 }
示例#15
0
 /// <summary>
 /// Stop PCM play
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnStopPcm_Click(object sender, EventArgs e)
 {
     Bass.BASS_ChannelStop(pcmImportStreamHandle);
     Msg("Raw PCM playback stopped");
 }
        /// <summary>
        /// Stretches audio, keeps channels and samplerate.
        /// negatief value slowsdown (makes longer) the audio
        /// Positief value speedsup (make shorter) the audio
        /// </summary>
        public AudioSamples TimeStretch(float[] inputAudioSamples, int inputSampleRate = 44100, int inputChannels = 2, float rateFactor = 0.0f)
        {
            // calculate total milliseconds to read
            int totalmilliseconds = Int32.MaxValue;

            float[] data = null;

            int stream = Bass.BASS_StreamCreatePush(inputSampleRate, inputChannels, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT, IntPtr.Zero);

            ThrowIfStreamIsInvalid(stream);
            BASS_CHANNELINFO channelInfo = Bass.BASS_ChannelGetInfo(stream);

            Bass.BASS_StreamPutData(stream, inputAudioSamples, inputAudioSamples.Length * 4);

            SoundTouch <Single, Double> soundTouch = new SoundTouch <Single, Double>();

            soundTouch.SetSampleRate(channelInfo.freq);
            soundTouch.SetChannels(channelInfo.chans);
            soundTouch.SetTempoChange(0.0f);
            soundTouch.SetPitchSemiTones(0.0f);
            soundTouch.SetRateChange(rateFactor); // -1.4f = Radio 538 setting
            soundTouch.SetSetting(SettingId.UseQuickseek, 0);
            soundTouch.SetSetting(SettingId.UseAntiAliasFilter, 0);

            int bufferSize = 2048;

            float[]        buffer   = new float[bufferSize];
            List <float[]> chunks   = new List <float[]>();
            int            size     = 0;
            int            nSamples = 0;

            while ((float)(size) / channelInfo.freq * 1000 < totalmilliseconds)
            {
                // get re-sampled data
                int bytesRead = Bass.BASS_ChannelGetData(stream, buffer, bufferSize);
                if (bytesRead <= 0)
                {
                    break;
                }
                nSamples = (bytesRead / 4) / channelInfo.chans;
                // Feed the samples into SoundTouch processor
                soundTouch.PutSamples(buffer, nSamples);

                // Read ready samples from SoundTouch processor & write them output file.
                // NOTES:
                // - 'receiveSamples' doesn't necessarily return any samples at all
                //   during some rounds!
                // - On the other hand, during some round 'receiveSamples' may have more
                //   ready samples than would fit into 'sampleBuffer', and for this reason
                //   the 'receiveSamples' call is iterated for as many times as it
                //   outputs samples.
                do
                {
                    nSamples = soundTouch.ReceiveSamples(buffer, (bufferSize / channelInfo.chans));
                    if (nSamples > 0)
                    {
                        float[] chunk = new float[nSamples * channelInfo.chans];
                        Array.Copy(buffer, chunk, nSamples * channelInfo.chans);
                        chunks.Add(chunk);
                        size += nSamples * channelInfo.chans; //size of the data
                    }
                } while (nSamples != 0);
            } //while

            // Now the input file is processed, yet 'flush' few last samples that are
            // hiding in the SoundTouch's internal processing pipeline.
            soundTouch.Flush();
            do
            {
                nSamples = soundTouch.ReceiveSamples(buffer, (bufferSize / channelInfo.chans));
                if (nSamples > 0)
                {
                    float[] chunk = new float[nSamples * channelInfo.chans];
                    Array.Copy(buffer, chunk, nSamples * channelInfo.chans);
                    chunks.Add(chunk);
                    size += nSamples * channelInfo.chans; //size of the data
                }
            } while (nSamples != 0);


            if (size <= 0)
            {
                // not enough samples to return the requested data
                return(null);
            }

            // Do bass cleanup
            Bass.BASS_ChannelStop(stream);
            Bass.BASS_StreamFree(stream);

            int start = 0;
            int end   = size;

            data = new float[size];
            int index = 0;

            // Concatenate
            foreach (float[] chunk in chunks)
            {
                Array.Copy(chunk, 0, data, index, chunk.Length);
                index += chunk.Length;
            }

            // Select specific part of the song
            if (start != 0 || end != size)
            {
                float[] temp = new float[end - start];
                Array.Copy(data, start, temp, 0, end - start);
                data = temp;
            }

            // Create audiosamples object
            AudioSamples audioSamples = new AudioSamples();

            audioSamples.Origin       = "MEMORY";
            audioSamples.Channels     = channelInfo.chans;
            audioSamples.SampleRate   = channelInfo.freq;
            audioSamples.StartInMS    = start;
            audioSamples.DurationInMS = end;
            audioSamples.Samples      = data;

            return(audioSamples);
        }
示例#17
0
 //остановка воспроизведения
 public static void Stop()
 {
     Bass.BASS_ChannelStop(Stream);
     Bass.BASS_StreamFree(Stream);
     isStopped = true;
 }
        /// <summary>
        /// Read audio file and mix it to mono, then resample it to "samplerate"
        /// </summary>
        /// <param name="filename">Name of the file</param>
        /// <param name="samplerate">Output sample rate, default 5512hz</param>
        /// <param name="toReadInMS">Milliseconds to read of or <= 0 to read everything</param>
        /// <param name="startmillisecond">Start position in millisecond, default 0 for begin</param>
        /// <returns>Array of samples</returns>
        /// <remarks>
        /// Seeking capabilities of Bass where not used because of the possible
        /// timing errors on different formats.
        /// </remarks>
        public AudioSamples ReadMonoFromFile(string filename, int outputSamplerate = 5512, int startPositionInMS = 0, int toReadInMS = -1)
        {
            if (!File.Exists(filename))
            {
                throw new Exception("File '" + filename + "' doesn't exists.");
            }

            // calculate total milliseconds to read
            int totalmilliseconds = toReadInMS <= 0 ? Int32.MaxValue : (toReadInMS + startPositionInMS);

            float[] data = null;

            //create streams for re-sampling
            int stream      = CreateStream(filename);
            int mixerStream = CreateMixerStream(outputSamplerate);

            if (!bassService.CombineMixerStreams(mixerStream, stream, BASSFlag.BASS_MIXER_FILTER | BASSFlag.BASS_MIXER_DOWNMIX))
            {
                throw new BassException(bassService.GetLastError());
            }

            int bufferSize = outputSamplerate * 10 * 4; /*read 10 seconds at each iteration*/

            float[]        buffer = new float[bufferSize];
            List <float[]> chunks = new List <float[]>();
            int            size   = 0;

            while ((float)(size) / outputSamplerate * 1000 < totalmilliseconds)
            {
                // get re-sampled/mono data
                int bytesRead = Bass.BASS_ChannelGetData(mixerStream, buffer, bufferSize);
                if (bytesRead == 0)
                {
                    break;
                }
                float[] chunk = new float[bytesRead / 4]; //each float contains 4 bytes
                Array.Copy(buffer, chunk, bytesRead / 4);
                chunks.Add(chunk);
                size += bytesRead / 4; //size of the data
            } //while

            if ((float)(size) / outputSamplerate * 1000 < (toReadInMS + startPositionInMS))
            {
                // not enough samples to return the requested data
                return(null);
            }

            // Do bass cleanup
            Bass.BASS_ChannelStop(mixerStream);
            Bass.BASS_ChannelStop(stream);
            Bass.BASS_StreamFree(mixerStream);
            Bass.BASS_StreamFree(stream);

            int start = (int)((float)startPositionInMS * outputSamplerate / 1000);
            int end   = (toReadInMS <= 0) ? size : (int)((float)(startPositionInMS + toReadInMS) * outputSamplerate / 1000);

            data = new float[size];
            int index = 0;

            // Concatenate
            foreach (float[] chunk in chunks)
            {
                Array.Copy(chunk, 0, data, index, chunk.Length);
                index += chunk.Length;
            }

            // Select specific part of the song
            if (start != 0 || end != size)
            {
                float[] temp = new float[end - start];
                Array.Copy(data, start, temp, 0, end - start);
                data = temp;
            }

            // Create audiosamples object
            AudioSamples audioSamples = new AudioSamples();

            audioSamples.Origin       = filename;
            audioSamples.Channels     = 1;
            audioSamples.SampleRate   = outputSamplerate;
            audioSamples.StartInMS    = start;
            audioSamples.DurationInMS = end;
            audioSamples.Samples      = data;

            return(audioSamples);
        }
 public void Stop()
 {
     Bass.BASS_ChannelStop(hStream);
     Bass.BASS_ChannelSetPosition(hStream, 0d);
 }
示例#20
0
 /// <summary>
 /// Останавливает текущий поток и перематывает его на начало
 /// </summary>
 public static void Stop()
 {
     Bass.BASS_ChannelStop(stream);
     SetPositionScroll(0);
 }
示例#21
0
 public void Stop()
 {
     _timer.Stop();
     _isPaused = true;
     Bass.BASS_ChannelStop(_channel);
 }
示例#22
0
 /// <summary>
 /// Останавливает текущий поток и очищает его
 /// </summary>
 public static void ClearStream()
 {
     Bass.BASS_ChannelStop(stream);
     Bass.BASS_StreamFree(stream);
 }
示例#23
0
 /// <summary>
 /// Implemented member, disposed
 /// </summary>
 public void Dispose()
 {
     Bass.BASS_ChannelStop(Handle);
 }
示例#24
0
 /// <summary>
 /// Выполнение функции Stop библиотеки BASS
 /// </summary>
 /// <returns></returns>
 protected override bool ChannelStop(int Channel)
 {
     return(Bass.BASS_ChannelStop(Channel));
 }
示例#25
0
 public virtual void Stop()
 {
     Bass.BASS_ChannelStop(audioHandle);
 }
示例#26
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     Bass.BASS_ChannelStop(stream);
     ifFirst = true;
 }
示例#27
0
        private void timer1_Tick(object sender, EventArgs e)                                         //自动播放下一曲
        {
            double c = Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetLength(stream));   //获取歌曲总长度
            double a = Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetPosition(stream)); //获取当前正播放歌曲的进度

            label1.Text = label1.Text.Substring(1) + label1.Text.Substring(0, 1);

            if (c == a && c >= 0)         //判断歌曲是否播放完了
            {
                if (radioButton1.Checked) //判断歌曲的播放模式是否为“顺序播放”
                {
                    try
                    {
                        int index = listBox1.SelectedIndex; //获得当前选中的索引
                        listBox1.SelectedIndices.Clear();   //清空当前所有选中的索引

                        index++;
                        if (index == listBox1.Items.Count)//如果歌曲为最后一曲
                        {
                            index = 0;
                        }                                                                                  //索引从头开始
                        listBox1.SelectedIndex = index;
                        Bass.BASS_ChannelStop(stream);                                                     //停止上一曲
                        string songname = listpath[listBox1.SelectedIndex];                                //获得当前的歌曲路径
                        stream = Bass.BASS_StreamCreateFile(songname, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT); //播放当前选中的歌曲
                        Bass.BASS_ChannelPlay(stream, true);
                        label1.Text              = "   " + songname;
                        button1.Enabled          = true;
                        暂停ToolStripMenuItem.Text = "暂停";
                        button1.Text             = "暂停";
                        p = true;
                    }
                    catch { }
                }
                else if (radioButton2.Checked)//当播放模式为随机播放
                {
                    try
                    {
                        Bass.BASS_ChannelStop(stream);
                        listBox1.SelectedIndices.Clear();//清空当前所有选中的索引
                        Random next     = new Random();
                        int    nextsong = next.Next(1, listBox1.Items.Count - 1);
                        listBox1.SelectedIndex = nextsong;
                        string songname = listpath[listBox1.SelectedIndex];
                        stream = Bass.BASS_StreamCreateFile(songname, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT);
                        Bass.BASS_ChannelPlay(stream, true);
                        label1.Text = "   " + songname;
                        暂停ToolStripMenuItem.Text = "暂停";
                        button1.Text             = "暂停";
                        p = true;
                    }
                    catch { }
                }
                else  //单曲循环播放模式
                {
                    try
                    {
                        int index = listBox1.SelectedIndex; //获得当前选中的索引
                        listBox1.SelectedIndices.Clear();   //清空当前所有选中的索引

                        // index++;
                        // if (index == listBox1.Items.Count)
                        // { index = 0; }
                        listBox1.SelectedIndex = index;
                        Bass.BASS_ChannelStop(stream);
                        string songname = listpath[listBox1.SelectedIndex];
                        stream = Bass.BASS_StreamCreateFile(songname, 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT);
                        Bass.BASS_ChannelPlay(stream, true);
                        label1.Text              = "   " + songname;
                        button1.Enabled          = true;
                        暂停ToolStripMenuItem.Text = "暂停";
                        button1.Text             = "暂停";
                        p = true;
                    }
                    catch { }
                }
            }
        }
示例#28
0
 private void btnStopLame_Click(object sender, EventArgs e)
 {
     Bass.BASS_ChannelStop(_blogStreamHandle);
     Msg("Lame MP3 playback stopped");
 }
        public void Stop()
        {
            Bass.BASS_ChannelStop(streamID);

            Bass.BASS_ChannelSetPosition(streamID, 0, BASSMode.BASS_POS_BYTES);
        }
示例#30
0
 void BNK_FSB_Clear(bool IsMessageShow = true)
 {
     if (IsClosing || IsBusy)
     {
         return;
     }
     if (IsMessageShow)
     {
         MessageBoxResult result = System.Windows.MessageBox.Show("内容をクリアしますか?", "確認", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No);
         if (result == MessageBoxResult.Yes)
         {
             Bass.BASS_ChannelStop(Stream);
             Bass.BASS_StreamFree(Stream);
             Voices_L.Items.Clear();
             Content_L.Items.Clear();
             BNK_FSB_Enable.Clear();
             BNK_FSB_Voices.Clear();
             Voices_L.Items.Add("音声ファイルが選択されていません。");
             BNK_FSB_Voices.Clear();
             File_Name_T.Text   = "";
             Location_S.Value   = 0;
             Location_S.Maximum = 0;
             Max_Stream_Count   = 0;
             Now_Stream_Count   = 0;
             Location_T.Text    = "00:00";
             try
             {
                 if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/BNK_WAV_WoT"))
                 {
                     Directory.Delete(Voice_Set.Special_Path + "/Wwise/BNK_WAV_WoT", true);
                 }
             }
             catch (Exception e1)
             {
                 Sub_Code.Error_Log_Write(e1.Message);
             }
             Message_Feed_Out("内容をクリアしました。");
         }
     }
     else
     {
         Bass.BASS_ChannelStop(Stream);
         Bass.BASS_StreamFree(Stream);
         Voices_L.Items.Clear();
         Content_L.Items.Clear();
         BNK_FSB_Enable.Clear();
         BNK_FSB_Voices.Clear();
         Voices_L.Items.Add("音声ファイルが選択されていません。");
         BNK_FSB_Voices.Clear();
         File_Name_T.Text   = "";
         Location_S.Value   = 0;
         Location_S.Maximum = 0;
         Max_Stream_Count   = 0;
         Now_Stream_Count   = 0;
         Location_T.Text    = "00:00";
         try
         {
             if (Directory.Exists(Voice_Set.Special_Path + "/Wwise/BNK_WAV_WoT"))
             {
                 Directory.Delete(Voice_Set.Special_Path + "/Wwise/BNK_WAV_WoT", true);
             }
         }
         catch (Exception e1)
         {
             Sub_Code.Error_Log_Write(e1.Message);
         }
     }
 }