|
「equalizer.cs」
using BASSNETPlayer.BASS.Player;
using System.Reflection.Metadata;
using System.Runtime.InteropServices;
using Un4seen.Bass;
namespace BASSNETPlayer.BASS.Control
{
public partial class equalizer : Form
{
private AudioPlayer BassSound;
private readonly HashSet<string> History = new(StringComparer.OrdinalIgnoreCase);
public readonly ToolTip tip = new();
public readonly EQualizer BassEQ = new();
public readonly int[] fxEQ = new int[11];
private Form1 form1;
private bool initialized = false; // イコライザー初期化フラグ
public static int BandsCount { get; private set; }
public equalizer(AudioPlayer bassSound, Form1 form1)
{
InitializeComponent();
BassSound = bassSound;
this.form1 = form1;
InitializeEqualizer(); // イコライザーを初期化
}
private void InitializeEqualizer()
{
if (!initialized)
{
BASS_ChannelAddEQ(); // イコライザーの設定を追加
initialized = true;
}
else
{
BASS_ChannelUpdateEQ(); // イコライザーの状態を更新
}
}
//イコライザ
#region イコライザ
public void BASS_ChannelAddEQ()
{
BassEQ.BASS_AddEQ(BassSound.Steam, fxEQ, 10);
BassEQ.BASS_SetParametersEQ(fxEQ, 100, 0);
BassEQ.BASS_SetParametersEQ(fxEQ, 200, 1);
BassEQ.BASS_SetParametersEQ(fxEQ, 400, 2);
BassEQ.BASS_SetParametersEQ(fxEQ, 600, 3);
BassEQ.BASS_SetParametersEQ(fxEQ, 1000, 4);
BassEQ.BASS_SetParametersEQ(fxEQ, 3000, 5);
BassEQ.BASS_SetParametersEQ(fxEQ, 6000, 6);
BassEQ.BASS_SetParametersEQ(fxEQ, 12000, 7);
BassEQ.BASS_SetParametersEQ(fxEQ, 14000, 8);
BassEQ.BASS_SetParametersEQ(fxEQ, 16000, 9);
}
public void BASS_ChannelUpdateEQ()
{
BassEQ.BASS_UpdateEQ(fxEQ, 0, (float)this.TrackBar1.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 1, (float)this.TrackBar2.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 2, (float)this.TrackBar3.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 3, (float)this.TrackBar4.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 4, (float)this.TrackBar5.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 5, (float)this.TrackBar6.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 6, (float)this.TrackBar7.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 7, (float)this.TrackBar8.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 8, (float)this.TrackBar9.Value);
BassEQ.BASS_UpdateEQ(fxEQ, 9, (float)this.TrackBar10.Value);
}
public void BASS_ChannelRemoveEQ()
{
BassEQ.BASS_RemoveEQ(BassSound.Steam, fxEQ, 10);
}
public void BASS_ResetVolumeEQ()
{
this.TrackBar1.Value = 0;
this.TrackBar2.Value = this.TrackBar1.Value;
this.TrackBar3.Value = this.TrackBar2.Value;
this.TrackBar4.Value = this.TrackBar3.Value;
this.TrackBar5.Value = this.TrackBar4.Value;
this.TrackBar6.Value = this.TrackBar5.Value;
this.TrackBar7.Value = this.TrackBar6.Value;
this.TrackBar8.Value = this.TrackBar7.Value;
this.TrackBar9.Value = this.TrackBar8.Value;
this.TrackBar10.Value = this.TrackBar9.Value;
}
#endregion
private void equalizer_Load(object sender, EventArgs e)
{
}
private void TrackBar1_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 0, (float)this.TrackBar1.Value);
}
private void TrackBar1_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 0, (float)this.TrackBar1.Value);
tip.SetToolTip(this.TrackBar1, this.TrackBar1.Value.ToString());
}
private void TrackBar2_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 1, (float)this.TrackBar2.Value);
}
private void TrackBar2_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 1, (float)this.TrackBar2.Value);
tip.SetToolTip(this.TrackBar2, this.TrackBar2.Value.ToString());
}
private void TrackBar3_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 2, (float)this.TrackBar3.Value);
}
private void TrackBar3_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 2, (float)this.TrackBar3.Value);
tip.SetToolTip(this.TrackBar3, this.TrackBar3.Value.ToString());
}
private void TrackBar4_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 3, (float)this.TrackBar4.Value);
}
private void TrackBar4_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 3, (float)this.TrackBar4.Value);
tip.SetToolTip(this.TrackBar4, this.TrackBar4.Value.ToString());
}
private void TrackBar5_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 4, (float)this.TrackBar5.Value);
}
private void TrackBar5_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 4, (float)this.TrackBar5.Value);
tip.SetToolTip(this.TrackBar5, this.TrackBar5.Value.ToString());
}
private void TrackBar6_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 5, (float)this.TrackBar6.Value);
}
private void TrackBar6_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 5, (float)this.TrackBar6.Value);
tip.SetToolTip(this.TrackBar6, this.TrackBar6.Value.ToString());
}
private void TrackBar7_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 6, (float)this.TrackBar7.Value);
}
private void TrackBar7_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 6, (float)this.TrackBar7.Value);
tip.SetToolTip(this.TrackBar7, this.TrackBar7.Value.ToString());
}
private void TrackBar8_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 7, (float)this.TrackBar8.Value);
}
private void TrackBar8_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 7, (float)this.TrackBar8.Value);
tip.SetToolTip(this.TrackBar8, this.TrackBar8.Value.ToString());
}
private void TrackBar9_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 8, (float)this.TrackBar9.Value);
}
private void TrackBar9_ValueChanged(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 8, (float)this.TrackBar9.Value);
tip.SetToolTip(this.TrackBar9, this.TrackBar9.Value.ToString());
}
private void TrackBar10_Scroll(object sender, EventArgs e)
{
BassEQ.BASS_UpdateEQ(fxEQ, 9, (float)this.TrackBar10.Value);
}
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
switch (this.CheckBox1.CheckState)
{
case CheckState.Checked:
{
BASS_ChannelAddEQ();
BASS_ChannelUpdateEQ();
this.TrackBar1.Enabled = true;
this.TrackBar2.Enabled = true;
this.TrackBar3.Enabled = true;
this.TrackBar4.Enabled = true;
this.TrackBar5.Enabled = true;
this.TrackBar6.Enabled = true;
this.TrackBar7.Enabled = true;
this.TrackBar8.Enabled = true;
this.TrackBar9.Enabled = true;
this.TrackBar10.Enabled = true;
break;
}
case CheckState.Unchecked:
{
BASS_ChannelRemoveEQ();
this.TrackBar1.Enabled = false;
this.TrackBar2.Enabled = false;
this.TrackBar3.Enabled = false;
this.TrackBar4.Enabled = false;
this.TrackBar5.Enabled = false;
this.TrackBar6.Enabled = false;
this.TrackBar7.Enabled = false;
this.TrackBar8.Enabled = false;
this.TrackBar9.Enabled = false;
this.TrackBar10.Enabled = false;
break;
}
default:
{
break;
}
}
}
|