Hi Ian, but I've been searching to no avail and can't figure out where the error is.
I have to mute a midi channel for example channel 4 on the conversion from midi to mp3.
I wrote this code but it doesn't work.
procedure OnMidiNote(handle: HSYNC; channel, data, user: DWORD ); stdcall;
var MidiChannel:Word;
vel,note:Byte;
begin
MidiChannel := HIWord(data);
note:=LOBYTE(Data);
Vel:=HIBYTE(word(Data));
if MidiChannel=3 then ////// channel 4
BASS_MIDI_StreamEvent(channel, MidiChannel, MIDI_EVENT_NOTE, note);
end;
procedure convert;
begin
ChanSF2 := BASS_MIDI_StreamCreateFile(False, PChar(Song), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE or BASS_MIDI_DECAYEND,48000);
BASS_MIDI_StreamSetFonts(ChanSF2, PBASS_MIDI_FONTEX(@fSoundfontMp3), 2 or BASS_MIDI_FONT_EX);
BASS_ChannelSetSync(ChanSF2, BASS_SYNC_MIDI_EVENT, MIDI_EVENT_NOTE, @OnMidiNote, nil);
handle_1 := BASS_Encode_Start(ChanSF2, PChar('lame.exe -b 128 - tempxx.mp3'), BASS_UNICODE or BASS_ENCODE_AUTOFREE, nil, nil);
t := Bass_ChannelGetLength(ChanSF2, BASS_POS_BYTE);
//dwGet := 0;
ProgressBar1.Value := 0;
dwSamples :=48000;
BufMp3 := AllocMem(dwSamples * sizeof(Integer));
while BASS_ChannelIsActive(ChanSF2) > 0 do
begin
c := BASS_ChannelGetPosition(ChanSF2, BASS_POS_BYTE); { current position }
BASS_ChannelGetData(ChanSF2, BufMp3, dwSamples * sizeof(Integer));
if t > 0 then
begin
ProgressBar1.Value := round((c * 100) / t);
ProgressBar1.Repaint;
end;
end;
........ other code
the OnMidiNote procedure is called correctly but on the mp3 file channel 4 is played and not muted.
Why ?
Thank for help.