正確加載插件會顯示如下圖

DSP插件需要BASS庫支持,在debug目錄加入bass_wadsp.dll擴展庫

完整代碼如下:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Un4seen.Bass; using Un4seen.Bass.AddOn.WaDsp; namespace WindowsFormsApp3 { public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void Form3_Load(object sender, EventArgs e) { //-1 表示 默認設備輸出 //44100 表示 輸出采樣率 //BASS_DEVICE_CPSPEAKERS 表示輸出模式 if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_CPSPEAKERS, this.Handle)) { MessageBox.Show("出錯了," + Bass.BASS_ErrorGetCode().ToString()); } } string fileName; int stream; int dspHandle; int dspModule = 0; private void btn_play_Click(object sender, EventArgs e) { OpenFileDialog o = new OpenFileDialog(); if (o.ShowDialog() == DialogResult.OK) { fileName = o.FileName; //第一個參數是文件名, //第二個參數是文件流開始位置, //第三個是文件流長度 0為使用文件整個長度, //最后一個是流的創建模式 stream = Bass.BASS_StreamCreateFile(fileName, 0L, 0L, BASSFlag.BASS_DEFAULT); Bass.BASS_ChannelPlay(stream, true); //開始播放 } } private void btn_load_Click(object sender, EventArgs e) { OpenFileDialog o = new OpenFileDialog(); if (o.ShowDialog() == DialogResult.OK) { BassWaDsp.BASS_WADSP_Init(this.Handle); dspHandle = BassWaDsp.BASS_WADSP_Load(o.FileName, 5, 5, 100, 100, null); BassWaDsp.BASS_WADSP_Start(dspHandle, dspModule, 0); int hDsp = BassWaDsp.BASS_WADSP_ChannelSetDSP(dspHandle, stream, 1); } } private void btn_dsp_set_Click(object sender, EventArgs e) { if (dspHandle >= 0 && dspModule >= 0) { BassWaDsp.BASS_WADSP_Config(dspHandle); } } private void btn_dsp_stop_Click(object sender, EventArgs e) { BassWaDsp.BASS_WADSP_Stop(dspHandle); } private void Form3_FormClosing(object sender, FormClosingEventArgs e) { Bass.BASS_ChannelStop(stream); //停止播放 BassWaDsp.BASS_WADSP_Stop(dspHandle); } } }
需要注意一下的是,同EQ設置一樣,每次播放完歌曲 播放新的歌曲時,都要重新設置一次。
可以這樣操作:

最后附上demo地址:
鏈接: https://pan.baidu.com/s/1ocvKixBjIvBk6tKv4uzBfQ 提取碼: dvtn
另附同款dsp音效(更多音效可以去網上找找):
鏈接: https://pan.baidu.com/s/1Jy60GqbcnNduZ0kFbANA4w 提取碼: udes

