[Scummvm-git-logs] scummvm master -> b0644919d608f39f21c47f1fbaa86b9081ff4e69

NMIError noreply at scummvm.org
Sat Jul 2 15:25:22 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b0644919d6 AUDIO: Generate note channel to track mapping for type 1 MIDI


Commit: b0644919d608f39f21c47f1fbaa86b9081ff4e69
    https://github.com/scummvm/scummvm/commit/b0644919d608f39f21c47f1fbaa86b9081ff4e69
Author: elasota (ejlasota at gmail.com)
Date: 2022-07-02T17:25:18+02:00

Commit Message:
AUDIO: Generate note channel to track mapping for type 1 MIDI

Changed paths:
    audio/midiparser_smf.cpp
    audio/midiparser_smf.h


diff --git a/audio/midiparser_smf.cpp b/audio/midiparser_smf.cpp
index 16ed203addf..a6568ee9bbe 100644
--- a/audio/midiparser_smf.cpp
+++ b/audio/midiparser_smf.cpp
@@ -29,6 +29,11 @@
 static const byte commandLengths[8] = { 3, 3, 3, 3, 2, 2, 3, 0 };
 static const byte specialLengths[16] = { 0, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 };
 
+MidiParser_SMF::MidiParser_SMF(int8 source) : MidiParser(source), _buffer(nullptr) {
+	for (int i = 0; i < ARRAYSIZE(_noteChannelToTrack); i++)
+		_noteChannelToTrack[i] = -1;
+}
+
 MidiParser_SMF::~MidiParser_SMF() {
 	free(_buffer);
 }
@@ -295,6 +300,8 @@ uint32 MidiParser_SMF::compressToType0(byte *tracks[], byte numTracks, byte *buf
 
 		if (commandLengths[(event >> 4) - 8] > 0) {
 			copyBytes = commandLengths[(event >> 4) - 8];
+			if ((event & 0xf0) == MidiDriver_BASE::MIDI_COMMAND_NOTE_ON)
+				_noteChannelToTrack[event & 0x0f] = bestTrack;
 		} else if (specialLengths[(event & 0x0F)] > 0) {
 			copyBytes = specialLengths[(event & 0x0F)];
 		} else if (event == 0xF0) {
diff --git a/audio/midiparser_smf.h b/audio/midiparser_smf.h
index d7503116fce..523833b5c55 100644
--- a/audio/midiparser_smf.h
+++ b/audio/midiparser_smf.h
@@ -30,6 +30,7 @@
 class MidiParser_SMF : public MidiParser {
 protected:
 	byte *_buffer;
+	int8 _noteChannelToTrack[16];
 
 protected:
 	/**
@@ -47,7 +48,7 @@ protected:
 	void parseNextEvent(EventInfo &info) override;
 
 public:
-	MidiParser_SMF(int8 source = -1) : MidiParser(source), _buffer(nullptr) {}
+	MidiParser_SMF(int8 source = -1);
 	~MidiParser_SMF();
 
 	bool loadMusic(byte *data, uint32 size) override;




More information about the Scummvm-git-logs mailing list