我知道如何在 midi 上产生声音和打击乐,但我需要上下增加节奏,我不知道如何做到这一点,我正在使用多媒体计时器,但问题是我遇到线程错误同时使用两个或多个音色时。
这是用于创建循环,它从 1 变为 4。
procedure TimeCallBack(TimerID, Msg: Uint; dwUser, dw1, dw2: DWORD); pascal;
var
nome: Integer;
begin
nome := FrmMetrolima.ListBox1.ItemIndex;
FrmMetrolima.panel518.Caption := FrmMetrolima.ListBox1.Items[nome];
if (FrmMetrolima.panel518.Caption = 'Binário-2 (pág. 13)') then
// Binário-2
begin
FrmMetrolima.panel3.Caption := '8';
inc(tempo, 1);
FrmMetrolima.Panel2.Caption := IntToStr(tempo);
if FrmMetrolima.Panel2.Caption = '5' then
begin
FrmMetrolima.Panel2.Caption := '1';
tempo := 1;
end;
// metrônomo
if (FrmMetrolima.Panel2.Caption = '1') and
(FrmMetrolima.Panel28.Caption = '1') and
(FrmMetrolima.Label7.Caption = '1') then
begin
noteOn(9, 75, 127);
end
else if (FrmMetrolima.Panel2.Caption = '2') and
(FrmMetrolima.Panel29.Caption = '2') and
(FrmMetrolima.Label7.Caption = '1') then
begin
noteOn(9, 62, 127);
end
else if (FrmMetrolima.Panel2.Caption = '3') and
(FrmMetrolima.Panel30.Caption = '3') and
(FrmMetrolima.Label7.Caption = '1') then
begin
noteOn(9, 63, 127);
end
else if (FrmMetrolima.Panel2.Caption = '4') and
(FrmMetrolima.Panel31.Caption = '4') and
(FrmMetrolima.Label7.Caption = '1') then
begin
noteOn(9, 62, 127);
end;
end;
end;
用法:
if (ListBox1.ItemIndex = 0) then
// Subdivisão Binária
begin
noteOn(9, 75, 127);
mmResult := TimeSetEvent(60000 div StrToInt(FlatEdit2.Text) div 2, 0,
@TimeCallBack, 0, TIME_PERIODIC);
end;