Implemented a MIDI plug-in
parent
ab97f832ed
commit
842932c322
Binary file not shown.
|
@ -62,6 +62,7 @@ td.icon { width: auto; }
|
||||||
<li>Apple Lossless</li>
|
<li>Apple Lossless</li>
|
||||||
<li>WMA Standard, Pro, Lossless, and Voice</li>
|
<li>WMA Standard, Pro, Lossless, and Voice</li>
|
||||||
<li>TrueAudio</li>
|
<li>TrueAudio</li>
|
||||||
|
<li>MIDI Sequences</li>
|
||||||
<li>Sequenced Module formats (IT, XM, S3M, MOD, STM, PTM, MTM, 669, PSM, AM, J2B, DSM, AMF, OKT/OKTA, and UMX)</li>
|
<li>Sequenced Module formats (IT, XM, S3M, MOD, STM, PTM, MTM, 669, PSM, AM, J2B, DSM, AMF, OKT/OKTA, and UMX)</li>
|
||||||
<li>Emulated Console formats supported by the Game_Music_Emu library (AY, GBS, HES, KSS, NSF/NSFE, SAP, SGC, SPC, and VGM/VGZ)</li>
|
<li>Emulated Console formats supported by the Game_Music_Emu library (AY, GBS, HES, KSS, NSF/NSFE, SAP, SGC, SPC, and VGM/VGZ)</li>
|
||||||
<li>Many Emulated Console formats utilizing the PSF format (PSF, PSF2, SSF, DSF, QSF, GSF, NCSF, 2SF, and their respective mini variants)</li>
|
<li>Many Emulated Console formats utilizing the PSF format (PSF, PSF2, SSF, DSF, QSF, GSF, NCSF, 2SF, and their respective mini variants)</li>
|
||||||
|
|
|
@ -179,6 +179,7 @@
|
||||||
838491871808591F00E7332D /* NDHotKey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8384917E1808585D00E7332D /* NDHotKey.framework */; };
|
838491871808591F00E7332D /* NDHotKey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8384917E1808585D00E7332D /* NDHotKey.framework */; };
|
||||||
838491881808593200E7332D /* NDHotKey.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8384917E1808585D00E7332D /* NDHotKey.framework */; };
|
838491881808593200E7332D /* NDHotKey.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8384917E1808585D00E7332D /* NDHotKey.framework */; };
|
||||||
8399D4E21805A55000B503B1 /* XmlContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8399D4E01805A55000B503B1 /* XmlContainer.m */; };
|
8399D4E21805A55000B503B1 /* XmlContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8399D4E01805A55000B503B1 /* XmlContainer.m */; };
|
||||||
|
83B06704180D579E008E3612 /* MIDI.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B066A1180D5669008E3612 /* MIDI.bundle */; };
|
||||||
83BCB8DE17FC971300760340 /* FFMPEG.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = B09E94350D747F7B0064F138 /* FFMPEG.bundle */; };
|
83BCB8DE17FC971300760340 /* FFMPEG.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = B09E94350D747F7B0064F138 /* FFMPEG.bundle */; };
|
||||||
83E5E54C18087CA5001F3284 /* miniModeOffTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 83E5E54A18087CA5001F3284 /* miniModeOffTemplate.pdf */; };
|
83E5E54C18087CA5001F3284 /* miniModeOffTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 83E5E54A18087CA5001F3284 /* miniModeOffTemplate.pdf */; };
|
||||||
83E5E54D18087CA5001F3284 /* miniModeOnTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 83E5E54B18087CA5001F3284 /* miniModeOnTemplate.pdf */; };
|
83E5E54D18087CA5001F3284 /* miniModeOnTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 83E5E54B18087CA5001F3284 /* miniModeOnTemplate.pdf */; };
|
||||||
|
@ -464,6 +465,20 @@
|
||||||
remoteGlobalIDString = 32F1615514E6BB3B00D6AB2F;
|
remoteGlobalIDString = 32F1615514E6BB3B00D6AB2F;
|
||||||
remoteInfo = NDHotKey;
|
remoteInfo = NDHotKey;
|
||||||
};
|
};
|
||||||
|
83B066A0180D5669008E3612 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 83B0669C180D5668008E3612 /* MIDI.xcodeproj */;
|
||||||
|
proxyType = 2;
|
||||||
|
remoteGlobalIDString = 83B06687180D5668008E3612;
|
||||||
|
remoteInfo = MIDI;
|
||||||
|
};
|
||||||
|
83B06702180D5776008E3612 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 83B0669C180D5668008E3612 /* MIDI.xcodeproj */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 83B06686180D5668008E3612;
|
||||||
|
remoteInfo = MIDI;
|
||||||
|
};
|
||||||
83BCB8D817FC96F800760340 /* PBXContainerItemProxy */ = {
|
83BCB8D817FC96F800760340 /* PBXContainerItemProxy */ = {
|
||||||
isa = PBXContainerItemProxy;
|
isa = PBXContainerItemProxy;
|
||||||
containerPortal = 8360EF0017F92B23005208A4 /* HighlyComplete.xcodeproj */;
|
containerPortal = 8360EF0017F92B23005208A4 /* HighlyComplete.xcodeproj */;
|
||||||
|
@ -531,6 +546,7 @@
|
||||||
dstPath = "";
|
dstPath = "";
|
||||||
dstSubfolderSpec = 13;
|
dstSubfolderSpec = 13;
|
||||||
files = (
|
files = (
|
||||||
|
83B06704180D579E008E3612 /* MIDI.bundle in CopyFiles */,
|
||||||
8375B36517FFEF130092A79F /* Opus.bundle in CopyFiles */,
|
8375B36517FFEF130092A79F /* Opus.bundle in CopyFiles */,
|
||||||
8359009D17FF06570060F3ED /* ArchiveSource.bundle in CopyFiles */,
|
8359009D17FF06570060F3ED /* ArchiveSource.bundle in CopyFiles */,
|
||||||
83BCB8DE17FC971300760340 /* FFMPEG.bundle in CopyFiles */,
|
83BCB8DE17FC971300760340 /* FFMPEG.bundle in CopyFiles */,
|
||||||
|
@ -816,6 +832,7 @@
|
||||||
838491791808585C00E7332D /* NDHotKey.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = NDHotKey.xcodeproj; path = Frameworks/NDHotKey/NDHotKey.xcodeproj; sourceTree = "<group>"; };
|
838491791808585C00E7332D /* NDHotKey.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = NDHotKey.xcodeproj; path = Frameworks/NDHotKey/NDHotKey.xcodeproj; sourceTree = "<group>"; };
|
||||||
8399D4E01805A55000B503B1 /* XmlContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XmlContainer.m; sourceTree = "<group>"; };
|
8399D4E01805A55000B503B1 /* XmlContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XmlContainer.m; sourceTree = "<group>"; };
|
||||||
8399D4E11805A55000B503B1 /* XmlContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XmlContainer.h; sourceTree = "<group>"; };
|
8399D4E11805A55000B503B1 /* XmlContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XmlContainer.h; sourceTree = "<group>"; };
|
||||||
|
83B0669C180D5668008E3612 /* MIDI.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MIDI.xcodeproj; path = Plugins/MIDI/MIDI.xcodeproj; sourceTree = "<group>"; };
|
||||||
83E5E54A18087CA5001F3284 /* miniModeOffTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = miniModeOffTemplate.pdf; path = Images/miniModeOffTemplate.pdf; sourceTree = "<group>"; };
|
83E5E54A18087CA5001F3284 /* miniModeOffTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = miniModeOffTemplate.pdf; path = Images/miniModeOffTemplate.pdf; sourceTree = "<group>"; };
|
||||||
83E5E54B18087CA5001F3284 /* miniModeOnTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = miniModeOnTemplate.pdf; path = Images/miniModeOnTemplate.pdf; sourceTree = "<group>"; };
|
83E5E54B18087CA5001F3284 /* miniModeOnTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = miniModeOnTemplate.pdf; path = Images/miniModeOnTemplate.pdf; sourceTree = "<group>"; };
|
||||||
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
@ -1119,6 +1136,7 @@
|
||||||
17C808660C3BD0F8005707C4 /* CoreAudio.xcodeproj */,
|
17C808660C3BD0F8005707C4 /* CoreAudio.xcodeproj */,
|
||||||
8359FF2C17FEF35C0060F3ED /* ArchiveSource.xcodeproj */,
|
8359FF2C17FEF35C0060F3ED /* ArchiveSource.xcodeproj */,
|
||||||
8375B05117FFEA400092A79F /* Opus.xcodeproj */,
|
8375B05117FFEA400092A79F /* Opus.xcodeproj */,
|
||||||
|
83B0669C180D5668008E3612 /* MIDI.xcodeproj */,
|
||||||
);
|
);
|
||||||
name = PlugIns;
|
name = PlugIns;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1484,6 +1502,14 @@
|
||||||
name = Products;
|
name = Products;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
83B0669D180D5668008E3612 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B066A1180D5669008E3612 /* MIDI.bundle */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
8E07AAEA0AAC90DC00A4B32F /* Preferences */ = {
|
8E07AAEA0AAC90DC00A4B32F /* Preferences */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
@ -1616,6 +1642,7 @@
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
|
83B06703180D5776008E3612 /* PBXTargetDependency */,
|
||||||
838491861808591400E7332D /* PBXTargetDependency */,
|
838491861808591400E7332D /* PBXTargetDependency */,
|
||||||
8375B36217FFEF010092A79F /* PBXTargetDependency */,
|
8375B36217FFEF010092A79F /* PBXTargetDependency */,
|
||||||
8375B36417FFEF010092A79F /* PBXTargetDependency */,
|
8375B36417FFEF010092A79F /* PBXTargetDependency */,
|
||||||
|
@ -1726,6 +1753,10 @@
|
||||||
ProductGroup = 8E8D40830CBB036600135C1B /* Products */;
|
ProductGroup = 8E8D40830CBB036600135C1B /* Products */;
|
||||||
ProjectRef = 8E8D40820CBB036600135C1B /* M3u.xcodeproj */;
|
ProjectRef = 8E8D40820CBB036600135C1B /* M3u.xcodeproj */;
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ProductGroup = 83B0669D180D5668008E3612 /* Products */;
|
||||||
|
ProjectRef = 83B0669C180D5668008E3612 /* MIDI.xcodeproj */;
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ProductGroup = 17C8089F0C3BD1AB005707C4 /* Products */;
|
ProductGroup = 17C8089F0C3BD1AB005707C4 /* Products */;
|
||||||
ProjectRef = 17C8089E0C3BD1AB005707C4 /* Musepack.xcodeproj */;
|
ProjectRef = 17C8089E0C3BD1AB005707C4 /* Musepack.xcodeproj */;
|
||||||
|
@ -1900,6 +1931,13 @@
|
||||||
remoteRef = 8384917D1808585D00E7332D /* PBXContainerItemProxy */;
|
remoteRef = 8384917D1808585D00E7332D /* PBXContainerItemProxy */;
|
||||||
sourceTree = BUILT_PRODUCTS_DIR;
|
sourceTree = BUILT_PRODUCTS_DIR;
|
||||||
};
|
};
|
||||||
|
83B066A1180D5669008E3612 /* MIDI.bundle */ = {
|
||||||
|
isa = PBXReferenceProxy;
|
||||||
|
fileType = wrapper.cfbundle;
|
||||||
|
path = MIDI.bundle;
|
||||||
|
remoteRef = 83B066A0180D5669008E3612 /* PBXContainerItemProxy */;
|
||||||
|
sourceTree = BUILT_PRODUCTS_DIR;
|
||||||
|
};
|
||||||
8E8D40870CBB036600135C1B /* M3u.bundle */ = {
|
8E8D40870CBB036600135C1B /* M3u.bundle */ = {
|
||||||
isa = PBXReferenceProxy;
|
isa = PBXReferenceProxy;
|
||||||
fileType = wrapper.cfbundle;
|
fileType = wrapper.cfbundle;
|
||||||
|
@ -2213,6 +2251,11 @@
|
||||||
name = NDHotKey;
|
name = NDHotKey;
|
||||||
targetProxy = 838491851808591400E7332D /* PBXContainerItemProxy */;
|
targetProxy = 838491851808591400E7332D /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
|
83B06703180D5776008E3612 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
name = MIDI;
|
||||||
|
targetProxy = 83B06702180D5776008E3612 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
83BCB8D917FC96F800760340 /* PBXTargetDependency */ = {
|
83BCB8D917FC96F800760340 /* PBXTargetDependency */ = {
|
||||||
isa = PBXTargetDependency;
|
isa = PBXTargetDependency;
|
||||||
name = HighlyComplete;
|
name = HighlyComplete;
|
||||||
|
|
|
@ -0,0 +1,342 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 46;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
83B066BA180D56B9008E3612 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 83B066B8180D56B9008E3612 /* InfoPlist.strings */; };
|
||||||
|
83B066F1180D5724008E3612 /* midi_container.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066E3180D5724008E3612 /* midi_container.cpp */; };
|
||||||
|
83B066F2180D5724008E3612 /* midi_container.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B066E4180D5724008E3612 /* midi_container.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
83B066F3180D5724008E3612 /* midi_processor_gmf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066E5180D5724008E3612 /* midi_processor_gmf.cpp */; };
|
||||||
|
83B066F4180D5724008E3612 /* midi_processor_helpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066E6180D5724008E3612 /* midi_processor_helpers.cpp */; };
|
||||||
|
83B066F5180D5724008E3612 /* midi_processor_hmi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066E7180D5724008E3612 /* midi_processor_hmi.cpp */; };
|
||||||
|
83B066F6180D5724008E3612 /* midi_processor_hmp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066E8180D5724008E3612 /* midi_processor_hmp.cpp */; };
|
||||||
|
83B066F7180D5724008E3612 /* midi_processor_lds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066E9180D5724008E3612 /* midi_processor_lds.cpp */; };
|
||||||
|
83B066F8180D5724008E3612 /* midi_processor_mids.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066EA180D5724008E3612 /* midi_processor_mids.cpp */; };
|
||||||
|
83B066F9180D5724008E3612 /* midi_processor_mus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066EB180D5724008E3612 /* midi_processor_mus.cpp */; };
|
||||||
|
83B066FA180D5724008E3612 /* midi_processor_riff_midi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066EC180D5724008E3612 /* midi_processor_riff_midi.cpp */; };
|
||||||
|
83B066FB180D5724008E3612 /* midi_processor_standard_midi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066ED180D5724008E3612 /* midi_processor_standard_midi.cpp */; };
|
||||||
|
83B066FC180D5724008E3612 /* midi_processor_syx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066EE180D5724008E3612 /* midi_processor_syx.cpp */; };
|
||||||
|
83B066FD180D5724008E3612 /* midi_processor_xmi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B066EF180D5724008E3612 /* midi_processor_xmi.cpp */; };
|
||||||
|
83B066FE180D5724008E3612 /* midi_processor.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B066F0180D5724008E3612 /* midi_processor.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
83B066AC180D56B9008E3612 /* midi_processing.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = midi_processing.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
83B066B7180D56B9008E3612 /* midi_processing-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "midi_processing-Info.plist"; sourceTree = "<group>"; };
|
||||||
|
83B066B9180D56B9008E3612 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
|
83B066E3180D5724008E3612 /* midi_container.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_container.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066E4180D5724008E3612 /* midi_container.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = midi_container.h; sourceTree = "<group>"; };
|
||||||
|
83B066E5180D5724008E3612 /* midi_processor_gmf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_gmf.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066E6180D5724008E3612 /* midi_processor_helpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_helpers.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066E7180D5724008E3612 /* midi_processor_hmi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_hmi.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066E8180D5724008E3612 /* midi_processor_hmp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_hmp.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066E9180D5724008E3612 /* midi_processor_lds.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_lds.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066EA180D5724008E3612 /* midi_processor_mids.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_mids.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066EB180D5724008E3612 /* midi_processor_mus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_mus.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066EC180D5724008E3612 /* midi_processor_riff_midi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_riff_midi.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066ED180D5724008E3612 /* midi_processor_standard_midi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_standard_midi.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066EE180D5724008E3612 /* midi_processor_syx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_syx.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066EF180D5724008E3612 /* midi_processor_xmi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = midi_processor_xmi.cpp; sourceTree = "<group>"; };
|
||||||
|
83B066F0180D5724008E3612 /* midi_processor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = midi_processor.h; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
83B066A8180D56B9008E3612 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
83B066A2180D56B9008E3612 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B066B5180D56B9008E3612 /* midi_processing */,
|
||||||
|
83B066AE180D56B9008E3612 /* Frameworks */,
|
||||||
|
83B066AD180D56B9008E3612 /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B066AD180D56B9008E3612 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B066AC180D56B9008E3612 /* midi_processing.framework */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B066AE180D56B9008E3612 /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B066B1180D56B9008E3612 /* Other Frameworks */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B066B1180D56B9008E3612 /* Other Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
);
|
||||||
|
name = "Other Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B066B5180D56B9008E3612 /* midi_processing */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B066E3180D5724008E3612 /* midi_container.cpp */,
|
||||||
|
83B066E4180D5724008E3612 /* midi_container.h */,
|
||||||
|
83B066E5180D5724008E3612 /* midi_processor_gmf.cpp */,
|
||||||
|
83B066E6180D5724008E3612 /* midi_processor_helpers.cpp */,
|
||||||
|
83B066E7180D5724008E3612 /* midi_processor_hmi.cpp */,
|
||||||
|
83B066E8180D5724008E3612 /* midi_processor_hmp.cpp */,
|
||||||
|
83B066E9180D5724008E3612 /* midi_processor_lds.cpp */,
|
||||||
|
83B066EA180D5724008E3612 /* midi_processor_mids.cpp */,
|
||||||
|
83B066EB180D5724008E3612 /* midi_processor_mus.cpp */,
|
||||||
|
83B066EC180D5724008E3612 /* midi_processor_riff_midi.cpp */,
|
||||||
|
83B066ED180D5724008E3612 /* midi_processor_standard_midi.cpp */,
|
||||||
|
83B066EE180D5724008E3612 /* midi_processor_syx.cpp */,
|
||||||
|
83B066EF180D5724008E3612 /* midi_processor_xmi.cpp */,
|
||||||
|
83B066F0180D5724008E3612 /* midi_processor.h */,
|
||||||
|
83B066B6180D56B9008E3612 /* Supporting Files */,
|
||||||
|
);
|
||||||
|
path = midi_processing;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B066B6180D56B9008E3612 /* Supporting Files */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B066B7180D56B9008E3612 /* midi_processing-Info.plist */,
|
||||||
|
83B066B8180D56B9008E3612 /* InfoPlist.strings */,
|
||||||
|
);
|
||||||
|
name = "Supporting Files";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXHeadersBuildPhase section */
|
||||||
|
83B066A9180D56B9008E3612 /* Headers */ = {
|
||||||
|
isa = PBXHeadersBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
83B066FE180D5724008E3612 /* midi_processor.h in Headers */,
|
||||||
|
83B066F2180D5724008E3612 /* midi_container.h in Headers */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXHeadersBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
83B066AB180D56B9008E3612 /* midi_processing */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 83B066D4180D56B9008E3612 /* Build configuration list for PBXNativeTarget "midi_processing" */;
|
||||||
|
buildPhases = (
|
||||||
|
83B066A7180D56B9008E3612 /* Sources */,
|
||||||
|
83B066A8180D56B9008E3612 /* Frameworks */,
|
||||||
|
83B066A9180D56B9008E3612 /* Headers */,
|
||||||
|
83B066AA180D56B9008E3612 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = midi_processing;
|
||||||
|
productName = midi_processing;
|
||||||
|
productReference = 83B066AC180D56B9008E3612 /* midi_processing.framework */;
|
||||||
|
productType = "com.apple.product-type.framework";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
83B066A3180D56B9008E3612 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0500;
|
||||||
|
ORGANIZATIONNAME = "Christopher Snowhill";
|
||||||
|
};
|
||||||
|
buildConfigurationList = 83B066A6180D56B9008E3612 /* Build configuration list for PBXProject "midi_processing" */;
|
||||||
|
compatibilityVersion = "Xcode 3.2";
|
||||||
|
developmentRegion = English;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
);
|
||||||
|
mainGroup = 83B066A2180D56B9008E3612;
|
||||||
|
productRefGroup = 83B066AD180D56B9008E3612 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
83B066AB180D56B9008E3612 /* midi_processing */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
83B066AA180D56B9008E3612 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
83B066BA180D56B9008E3612 /* InfoPlist.strings in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
83B066A7180D56B9008E3612 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
83B066F4180D5724008E3612 /* midi_processor_helpers.cpp in Sources */,
|
||||||
|
83B066F3180D5724008E3612 /* midi_processor_gmf.cpp in Sources */,
|
||||||
|
83B066FB180D5724008E3612 /* midi_processor_standard_midi.cpp in Sources */,
|
||||||
|
83B066FC180D5724008E3612 /* midi_processor_syx.cpp in Sources */,
|
||||||
|
83B066F5180D5724008E3612 /* midi_processor_hmi.cpp in Sources */,
|
||||||
|
83B066F8180D5724008E3612 /* midi_processor_mids.cpp in Sources */,
|
||||||
|
83B066F6180D5724008E3612 /* midi_processor_hmp.cpp in Sources */,
|
||||||
|
83B066F9180D5724008E3612 /* midi_processor_mus.cpp in Sources */,
|
||||||
|
83B066FA180D5724008E3612 /* midi_processor_riff_midi.cpp in Sources */,
|
||||||
|
83B066F1180D5724008E3612 /* midi_container.cpp in Sources */,
|
||||||
|
83B066FD180D5724008E3612 /* midi_processor_xmi.cpp in Sources */,
|
||||||
|
83B066F7180D5724008E3612 /* midi_processor_lds.cpp in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
83B066B8180D56B9008E3612 /* InfoPlist.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
83B066B9180D56B9008E3612 /* en */,
|
||||||
|
);
|
||||||
|
name = InfoPlist.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
83B066D2180D56B9008E3612 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
83B066D3180D56B9008E3612 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = YES;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
83B066D5180D56B9008E3612 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
|
FRAMEWORK_VERSION = A;
|
||||||
|
INFOPLIST_FILE = "midi_processing/midi_processing-Info.plist";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
WRAPPER_EXTENSION = framework;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
83B066D6180D56B9008E3612 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
|
FRAMEWORK_VERSION = A;
|
||||||
|
INFOPLIST_FILE = "midi_processing/midi_processing-Info.plist";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
WRAPPER_EXTENSION = framework;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
83B066A6180D56B9008E3612 /* Build configuration list for PBXProject "midi_processing" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
83B066D2180D56B9008E3612 /* Debug */,
|
||||||
|
83B066D3180D56B9008E3612 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
83B066D4180D56B9008E3612 /* Build configuration list for PBXNativeTarget "midi_processing" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
83B066D5180D56B9008E3612 /* Debug */,
|
||||||
|
83B066D6180D56B9008E3612 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 83B066A3180D56B9008E3612 /* Project object */;
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
/* Localized versions of Info.plist keys */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,244 @@
|
||||||
|
#ifndef _MIDI_CONTAINER_H_
|
||||||
|
#define _MIDI_CONTAINER_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct midi_event
|
||||||
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
max_static_data_count = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
enum event_type
|
||||||
|
{
|
||||||
|
note_off = 0,
|
||||||
|
note_on,
|
||||||
|
polyphonic_aftertouch,
|
||||||
|
control_change,
|
||||||
|
program_change,
|
||||||
|
channel_aftertouch,
|
||||||
|
pitch_wheel,
|
||||||
|
extended
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned long m_timestamp;
|
||||||
|
|
||||||
|
event_type m_type;
|
||||||
|
unsigned m_channel;
|
||||||
|
unsigned long m_data_count;
|
||||||
|
uint8_t m_data[max_static_data_count];
|
||||||
|
std::vector<uint8_t> m_ext_data;
|
||||||
|
|
||||||
|
midi_event() : m_timestamp(0), m_type(note_off), m_channel(0), m_data_count(0) { }
|
||||||
|
midi_event( const midi_event & p_in );
|
||||||
|
midi_event( unsigned long p_timestamp, event_type p_type, unsigned p_channel, const uint8_t * p_data, std::size_t p_data_count );
|
||||||
|
|
||||||
|
unsigned long get_data_count() const;
|
||||||
|
void copy_data( uint8_t * p_out, unsigned long p_offset, unsigned long p_count ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class midi_track
|
||||||
|
{
|
||||||
|
std::vector<midi_event> m_events;
|
||||||
|
|
||||||
|
public:
|
||||||
|
midi_track() { }
|
||||||
|
midi_track(const midi_track & p_in);
|
||||||
|
|
||||||
|
void add_event( const midi_event & p_event );
|
||||||
|
std::size_t get_count() const;
|
||||||
|
const midi_event & operator [] ( std::size_t p_index ) const;
|
||||||
|
|
||||||
|
void remove_event( unsigned long index );
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tempo_entry
|
||||||
|
{
|
||||||
|
unsigned long m_timestamp;
|
||||||
|
unsigned m_tempo;
|
||||||
|
|
||||||
|
tempo_entry() : m_timestamp(0), m_tempo(0) { }
|
||||||
|
tempo_entry(unsigned long p_timestamp, unsigned p_tempo);
|
||||||
|
};
|
||||||
|
|
||||||
|
class tempo_map
|
||||||
|
{
|
||||||
|
std::vector<tempo_entry> m_entries;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void add_tempo( unsigned p_tempo, unsigned long p_timestamp );
|
||||||
|
unsigned long timestamp_to_ms( unsigned long p_timestamp, unsigned p_dtx ) const;
|
||||||
|
|
||||||
|
std::size_t get_count() const;
|
||||||
|
const tempo_entry & operator [] ( std::size_t p_index ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct system_exclusive_entry
|
||||||
|
{
|
||||||
|
std::size_t m_port;
|
||||||
|
std::size_t m_offset;
|
||||||
|
std::size_t m_length;
|
||||||
|
system_exclusive_entry() : m_port(0), m_offset(0), m_length(0) { }
|
||||||
|
system_exclusive_entry(const system_exclusive_entry & p_in);
|
||||||
|
system_exclusive_entry(std::size_t p_port, std::size_t p_offset, std::size_t p_length);
|
||||||
|
};
|
||||||
|
|
||||||
|
class system_exclusive_table
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> m_data;
|
||||||
|
std::vector<system_exclusive_entry> m_entries;
|
||||||
|
|
||||||
|
public:
|
||||||
|
unsigned add_entry( const uint8_t * p_data, std::size_t p_size, std::size_t p_port );
|
||||||
|
void get_entry( unsigned p_index, const uint8_t * & p_data, std::size_t & p_size, std::size_t & p_port );
|
||||||
|
};
|
||||||
|
|
||||||
|
struct midi_stream_event
|
||||||
|
{
|
||||||
|
unsigned long m_timestamp;
|
||||||
|
uint32_t m_event;
|
||||||
|
|
||||||
|
midi_stream_event() : m_timestamp(0), m_event(0) { }
|
||||||
|
midi_stream_event(unsigned long p_timestamp, uint32_t p_event);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct midi_meta_data_item
|
||||||
|
{
|
||||||
|
unsigned long m_timestamp;
|
||||||
|
std::string m_name;
|
||||||
|
std::string m_value;
|
||||||
|
|
||||||
|
midi_meta_data_item() : m_timestamp(0) { }
|
||||||
|
midi_meta_data_item(const midi_meta_data_item & p_in);
|
||||||
|
midi_meta_data_item(unsigned long p_timestamp, const char * p_name, const char * p_value);
|
||||||
|
};
|
||||||
|
|
||||||
|
class midi_meta_data
|
||||||
|
{
|
||||||
|
std::vector<midi_meta_data_item> m_data;
|
||||||
|
|
||||||
|
public:
|
||||||
|
midi_meta_data() { }
|
||||||
|
|
||||||
|
void add_item( const midi_meta_data_item & p_item );
|
||||||
|
|
||||||
|
void append( const midi_meta_data & p_data );
|
||||||
|
|
||||||
|
bool get_item( const char * p_name, midi_meta_data_item & p_out ) const;
|
||||||
|
|
||||||
|
std::size_t get_count() const;
|
||||||
|
|
||||||
|
const midi_meta_data_item & operator [] ( std::size_t p_index ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class midi_container
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
clean_flag_emidi = 1 << 0,
|
||||||
|
clean_flag_instruments = 1 << 1,
|
||||||
|
clean_flag_banks = 1 << 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned m_form;
|
||||||
|
unsigned m_dtx;
|
||||||
|
std::vector<uint64_t> m_channel_mask;
|
||||||
|
std::vector<tempo_map> m_tempo_map;
|
||||||
|
std::vector<midi_track> m_tracks;
|
||||||
|
|
||||||
|
std::vector<uint8_t> m_port_numbers;
|
||||||
|
|
||||||
|
std::vector< std::vector< std::string > > m_device_names;
|
||||||
|
|
||||||
|
midi_meta_data m_extra_meta_data;
|
||||||
|
|
||||||
|
std::vector<unsigned long> m_timestamp_end;
|
||||||
|
|
||||||
|
std::vector<unsigned long> m_timestamp_loop_start;
|
||||||
|
std::vector<unsigned long> m_timestamp_loop_end;
|
||||||
|
|
||||||
|
unsigned long timestamp_to_ms( unsigned long p_timestamp, unsigned long p_subsong ) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Normalize port numbers properly
|
||||||
|
*/
|
||||||
|
template <typename T> void limit_port_number(T & number)
|
||||||
|
{
|
||||||
|
for ( unsigned i = 0; i < m_port_numbers.size(); i++ )
|
||||||
|
{
|
||||||
|
if ( m_port_numbers[ i ] == number )
|
||||||
|
{
|
||||||
|
number = i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_port_numbers.push_back( number );
|
||||||
|
number = m_port_numbers.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> void limit_port_number(T & number) const
|
||||||
|
{
|
||||||
|
for ( unsigned i = 0; i < m_port_numbers.size(); i++ )
|
||||||
|
{
|
||||||
|
if ( m_port_numbers[ i ] == number )
|
||||||
|
{
|
||||||
|
number = i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
midi_container() { m_device_names.resize( 16 ); }
|
||||||
|
|
||||||
|
void initialize( unsigned p_form, unsigned p_dtx );
|
||||||
|
|
||||||
|
void add_track( const midi_track & p_track );
|
||||||
|
|
||||||
|
void add_track_event( std::size_t p_track_index, const midi_event & p_event );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions are really only designed to merge and later remove System Exclusive message dumps
|
||||||
|
*/
|
||||||
|
void merge_tracks( const midi_container & p_source );
|
||||||
|
void set_track_count( unsigned count );
|
||||||
|
void set_extra_meta_data( const midi_meta_data & p_data );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Blah.
|
||||||
|
* Hack 0: Remove channel 16
|
||||||
|
* Hack 1: Remove channels 11-16
|
||||||
|
*/
|
||||||
|
void apply_hackfix( unsigned hack );
|
||||||
|
|
||||||
|
void serialize_as_stream( unsigned long subsong, std::vector<midi_stream_event> & p_stream, system_exclusive_table & p_system_exclusive, unsigned clean_flags ) const;
|
||||||
|
|
||||||
|
void serialize_as_standard_midi_file( std::vector<uint8_t> & p_midi_file ) const;
|
||||||
|
|
||||||
|
void promote_to_type1();
|
||||||
|
|
||||||
|
unsigned long get_subsong_count() const;
|
||||||
|
unsigned long get_subsong( unsigned long p_index ) const;
|
||||||
|
|
||||||
|
unsigned long get_timestamp_end(unsigned long subsong, bool ms = false) const;
|
||||||
|
|
||||||
|
unsigned get_format() const;
|
||||||
|
unsigned get_track_count() const;
|
||||||
|
unsigned get_channel_count(unsigned long subsong) const;
|
||||||
|
|
||||||
|
unsigned long get_timestamp_loop_start(unsigned long subsong, bool ms = false) const;
|
||||||
|
unsigned long get_timestamp_loop_end(unsigned long subsong, bool ms = false) const;
|
||||||
|
|
||||||
|
void get_meta_data( unsigned long subsong, midi_meta_data & p_out );
|
||||||
|
|
||||||
|
void scan_for_loops( bool p_xmi_loops, bool p_marker_loops );
|
||||||
|
|
||||||
|
static void encode_delta( std::vector<uint8_t> & p_out, unsigned long delta );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>NoWork-Inc.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright © 2013 Christopher Snowhill. All rights reserved.</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string></string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,61 @@
|
||||||
|
#ifndef _MIDI_PROCESSORS_H_
|
||||||
|
#define _MIDI_PROCESSORS_H_
|
||||||
|
|
||||||
|
#include "midi_container.h"
|
||||||
|
|
||||||
|
#ifndef _countof
|
||||||
|
template <typename T, size_t N>
|
||||||
|
char ( &_ArraySizeHelper( T (&array)[N] ))[N];
|
||||||
|
#define _countof( array ) (sizeof( _ArraySizeHelper( array ) ))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class midi_processor
|
||||||
|
{
|
||||||
|
static const uint8_t end_of_track[2];
|
||||||
|
static const uint8_t loop_start[11];
|
||||||
|
static const uint8_t loop_end[9];
|
||||||
|
|
||||||
|
static const uint8_t hmp_default_tempo[5];
|
||||||
|
|
||||||
|
static const uint8_t xmi_default_tempo[5];
|
||||||
|
|
||||||
|
static const uint8_t mus_default_tempo[5];
|
||||||
|
static const uint8_t mus_controllers[15];
|
||||||
|
|
||||||
|
static const uint8_t lds_default_tempo[5];
|
||||||
|
|
||||||
|
static int decode_delta( std::vector<uint8_t>::const_iterator & it );
|
||||||
|
static unsigned decode_hmp_delta( std::vector<uint8_t>::const_iterator & it );
|
||||||
|
static unsigned decode_xmi_delta( std::vector<uint8_t>::const_iterator & it, std::vector<uint8_t>::const_iterator end );
|
||||||
|
|
||||||
|
static bool is_standard_midi( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_riff_midi( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_hmp( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_hmi( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_xmi( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_mus( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_mids( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_lds( std::vector<uint8_t> const& p_file, const char * p_extension );
|
||||||
|
static bool is_gmf( std::vector<uint8_t> const& p_file );
|
||||||
|
static bool is_syx( std::vector<uint8_t> const& p_file );
|
||||||
|
|
||||||
|
static bool process_standard_midi_track( std::vector<uint8_t>::const_iterator & it, std::vector<uint8_t>::const_iterator end, midi_container & p_out, bool needs_end_marker );
|
||||||
|
|
||||||
|
static bool process_standard_midi( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_riff_midi( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_hmp( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_hmi( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_xmi( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_mus( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_mids( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_lds( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_gmf( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
static bool process_syx( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
|
||||||
|
public:
|
||||||
|
static bool process_file( std::vector<uint8_t> const& p_file, const char * p_extension, midi_container & p_out );
|
||||||
|
|
||||||
|
static bool process_syx_file( std::vector<uint8_t> const& p_file, midi_container & p_out );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,52 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
bool midi_processor::is_gmf( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 32 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'G' || p_file[ 1 ] != 'M' || p_file[ 2 ] != 'F' || p_file[ 3 ] != 1 ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_gmf( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
uint8_t buffer[10];
|
||||||
|
|
||||||
|
p_out.initialize( 0, 0xC0 );
|
||||||
|
|
||||||
|
uint16_t tempo = ( p_file[ 4 ] << 8 ) | p_file[ 5 ];
|
||||||
|
uint32_t tempo_scaled = tempo * 100000;
|
||||||
|
|
||||||
|
midi_track track;
|
||||||
|
|
||||||
|
buffer[0] = 0xFF;
|
||||||
|
buffer[1] = 0x51;
|
||||||
|
buffer[2] = tempo_scaled >> 16;
|
||||||
|
buffer[3] = tempo_scaled >> 8;
|
||||||
|
buffer[4] = tempo_scaled;
|
||||||
|
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, buffer, 5 ) );
|
||||||
|
|
||||||
|
buffer[0] = 0xF0;
|
||||||
|
buffer[1] = 0x41;
|
||||||
|
buffer[2] = 0x10;
|
||||||
|
buffer[3] = 0x16;
|
||||||
|
buffer[4] = 0x12;
|
||||||
|
buffer[5] = 0x7F;
|
||||||
|
buffer[6] = 0x00;
|
||||||
|
buffer[7] = 0x00;
|
||||||
|
buffer[8] = 0x01;
|
||||||
|
buffer[9] = 0xF7;
|
||||||
|
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, buffer, 10 ) );
|
||||||
|
|
||||||
|
buffer[0] = 0xFF;
|
||||||
|
buffer[1] = 0x2F;
|
||||||
|
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, buffer, 2 ) );
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin() + 7;
|
||||||
|
|
||||||
|
return process_standard_midi_track( it, p_file.end(), p_out, false );
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
const uint8_t midi_processor::end_of_track[2] = {0xFF, 0x2F};
|
||||||
|
const uint8_t midi_processor::loop_start[11] = {0xFF, 0x06, 'l', 'o', 'o', 'p', 'S', 't', 'a', 'r', 't'};
|
||||||
|
const uint8_t midi_processor::loop_end[9] = {0xFF, 0x06, 'l', 'o', 'o', 'p', 'E', 'n', 'd'};
|
||||||
|
|
||||||
|
int midi_processor::decode_delta( std::vector<uint8_t>::const_iterator & it )
|
||||||
|
{
|
||||||
|
int delta = 0;
|
||||||
|
unsigned char byte;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
byte = *it++;
|
||||||
|
delta = ( delta << 7 ) + ( byte & 0x7F );
|
||||||
|
}
|
||||||
|
while ( byte & 0x80 );
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_file( std::vector<uint8_t> const& p_file, const char * p_extension, midi_container & p_out )
|
||||||
|
{
|
||||||
|
if ( is_standard_midi( p_file ) )
|
||||||
|
{
|
||||||
|
return process_standard_midi( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_riff_midi( p_file ) )
|
||||||
|
{
|
||||||
|
return process_riff_midi( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_hmp( p_file ) )
|
||||||
|
{
|
||||||
|
return process_hmp( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_hmi( p_file ) )
|
||||||
|
{
|
||||||
|
return process_hmi( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_xmi( p_file ) )
|
||||||
|
{
|
||||||
|
return process_xmi( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_mus( p_file ) )
|
||||||
|
{
|
||||||
|
return process_mus( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_mids( p_file ) )
|
||||||
|
{
|
||||||
|
return process_mids( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_lds( p_file, p_extension ) )
|
||||||
|
{
|
||||||
|
return process_lds( p_file, p_out );
|
||||||
|
}
|
||||||
|
else if ( is_gmf( p_file ) )
|
||||||
|
{
|
||||||
|
return process_gmf( p_file, p_out );
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_syx_file( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
if ( is_syx( p_file ) )
|
||||||
|
{
|
||||||
|
return process_syx( p_file, p_out );
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
|
@ -0,0 +1,209 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
bool midi_processor::is_hmi( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 12 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'H' || p_file[ 1 ] != 'M' || p_file[ 2 ] != 'I' || p_file[ 3 ] != '-' ||
|
||||||
|
p_file[ 4 ] != 'M' || p_file[ 5 ] != 'I' || p_file[ 6 ] != 'D' || p_file[ 7 ] != 'I' ||
|
||||||
|
p_file[ 8 ] != 'S' || p_file[ 9 ] != 'O' || p_file[ 10 ] != 'N' || p_file[ 11 ] != 'G' ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_hmi( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> buffer;
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin() + 0xE4;
|
||||||
|
|
||||||
|
uint32_t track_count = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
uint32_t track_table_offset = it[ 4 ] | ( it[ 5 ] << 8 ) | ( it[ 6 ] << 16 ) | ( it[ 7 ] << 24 );
|
||||||
|
|
||||||
|
it = p_file.begin() + track_table_offset;
|
||||||
|
|
||||||
|
std::vector<uint32_t> track_offsets;
|
||||||
|
track_offsets.resize( track_count );
|
||||||
|
|
||||||
|
for ( unsigned i = 0; i < track_count; ++i )
|
||||||
|
{
|
||||||
|
track_offsets[ i ] = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_out.initialize( 1, 0xC0 );
|
||||||
|
|
||||||
|
{
|
||||||
|
midi_track track;
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, hmp_default_tempo, _countof( hmp_default_tempo ) ) );
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, end_of_track, _countof( end_of_track ) ) );
|
||||||
|
p_out.add_track( track );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( unsigned i = 0; i < track_count; ++i )
|
||||||
|
{
|
||||||
|
unsigned track_offset = track_offsets[ i ];
|
||||||
|
unsigned long track_length;
|
||||||
|
if ( i + 1 < track_count )
|
||||||
|
{
|
||||||
|
track_length = track_offsets[ i + 1 ] - track_offset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
track_length = p_file.size() - track_offset;
|
||||||
|
}
|
||||||
|
std::vector<uint8_t>::const_iterator track_body = p_file.begin() + track_offset;
|
||||||
|
std::vector<uint8_t>::const_iterator track_end = track_body + track_length;
|
||||||
|
|
||||||
|
if ( track_length < 13 ) return false;
|
||||||
|
if ( track_body[ 0 ] != 'H' || track_body[ 1 ] != 'M' || track_body[ 2 ] != 'I' || track_body[ 3 ] != '-' ||
|
||||||
|
track_body[ 4 ] != 'M' || track_body[ 5 ] != 'I' || track_body[ 6 ] != 'D' || track_body[ 7 ] != 'I' ||
|
||||||
|
track_body[ 8 ] != 'T' || track_body[ 9 ] != 'R' || track_body[ 10 ] != 'A' || track_body[ 11 ] != 'C' ||
|
||||||
|
track_body[ 12 ] != 'K' ) return false;
|
||||||
|
|
||||||
|
midi_track track;
|
||||||
|
unsigned current_timestamp = 0;
|
||||||
|
unsigned char last_event_code = 0xFF;
|
||||||
|
|
||||||
|
unsigned last_event_timestamp = 0;
|
||||||
|
|
||||||
|
if ( track_length < 0x4B + 4 ) return false;
|
||||||
|
|
||||||
|
uint32_t meta_offset = track_body[ 0x4B ] | ( track_body[ 0x4C ] << 8 ) | ( track_body[ 0x4D ] << 16 ) | ( track_body[ 0x4E ] << 24 );
|
||||||
|
if ( meta_offset && meta_offset + 1 < track_length )
|
||||||
|
{
|
||||||
|
buffer.resize( 2 );
|
||||||
|
std::copy( track_body + meta_offset, track_body + meta_offset + 2, buffer.begin() );
|
||||||
|
unsigned meta_size = buffer[ 1 ];
|
||||||
|
if ( meta_offset + 2 + meta_size > track_length ) return false;
|
||||||
|
buffer.resize( meta_size + 2 );
|
||||||
|
std::copy( track_body + meta_offset + 2, track_body + meta_offset + 2 + meta_size, buffer.begin() + 2 );
|
||||||
|
while ( meta_size > 0 && buffer[ meta_size + 1 ] == ' ' ) --meta_size;
|
||||||
|
if ( meta_size > 0 )
|
||||||
|
{
|
||||||
|
buffer[ 0 ] = 0xFF;
|
||||||
|
buffer[ 1 ] = 0x01;
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, &buffer[0], meta_size + 2 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( track_length < 0x57 + 4 ) return false;
|
||||||
|
|
||||||
|
uint32_t track_data_offset = track_body[ 0x57 ] | ( track_body[ 0x58 ] << 8 ) | ( track_body[ 0x59 ] << 16 ) | ( track_body[ 0x5A ] << 24 );
|
||||||
|
|
||||||
|
it = track_body + track_data_offset;
|
||||||
|
|
||||||
|
buffer.resize( 3 );
|
||||||
|
|
||||||
|
while ( it < track_end )
|
||||||
|
{
|
||||||
|
int delta = decode_delta( it );
|
||||||
|
if ( delta > 0xFFFF || delta < 0 )
|
||||||
|
{
|
||||||
|
current_timestamp = last_event_timestamp;
|
||||||
|
/*console::formatter() << "[foo_midi] Large HMI delta detected, shunting.";*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current_timestamp += delta;
|
||||||
|
if ( current_timestamp > last_event_timestamp )
|
||||||
|
{
|
||||||
|
last_event_timestamp = current_timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[ 0 ] = *it++;
|
||||||
|
if ( buffer[ 0 ] == 0xFF )
|
||||||
|
{
|
||||||
|
last_event_code = 0xFF;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
int meta_count = decode_delta( it );
|
||||||
|
if ( meta_count < 0 ) return false; /*throw exception_io_data( "Invalid HMI meta message" );*/
|
||||||
|
buffer.resize( meta_count + 2 );
|
||||||
|
std::copy( it, it + meta_count, buffer.begin() + 2 );
|
||||||
|
it += meta_count;
|
||||||
|
if ( buffer[ 1 ] == 0x2F && last_event_timestamp > current_timestamp )
|
||||||
|
{
|
||||||
|
current_timestamp = last_event_timestamp;
|
||||||
|
}
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], meta_count + 2 ) );
|
||||||
|
if ( buffer[ 1 ] == 0x2F ) break;
|
||||||
|
}
|
||||||
|
else if ( buffer[ 0 ] == 0xF0 )
|
||||||
|
{
|
||||||
|
last_event_code = 0xFF;
|
||||||
|
int system_exclusive_count = decode_delta( it );
|
||||||
|
if ( system_exclusive_count < 0 ) return false; /*throw exception_io_data( "Invalid HMI System Exclusive message" );*/
|
||||||
|
buffer.resize( system_exclusive_count + 1 );
|
||||||
|
std::copy( it, it + system_exclusive_count, buffer.begin() + 1 );
|
||||||
|
it += system_exclusive_count;
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], system_exclusive_count + 1 ) );
|
||||||
|
}
|
||||||
|
else if ( buffer[ 0 ] == 0xFE )
|
||||||
|
{
|
||||||
|
last_event_code = 0xFF;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
if ( buffer[ 1 ] == 0x10 )
|
||||||
|
{
|
||||||
|
it += 2;
|
||||||
|
buffer[ 2 ] = *it++;
|
||||||
|
it += buffer[ 2 ] + 4;
|
||||||
|
}
|
||||||
|
else if ( buffer[ 1 ] == 0x12 )
|
||||||
|
{
|
||||||
|
it += 2;
|
||||||
|
}
|
||||||
|
else if ( buffer[ 1 ] == 0x13 )
|
||||||
|
{
|
||||||
|
it += 10;
|
||||||
|
}
|
||||||
|
else if ( buffer[ 1 ] == 0x14 )
|
||||||
|
{
|
||||||
|
it += 2;
|
||||||
|
p_out.add_track_event( 0, midi_event( current_timestamp, midi_event::extended, 0, loop_start, _countof( loop_start ) ) );
|
||||||
|
}
|
||||||
|
else if ( buffer[ 1 ] == 0x15 )
|
||||||
|
{
|
||||||
|
it += 6;
|
||||||
|
p_out.add_track_event( 0, midi_event( current_timestamp, midi_event::extended, 0, loop_end, _countof( loop_end ) ) );
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Unexpected HMI meta event" );*/
|
||||||
|
}
|
||||||
|
else if ( buffer[ 0 ] <= 0xEF )
|
||||||
|
{
|
||||||
|
unsigned bytes_read = 1;
|
||||||
|
if ( buffer[ 0 ] >= 0x80 )
|
||||||
|
{
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
last_event_code = buffer[ 0 ];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( last_event_code == 0xFF ) return false; /*throw exception_io_data( "HMI used shortened event after Meta or SysEx message" );*/
|
||||||
|
buffer[ 1 ] = buffer[ 0 ];
|
||||||
|
buffer[ 0 ] = last_event_code;
|
||||||
|
}
|
||||||
|
midi_event::event_type type = (midi_event::event_type)( ( buffer[ 0 ] >> 4 ) - 8 );
|
||||||
|
unsigned channel = buffer[ 0 ] & 0x0F;
|
||||||
|
if ( type != midi_event::program_change && type != midi_event::channel_aftertouch )
|
||||||
|
{
|
||||||
|
buffer[ 2 ] = *it++;
|
||||||
|
bytes_read = 2;
|
||||||
|
}
|
||||||
|
track.add_event( midi_event( current_timestamp, type, channel, &buffer[ 1 ], bytes_read ) );
|
||||||
|
if ( type == midi_event::note_on )
|
||||||
|
{
|
||||||
|
buffer[ 2 ] = 0x00;
|
||||||
|
int note_length = decode_delta( it );
|
||||||
|
if ( note_length < 0 ) return false; /*throw exception_io_data( "Invalid HMI note message" );*/
|
||||||
|
unsigned note_end_timestamp = current_timestamp + note_length;
|
||||||
|
if ( note_end_timestamp > last_event_timestamp ) last_event_timestamp = note_end_timestamp;
|
||||||
|
track.add_event( midi_event( note_end_timestamp, midi_event::note_on, channel, &buffer[1], bytes_read ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Unexpected HMI status code" );*/
|
||||||
|
}
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,147 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
const uint8_t midi_processor::hmp_default_tempo[5] = {0xFF, 0x51, 0x18, 0x80, 0x00};
|
||||||
|
|
||||||
|
bool midi_processor::is_hmp( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 8 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'H' || p_file[ 1 ] != 'M' || p_file[ 2 ] != 'I' || p_file[ 3 ] != 'M' ||
|
||||||
|
p_file[ 4 ] != 'I' || p_file[ 5 ] != 'D' || p_file[ 6 ] != 'I' ||
|
||||||
|
( p_file[ 7 ] != 'P' && p_file[ 7 ] != 'R' ) ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned midi_processor::decode_hmp_delta( std::vector<uint8_t>::const_iterator & it )
|
||||||
|
{
|
||||||
|
unsigned delta = 0;
|
||||||
|
unsigned shift = 0;
|
||||||
|
unsigned char byte;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
byte = *it++;
|
||||||
|
delta = delta + ( ( byte & 0x7F ) << shift );
|
||||||
|
shift += 7;
|
||||||
|
}
|
||||||
|
while ( !( byte & 0x80 ) );
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_hmp( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
bool is_funky = p_file[ 7 ] == 'R';
|
||||||
|
|
||||||
|
uint8_t track_count_8;
|
||||||
|
uint16_t dtx = 0xC0;
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin() + ( is_funky ? 0x1A : 0x30 );
|
||||||
|
|
||||||
|
track_count_8 = *it;
|
||||||
|
|
||||||
|
if ( is_funky )
|
||||||
|
{
|
||||||
|
dtx = ( p_file[ 0x4C ] << 16 ) | p_file[ 0x4D ];
|
||||||
|
}
|
||||||
|
|
||||||
|
p_out.initialize( 1, dtx );
|
||||||
|
|
||||||
|
{
|
||||||
|
midi_track track;
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, hmp_default_tempo, _countof( hmp_default_tempo ) ) );
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, end_of_track, _countof( end_of_track ) ) );
|
||||||
|
p_out.add_track( track );
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t buffer[ 4 ];
|
||||||
|
|
||||||
|
buffer[ 0 ] = *it++;
|
||||||
|
|
||||||
|
while ( it < p_file.end() )
|
||||||
|
{
|
||||||
|
if ( buffer[ 0 ] != 0xFF )
|
||||||
|
{
|
||||||
|
buffer[ 0 ] = *it++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
if ( buffer[ 1 ] != 0x2F )
|
||||||
|
{
|
||||||
|
buffer[ 0 ] = buffer[ 1 ];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
it += ( is_funky ? 3 : 5 );
|
||||||
|
|
||||||
|
unsigned track_count = track_count_8;
|
||||||
|
|
||||||
|
for ( unsigned i = 1; i < track_count; ++i )
|
||||||
|
{
|
||||||
|
uint16_t track_size_16;
|
||||||
|
uint32_t track_size_32;
|
||||||
|
|
||||||
|
if ( is_funky )
|
||||||
|
{
|
||||||
|
track_size_16 = it[ 0 ] | ( it[ 1 ] << 8 );
|
||||||
|
it += 2;
|
||||||
|
track_size_32 = track_size_16 - 4;
|
||||||
|
if ( p_file.end() - it < track_size_32 + 2 ) break;
|
||||||
|
it += 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
track_size_32 = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
track_size_32 -= 12;
|
||||||
|
if ( p_file.end() - it < track_size_32 + 8 ) break;
|
||||||
|
it += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
midi_track track;
|
||||||
|
|
||||||
|
unsigned current_timestamp = 0;
|
||||||
|
|
||||||
|
std::vector<uint8_t> buffer;
|
||||||
|
buffer.resize( 3 );
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator track_end = it + track_size_32;
|
||||||
|
|
||||||
|
while ( it < track_end )
|
||||||
|
{
|
||||||
|
unsigned delta = decode_hmp_delta( it );
|
||||||
|
current_timestamp += delta;
|
||||||
|
buffer[ 0 ] = *it++;
|
||||||
|
if ( buffer[ 0 ] == 0xFF )
|
||||||
|
{
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
int meta_count = decode_delta( it );
|
||||||
|
if ( meta_count < 0 ) return false; /*throw exception_io_data( "Invalid HMP meta message" );*/
|
||||||
|
buffer.resize( meta_count + 2 );
|
||||||
|
std::copy( it, it + meta_count, buffer.begin() + 2 );
|
||||||
|
it += meta_count;
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], meta_count + 2 ) );
|
||||||
|
if ( buffer[ 1 ] == 0x2F ) break;
|
||||||
|
}
|
||||||
|
else if ( buffer[ 0 ] >= 0x80 && buffer[ 0 ] <= 0xEF )
|
||||||
|
{
|
||||||
|
unsigned bytes_read = 2;
|
||||||
|
switch ( buffer[ 0 ] & 0xF0 )
|
||||||
|
{
|
||||||
|
case 0xC0:
|
||||||
|
case 0xD0:
|
||||||
|
bytes_read = 1;
|
||||||
|
}
|
||||||
|
std::copy( it, it + bytes_read, buffer.begin() + 1 );
|
||||||
|
it += bytes_read;
|
||||||
|
track.add_event( midi_event( current_timestamp, (midi_event::event_type)( ( buffer[ 0 ] >> 4 ) - 8 ), buffer[ 0 ] & 0x0F, &buffer[1], bytes_read ) );
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Unexpected status code in HMP track" );*/
|
||||||
|
}
|
||||||
|
|
||||||
|
it = track_end + ( is_funky ? 0 : 4 );
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,120 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
bool midi_processor::is_mids( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 8 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'R' || p_file[ 1 ] != 'I' || p_file[ 2 ] != 'F' || p_file[ 3 ] != 'F' ) return false;
|
||||||
|
uint32_t size = p_file[ 4 ] | ( p_file[ 5 ] << 8 ) | ( p_file[ 6 ] << 16 ) | ( p_file[ 7 ] << 24 );
|
||||||
|
if ( size < 8 || ( p_file.size() < size + 8 ) ) return false;
|
||||||
|
if ( p_file[ 8 ] != 'M' || p_file[ 9 ] != 'I' || p_file[ 10 ] != 'D' || p_file[ 11 ] != 'S' ||
|
||||||
|
p_file[ 12 ] != 'f' || p_file[ 13 ] != 'm' || p_file[ 14 ] != 't' || p_file[ 15 ] != ' ' ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_mids( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin() + 16;
|
||||||
|
|
||||||
|
uint32_t fmt_size = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
|
||||||
|
uint32_t time_format = 1;
|
||||||
|
/*uint32_t max_buffer = 0;*/
|
||||||
|
uint32_t flags = 0;
|
||||||
|
|
||||||
|
if ( fmt_size >= 4 )
|
||||||
|
{
|
||||||
|
time_format = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
fmt_size -= 4;
|
||||||
|
}
|
||||||
|
if ( fmt_size >= 4 )
|
||||||
|
{
|
||||||
|
/*max_buffer = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );*/
|
||||||
|
it += 4;
|
||||||
|
fmt_size -= 4;
|
||||||
|
}
|
||||||
|
if ( fmt_size >= 4 )
|
||||||
|
{
|
||||||
|
flags = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
fmt_size -= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
it += fmt_size;
|
||||||
|
if ( fmt_size & 1 ) ++it;
|
||||||
|
|
||||||
|
p_out.initialize( 0, time_format );
|
||||||
|
|
||||||
|
if ( it[ 0 ] != 'd' || it[ 1 ] != 'a' || it[ 2 ] != 't' || it[ 3 ] != 'a' ) return false; /*throw exception_io_data( "MIDS missing RIFF data chunk" );*/
|
||||||
|
|
||||||
|
it += 4;
|
||||||
|
|
||||||
|
{
|
||||||
|
midi_track track;
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, end_of_track, _countof( end_of_track ) ) );
|
||||||
|
p_out.add_track( track );
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t data_size = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator body_end = it + data_size;
|
||||||
|
|
||||||
|
uint32_t segment_count = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
|
||||||
|
bool is_eight_byte = !!(flags & 1);
|
||||||
|
|
||||||
|
midi_track track;
|
||||||
|
|
||||||
|
unsigned current_timestamp = 0;
|
||||||
|
|
||||||
|
for ( unsigned i = 0; i < segment_count; ++i )
|
||||||
|
{
|
||||||
|
it += 4;
|
||||||
|
uint32_t segment_size = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
std::vector<uint8_t>::const_iterator segment_end = it + segment_size;
|
||||||
|
while ( it < segment_end && it < body_end )
|
||||||
|
{
|
||||||
|
uint32_t delta = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
uint32_t event;
|
||||||
|
current_timestamp += delta;
|
||||||
|
if ( !is_eight_byte ) it += 4;
|
||||||
|
event = it[ 0 ] | ( it[ 1 ] << 8 ) | ( it[ 2 ] << 16 ) | ( it[ 3 ] << 24 );
|
||||||
|
it += 4;
|
||||||
|
if ( event >> 24 == 0x01 )
|
||||||
|
{
|
||||||
|
uint8_t buffer[ 5 ] = { 0xFF, 0x51 };
|
||||||
|
buffer[ 2 ] = (uint8_t)( event >> 16 );
|
||||||
|
buffer[ 3 ] = (uint8_t)( event >> 8 );
|
||||||
|
buffer[ 4 ] = (uint8_t)event;
|
||||||
|
p_out.add_track_event( 0, midi_event( current_timestamp, midi_event::extended, 0, buffer, sizeof( buffer ) ) );
|
||||||
|
}
|
||||||
|
else if ( !( event >> 24 ) )
|
||||||
|
{
|
||||||
|
unsigned event_code = ( event & 0xF0 ) >> 4;
|
||||||
|
if ( event_code >= 0x8 && event_code <= 0xE )
|
||||||
|
{
|
||||||
|
unsigned bytes_to_write = 1;
|
||||||
|
uint8_t buffer[2];
|
||||||
|
buffer[ 0 ] = (uint8_t)( event >> 8 );
|
||||||
|
if ( event_code != 0xC && event_code != 0xD )
|
||||||
|
{
|
||||||
|
buffer[ 1 ] = (uint8_t)( event >> 16 );
|
||||||
|
bytes_to_write = 2;
|
||||||
|
}
|
||||||
|
track.add_event( midi_event( current_timestamp, (midi_event::event_type)( event_code - 8 ), event & 0x0F, buffer, bytes_to_write ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, end_of_track, _countof( end_of_track ) ) );
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
const uint8_t midi_processor::mus_default_tempo[5] = {0xFF, 0x51, 0x09, 0xA3, 0x1A};
|
||||||
|
|
||||||
|
const uint8_t midi_processor::mus_controllers[15] = {0,0,1,7,10,11,91,93,64,67,120,123,126,127,121};
|
||||||
|
|
||||||
|
bool midi_processor::is_mus( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 0x20 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'M' || p_file[ 1 ] != 'U' || p_file[ 2 ] != 'S' || p_file[ 3 ] != 0x1A ) return false;
|
||||||
|
uint16_t length = p_file[ 4 ] | ( p_file[ 5 ] << 8 );
|
||||||
|
uint16_t offset = p_file[ 6 ] | ( p_file[ 7 ] << 8 );
|
||||||
|
uint16_t instrument_count = p_file[ 12 ] | ( p_file[ 13 ] << 8 );
|
||||||
|
if ( offset >= 16 + instrument_count * 2 && offset < 16 + instrument_count * 4 && offset + length <= p_file.size() ) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_mus( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
uint16_t length = p_file[ 4 ] | ( p_file[ 5 ] << 8 );
|
||||||
|
uint16_t offset = p_file[ 6 ] | ( p_file[ 7 ] << 8 );
|
||||||
|
|
||||||
|
p_out.initialize( 0, 0x59 );
|
||||||
|
|
||||||
|
{
|
||||||
|
midi_track track;
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, mus_default_tempo, _countof( mus_default_tempo ) ) );
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, end_of_track, _countof( end_of_track ) ) );
|
||||||
|
p_out.add_track( track );
|
||||||
|
}
|
||||||
|
|
||||||
|
midi_track track;
|
||||||
|
|
||||||
|
unsigned current_timestamp = 0;
|
||||||
|
|
||||||
|
uint8_t velocity_levels[ 16 ] = { 0 };
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin() + offset, end = p_file.begin() + offset + length;
|
||||||
|
|
||||||
|
uint8_t buffer[ 4 ];
|
||||||
|
|
||||||
|
while ( it < end )
|
||||||
|
{
|
||||||
|
buffer[ 0 ] = *it++;
|
||||||
|
if ( buffer[ 0 ] == 0x60 ) break;
|
||||||
|
|
||||||
|
midi_event::event_type type;
|
||||||
|
|
||||||
|
unsigned bytes_to_write;
|
||||||
|
|
||||||
|
unsigned channel = buffer[ 0 ] & 0x0F;
|
||||||
|
if ( channel == 0x0F ) channel = 9;
|
||||||
|
else if ( channel >= 9 ) ++channel;
|
||||||
|
|
||||||
|
switch ( buffer[ 0 ] & 0x70 )
|
||||||
|
{
|
||||||
|
case 0x00:
|
||||||
|
type = midi_event::note_on;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
buffer[ 2 ] = 0;
|
||||||
|
bytes_to_write = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x10:
|
||||||
|
type = midi_event::note_on;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
if ( buffer[ 1 ] & 0x80 )
|
||||||
|
{
|
||||||
|
buffer[ 2 ] = *it++;
|
||||||
|
velocity_levels[ channel ] = buffer[ 2 ];
|
||||||
|
buffer[ 1 ] &= 0x7F;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer[ 2 ] = velocity_levels[ channel ];
|
||||||
|
}
|
||||||
|
bytes_to_write = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x20:
|
||||||
|
type = midi_event::pitch_wheel;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
buffer[ 2 ] = buffer[ 1 ] >> 1;
|
||||||
|
buffer[ 1 ] <<= 7;
|
||||||
|
bytes_to_write = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x30:
|
||||||
|
type = midi_event::control_change;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
if ( buffer[ 1 ] >= 10 && buffer[ 1 ] <= 14 )
|
||||||
|
{
|
||||||
|
buffer[ 1 ] = mus_controllers[ buffer[ 1 ] ];
|
||||||
|
buffer[ 2 ] = 1;
|
||||||
|
bytes_to_write = 2;
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Unhandled MUS system event" );*/
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x40:
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
if ( buffer[ 1 ] )
|
||||||
|
{
|
||||||
|
if ( buffer[ 1 ] < 10 )
|
||||||
|
{
|
||||||
|
type = midi_event::control_change;
|
||||||
|
buffer[ 1 ] = mus_controllers[ buffer[ 1 ] ];
|
||||||
|
buffer[ 2 ] = *it++;
|
||||||
|
bytes_to_write = 2;
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Invalid MUS controller change event" );*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = midi_event::program_change;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
bytes_to_write = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false; /*throw exception_io_data( "Invalid MUS status code" );*/
|
||||||
|
}
|
||||||
|
|
||||||
|
track.add_event( midi_event( current_timestamp, type, channel, buffer + 1, bytes_to_write ) );
|
||||||
|
|
||||||
|
if ( buffer[ 0 ] & 0x80 )
|
||||||
|
{
|
||||||
|
int delta = decode_delta( it );
|
||||||
|
if ( delta < 0 ) return false; /*throw exception_io_data( "Invalid MUS delta" );*/
|
||||||
|
current_timestamp += delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, end_of_track, _countof( end_of_track ) ) );
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
bool midi_processor::is_riff_midi( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 20 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'R' || p_file[ 1 ] != 'I' || p_file[ 2 ] != 'F' || p_file[ 3 ] != 'F' ) return false;
|
||||||
|
uint32_t riff_size = p_file[ 4 ] | ( p_file[ 5 ] << 8 ) | ( p_file[ 6 ] << 16 ) | ( p_file[ 7 ] << 24 );
|
||||||
|
if ( riff_size < 12 || ( p_file.size() < riff_size + 8 ) ) return false;
|
||||||
|
if ( p_file[ 8 ] != 'R' || p_file[ 9 ] != 'M' || p_file[ 10 ] != 'I' || p_file[ 11 ] != 'D' ||
|
||||||
|
p_file[ 12 ] != 'd' || p_file[ 13 ] != 'a' || p_file[ 14 ] != 't' || p_file[ 15 ] != 'a' ) return false;
|
||||||
|
uint32_t data_size = p_file[ 16 ] | ( p_file[ 17 ] << 8 ) | ( p_file[ 18 ] << 16 ) | ( p_file[ 19 ] << 24 );
|
||||||
|
if ( data_size < 18 || p_file.size() < data_size + 20 || riff_size < data_size + 12 ) return false;
|
||||||
|
std::vector<uint8_t> test;
|
||||||
|
test.assign( p_file.begin() + 20, p_file.begin() + 20 + 18 );
|
||||||
|
return is_standard_midi( test );
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char * riff_tag_mappings[][2] =
|
||||||
|
{
|
||||||
|
{ "IALB", "album" },
|
||||||
|
{ "IARL", "archival_location" },
|
||||||
|
{ "IART", "artist" },
|
||||||
|
{ "ITRK", "tracknumber" },
|
||||||
|
{ "ICMS", "commissioned" },
|
||||||
|
{ "ICMP", "composer" },
|
||||||
|
{ "ICMT", "comment" },
|
||||||
|
{ "ICOP", "copyright" },
|
||||||
|
{ "ICRD", "creation_date" },
|
||||||
|
{ "IENG", "engineer" },
|
||||||
|
{ "IGNR", "genre" },
|
||||||
|
{ "IKEY", "keywords" },
|
||||||
|
{ "IMED", "medium" },
|
||||||
|
{ "INAM", "title" },
|
||||||
|
{ "IPRD", "product" },
|
||||||
|
{ "ISBJ", "subject" },
|
||||||
|
{ "ISFT", "software" },
|
||||||
|
{ "ISRC", "source" },
|
||||||
|
{ "ISRF", "source_form" },
|
||||||
|
{ "ITCH", "technician" }
|
||||||
|
};
|
||||||
|
|
||||||
|
bool midi_processor::process_riff_midi( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
uint32_t file_size = p_file[ 4 ] | ( p_file[ 5 ] << 8 ) | ( p_file[ 6 ] << 16 ) | ( p_file[ 7 ] << 24 );
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin() + 12;
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator body_end = p_file.begin() + 8 + file_size;
|
||||||
|
|
||||||
|
bool found_data = false;
|
||||||
|
bool found_info = false;
|
||||||
|
|
||||||
|
midi_meta_data meta_data;
|
||||||
|
|
||||||
|
std::vector<uint8_t> extra_buffer;
|
||||||
|
|
||||||
|
while ( it < body_end )
|
||||||
|
{
|
||||||
|
uint32_t chunk_size = it[ 4 ] | ( it[ 5 ] << 8 ) | ( it[ 6 ] << 16 ) | ( it[ 7 ] << 24 );
|
||||||
|
if ( it[ 0 ] == 'd' && it[ 1 ] == 'a' && it[ 2 ] == 't' && it[ 3 ] == 'a' )
|
||||||
|
{
|
||||||
|
if ( !found_data )
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> midi_file;
|
||||||
|
midi_file.assign( it + 8, it + 8 + chunk_size );
|
||||||
|
if ( !process_standard_midi( midi_file, p_out ) ) return false;
|
||||||
|
found_data = true;
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Multiple RIFF data chunks found" );*/
|
||||||
|
it += 8 + chunk_size;
|
||||||
|
if ( chunk_size & 1 && it < body_end ) ++it;
|
||||||
|
}
|
||||||
|
else if ( it[ 0 ] == 'D' && it[ 1 ] == 'I' && it[ 2 ] == 'S' && it[ 3 ] == 'P' )
|
||||||
|
{
|
||||||
|
uint32_t type = it[ 8 ] | ( it[ 9 ] << 8 ) | ( it[ 10 ] << 16 ) | ( it[ 11 ] << 24 );
|
||||||
|
if ( type == 1 )
|
||||||
|
{
|
||||||
|
extra_buffer.resize( chunk_size - 4 );
|
||||||
|
std::copy( it + 12, it + 8 + chunk_size, extra_buffer.begin() );
|
||||||
|
meta_data.add_item( midi_meta_data_item( 0, "display_name", (const char *) &extra_buffer[0] ) );
|
||||||
|
}
|
||||||
|
it += 8 + chunk_size;
|
||||||
|
if ( chunk_size & 1 && it < body_end ) ++it;
|
||||||
|
}
|
||||||
|
else if ( it[ 0 ] == 'L' && it[ 1 ] == 'I' && it[ 2 ] == 'S' && it[ 3 ] == 'T' )
|
||||||
|
{
|
||||||
|
std::vector<uint8_t>::const_iterator chunk_end = it + 8 + chunk_size;
|
||||||
|
if ( it[ 8 ] == 'I' && it[ 9 ] == 'N' && it[ 10 ] == 'F' && it[ 11 ] == 'O' )
|
||||||
|
{
|
||||||
|
if ( !found_info )
|
||||||
|
{
|
||||||
|
it += 12;
|
||||||
|
while ( it < chunk_end )
|
||||||
|
{
|
||||||
|
uint32_t field_size = it[ 4 ] | ( it[ 5 ] << 8 ) | ( it[ 6 ] << 16 ) | ( it[ 7 ] << 24 );
|
||||||
|
std::string field;
|
||||||
|
field.assign( it, it + 4 );
|
||||||
|
for ( unsigned i = 0; i < _countof(riff_tag_mappings); ++i )
|
||||||
|
{
|
||||||
|
if ( !memcmp( &it[0], riff_tag_mappings[ i ][ 0 ], 4 ) )
|
||||||
|
{
|
||||||
|
field = riff_tag_mappings[ i ][ 1 ];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
extra_buffer.resize( field_size );
|
||||||
|
std::copy( it + 8, it + 8 + field_size, extra_buffer.begin() );
|
||||||
|
it += 8 + field_size;
|
||||||
|
meta_data.add_item( midi_meta_data_item( 0, field.c_str(), ( const char * ) &extra_buffer[0] ) );
|
||||||
|
if ( field_size & 1 && it < chunk_end ) ++it;
|
||||||
|
}
|
||||||
|
found_info = true;
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Multiple RIFF LIST INFO chunks found" );*/
|
||||||
|
}
|
||||||
|
else return false; /* unknown LIST chunk */
|
||||||
|
it = chunk_end;
|
||||||
|
if ( chunk_size & 1 && it < body_end ) ++it;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it += chunk_size;
|
||||||
|
if ( chunk_size & 1 && it < body_end ) ++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( found_data && found_info ) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_out.set_extra_meta_data( meta_data );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
bool midi_processor::is_standard_midi( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 18 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'M' || p_file[ 1 ] != 'T' || p_file[ 2 ] != 'h' || p_file[ 3 ] != 'd') return false;
|
||||||
|
if ( p_file[ 4 ] != 0 || p_file[ 5 ] != 0 || p_file[ 6 ] != 0 || p_file[ 7 ] != 6 ) return false;
|
||||||
|
if ( p_file[ 14 ] != 'M' || p_file[ 15 ] != 'T' || p_file[ 16 ] != 'r' || p_file[ 17 ] != 'k' ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_standard_midi_track( std::vector<uint8_t>::const_iterator & it, std::vector<uint8_t>::const_iterator end, midi_container & p_out, bool needs_end_marker )
|
||||||
|
{
|
||||||
|
midi_track track;
|
||||||
|
unsigned current_timestamp = 0;
|
||||||
|
unsigned char last_event_code = 0xFF;
|
||||||
|
|
||||||
|
std::vector<uint8_t> buffer;
|
||||||
|
buffer.resize( 3 );
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if ( !needs_end_marker && it >= end ) break;
|
||||||
|
int delta = decode_delta( it );
|
||||||
|
if ( !needs_end_marker && it >= end ) break;
|
||||||
|
|
||||||
|
if ( delta < 0 )
|
||||||
|
{
|
||||||
|
/*"MIDI processor encountered negative delta: " << delta << "; flipping sign.";*/
|
||||||
|
delta = -delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_timestamp += delta;
|
||||||
|
unsigned char event_code = *it++;
|
||||||
|
unsigned data_bytes_read = 0;
|
||||||
|
if ( event_code < 0x80 )
|
||||||
|
{
|
||||||
|
if ( last_event_code == 0xFF ) return false; /*throw exception_io_data("First MIDI track event short encoded");*/
|
||||||
|
buffer[ data_bytes_read++ ] = event_code;
|
||||||
|
event_code = last_event_code;
|
||||||
|
}
|
||||||
|
if ( event_code < 0xF0 )
|
||||||
|
{
|
||||||
|
last_event_code = event_code;
|
||||||
|
if ( !needs_end_marker && ( event_code & 0xF0 ) == 0xE0 ) continue;
|
||||||
|
if ( data_bytes_read < 1 )
|
||||||
|
{
|
||||||
|
buffer[ 0 ] = *it++;
|
||||||
|
++data_bytes_read;
|
||||||
|
}
|
||||||
|
switch ( event_code & 0xF0 )
|
||||||
|
{
|
||||||
|
case 0xC0:
|
||||||
|
case 0xD0:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
buffer[ data_bytes_read ] = *it++;
|
||||||
|
++data_bytes_read;
|
||||||
|
}
|
||||||
|
track.add_event( midi_event( current_timestamp, (midi_event::event_type)(( event_code >> 4 ) - 8), event_code & 0x0F, &buffer[0], data_bytes_read ) );
|
||||||
|
}
|
||||||
|
else if ( event_code == 0xF0 )
|
||||||
|
{
|
||||||
|
int data_count = decode_delta( it );
|
||||||
|
if ( data_count < 0 ) return false; /*throw exception_io_data( "Invalid System Exclusive message" );*/
|
||||||
|
buffer.resize( data_count + 1 );
|
||||||
|
buffer[ 0 ] = 0xF0;
|
||||||
|
std::copy( it, it + data_count, buffer.begin() + 1 );
|
||||||
|
it += data_count;
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], data_count + 1 ) );
|
||||||
|
}
|
||||||
|
else if ( event_code == 0xFF )
|
||||||
|
{
|
||||||
|
unsigned char meta_type = *it++;
|
||||||
|
int data_count = decode_delta( it );
|
||||||
|
if ( data_count < 0 ) return false; /*throw exception_io_data( "Invalid meta message" );*/
|
||||||
|
buffer.resize( data_count + 2 );
|
||||||
|
buffer[ 0 ] = 0xFF;
|
||||||
|
buffer[ 1 ] = meta_type;
|
||||||
|
std::copy( it, it + data_count, buffer.begin() + 2 );
|
||||||
|
it += data_count;
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], data_count + 2 ) );
|
||||||
|
|
||||||
|
if ( meta_type == 0x2F )
|
||||||
|
{
|
||||||
|
needs_end_marker = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( event_code == 0xFB || event_code == 0xFC )
|
||||||
|
{
|
||||||
|
/*console::formatter() << "MIDI " << ( ( event_code == 0xFC ) ? "stop" : "start" ) << " status code ignored";*/
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data("Unhandled MIDI status code");*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !needs_end_marker )
|
||||||
|
{
|
||||||
|
buffer[ 0 ] = 0xFF;
|
||||||
|
buffer[ 1 ] = 0x2F;
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], 2 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_standard_midi( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
if ( p_file[ 0 ] != 'M' || p_file[ 1 ] != 'T' || p_file[ 2 ] != 'h' || p_file[ 3 ] != 'd' ) return false;
|
||||||
|
if ( p_file[ 4 ] != 0 || p_file[ 5 ] != 0 || p_file[ 6 ] != 0 || p_file[ 7 ] != 6 ) return false; /*throw exception_io_data("Bad MIDI header size");*/
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin() + 8;
|
||||||
|
|
||||||
|
uint16_t form = ( it[0] << 8 ) | it[1];
|
||||||
|
if ( form > 2 ) return false;
|
||||||
|
|
||||||
|
uint16_t track_count_16 = ( it[2] << 8 ) | it[3];
|
||||||
|
uint16_t dtx = ( it[4] << 8 ) | it[5];
|
||||||
|
|
||||||
|
it += 6;
|
||||||
|
|
||||||
|
std::size_t track_count = track_count_16;
|
||||||
|
|
||||||
|
p_out.initialize( form, dtx );
|
||||||
|
|
||||||
|
for ( std::size_t i = 0; i < track_count; ++i )
|
||||||
|
{
|
||||||
|
if ( it[0] != 'M' || it[1] != 'T' || it[2] != 'r' || it[3] != 'k' ) return false;
|
||||||
|
|
||||||
|
uint32_t track_size = ( it[4] << 24 ) | ( it[5] << 16 ) | ( it[6] << 8 ) | it[7];
|
||||||
|
|
||||||
|
it += 8;
|
||||||
|
|
||||||
|
intptr_t track_data_offset = it - p_file.begin();
|
||||||
|
|
||||||
|
if ( !process_standard_midi_track( it, it + track_size, p_out, true ) ) return false;
|
||||||
|
|
||||||
|
track_data_offset += track_size;
|
||||||
|
if ( it - p_file.begin() != track_data_offset )
|
||||||
|
{
|
||||||
|
it = p_file.begin() + track_data_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
bool midi_processor::is_syx( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 2 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 0xF0 || p_file[ p_file.size() - 1 ] != 0xF7 ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_syx( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
const size_t size = p_file.size();
|
||||||
|
size_t ptr = 0;
|
||||||
|
|
||||||
|
p_out.initialize( 0, 1 );
|
||||||
|
|
||||||
|
midi_track track;
|
||||||
|
|
||||||
|
while ( ptr < size )
|
||||||
|
{
|
||||||
|
size_t msg_length = 1;
|
||||||
|
|
||||||
|
if ( p_file[ptr] != 0xF0 ) return false;
|
||||||
|
|
||||||
|
while ( p_file[ptr + msg_length++] != 0xF7 );
|
||||||
|
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, &p_file[ptr], msg_length ) );
|
||||||
|
|
||||||
|
ptr += msg_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,277 @@
|
||||||
|
#include "midi_processor.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
bool midi_processor::is_xmi( std::vector<uint8_t> const& p_file )
|
||||||
|
{
|
||||||
|
if ( p_file.size() < 0x22 ) return false;
|
||||||
|
if ( p_file[ 0 ] != 'F' || p_file[ 1 ] != 'O' || p_file[ 2 ] != 'R' || p_file[ 3 ] != 'M' ||
|
||||||
|
p_file[ 8 ] != 'X' || p_file[ 9 ] != 'D' || p_file[ 10 ] != 'I' || p_file[ 11 ] != 'R' ||
|
||||||
|
p_file[ 0x1E ] != 'X' || p_file[ 0x1F ] != 'M' || p_file[ 0x20 ] != 'I' || p_file[ 0x21 ] != 'D' ) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t midi_processor::xmi_default_tempo[5] = {0xFF, 0x51, 0x07, 0xA1, 0x20};
|
||||||
|
|
||||||
|
unsigned midi_processor::decode_xmi_delta( std::vector<uint8_t>::const_iterator & it, std::vector<uint8_t>::const_iterator end )
|
||||||
|
{
|
||||||
|
unsigned delta = 0;
|
||||||
|
uint8_t byte = *it++;
|
||||||
|
if ( !( byte & 0x80 ) )
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
delta += byte;
|
||||||
|
byte = *it++;
|
||||||
|
}
|
||||||
|
while ( !( byte & 0x80 ) && it < end );
|
||||||
|
}
|
||||||
|
--it;
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct iff_chunk
|
||||||
|
{
|
||||||
|
uint8_t m_id[4];
|
||||||
|
uint8_t m_type[4];
|
||||||
|
std::vector<uint8_t> m_data;
|
||||||
|
std::vector<iff_chunk> m_sub_chunks;
|
||||||
|
|
||||||
|
iff_chunk()
|
||||||
|
{
|
||||||
|
memset( m_id, 0, sizeof( m_id ) );
|
||||||
|
memset( m_type, 0, sizeof( m_type ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
iff_chunk( const iff_chunk & p_in )
|
||||||
|
{
|
||||||
|
memcpy( m_id, p_in.m_id, sizeof( m_id ) );
|
||||||
|
memcpy( m_type, p_in.m_type, sizeof( m_type ) );
|
||||||
|
m_data = p_in.m_data;
|
||||||
|
m_sub_chunks = p_in.m_sub_chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
const iff_chunk & find_sub_chunk( const char * p_id, unsigned index = 0 ) const
|
||||||
|
{
|
||||||
|
for ( std::size_t i = 0; i < m_sub_chunks.size(); ++i )
|
||||||
|
{
|
||||||
|
if ( !memcmp( p_id, m_sub_chunks[ i ].m_id, 4 ) )
|
||||||
|
{
|
||||||
|
if ( index ) --index;
|
||||||
|
if ( !index ) return m_sub_chunks[ i ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*throw exception_io_data( pfc::string_formatter() << "Missing IFF chunk: " << p_id );*/
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned get_chunk_count( const char * p_id ) const
|
||||||
|
{
|
||||||
|
unsigned chunk_count = 0;
|
||||||
|
for ( std::size_t i = 0; i < m_sub_chunks.size(); ++i )
|
||||||
|
{
|
||||||
|
if ( !memcmp( p_id, m_sub_chunks[ i ].m_id, 4 ) )
|
||||||
|
{
|
||||||
|
++chunk_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chunk_count;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct iff_stream
|
||||||
|
{
|
||||||
|
std::vector<iff_chunk> m_chunks;
|
||||||
|
|
||||||
|
iff_chunk fail;
|
||||||
|
|
||||||
|
const iff_chunk & find_chunk( const char * p_id ) const
|
||||||
|
{
|
||||||
|
for ( std::size_t i = 0; i < m_chunks.size(); ++i )
|
||||||
|
{
|
||||||
|
if ( !memcmp( p_id, m_chunks[ i ].m_id, 4 ) )
|
||||||
|
{
|
||||||
|
return m_chunks[ i ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*throw exception_io_data( pfc::string_formatter() << "Missing IFF chunk: " << p_id );*/
|
||||||
|
return fail;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool read_iff_chunk( std::vector<uint8_t>::const_iterator & it, std::vector<uint8_t>::const_iterator end, iff_chunk & p_out, bool first_chunk )
|
||||||
|
{
|
||||||
|
std::copy( it, it + 4, p_out.m_id );
|
||||||
|
it += 4;
|
||||||
|
uint32_t chunk_size = ( it[ 0 ] << 24 ) | ( it[ 1 ] << 16 ) | ( it[ 2 ] << 8 ) | it[ 3 ];
|
||||||
|
it += 4;
|
||||||
|
bool is_cat_chunk = !memcmp( p_out.m_id, "CAT ", 4 );
|
||||||
|
bool is_form_chunk = !memcmp( p_out.m_id, "FORM", 4 );
|
||||||
|
std::size_t chunk_size_limit = end - it;
|
||||||
|
if ( chunk_size > chunk_size_limit ) chunk_size = (uint32_t) chunk_size_limit;
|
||||||
|
if ( ( first_chunk && is_form_chunk ) || ( !first_chunk && is_cat_chunk ) )
|
||||||
|
{
|
||||||
|
std::vector<uint8_t>::const_iterator chunk_end = it + chunk_size;
|
||||||
|
std::copy( it, it + 4, p_out.m_type );
|
||||||
|
it += 4;
|
||||||
|
while ( it < chunk_end )
|
||||||
|
{
|
||||||
|
iff_chunk chunk;
|
||||||
|
if ( !read_iff_chunk( it, chunk_end, chunk, is_cat_chunk ) ) return false;
|
||||||
|
p_out.m_sub_chunks.push_back( chunk );
|
||||||
|
}
|
||||||
|
it = chunk_end;
|
||||||
|
if ( chunk_size & 1 && it < end ) ++it;
|
||||||
|
}
|
||||||
|
else if ( !is_form_chunk && !is_cat_chunk )
|
||||||
|
{
|
||||||
|
p_out.m_data.assign( it, it + chunk_size );
|
||||||
|
it += chunk_size;
|
||||||
|
if ( chunk_size & 1 && it < end ) ++it;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*if ( first_chunk ) throw exception_io_data( pfc::string_formatter() << "Found " << pfc::string8( (const char *)p_out.m_id, 4 ) << " chunk instead of FORM" );
|
||||||
|
else throw exception_io_data( "Found multiple FORM chunks" );*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool read_iff_stream( std::vector<uint8_t> const& p_file, iff_stream & p_out )
|
||||||
|
{
|
||||||
|
std::vector<uint8_t>::const_iterator it = p_file.begin(), end = p_file.end();
|
||||||
|
bool first_chunk = true;
|
||||||
|
while ( it < end )
|
||||||
|
{
|
||||||
|
iff_chunk chunk;
|
||||||
|
if ( !read_iff_chunk( it, end, chunk, first_chunk ) ) return false;
|
||||||
|
p_out.m_chunks.push_back( chunk );
|
||||||
|
first_chunk = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool midi_processor::process_xmi( std::vector<uint8_t> const& p_file, midi_container & p_out )
|
||||||
|
{
|
||||||
|
iff_stream xmi_file;
|
||||||
|
if ( !read_iff_stream( p_file, xmi_file ) ) return false;
|
||||||
|
|
||||||
|
const iff_chunk & form_chunk = xmi_file.find_chunk( "FORM" );
|
||||||
|
if ( memcmp( form_chunk.m_type, "XDIR", 4 ) ) return false; /*throw exception_io_data( "XMI IFF not XDIR type" );*/
|
||||||
|
|
||||||
|
const iff_chunk & cat_chunk = xmi_file.find_chunk( "CAT " );
|
||||||
|
if ( memcmp( cat_chunk.m_type, "XMID", 4 ) ) return false; /*throw exception_io_data( "XMI CAT chunk not XMID type" );*/
|
||||||
|
|
||||||
|
unsigned track_count = cat_chunk.get_chunk_count( "FORM" );
|
||||||
|
|
||||||
|
p_out.initialize( track_count > 1 ? 2 : 0, 60 );
|
||||||
|
|
||||||
|
for ( unsigned i = 0; i < track_count; ++i )
|
||||||
|
{
|
||||||
|
const iff_chunk & xmid_form_chunk = cat_chunk.find_sub_chunk( "FORM", i );
|
||||||
|
if ( memcmp( xmid_form_chunk.m_type, "XMID", 4 ) ) return false; /*throw exception_io_data( "XMI nested FORM chunk not XMID type" );*/
|
||||||
|
|
||||||
|
const iff_chunk & event_chunk = xmid_form_chunk.find_sub_chunk( "EVNT" );
|
||||||
|
if ( memcmp( event_chunk.m_id, "EVNT", 4 ) ) return false; /* EVNT chunk not found */
|
||||||
|
std::vector<uint8_t> const& event_body = event_chunk.m_data;
|
||||||
|
|
||||||
|
midi_track track;
|
||||||
|
|
||||||
|
bool initial_tempo = false;
|
||||||
|
|
||||||
|
unsigned current_timestamp = 0;
|
||||||
|
|
||||||
|
unsigned last_event_timestamp = 0;
|
||||||
|
|
||||||
|
std::vector<uint8_t> buffer;
|
||||||
|
buffer.resize( 3 );
|
||||||
|
|
||||||
|
std::vector<uint8_t>::const_iterator it = event_body.begin(), end = event_body.end();
|
||||||
|
|
||||||
|
while ( it < end )
|
||||||
|
{
|
||||||
|
unsigned delta = decode_xmi_delta( it, end );
|
||||||
|
current_timestamp += delta;
|
||||||
|
|
||||||
|
if ( current_timestamp > last_event_timestamp )
|
||||||
|
{
|
||||||
|
last_event_timestamp = current_timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[ 0 ] = *it++;
|
||||||
|
if ( buffer[ 0 ] == 0xFF )
|
||||||
|
{
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
int meta_count;
|
||||||
|
if ( buffer[ 1 ] == 0x2F )
|
||||||
|
{
|
||||||
|
meta_count = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta_count = decode_delta( it );
|
||||||
|
if ( meta_count < 0 ) return false; /*throw exception_io_data( "Invalid XMI meta message" );*/
|
||||||
|
buffer.resize( meta_count + 2 );
|
||||||
|
std::copy( it, it + meta_count, buffer.begin() + 2 );
|
||||||
|
it += meta_count;
|
||||||
|
}
|
||||||
|
if ( buffer[ 1 ] == 0x2F && current_timestamp < last_event_timestamp )
|
||||||
|
{
|
||||||
|
current_timestamp = last_event_timestamp;
|
||||||
|
}
|
||||||
|
if ( buffer[ 1 ] == 0x51 && meta_count == 3 )
|
||||||
|
{
|
||||||
|
unsigned tempo = buffer[ 2 ] * 0x10000 + buffer[ 3 ] * 0x100 + buffer[ 4 ];
|
||||||
|
unsigned ppqn = ( tempo * 3 ) / 25000;
|
||||||
|
tempo = tempo * 60 / ppqn;
|
||||||
|
buffer[ 2 ] = tempo / 0x10000;
|
||||||
|
buffer[ 3 ] = tempo / 0x100;
|
||||||
|
buffer[ 4 ] = tempo;
|
||||||
|
if ( current_timestamp == 0 ) initial_tempo = true;
|
||||||
|
}
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], meta_count + 2 ) );
|
||||||
|
if ( buffer[ 1 ] == 0x2F ) break;
|
||||||
|
}
|
||||||
|
else if ( buffer[ 0 ] == 0xF0 )
|
||||||
|
{
|
||||||
|
int system_exclusive_count = decode_delta( it );
|
||||||
|
if ( system_exclusive_count < 0 ) return false; /*throw exception_io_data( "Invalid XMI System Exclusive message" );*/
|
||||||
|
buffer.resize( system_exclusive_count + 1 );
|
||||||
|
std::copy( it, it + system_exclusive_count, buffer.begin() + 1 );
|
||||||
|
it += system_exclusive_count;
|
||||||
|
track.add_event( midi_event( current_timestamp, midi_event::extended, 0, &buffer[0], system_exclusive_count + 1 ) );
|
||||||
|
}
|
||||||
|
else if ( buffer[ 0 ] >= 0x80 && buffer[ 0 ] <= 0xEF )
|
||||||
|
{
|
||||||
|
unsigned bytes_read = 1;
|
||||||
|
buffer[ 1 ] = *it++;
|
||||||
|
midi_event::event_type type = (midi_event::event_type)( ( buffer[ 0 ] >> 4 ) - 8 );
|
||||||
|
unsigned channel = buffer[ 0 ] & 0x0F;
|
||||||
|
if ( type != midi_event::program_change && type != midi_event::channel_aftertouch )
|
||||||
|
{
|
||||||
|
buffer[ 2 ] = *it++;
|
||||||
|
bytes_read = 2;
|
||||||
|
}
|
||||||
|
track.add_event( midi_event( current_timestamp, type, channel, &buffer[1], bytes_read ) );
|
||||||
|
if ( type == midi_event::note_on )
|
||||||
|
{
|
||||||
|
buffer[ 2 ] = 0x00;
|
||||||
|
int note_length = decode_delta( it );
|
||||||
|
if ( note_length < 0 ) return false; /*throw exception_io_data( "Invalid XMI note message" );*/
|
||||||
|
unsigned note_end_timestamp = current_timestamp + note_length;
|
||||||
|
if ( note_end_timestamp > last_event_timestamp ) last_event_timestamp = note_end_timestamp;
|
||||||
|
track.add_event( midi_event( note_end_timestamp, type, channel, &buffer[1], bytes_read ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return false; /*throw exception_io_data( "Unexpected XMI status code" );*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !initial_tempo )
|
||||||
|
track.add_event( midi_event( 0, midi_event::extended, 0, xmi_default_tempo, _countof( xmi_default_tempo ) ) );
|
||||||
|
|
||||||
|
p_out.add_track( track );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
24
Info.plist
24
Info.plist
|
@ -22,6 +22,30 @@
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>None</string>
|
<string>None</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>lds</string>
|
||||||
|
<string>xmi</string>
|
||||||
|
<string>mus</string>
|
||||||
|
<string>hmp</string>
|
||||||
|
<string>hmi</string>
|
||||||
|
<string>mds</string>
|
||||||
|
<string>mids</string>
|
||||||
|
<string>rmi</string>
|
||||||
|
<string>kar</string>
|
||||||
|
<string>midi</string>
|
||||||
|
<string>mid</string>
|
||||||
|
</array>
|
||||||
|
<key>LSTypeIsPackage</key>
|
||||||
|
<false/>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
<key>CFBundleTypeIconFile</key>
|
||||||
|
<string>song.icns</string>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>MIDI Audio File</string>
|
||||||
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
<array>
|
<array>
|
||||||
|
|
|
@ -0,0 +1,412 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 46;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
83B0668B180D5668008E3612 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83B0668A180D5668008E3612 /* Cocoa.framework */; };
|
||||||
|
83B06695180D5668008E3612 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 83B06693180D5668008E3612 /* InfoPlist.strings */; };
|
||||||
|
83B06701180D5747008E3612 /* midi_processing.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83B066E0180D56BA008E3612 /* midi_processing.framework */; };
|
||||||
|
83B06709180D64DA008E3612 /* MIDIPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B06708180D64DA008E3612 /* MIDIPlayer.cpp */; };
|
||||||
|
83B0670C180D6665008E3612 /* BMPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83B0670A180D6665008E3612 /* BMPlayer.cpp */; };
|
||||||
|
83B0670F180D6F7F008E3612 /* libbass.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 83B0670D180D6F7F008E3612 /* libbass.dylib */; };
|
||||||
|
83B06710180D6F7F008E3612 /* libbassmidi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 83B0670E180D6F7F008E3612 /* libbassmidi.dylib */; };
|
||||||
|
83B06712180D6FAA008E3612 /* libbass.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B0670D180D6F7F008E3612 /* libbass.dylib */; };
|
||||||
|
83B06713180D6FAA008E3612 /* libbassmidi.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B0670E180D6F7F008E3612 /* libbassmidi.dylib */; };
|
||||||
|
83B0671C180D6FD8008E3612 /* libbass_mpc.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B06714180D6FC8008E3612 /* libbass_mpc.dylib */; };
|
||||||
|
83B0671D180D6FD8008E3612 /* libbassflac.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B06715180D6FC8008E3612 /* libbassflac.dylib */; };
|
||||||
|
83B0671E180D6FD8008E3612 /* libbassopus.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B06716180D6FC8008E3612 /* libbassopus.dylib */; };
|
||||||
|
83B0671F180D6FD8008E3612 /* libbasswv.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83B06717180D6FC8008E3612 /* libbasswv.dylib */; };
|
||||||
|
83B06722180D70FE008E3612 /* MIDIDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83B06721180D70FE008E3612 /* MIDIDecoder.mm */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
83B066DF180D56BA008E3612 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 83B066DA180D56B9008E3612 /* midi_processing.xcodeproj */;
|
||||||
|
proxyType = 2;
|
||||||
|
remoteGlobalIDString = 83B066AC180D56B9008E3612;
|
||||||
|
remoteInfo = midi_processing;
|
||||||
|
};
|
||||||
|
83B066FF180D573D008E3612 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 83B066DA180D56B9008E3612 /* midi_processing.xcodeproj */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = 83B066AB180D56B9008E3612;
|
||||||
|
remoteInfo = midi_processing;
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
83B06711180D6F87008E3612 /* CopyFiles */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 6;
|
||||||
|
files = (
|
||||||
|
83B0671C180D6FD8008E3612 /* libbass_mpc.dylib in CopyFiles */,
|
||||||
|
83B0671D180D6FD8008E3612 /* libbassflac.dylib in CopyFiles */,
|
||||||
|
83B0671E180D6FD8008E3612 /* libbassopus.dylib in CopyFiles */,
|
||||||
|
83B0671F180D6FD8008E3612 /* libbasswv.dylib in CopyFiles */,
|
||||||
|
83B06712180D6FAA008E3612 /* libbass.dylib in CopyFiles */,
|
||||||
|
83B06713180D6FAA008E3612 /* libbassmidi.dylib in CopyFiles */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
83B06687180D5668008E3612 /* MIDI.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MIDI.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
83B0668A180D5668008E3612 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||||
|
83B0668D180D5668008E3612 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||||
|
83B0668E180D5668008E3612 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
|
||||||
|
83B0668F180D5668008E3612 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
|
||||||
|
83B06692180D5668008E3612 /* MIDI-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MIDI-Info.plist"; sourceTree = "<group>"; };
|
||||||
|
83B06694180D5668008E3612 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||||
|
83B06696180D5668008E3612 /* MIDI-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MIDI-Prefix.pch"; sourceTree = "<group>"; };
|
||||||
|
83B066DA180D56B9008E3612 /* midi_processing.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = midi_processing.xcodeproj; path = ../../Frameworks/midi_processing/midi_processing.xcodeproj; sourceTree = "<group>"; };
|
||||||
|
83B06706180D6471008E3612 /* MIDIPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIPlayer.h; sourceTree = "<group>"; };
|
||||||
|
83B06708180D64DA008E3612 /* MIDIPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MIDIPlayer.cpp; sourceTree = "<group>"; };
|
||||||
|
83B0670A180D6665008E3612 /* BMPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BMPlayer.cpp; sourceTree = "<group>"; };
|
||||||
|
83B0670B180D6665008E3612 /* BMPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BMPlayer.h; sourceTree = "<group>"; };
|
||||||
|
83B0670D180D6F7F008E3612 /* libbass.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbass.dylib; path = ../../ThirdParty/BASS/libbass.dylib; sourceTree = "<group>"; };
|
||||||
|
83B0670E180D6F7F008E3612 /* libbassmidi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbassmidi.dylib; path = ../../ThirdParty/BASS/libbassmidi.dylib; sourceTree = "<group>"; };
|
||||||
|
83B06714180D6FC8008E3612 /* libbass_mpc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbass_mpc.dylib; path = ../../ThirdParty/BASS/libbass_mpc.dylib; sourceTree = "<group>"; };
|
||||||
|
83B06715180D6FC8008E3612 /* libbassflac.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbassflac.dylib; path = ../../ThirdParty/BASS/libbassflac.dylib; sourceTree = "<group>"; };
|
||||||
|
83B06716180D6FC8008E3612 /* libbassopus.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbassopus.dylib; path = ../../ThirdParty/BASS/libbassopus.dylib; sourceTree = "<group>"; };
|
||||||
|
83B06717180D6FC8008E3612 /* libbasswv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbasswv.dylib; path = ../../ThirdParty/BASS/libbasswv.dylib; sourceTree = "<group>"; };
|
||||||
|
83B06720180D70FE008E3612 /* MIDIDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIDecoder.h; sourceTree = "<group>"; };
|
||||||
|
83B06721180D70FE008E3612 /* MIDIDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MIDIDecoder.mm; sourceTree = "<group>"; };
|
||||||
|
83B06723180D714F008E3612 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../../Audio/Plugin.h; sourceTree = "<group>"; };
|
||||||
|
83B06724180D792E008E3612 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../../Utils/Logging.h; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
83B06684180D5668008E3612 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
83B0670F180D6F7F008E3612 /* libbass.dylib in Frameworks */,
|
||||||
|
83B06701180D5747008E3612 /* midi_processing.framework in Frameworks */,
|
||||||
|
83B06710180D6F7F008E3612 /* libbassmidi.dylib in Frameworks */,
|
||||||
|
83B0668B180D5668008E3612 /* Cocoa.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
83B0667E180D5668008E3612 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B06690180D5668008E3612 /* MIDI */,
|
||||||
|
83B06689180D5668008E3612 /* Frameworks */,
|
||||||
|
83B06688180D5668008E3612 /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B06688180D5668008E3612 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B06687180D5668008E3612 /* MIDI.bundle */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B06689180D5668008E3612 /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B06714180D6FC8008E3612 /* libbass_mpc.dylib */,
|
||||||
|
83B06715180D6FC8008E3612 /* libbassflac.dylib */,
|
||||||
|
83B06716180D6FC8008E3612 /* libbassopus.dylib */,
|
||||||
|
83B06717180D6FC8008E3612 /* libbasswv.dylib */,
|
||||||
|
83B0670D180D6F7F008E3612 /* libbass.dylib */,
|
||||||
|
83B0670E180D6F7F008E3612 /* libbassmidi.dylib */,
|
||||||
|
83B0668A180D5668008E3612 /* Cocoa.framework */,
|
||||||
|
83B0668C180D5668008E3612 /* Other Frameworks */,
|
||||||
|
83B066DA180D56B9008E3612 /* midi_processing.xcodeproj */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B0668C180D5668008E3612 /* Other Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B0668D180D5668008E3612 /* Foundation.framework */,
|
||||||
|
83B0668E180D5668008E3612 /* CoreData.framework */,
|
||||||
|
83B0668F180D5668008E3612 /* AppKit.framework */,
|
||||||
|
);
|
||||||
|
name = "Other Frameworks";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B06690180D5668008E3612 /* MIDI */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B06724180D792E008E3612 /* Logging.h */,
|
||||||
|
83B06723180D714F008E3612 /* Plugin.h */,
|
||||||
|
83B06720180D70FE008E3612 /* MIDIDecoder.h */,
|
||||||
|
83B06721180D70FE008E3612 /* MIDIDecoder.mm */,
|
||||||
|
83B0670A180D6665008E3612 /* BMPlayer.cpp */,
|
||||||
|
83B0670B180D6665008E3612 /* BMPlayer.h */,
|
||||||
|
83B06708180D64DA008E3612 /* MIDIPlayer.cpp */,
|
||||||
|
83B06706180D6471008E3612 /* MIDIPlayer.h */,
|
||||||
|
83B06691180D5668008E3612 /* Supporting Files */,
|
||||||
|
);
|
||||||
|
path = MIDI;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B06691180D5668008E3612 /* Supporting Files */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B06692180D5668008E3612 /* MIDI-Info.plist */,
|
||||||
|
83B06693180D5668008E3612 /* InfoPlist.strings */,
|
||||||
|
83B06696180D5668008E3612 /* MIDI-Prefix.pch */,
|
||||||
|
);
|
||||||
|
name = "Supporting Files";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
83B066DB180D56B9008E3612 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
83B066E0180D56BA008E3612 /* midi_processing.framework */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
83B06686180D5668008E3612 /* MIDI */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 83B06699180D5668008E3612 /* Build configuration list for PBXNativeTarget "MIDI" */;
|
||||||
|
buildPhases = (
|
||||||
|
83B06683180D5668008E3612 /* Sources */,
|
||||||
|
83B06684180D5668008E3612 /* Frameworks */,
|
||||||
|
83B06685180D5668008E3612 /* Resources */,
|
||||||
|
83B06711180D6F87008E3612 /* CopyFiles */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
83B06700180D573D008E3612 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = MIDI;
|
||||||
|
productName = MIDI;
|
||||||
|
productReference = 83B06687180D5668008E3612 /* MIDI.bundle */;
|
||||||
|
productType = "com.apple.product-type.bundle";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
83B0667F180D5668008E3612 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0500;
|
||||||
|
ORGANIZATIONNAME = "Christopher Snowhill";
|
||||||
|
};
|
||||||
|
buildConfigurationList = 83B06682180D5668008E3612 /* Build configuration list for PBXProject "MIDI" */;
|
||||||
|
compatibilityVersion = "Xcode 3.2";
|
||||||
|
developmentRegion = English;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
);
|
||||||
|
mainGroup = 83B0667E180D5668008E3612;
|
||||||
|
productRefGroup = 83B06688180D5668008E3612 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectReferences = (
|
||||||
|
{
|
||||||
|
ProductGroup = 83B066DB180D56B9008E3612 /* Products */;
|
||||||
|
ProjectRef = 83B066DA180D56B9008E3612 /* midi_processing.xcodeproj */;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
83B06686180D5668008E3612 /* MIDI */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXReferenceProxy section */
|
||||||
|
83B066E0180D56BA008E3612 /* midi_processing.framework */ = {
|
||||||
|
isa = PBXReferenceProxy;
|
||||||
|
fileType = wrapper.framework;
|
||||||
|
path = midi_processing.framework;
|
||||||
|
remoteRef = 83B066DF180D56BA008E3612 /* PBXContainerItemProxy */;
|
||||||
|
sourceTree = BUILT_PRODUCTS_DIR;
|
||||||
|
};
|
||||||
|
/* End PBXReferenceProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
83B06685180D5668008E3612 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
83B06695180D5668008E3612 /* InfoPlist.strings in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
83B06683180D5668008E3612 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
83B06709180D64DA008E3612 /* MIDIPlayer.cpp in Sources */,
|
||||||
|
83B06722180D70FE008E3612 /* MIDIDecoder.mm in Sources */,
|
||||||
|
83B0670C180D6665008E3612 /* BMPlayer.cpp in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
83B06700180D573D008E3612 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
name = midi_processing;
|
||||||
|
targetProxy = 83B066FF180D573D008E3612 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
83B06693180D5668008E3612 /* InfoPlist.strings */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
83B06694180D5668008E3612 /* en */,
|
||||||
|
);
|
||||||
|
name = InfoPlist.strings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
83B06697180D5668008E3612 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
83B06698180D5668008E3612 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = YES;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
83B0669A180D5668008E3612 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
|
GCC_PREFIX_HEADER = "MIDI/MIDI-Prefix.pch";
|
||||||
|
INFOPLIST_FILE = "MIDI/MIDI-Info.plist";
|
||||||
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
|
||||||
|
LIBRARY_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
/Users/Chris/Source/Repos/cog/ThirdParty/BASS,
|
||||||
|
);
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
WRAPPER_EXTENSION = bundle;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
83B0669B180D5668008E3612 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
|
GCC_PREFIX_HEADER = "MIDI/MIDI-Prefix.pch";
|
||||||
|
INFOPLIST_FILE = "MIDI/MIDI-Info.plist";
|
||||||
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
|
||||||
|
LIBRARY_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
/Users/Chris/Source/Repos/cog/ThirdParty/BASS,
|
||||||
|
);
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
WRAPPER_EXTENSION = bundle;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
83B06682180D5668008E3612 /* Build configuration list for PBXProject "MIDI" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
83B06697180D5668008E3612 /* Debug */,
|
||||||
|
83B06698180D5668008E3612 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
83B06699180D5668008E3612 /* Build configuration list for PBXNativeTarget "MIDI" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
83B0669A180D5668008E3612 /* Debug */,
|
||||||
|
83B0669B180D5668008E3612 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 83B0667F180D5668008E3612 /* Project object */;
|
||||||
|
}
|
|
@ -0,0 +1,351 @@
|
||||||
|
#include "BMPlayer.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#define SF2PACK
|
||||||
|
|
||||||
|
#define _countof(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||||
|
|
||||||
|
static const uint8_t sysex_gm_reset[] = { 0xF0, 0x7E, 0x7F, 0x09, 0x01, 0xF7 };
|
||||||
|
static const uint8_t sysex_gm2_reset[]= { 0xF0, 0x7E, 0x7F, 0x09, 0x03, 0xF7 };
|
||||||
|
static const uint8_t sysex_gs_reset[] = { 0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7 };
|
||||||
|
static const uint8_t sysex_xg_reset[] = { 0xF0, 0x43, 0x10, 0x4C, 0x00, 0x00, 0x7E, 0x00, 0xF7 };
|
||||||
|
|
||||||
|
static bool is_gs_reset(const unsigned char * data, unsigned long size)
|
||||||
|
{
|
||||||
|
if ( size != _countof( sysex_gs_reset ) ) return false;
|
||||||
|
|
||||||
|
if ( memcmp( data, sysex_gs_reset, 5 ) != 0 ) return false;
|
||||||
|
if ( memcmp( data + 7, sysex_gs_reset + 7, 2 ) != 0 ) return false;
|
||||||
|
if ( ( ( data[ 5 ] + data[ 6 ] + 1 ) & 127 ) != data[ 9 ] ) return false;
|
||||||
|
if ( data[ 10 ] != sysex_gs_reset[ 10 ] ) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bass_Initializer
|
||||||
|
{
|
||||||
|
pthread_mutex_t lock;
|
||||||
|
|
||||||
|
bool initialized;
|
||||||
|
|
||||||
|
std::string base_path;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Bass_Initializer() : initialized(false)
|
||||||
|
{
|
||||||
|
pthread_mutex_init( &lock, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
~Bass_Initializer()
|
||||||
|
{
|
||||||
|
if ( initialized )
|
||||||
|
{
|
||||||
|
BASS_Free();
|
||||||
|
}
|
||||||
|
pthread_mutex_destroy( &lock );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check_initialized()
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&lock);
|
||||||
|
bool initialized = this->initialized;
|
||||||
|
pthread_mutex_unlock(&lock);
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_base_path()
|
||||||
|
{
|
||||||
|
Dl_info info;
|
||||||
|
dladdr( (void*) &BASS_Init, &info );
|
||||||
|
base_path = info.dli_fname;
|
||||||
|
size_t slash = base_path.find_last_of( '/' );
|
||||||
|
base_path.erase( base_path.begin() + slash + 1, base_path.end() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_plugin(const char * name)
|
||||||
|
{
|
||||||
|
std::string full_path = base_path;
|
||||||
|
full_path += name;
|
||||||
|
BASS_PluginLoad( full_path.c_str(), 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool initialize()
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&lock);
|
||||||
|
bool initialized = this->initialized;
|
||||||
|
if ( !initialized )
|
||||||
|
{
|
||||||
|
#ifdef SF2PACK
|
||||||
|
set_base_path();
|
||||||
|
load_plugin( "libbassflac.dylib" );
|
||||||
|
load_plugin( "libbasswv.dylib" );
|
||||||
|
load_plugin( "libbassopus.dylib" );
|
||||||
|
load_plugin( "libbass_mpc.dylib" );
|
||||||
|
#endif
|
||||||
|
BASS_SetConfig( BASS_CONFIG_UPDATEPERIOD, 0 );
|
||||||
|
initialized = !!BASS_Init( 0, 44100, 0, NULL, NULL );
|
||||||
|
if ( initialized )
|
||||||
|
{
|
||||||
|
BASS_SetConfigPtr( BASS_CONFIG_MIDI_DEFFONT, NULL );
|
||||||
|
BASS_SetConfig( BASS_CONFIG_MIDI_VOICES, 256 );
|
||||||
|
this->initialized = initialized;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&lock);
|
||||||
|
return initialized;
|
||||||
|
}
|
||||||
|
} g_initializer;
|
||||||
|
|
||||||
|
BMPlayer::BMPlayer() : MIDIPlayer()
|
||||||
|
{
|
||||||
|
_stream = 0;
|
||||||
|
bSincInterpolation = false;
|
||||||
|
|
||||||
|
if ( !g_initializer.initialize() ) throw std::runtime_error( "Unable to initialize BASS" );
|
||||||
|
}
|
||||||
|
|
||||||
|
BMPlayer::~BMPlayer()
|
||||||
|
{
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMPlayer::setSincInterpolation(bool enable)
|
||||||
|
{
|
||||||
|
bSincInterpolation = enable;
|
||||||
|
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMPlayer::send_event(uint32_t b)
|
||||||
|
{
|
||||||
|
if (!(b & 0x80000000))
|
||||||
|
{
|
||||||
|
unsigned char event[ 3 ];
|
||||||
|
event[ 0 ] = (unsigned char)b;
|
||||||
|
event[ 1 ] = (unsigned char)( b >> 8 );
|
||||||
|
event[ 2 ] = (unsigned char)( b >> 16 );
|
||||||
|
unsigned port = (b >> 24) & 0x7F;
|
||||||
|
unsigned channel = b & 0x0F;
|
||||||
|
unsigned command = b & 0xF0;
|
||||||
|
unsigned event_length = ( command == 0xC0 || command == 0xD0 ) ? 2 : 3;
|
||||||
|
channel += 16 * port;
|
||||||
|
BASS_MIDI_StreamEvents( _stream, BASS_MIDI_EVENTS_RAW + 1 + channel, event, event_length );
|
||||||
|
if ( command == 0xB0 && event[ 1 ] == 0 )
|
||||||
|
{
|
||||||
|
if ( synth_mode == mode_xg )
|
||||||
|
{
|
||||||
|
if ( event[ 2 ] == 127 ) drum_channels[ channel ] = 1;
|
||||||
|
else drum_channels[ channel ] = 0;
|
||||||
|
}
|
||||||
|
else if ( synth_mode == mode_gm2 )
|
||||||
|
{
|
||||||
|
if ( event[ 2 ] == 120 ) drum_channels[ channel ] = 1;
|
||||||
|
else if ( event[ 2 ] == 121 ) drum_channels[ channel ] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( command == 0xC0 )
|
||||||
|
{
|
||||||
|
unsigned channel_masked = channel & 0x0F;
|
||||||
|
unsigned drum_channel = drum_channels[ channel ];
|
||||||
|
if ( ( channel_masked == 9 && !drum_channel ) ||
|
||||||
|
( channel_masked != 9 && drum_channel ) )
|
||||||
|
BASS_MIDI_StreamEvent( _stream, channel, MIDI_EVENT_DRUMS, drum_channel );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned long n = b & 0xffffff;
|
||||||
|
const uint8_t * data;
|
||||||
|
std::size_t size, port;
|
||||||
|
mSysexMap.get_entry( n, data, size, port );
|
||||||
|
if ( port > 2 ) port = 2;
|
||||||
|
BASS_MIDI_StreamEvents( _stream, BASS_MIDI_EVENTS_RAW, data, size );
|
||||||
|
if ( ( size == _countof( sysex_gm_reset ) && !memcmp( data, sysex_gm_reset, _countof( sysex_gm_reset ) ) ) ||
|
||||||
|
( size == _countof( sysex_gm2_reset ) && !memcmp( data, sysex_gm2_reset, _countof( sysex_gm2_reset ) ) ) ||
|
||||||
|
is_gs_reset( data, size ) ||
|
||||||
|
( size == _countof( sysex_xg_reset ) && !memcmp( data, sysex_xg_reset, _countof( sysex_xg_reset ) ) ) )
|
||||||
|
{
|
||||||
|
reset_drum_channels();
|
||||||
|
synth_mode = ( size == _countof( sysex_xg_reset ) ) ? mode_xg :
|
||||||
|
( size == _countof( sysex_gs_reset ) ) ? mode_gs :
|
||||||
|
( data [4] == 0x01 ) ? mode_gm :
|
||||||
|
mode_gm2;
|
||||||
|
}
|
||||||
|
else if ( synth_mode == mode_gs && size == 11 &&
|
||||||
|
data [0] == 0xF0 && data [1] == 0x41 && data [3] == 0x42 &&
|
||||||
|
data [4] == 0x12 && data [5] == 0x40 && (data [6] & 0xF0) == 0x10 &&
|
||||||
|
data [10] == 0xF7)
|
||||||
|
{
|
||||||
|
if (data [7] == 2)
|
||||||
|
{
|
||||||
|
// GS MIDI channel to part assign
|
||||||
|
gs_part_to_ch [ port ][ data [6] & 15 ] = data [8];
|
||||||
|
}
|
||||||
|
else if ( data [7] == 0x15 )
|
||||||
|
{
|
||||||
|
// GS part to rhythm allocation
|
||||||
|
unsigned int drum_channel = gs_part_to_ch [ port ][ data [6] & 15 ];
|
||||||
|
if ( drum_channel < 16 )
|
||||||
|
{
|
||||||
|
drum_channel += 16 * port;
|
||||||
|
drum_channels [ drum_channel ] = data [8];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMPlayer::render(float * out, unsigned long count)
|
||||||
|
{
|
||||||
|
BASS_ChannelGetData( _stream, out, BASS_DATA_FLOAT | (unsigned int) ( count * sizeof( float ) * 2 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMPlayer::setSoundFont( const char * in )
|
||||||
|
{
|
||||||
|
sSoundFontName = in;
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMPlayer::setFileSoundFont( const char * in )
|
||||||
|
{
|
||||||
|
sFileSoundFontName = in;
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMPlayer::shutdown()
|
||||||
|
{
|
||||||
|
if ( _stream ) BASS_StreamFree( _stream );
|
||||||
|
_stream = NULL;
|
||||||
|
for ( unsigned long i = 0; i < _soundFonts.size(); ++i )
|
||||||
|
{
|
||||||
|
BASS_MIDI_FontFree( _soundFonts[i] );
|
||||||
|
}
|
||||||
|
_soundFonts.resize( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMPlayer::startup()
|
||||||
|
{
|
||||||
|
if ( _stream ) return true;
|
||||||
|
|
||||||
|
_stream = BASS_MIDI_StreamCreate( 48, BASS_SAMPLE_FLOAT | BASS_STREAM_DECODE | ( bSincInterpolation ? BASS_MIDI_SINCINTER : 0 ), (unsigned int) uSampleRate );
|
||||||
|
if (!_stream)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (sSoundFontName.length())
|
||||||
|
{
|
||||||
|
std::string ext;
|
||||||
|
size_t dot = sSoundFontName.find_last_of('.');
|
||||||
|
if (dot != std::string::npos) ext.assign( sSoundFontName.begin() + dot + 1, sSoundFontName.end() );
|
||||||
|
if ( !strcasecmp( ext.c_str(), "sf2" )
|
||||||
|
#ifdef SF2PACK
|
||||||
|
|| !strcasecmp( ext.c_str(), "sf2pack" )
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HSOUNDFONT font = BASS_MIDI_FontInit( sSoundFontName.c_str(), 0 );
|
||||||
|
if ( !font )
|
||||||
|
{
|
||||||
|
shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_soundFonts.push_back( font );
|
||||||
|
}
|
||||||
|
else if ( !strcasecmp( ext.c_str(), "sflist" ) )
|
||||||
|
{
|
||||||
|
FILE * fl = fopen( sSoundFontName.c_str(), "r" );
|
||||||
|
if ( fl )
|
||||||
|
{
|
||||||
|
std::string path, temp;
|
||||||
|
char name[32768];
|
||||||
|
size_t slash = sSoundFontName.find_last_of('/');
|
||||||
|
if ( slash != std::string::npos ) path.assign( sSoundFontName.begin(), sSoundFontName.begin() + slash + 1 );
|
||||||
|
while ( !feof( fl ) )
|
||||||
|
{
|
||||||
|
if ( !fgets( name, 32767, fl ) ) break;
|
||||||
|
name[32767] = 0;
|
||||||
|
char * cr = strchr( name, '\n' );
|
||||||
|
if ( cr ) *cr = 0;
|
||||||
|
cr = strchr( name, '\r' );
|
||||||
|
if ( cr ) *cr = 0;
|
||||||
|
if ( name[0] == '/' )
|
||||||
|
{
|
||||||
|
temp = name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
temp = path;
|
||||||
|
temp += name;
|
||||||
|
}
|
||||||
|
HSOUNDFONT font = BASS_MIDI_FontInit( temp.c_str(), 0 );
|
||||||
|
if ( !font )
|
||||||
|
{
|
||||||
|
fclose( fl );
|
||||||
|
shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_soundFonts.push_back( font );
|
||||||
|
}
|
||||||
|
fclose( fl );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( sFileSoundFontName.length() )
|
||||||
|
{
|
||||||
|
HSOUNDFONT font = BASS_MIDI_FontInit( sFileSoundFontName.c_str(), 0 );
|
||||||
|
if ( !font )
|
||||||
|
{
|
||||||
|
shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_soundFonts.push_back( font );
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector< BASS_MIDI_FONT > fonts;
|
||||||
|
for ( unsigned long i = 0, j = _soundFonts.size(); i < j; ++i )
|
||||||
|
{
|
||||||
|
BASS_MIDI_FONT sf;
|
||||||
|
sf.font = _soundFonts[ j - i - 1 ];
|
||||||
|
sf.preset = -1;
|
||||||
|
sf.bank = 0;
|
||||||
|
fonts.push_back( sf );
|
||||||
|
}
|
||||||
|
BASS_MIDI_StreamSetFonts( _stream, &fonts[0], (unsigned int) fonts.size() );
|
||||||
|
|
||||||
|
reset_drum_channels();
|
||||||
|
|
||||||
|
synth_mode = mode_gm;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BMPlayer::reset_drum_channels()
|
||||||
|
{
|
||||||
|
static const uint8_t part_to_ch[16] = { 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15 };
|
||||||
|
|
||||||
|
memset( drum_channels, 0, sizeof( drum_channels ) );
|
||||||
|
drum_channels[ 9 ] = 1;
|
||||||
|
drum_channels[ 25 ] = 1;
|
||||||
|
drum_channels[ 41 ] = 1;
|
||||||
|
|
||||||
|
for ( unsigned long i = 0; i < 3; i++ )
|
||||||
|
memcpy( gs_part_to_ch[ i ], part_to_ch, sizeof( gs_part_to_ch[ i ] ) );
|
||||||
|
|
||||||
|
if ( _stream )
|
||||||
|
{
|
||||||
|
for ( unsigned i = 0; i < 48; ++i )
|
||||||
|
{
|
||||||
|
BASS_MIDI_StreamEvent( _stream, i, MIDI_EVENT_DRUMS, drum_channels[ i ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
#ifndef __BMPlayer_h__
|
||||||
|
#define __BMPlayer_h__
|
||||||
|
|
||||||
|
#include "MIDIPlayer.h"
|
||||||
|
|
||||||
|
#include "../../../ThirdParty/BASS/bassmidi.h"
|
||||||
|
|
||||||
|
class BMPlayer : public MIDIPlayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// zero variables
|
||||||
|
BMPlayer();
|
||||||
|
|
||||||
|
// close, unload
|
||||||
|
virtual ~BMPlayer();
|
||||||
|
|
||||||
|
// configuration
|
||||||
|
void setSoundFont( const char * in );
|
||||||
|
void setFileSoundFont( const char * in );
|
||||||
|
void setSincInterpolation(bool enable = true);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void send_event(uint32_t b);
|
||||||
|
virtual void render(float * out, unsigned long count);
|
||||||
|
|
||||||
|
virtual void shutdown();
|
||||||
|
virtual bool startup();
|
||||||
|
|
||||||
|
void reset_drum_channels();
|
||||||
|
|
||||||
|
std::vector<HSOUNDFONT> _soundFonts;
|
||||||
|
std::string sSoundFontName;
|
||||||
|
std::string sFileSoundFontName;
|
||||||
|
|
||||||
|
HSTREAM _stream;
|
||||||
|
|
||||||
|
bool bSincInterpolation;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
mode_gm = 0,
|
||||||
|
mode_gm2,
|
||||||
|
mode_gs,
|
||||||
|
mode_xg
|
||||||
|
}
|
||||||
|
synth_mode;
|
||||||
|
|
||||||
|
uint8_t gs_part_to_ch[3][16];
|
||||||
|
uint8_t drum_channels[48];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>net.kode54.midi</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>BNDL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright © 2013 Christopher Snowhill. All rights reserved.</string>
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string></string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,9 @@
|
||||||
|
//
|
||||||
|
// Prefix header
|
||||||
|
//
|
||||||
|
// The contents of this file are implicitly included at the beginning of every source file.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#endif
|
|
@ -0,0 +1,27 @@
|
||||||
|
//
|
||||||
|
// MIDIDecoder.h
|
||||||
|
// MIDI
|
||||||
|
//
|
||||||
|
// Created by Christopher Snowhill on 10/15/13.
|
||||||
|
// Copyright 2013 __NoWork, Inc__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#import "MIDIPlayer.h"
|
||||||
|
|
||||||
|
#import "Plugin.h"
|
||||||
|
|
||||||
|
@interface MIDIDecoder : NSObject <CogDecoder> {
|
||||||
|
MIDIPlayer* player;
|
||||||
|
midi_container midi_file;
|
||||||
|
|
||||||
|
BOOL soundFontsAssigned;
|
||||||
|
|
||||||
|
long totalFrames;
|
||||||
|
long framesLength;
|
||||||
|
long framesFade;
|
||||||
|
long framesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,167 @@
|
||||||
|
//
|
||||||
|
// MIDIDecoder.mm
|
||||||
|
// MIDI
|
||||||
|
//
|
||||||
|
// Created by Christopher Snowhill on 10/15/13.
|
||||||
|
// Copyright 2013 __NoWork, Inc__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MIDIDecoder.h"
|
||||||
|
|
||||||
|
#import "BMPlayer.h"
|
||||||
|
|
||||||
|
#import "Logging.h"
|
||||||
|
|
||||||
|
#import <midi_processing/midi_processor.h>
|
||||||
|
|
||||||
|
@implementation MIDIDecoder
|
||||||
|
|
||||||
|
- (BOOL)open:(id<CogSource>)s
|
||||||
|
{
|
||||||
|
//We need file-size to use midi_processing
|
||||||
|
if (![s seekable]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<uint8_t> file_data;
|
||||||
|
|
||||||
|
[s seek:0 whence:SEEK_END];
|
||||||
|
size_t size = [s tell];
|
||||||
|
[s seek:0 whence:SEEK_SET];
|
||||||
|
file_data.resize( size );
|
||||||
|
[s read:&file_data[0] amount:size];
|
||||||
|
|
||||||
|
if ( !midi_processor::process_file(file_data, [[[[s url] absoluteString] lastPathComponent] UTF8String], midi_file) )
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
int track_num = [[[s url] fragment] intValue]; //What if theres no fragment? Assuming we get 0.
|
||||||
|
|
||||||
|
midi_file.scan_for_loops( true, true );
|
||||||
|
|
||||||
|
framesLength = midi_file.get_timestamp_end( track_num, true ) + 1000;
|
||||||
|
|
||||||
|
unsigned long loopStart = midi_file.get_timestamp_loop_start( track_num, true );
|
||||||
|
unsigned long loopEnd = midi_file.get_timestamp_loop_end( track_num, true );
|
||||||
|
|
||||||
|
if ( loopStart != ~0UL && loopEnd != ~0UL )
|
||||||
|
{
|
||||||
|
// two loops and a fade
|
||||||
|
framesLength = loopStart + ( loopEnd - loopStart ) * 2;
|
||||||
|
framesFade = 8000;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
framesFade = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
framesLength = framesLength * 441 / 10;
|
||||||
|
framesFade = framesFade * 441 / 10;
|
||||||
|
|
||||||
|
totalFrames = framesLength + framesFade;
|
||||||
|
|
||||||
|
DLog(@"Length: %li", totalFrames);
|
||||||
|
|
||||||
|
DLog(@"Track num: %i", track_num);
|
||||||
|
|
||||||
|
BMPlayer * bmplayer = new BMPlayer;
|
||||||
|
player = bmplayer;
|
||||||
|
|
||||||
|
bmplayer->setSincInterpolation( true );
|
||||||
|
bmplayer->setSampleRate( 44100 );
|
||||||
|
|
||||||
|
unsigned int loop_mode = framesFade ? MIDIPlayer::loop_mode_enable | MIDIPlayer::loop_mode_force : 0;
|
||||||
|
unsigned int clean_flags = midi_container::clean_flag_emidi;
|
||||||
|
|
||||||
|
if ( !bmplayer->Load( midi_file, track_num, loop_mode, clean_flags) )
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
framesRead = 0;
|
||||||
|
|
||||||
|
[self willChangeValueForKey:@"properties"];
|
||||||
|
[self didChangeValueForKey:@"properties"];
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *)properties
|
||||||
|
{
|
||||||
|
return [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
[NSNumber numberWithInt:0], @"bitrate",
|
||||||
|
[NSNumber numberWithFloat:44100], @"sampleRate",
|
||||||
|
[NSNumber numberWithLong:totalFrames], @"totalFrames",
|
||||||
|
[NSNumber numberWithInt:32], @"bitsPerSample",
|
||||||
|
[NSNumber numberWithBool:YES], @"floatingPoint",
|
||||||
|
[NSNumber numberWithInt:2], @"channels", //output from gme_play is in stereo
|
||||||
|
[NSNumber numberWithBool:YES], @"seekable",
|
||||||
|
@"host", @"endian",
|
||||||
|
nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int)readAudio:(void *)buf frames:(UInt32)frames
|
||||||
|
{
|
||||||
|
if ( !soundFontsAssigned ) {
|
||||||
|
NSString * soundFontPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"soundFontPath"];
|
||||||
|
if (soundFontPath == nil)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
((BMPlayer *)player)->setSoundFont( [soundFontPath UTF8String] );
|
||||||
|
|
||||||
|
soundFontsAssigned = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
player->Play( (float *) buf, frames );
|
||||||
|
|
||||||
|
if ( framesRead + frames > framesLength ) {
|
||||||
|
if ( framesFade ) {
|
||||||
|
long fadeStart = (framesLength > framesRead) ? framesLength : framesRead;
|
||||||
|
long fadeEnd = (framesRead + frames > totalFrames) ? totalFrames : (framesRead + frames);
|
||||||
|
long fadePos;
|
||||||
|
|
||||||
|
float * buff = ( float * ) buf;
|
||||||
|
|
||||||
|
float fadeScale = (fadeStart - framesLength) / framesFade;
|
||||||
|
float fadeStep = 1 / framesFade;
|
||||||
|
for (fadePos = fadeStart; fadePos < fadeEnd; ++fadePos) {
|
||||||
|
buff[ 0 ] *= fadeScale;
|
||||||
|
buff[ 1 ] *= fadeScale;
|
||||||
|
buff += 2;
|
||||||
|
fadeScale -= fadeStep;
|
||||||
|
if (fadeScale < 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fadePos < totalFrames)
|
||||||
|
frames = (int)(fadePos - fadeStart);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
frames = (int)(totalFrames - framesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
framesRead += frames;
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (long)seek:(long)frame
|
||||||
|
{
|
||||||
|
player->Seek( frame );
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)close
|
||||||
|
{
|
||||||
|
delete player;
|
||||||
|
player = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)fileTypes
|
||||||
|
{
|
||||||
|
return [NSArray arrayWithObjects:@"mid", @"midi", @"kar", @"rmi", @"mids", @"mds", @"hmi", @"hmp", @"mus", @"xmi", @"lds", nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSArray *)mimeTypes
|
||||||
|
{
|
||||||
|
return [NSArray arrayWithObjects:@"audio/midi", @"audio/x-midi", nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,313 @@
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "MIDIPlayer.h"
|
||||||
|
|
||||||
|
MIDIPlayer::MIDIPlayer()
|
||||||
|
{
|
||||||
|
uSamplesRemaining = 0;
|
||||||
|
uSampleRate = 1000;
|
||||||
|
uTimeCurrent = 0;
|
||||||
|
uTimeEnd = 0;
|
||||||
|
uTimeLoopStart = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MIDIPlayer::setSampleRate(unsigned long rate)
|
||||||
|
{
|
||||||
|
if (mStream.size())
|
||||||
|
{
|
||||||
|
for (unsigned long i = 0; i < mStream.size(); i++)
|
||||||
|
{
|
||||||
|
mStream[i].m_timestamp = mStream[i].m_timestamp * rate / uSampleRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uTimeCurrent)
|
||||||
|
{
|
||||||
|
uTimeCurrent = uTimeCurrent * rate / uSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uTimeEnd)
|
||||||
|
{
|
||||||
|
uTimeEnd = uTimeEnd * rate / uSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uTimeLoopStart)
|
||||||
|
{
|
||||||
|
uTimeLoopStart = uTimeLoopStart * rate / uSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
uSampleRate = rate;
|
||||||
|
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MIDIPlayer::Load(const midi_container & midi_file, unsigned subsong, unsigned loop_mode, unsigned clean_flags)
|
||||||
|
{
|
||||||
|
assert(!mStream.size());
|
||||||
|
|
||||||
|
midi_file.serialize_as_stream( subsong, mStream, mSysexMap, clean_flags );
|
||||||
|
|
||||||
|
if (mStream.size())
|
||||||
|
{
|
||||||
|
uStreamPosition = 0;
|
||||||
|
uTimeCurrent = 0;
|
||||||
|
|
||||||
|
uLoopMode = loop_mode;
|
||||||
|
|
||||||
|
if (uLoopMode & loop_mode_enable)
|
||||||
|
{
|
||||||
|
uTimeLoopStart = midi_file.get_timestamp_loop_start( subsong, true );
|
||||||
|
unsigned long uTimeLoopEnd = midi_file.get_timestamp_loop_end( subsong, true );
|
||||||
|
uTimeEnd = midi_file.get_timestamp_end( subsong, true );
|
||||||
|
|
||||||
|
if ( uTimeLoopStart != ~0UL || uTimeLoopEnd != ~0UL )
|
||||||
|
{
|
||||||
|
uLoopMode |= loop_mode_force;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( uTimeLoopStart != ~0 )
|
||||||
|
{
|
||||||
|
for ( unsigned i = 0; i < mStream.size(); ++i )
|
||||||
|
{
|
||||||
|
if ( mStream[ i ].m_timestamp >= uTimeLoopStart )
|
||||||
|
{
|
||||||
|
uStreamLoopStart = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else uStreamLoopStart = ~0UL;
|
||||||
|
|
||||||
|
if ( uTimeLoopEnd != ~0UL )
|
||||||
|
{
|
||||||
|
uTimeEnd = uTimeLoopEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(uLoopMode & loop_mode_force)) uTimeEnd += 1000;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned long i;
|
||||||
|
unsigned char note_on[128 * 16];
|
||||||
|
memset( note_on, 0, sizeof( note_on ) );
|
||||||
|
for (i = 0; i < mStream.size(); i++)
|
||||||
|
{
|
||||||
|
if (mStream[ i ].m_timestamp > uTimeEnd) break;
|
||||||
|
uint32_t ev = mStream[ i ].m_event & 0x800000F0;
|
||||||
|
if ( ev == 0x90 || ev == 0x80 )
|
||||||
|
{
|
||||||
|
unsigned long port = ( mStream[ i ].m_event & 0x7F000000 ) >> 24;
|
||||||
|
unsigned long ch = mStream[ i ].m_event & 0x0F;
|
||||||
|
unsigned long note = ( mStream[ i ].m_event >> 8 ) & 0x7F;
|
||||||
|
unsigned long on = ( ev == 0x90 ) && ( mStream[ i ].m_event & 0xFF0000 );
|
||||||
|
unsigned long bit = 1 << port;
|
||||||
|
note_on [ ch * 128 + note ] = ( note_on [ ch * 128 + note ] & ~bit ) | ( bit * on );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mStream.resize( i );
|
||||||
|
for ( unsigned long j = 0; j < 128 * 16; j++ )
|
||||||
|
{
|
||||||
|
if ( note_on[ j ] )
|
||||||
|
{
|
||||||
|
for ( unsigned long k = 0; k < 8; k++ )
|
||||||
|
{
|
||||||
|
if ( note_on[ j ] & ( 1 << k ) )
|
||||||
|
{
|
||||||
|
mStream.push_back( midi_stream_event( uTimeEnd, (uint32_t)(( k << 24 ) + ( j >> 7 ) + ( j & 0x7F ) * 0x100 + 0x90 )) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else uTimeEnd = midi_file.get_timestamp_end( subsong, true ) + 1000;
|
||||||
|
|
||||||
|
if (uSampleRate != 1000)
|
||||||
|
{
|
||||||
|
unsigned long rate = uSampleRate;
|
||||||
|
uSampleRate = 1000;
|
||||||
|
setSampleRate(rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long MIDIPlayer::Play(float * out, unsigned long count)
|
||||||
|
{
|
||||||
|
assert(mStream.size());
|
||||||
|
|
||||||
|
if ( !startup() ) return 0;
|
||||||
|
|
||||||
|
unsigned long done = 0;
|
||||||
|
|
||||||
|
if ( uSamplesRemaining )
|
||||||
|
{
|
||||||
|
unsigned long todo = uSamplesRemaining;
|
||||||
|
if (todo > count) todo = count;
|
||||||
|
render( out, todo );
|
||||||
|
uSamplesRemaining -= todo;
|
||||||
|
done += todo;
|
||||||
|
uTimeCurrent += todo;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (done < count)
|
||||||
|
{
|
||||||
|
unsigned long todo = uTimeEnd - uTimeCurrent;
|
||||||
|
if (todo > count - done) todo = count - done;
|
||||||
|
|
||||||
|
unsigned long time_target = todo + uTimeCurrent;
|
||||||
|
unsigned long stream_end = uStreamPosition;
|
||||||
|
|
||||||
|
while (stream_end < mStream.size() && mStream[stream_end].m_timestamp < time_target) stream_end++;
|
||||||
|
|
||||||
|
if (stream_end > uStreamPosition)
|
||||||
|
{
|
||||||
|
for (; uStreamPosition < stream_end; uStreamPosition++)
|
||||||
|
{
|
||||||
|
midi_stream_event * me = &mStream[uStreamPosition];
|
||||||
|
|
||||||
|
unsigned long samples_todo = me->m_timestamp - uTimeCurrent;
|
||||||
|
if ( samples_todo )
|
||||||
|
{
|
||||||
|
if ( samples_todo > count - done )
|
||||||
|
{
|
||||||
|
uSamplesRemaining = samples_todo - ( count - done );
|
||||||
|
samples_todo = count - done;
|
||||||
|
}
|
||||||
|
render( out + done * 2, samples_todo );
|
||||||
|
done += samples_todo;
|
||||||
|
|
||||||
|
if ( uSamplesRemaining )
|
||||||
|
{
|
||||||
|
uTimeCurrent = me->m_timestamp;
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
send_event( me->m_event );
|
||||||
|
|
||||||
|
uTimeCurrent = me->m_timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( done < count )
|
||||||
|
{
|
||||||
|
unsigned long samples_todo;
|
||||||
|
if ( uStreamPosition < mStream.size() ) samples_todo = mStream[uStreamPosition].m_timestamp;
|
||||||
|
else samples_todo = uTimeEnd;
|
||||||
|
samples_todo -= uTimeCurrent;
|
||||||
|
if ( samples_todo > count - done ) samples_todo = count - done;
|
||||||
|
render( out + done * 2, samples_todo );
|
||||||
|
done += samples_todo;
|
||||||
|
}
|
||||||
|
|
||||||
|
uTimeCurrent = time_target;
|
||||||
|
|
||||||
|
if (uTimeCurrent >= uTimeEnd)
|
||||||
|
{
|
||||||
|
if ( uStreamPosition < mStream.size() )
|
||||||
|
{
|
||||||
|
for (; uStreamPosition < mStream.size(); uStreamPosition++)
|
||||||
|
{
|
||||||
|
send_event( mStream[ uStreamPosition ].m_event );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((uLoopMode & (loop_mode_enable | loop_mode_force)) == (loop_mode_enable | loop_mode_force))
|
||||||
|
{
|
||||||
|
if (uStreamLoopStart == ~0)
|
||||||
|
{
|
||||||
|
uStreamPosition = 0;
|
||||||
|
uTimeCurrent = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uStreamPosition = uStreamLoopStart;
|
||||||
|
uTimeCurrent = uTimeLoopStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MIDIPlayer::Seek(unsigned long sample)
|
||||||
|
{
|
||||||
|
if (sample >= uTimeEnd)
|
||||||
|
{
|
||||||
|
if ((uLoopMode & (loop_mode_enable | loop_mode_force)) == (loop_mode_enable | loop_mode_force))
|
||||||
|
{
|
||||||
|
while (sample >= uTimeEnd) sample -= uTimeEnd - uTimeLoopStart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sample = uTimeEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uTimeCurrent > sample)
|
||||||
|
{
|
||||||
|
// hokkai, let's kill any hanging notes
|
||||||
|
uStreamPosition = 0;
|
||||||
|
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!startup()) return;
|
||||||
|
|
||||||
|
uTimeCurrent = sample;
|
||||||
|
|
||||||
|
std::vector<midi_stream_event> filler;
|
||||||
|
|
||||||
|
unsigned long stream_start = uStreamPosition;
|
||||||
|
|
||||||
|
for (; uStreamPosition < mStream.size() && mStream[uStreamPosition].m_timestamp < uTimeCurrent; uStreamPosition++);
|
||||||
|
|
||||||
|
uSamplesRemaining = mStream[uStreamPosition].m_timestamp - uTimeCurrent;
|
||||||
|
|
||||||
|
if (uStreamPosition > stream_start)
|
||||||
|
{
|
||||||
|
filler.resize( uStreamPosition - stream_start );
|
||||||
|
filler.assign( &mStream[stream_start], &mStream[uStreamPosition] );
|
||||||
|
|
||||||
|
unsigned long i, j;
|
||||||
|
midi_stream_event * me = &filler[0];
|
||||||
|
|
||||||
|
for (i = 0, stream_start = uStreamPosition - stream_start; i < stream_start; i++)
|
||||||
|
{
|
||||||
|
midi_stream_event & e = me[i];
|
||||||
|
if ((e.m_event & 0x800000F0) == 0x90 && (e.m_event & 0xFF0000)) // note on
|
||||||
|
{
|
||||||
|
if ((e.m_event & 0x0F) == 9) // hax
|
||||||
|
{
|
||||||
|
e.m_event = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
uint32_t m = (e.m_event & 0x7F00FF0F) | 0x80; // note off
|
||||||
|
uint32_t m2 = e.m_event & 0x7F00FFFF; // also note off
|
||||||
|
for (j = i + 1; j < stream_start; j++)
|
||||||
|
{
|
||||||
|
midi_stream_event & e2 = me[j];
|
||||||
|
if ((e2.m_event & 0xFF00FFFF) == m || e2.m_event == m2)
|
||||||
|
{
|
||||||
|
// kill 'em
|
||||||
|
e.m_event = 0;
|
||||||
|
e2.m_event = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < stream_start; i++)
|
||||||
|
{
|
||||||
|
if (me[i].m_event)
|
||||||
|
send_event(me[i].m_event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef __MIDIPlayer_h__
|
||||||
|
#define __MIDIPlayer_h__
|
||||||
|
|
||||||
|
#include <midi_processing/midi_container.h>
|
||||||
|
|
||||||
|
class MIDIPlayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
loop_mode_enable = 1 << 0,
|
||||||
|
loop_mode_force = 1 << 1
|
||||||
|
};
|
||||||
|
|
||||||
|
// zero variables
|
||||||
|
MIDIPlayer();
|
||||||
|
|
||||||
|
// close, unload
|
||||||
|
virtual ~MIDIPlayer() {};
|
||||||
|
|
||||||
|
// setup
|
||||||
|
void setSampleRate(unsigned long rate);
|
||||||
|
|
||||||
|
bool Load(const midi_container & midi_file, unsigned subsong, unsigned loop_mode, unsigned clean_flags);
|
||||||
|
unsigned long Play(float * out, unsigned long count);
|
||||||
|
void Seek(unsigned long sample);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void send_event(uint32_t b) {}
|
||||||
|
virtual void render(float * out, unsigned long count) {}
|
||||||
|
|
||||||
|
virtual void shutdown() {};
|
||||||
|
virtual bool startup() {return false;}
|
||||||
|
|
||||||
|
unsigned long uSampleRate;
|
||||||
|
system_exclusive_table mSysexMap;
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned long uSamplesRemaining;
|
||||||
|
|
||||||
|
unsigned uLoopMode;
|
||||||
|
|
||||||
|
std::vector<midi_stream_event> mStream;
|
||||||
|
|
||||||
|
unsigned long uStreamPosition;
|
||||||
|
unsigned long uTimeCurrent;
|
||||||
|
unsigned long uTimeEnd;
|
||||||
|
|
||||||
|
unsigned long uStreamLoopStart;
|
||||||
|
unsigned long uTimeLoopStart;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
/* Localized versions of Info.plist keys */
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"Playlist" = "Playlist";
|
"Playlist" = "Playlist";
|
||||||
"Growl" = "Growl";
|
"Growl" = "Growl";
|
||||||
"Appearance" = "Appearance";
|
"Appearance" = "Appearance";
|
||||||
|
"MIDI" = "MIDI";
|
||||||
|
|
||||||
"Press Key..." = "Press Key...";
|
"Press Key..." = "Press Key...";
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<outlet property="appearanceView" destination="CgN-sy-RmM" id="wvB-aW-Gfx"/>
|
<outlet property="appearanceView" destination="CgN-sy-RmM" id="wvB-aW-Gfx"/>
|
||||||
<outlet property="growlView" destination="U4w-jw-ca5" id="IUJ-gB-jwT"/>
|
<outlet property="growlView" destination="U4w-jw-ca5" id="IUJ-gB-jwT"/>
|
||||||
<outlet property="hotKeyPane" destination="6" id="14"/>
|
<outlet property="hotKeyPane" destination="6" id="14"/>
|
||||||
|
<outlet property="midiPane" destination="i5B-ga-Atm" id="rbe-uK-5n2"/>
|
||||||
<outlet property="outputPane" destination="57" id="75"/>
|
<outlet property="outputPane" destination="57" id="75"/>
|
||||||
<outlet property="playlistView" destination="231" id="244"/>
|
<outlet property="playlistView" destination="231" id="244"/>
|
||||||
<outlet property="remoteView" destination="43" id="100"/>
|
<outlet property="remoteView" destination="43" id="100"/>
|
||||||
|
@ -267,6 +268,11 @@
|
||||||
</popUpButton>
|
</popUpButton>
|
||||||
</subviews>
|
</subviews>
|
||||||
</customView>
|
</customView>
|
||||||
|
<customObject id="i5B-ga-Atm" userLabel="MIDIPane" customClass="MIDIPane">
|
||||||
|
<connections>
|
||||||
|
<outlet property="view" destination="JXu-ar-J3Y" id="Jal-Yh-Yg3"/>
|
||||||
|
</connections>
|
||||||
|
</customObject>
|
||||||
<arrayController id="59" userLabel="OutputDevices" customClass="OutputsArrayController">
|
<arrayController id="59" userLabel="OutputDevices" customClass="OutputsArrayController">
|
||||||
<declaredKeys>
|
<declaredKeys>
|
||||||
<string>name</string>
|
<string>name</string>
|
||||||
|
@ -442,5 +448,22 @@
|
||||||
</button>
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
</customView>
|
</customView>
|
||||||
|
<customView id="JXu-ar-J3Y" userLabel="MIDIView">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="432" height="54"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<button verticalHuggingPriority="750" id="SBO-WF-DVS" userLabel="Push Button - Select a SoundFont">
|
||||||
|
<rect key="frame" x="136" y="10" width="160" height="32"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<buttonCell key="cell" type="push" title="Select a SoundFont" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="yeL-9c-lFq" userLabel="Button Cell - Select a SoundFont">
|
||||||
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
</buttonCell>
|
||||||
|
<connections>
|
||||||
|
<action selector="setSoundFont:" target="i5B-ga-Atm" id="b2t-MX-dua"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
</subviews>
|
||||||
|
</customView>
|
||||||
</objects>
|
</objects>
|
||||||
</document>
|
</document>
|
|
@ -22,6 +22,8 @@
|
||||||
8384917718084D9F00E7332D /* appearance.png in Resources */ = {isa = PBXBuildFile; fileRef = 8384917518084D9F00E7332D /* appearance.png */; };
|
8384917718084D9F00E7332D /* appearance.png in Resources */ = {isa = PBXBuildFile; fileRef = 8384917518084D9F00E7332D /* appearance.png */; };
|
||||||
8384917818084D9F00E7332D /* growl.png in Resources */ = {isa = PBXBuildFile; fileRef = 8384917618084D9F00E7332D /* growl.png */; };
|
8384917818084D9F00E7332D /* growl.png in Resources */ = {isa = PBXBuildFile; fileRef = 8384917618084D9F00E7332D /* growl.png */; };
|
||||||
8384918C1808596A00E7332D /* NDHotKey.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 838491841808588D00E7332D /* NDHotKey.framework */; };
|
8384918C1808596A00E7332D /* NDHotKey.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 838491841808588D00E7332D /* NDHotKey.framework */; };
|
||||||
|
83B06729180D85B8008E3612 /* MIDIPane.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B06728180D85B8008E3612 /* MIDIPane.m */; };
|
||||||
|
83B0672B180D8B39008E3612 /* midi.png in Resources */ = {isa = PBXBuildFile; fileRef = 83B0672A180D8B39008E3612 /* midi.png */; };
|
||||||
83EF495F17FBC96A00642E3C /* VolumeBehaviorArrayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83EF495E17FBC96A00642E3C /* VolumeBehaviorArrayController.m */; };
|
83EF495F17FBC96A00642E3C /* VolumeBehaviorArrayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83EF495E17FBC96A00642E3C /* VolumeBehaviorArrayController.m */; };
|
||||||
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
||||||
8E07AA880AAC8EA200A4B32F /* HotKeyPane.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E07AA810AAC8EA200A4B32F /* HotKeyPane.m */; };
|
8E07AA880AAC8EA200A4B32F /* HotKeyPane.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E07AA810AAC8EA200A4B32F /* HotKeyPane.m */; };
|
||||||
|
@ -89,6 +91,9 @@
|
||||||
8384917518084D9F00E7332D /* appearance.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = appearance.png; path = Icons/appearance.png; sourceTree = "<group>"; };
|
8384917518084D9F00E7332D /* appearance.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = appearance.png; path = Icons/appearance.png; sourceTree = "<group>"; };
|
||||||
8384917618084D9F00E7332D /* growl.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = growl.png; path = Icons/growl.png; sourceTree = "<group>"; };
|
8384917618084D9F00E7332D /* growl.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = growl.png; path = Icons/growl.png; sourceTree = "<group>"; };
|
||||||
8384917F1808588D00E7332D /* NDHotKey.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = NDHotKey.xcodeproj; path = ../../Frameworks/NDHotKey/NDHotKey.xcodeproj; sourceTree = "<group>"; };
|
8384917F1808588D00E7332D /* NDHotKey.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = NDHotKey.xcodeproj; path = ../../Frameworks/NDHotKey/NDHotKey.xcodeproj; sourceTree = "<group>"; };
|
||||||
|
83B06727180D85B8008E3612 /* MIDIPane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIPane.h; sourceTree = "<group>"; };
|
||||||
|
83B06728180D85B8008E3612 /* MIDIPane.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIDIPane.m; sourceTree = "<group>"; };
|
||||||
|
83B0672A180D8B39008E3612 /* midi.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = midi.png; path = Icons/midi.png; sourceTree = "<group>"; };
|
||||||
83EF495D17FBC96A00642E3C /* VolumeBehaviorArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VolumeBehaviorArrayController.h; sourceTree = "<group>"; };
|
83EF495D17FBC96A00642E3C /* VolumeBehaviorArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VolumeBehaviorArrayController.h; sourceTree = "<group>"; };
|
||||||
83EF495E17FBC96A00642E3C /* VolumeBehaviorArrayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VolumeBehaviorArrayController.m; sourceTree = "<group>"; };
|
83EF495E17FBC96A00642E3C /* VolumeBehaviorArrayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VolumeBehaviorArrayController.m; sourceTree = "<group>"; };
|
||||||
8D5B49B6048680CD000E48DA /* General.preferencePane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = General.preferencePane; sourceTree = BUILT_PRODUCTS_DIR; };
|
8D5B49B6048680CD000E48DA /* General.preferencePane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = General.preferencePane; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
@ -197,6 +202,8 @@
|
||||||
8E07AA810AAC8EA200A4B32F /* HotKeyPane.m */,
|
8E07AA810AAC8EA200A4B32F /* HotKeyPane.m */,
|
||||||
17C6433D0B8A783F00C53518 /* OutputPane.h */,
|
17C6433D0B8A783F00C53518 /* OutputPane.h */,
|
||||||
17C6433E0B8A783F00C53518 /* OutputPane.m */,
|
17C6433E0B8A783F00C53518 /* OutputPane.m */,
|
||||||
|
83B06727180D85B8008E3612 /* MIDIPane.h */,
|
||||||
|
83B06728180D85B8008E3612 /* MIDIPane.m */,
|
||||||
);
|
);
|
||||||
name = Panes;
|
name = Panes;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -245,6 +252,7 @@
|
||||||
8E07ABD90AAC95AF00A4B32F /* Icons */ = {
|
8E07ABD90AAC95AF00A4B32F /* Icons */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
83B0672A180D8B39008E3612 /* midi.png */,
|
||||||
8384917518084D9F00E7332D /* appearance.png */,
|
8384917518084D9F00E7332D /* appearance.png */,
|
||||||
8384917618084D9F00E7332D /* growl.png */,
|
8384917618084D9F00E7332D /* growl.png */,
|
||||||
17C7E5AF0DCCC30A003CBCF7 /* playlist.png */,
|
17C7E5AF0DCCC30A003CBCF7 /* playlist.png */,
|
||||||
|
@ -333,6 +341,7 @@
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
83B0672B180D8B39008E3612 /* midi.png in Resources */,
|
||||||
178E386E0C3DA64500EE6711 /* InfoPlist.strings in Resources */,
|
178E386E0C3DA64500EE6711 /* InfoPlist.strings in Resources */,
|
||||||
8E07ABDD0AAC95BC00A4B32F /* hot_keys.png in Resources */,
|
8E07ABDD0AAC95BC00A4B32F /* hot_keys.png in Resources */,
|
||||||
172D72AD0B8926CA00D095BB /* apple_remote.png in Resources */,
|
172D72AD0B8926CA00D095BB /* apple_remote.png in Resources */,
|
||||||
|
@ -355,6 +364,7 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
83B06729180D85B8008E3612 /* MIDIPane.m in Sources */,
|
||||||
8E07AA880AAC8EA200A4B32F /* HotKeyPane.m in Sources */,
|
8E07AA880AAC8EA200A4B32F /* HotKeyPane.m in Sources */,
|
||||||
8E07AA890AAC8EA200A4B32F /* GeneralPreferencePane.m in Sources */,
|
8E07AA890AAC8EA200A4B32F /* GeneralPreferencePane.m in Sources */,
|
||||||
8E07AA8A0AAC8EA200A4B32F /* GeneralPreferencesPlugin.m in Sources */,
|
8E07AA8A0AAC8EA200A4B32F /* GeneralPreferencesPlugin.m in Sources */,
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
|
|
||||||
#import "HotKeyPane.h"
|
#import "HotKeyPane.h"
|
||||||
#import "OutputPane.h"
|
#import "OutputPane.h"
|
||||||
|
#import "MIDIPane.h"
|
||||||
|
|
||||||
@interface GeneralPreferencesPlugin : NSObject <PreferencePanePlugin> {
|
@interface GeneralPreferencesPlugin : NSObject <PreferencePanePlugin> {
|
||||||
IBOutlet HotKeyPane *hotKeyPane;
|
IBOutlet HotKeyPane *hotKeyPane;
|
||||||
IBOutlet OutputPane *outputPane;
|
IBOutlet OutputPane *outputPane;
|
||||||
|
IBOutlet MIDIPane *midiPane;
|
||||||
|
|
||||||
IBOutlet NSView *playlistView;
|
IBOutlet NSView *playlistView;
|
||||||
IBOutlet NSView *scrobblerView;
|
IBOutlet NSView *scrobblerView;
|
||||||
|
@ -23,10 +25,12 @@
|
||||||
IBOutlet NSView *updatesView;
|
IBOutlet NSView *updatesView;
|
||||||
IBOutlet NSView *growlView;
|
IBOutlet NSView *growlView;
|
||||||
IBOutlet NSView *appearanceView;
|
IBOutlet NSView *appearanceView;
|
||||||
|
IBOutlet NSView *midiView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (HotKeyPane *)hotKeyPane;
|
- (HotKeyPane *)hotKeyPane;
|
||||||
- (OutputPane *)outputPane;
|
- (OutputPane *)outputPane;
|
||||||
|
- (MIDIPane *)midiPane;
|
||||||
|
|
||||||
- (GeneralPreferencePane *)remotePane;
|
- (GeneralPreferencePane *)remotePane;
|
||||||
- (GeneralPreferencePane *)updatesPane;
|
- (GeneralPreferencePane *)updatesPane;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
[plugin scrobblerPane],
|
[plugin scrobblerPane],
|
||||||
[plugin growlPane],
|
[plugin growlPane],
|
||||||
[plugin appearancePane],
|
[plugin appearancePane],
|
||||||
|
[plugin midiPane],
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +38,11 @@
|
||||||
return outputPane;
|
return outputPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (MIDIPane *)midiPane
|
||||||
|
{
|
||||||
|
return midiPane;
|
||||||
|
}
|
||||||
|
|
||||||
- (GeneralPreferencePane *)remotePane
|
- (GeneralPreferencePane *)remotePane
|
||||||
{
|
{
|
||||||
return [GeneralPreferencePane preferencePaneWithView:remoteView title:NSLocalizedStringFromTableInBundle(@"Remote", nil, [NSBundle bundleForClass:[self class]], @"") iconNamed:@"apple_remote"];
|
return [GeneralPreferencePane preferencePaneWithView:remoteView title:NSLocalizedStringFromTableInBundle(@"Remote", nil, [NSBundle bundleForClass:[self class]], @"") iconNamed:@"apple_remote"];
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// MIDIPane.h
|
||||||
|
// General
|
||||||
|
//
|
||||||
|
// Created by Christopher Snowhill on 10/15/13.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import "GeneralPreferencePane.h"
|
||||||
|
|
||||||
|
@interface MIDIPane : GeneralPreferencePane {
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)setSoundFont:(id)sender;
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,42 @@
|
||||||
|
//
|
||||||
|
// MIDIPane.m
|
||||||
|
// General
|
||||||
|
//
|
||||||
|
// Created by Christopher Snowhill on 10/15/13.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MIDIPane.h"
|
||||||
|
|
||||||
|
@implementation MIDIPane
|
||||||
|
|
||||||
|
- (NSString *)title
|
||||||
|
{
|
||||||
|
return NSLocalizedStringFromTableInBundle(@"MIDI", nil, [NSBundle bundleForClass:[self class]], @"");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSImage *)icon
|
||||||
|
{
|
||||||
|
return [[[NSImage alloc] initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForImageResource:@"midi"]] autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction)setSoundFont:(id)sender
|
||||||
|
{
|
||||||
|
NSArray *fileTypes = [NSArray arrayWithObjects:@"sf2",@"sf2pack",@"sflist",nil];
|
||||||
|
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||||
|
[panel setAllowsMultipleSelection:NO];
|
||||||
|
[panel setCanChooseDirectories:NO];
|
||||||
|
[panel setCanChooseFiles:YES];
|
||||||
|
[panel setFloatingPanel:YES];
|
||||||
|
[panel setAllowedFileTypes:fileTypes];
|
||||||
|
NSString * oldPath = [[NSUserDefaults standardUserDefaults] stringForKey:@"soundFontPath"];
|
||||||
|
if ( oldPath != nil )
|
||||||
|
[panel setDirectoryURL:[NSURL fileURLWithPath:oldPath]];
|
||||||
|
NSInteger result = [panel runModal];
|
||||||
|
if(result == NSOKButton)
|
||||||
|
{
|
||||||
|
[[NSUserDefaults standardUserDefaults] setValue:[[panel URL] path] forKey:@"soundFontPath"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,990 @@
|
||||||
|
/*
|
||||||
|
BASS 2.4 C/C++ header file
|
||||||
|
Copyright (c) 1999-2013 Un4seen Developments Ltd.
|
||||||
|
|
||||||
|
See the BASS.CHM file for more detailed documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BASS_H
|
||||||
|
#define BASS_H
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <wtypes.h>
|
||||||
|
typedef unsigned __int64 QWORD;
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#define WINAPI
|
||||||
|
#define CALLBACK
|
||||||
|
typedef uint8_t BYTE;
|
||||||
|
typedef uint16_t WORD;
|
||||||
|
typedef uint32_t DWORD;
|
||||||
|
typedef uint64_t QWORD;
|
||||||
|
#ifndef __OBJC__
|
||||||
|
typedef int BOOL;
|
||||||
|
#endif
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
#define LOBYTE(a) (BYTE)(a)
|
||||||
|
#define HIBYTE(a) (BYTE)((a)>>8)
|
||||||
|
#define LOWORD(a) (WORD)(a)
|
||||||
|
#define HIWORD(a) (WORD)((a)>>16)
|
||||||
|
#define MAKEWORD(a,b) (WORD)(((a)&0xff)|((b)<<8))
|
||||||
|
#define MAKELONG(a,b) (DWORD)(((a)&0xffff)|((b)<<16))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BASSVERSION 0x204 // API version
|
||||||
|
#define BASSVERSIONTEXT "2.4"
|
||||||
|
|
||||||
|
#ifndef BASSDEF
|
||||||
|
#define BASSDEF(f) WINAPI f
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef DWORD HMUSIC; // MOD music handle
|
||||||
|
typedef DWORD HSAMPLE; // sample handle
|
||||||
|
typedef DWORD HCHANNEL; // playing sample's channel handle
|
||||||
|
typedef DWORD HSTREAM; // sample stream handle
|
||||||
|
typedef DWORD HRECORD; // recording handle
|
||||||
|
typedef DWORD HSYNC; // synchronizer handle
|
||||||
|
typedef DWORD HDSP; // DSP handle
|
||||||
|
typedef DWORD HFX; // DX8 effect handle
|
||||||
|
typedef DWORD HPLUGIN; // Plugin handle
|
||||||
|
|
||||||
|
// Error codes returned by BASS_ErrorGetCode
|
||||||
|
#define BASS_OK 0 // all is OK
|
||||||
|
#define BASS_ERROR_MEM 1 // memory error
|
||||||
|
#define BASS_ERROR_FILEOPEN 2 // can't open the file
|
||||||
|
#define BASS_ERROR_DRIVER 3 // can't find a free/valid driver
|
||||||
|
#define BASS_ERROR_BUFLOST 4 // the sample buffer was lost
|
||||||
|
#define BASS_ERROR_HANDLE 5 // invalid handle
|
||||||
|
#define BASS_ERROR_FORMAT 6 // unsupported sample format
|
||||||
|
#define BASS_ERROR_POSITION 7 // invalid position
|
||||||
|
#define BASS_ERROR_INIT 8 // BASS_Init has not been successfully called
|
||||||
|
#define BASS_ERROR_START 9 // BASS_Start has not been successfully called
|
||||||
|
#define BASS_ERROR_ALREADY 14 // already initialized/paused/whatever
|
||||||
|
#define BASS_ERROR_NOCHAN 18 // can't get a free channel
|
||||||
|
#define BASS_ERROR_ILLTYPE 19 // an illegal type was specified
|
||||||
|
#define BASS_ERROR_ILLPARAM 20 // an illegal parameter was specified
|
||||||
|
#define BASS_ERROR_NO3D 21 // no 3D support
|
||||||
|
#define BASS_ERROR_NOEAX 22 // no EAX support
|
||||||
|
#define BASS_ERROR_DEVICE 23 // illegal device number
|
||||||
|
#define BASS_ERROR_NOPLAY 24 // not playing
|
||||||
|
#define BASS_ERROR_FREQ 25 // illegal sample rate
|
||||||
|
#define BASS_ERROR_NOTFILE 27 // the stream is not a file stream
|
||||||
|
#define BASS_ERROR_NOHW 29 // no hardware voices available
|
||||||
|
#define BASS_ERROR_EMPTY 31 // the MOD music has no sequence data
|
||||||
|
#define BASS_ERROR_NONET 32 // no internet connection could be opened
|
||||||
|
#define BASS_ERROR_CREATE 33 // couldn't create the file
|
||||||
|
#define BASS_ERROR_NOFX 34 // effects are not available
|
||||||
|
#define BASS_ERROR_NOTAVAIL 37 // requested data is not available
|
||||||
|
#define BASS_ERROR_DECODE 38 // the channel is/isn't a "decoding channel"
|
||||||
|
#define BASS_ERROR_DX 39 // a sufficient DirectX version is not installed
|
||||||
|
#define BASS_ERROR_TIMEOUT 40 // connection timedout
|
||||||
|
#define BASS_ERROR_FILEFORM 41 // unsupported file format
|
||||||
|
#define BASS_ERROR_SPEAKER 42 // unavailable speaker
|
||||||
|
#define BASS_ERROR_VERSION 43 // invalid BASS version (used by add-ons)
|
||||||
|
#define BASS_ERROR_CODEC 44 // codec is not available/supported
|
||||||
|
#define BASS_ERROR_ENDED 45 // the channel/file has ended
|
||||||
|
#define BASS_ERROR_BUSY 46 // the device is busy
|
||||||
|
#define BASS_ERROR_UNKNOWN -1 // some other mystery problem
|
||||||
|
|
||||||
|
// BASS_SetConfig options
|
||||||
|
#define BASS_CONFIG_BUFFER 0
|
||||||
|
#define BASS_CONFIG_UPDATEPERIOD 1
|
||||||
|
#define BASS_CONFIG_GVOL_SAMPLE 4
|
||||||
|
#define BASS_CONFIG_GVOL_STREAM 5
|
||||||
|
#define BASS_CONFIG_GVOL_MUSIC 6
|
||||||
|
#define BASS_CONFIG_CURVE_VOL 7
|
||||||
|
#define BASS_CONFIG_CURVE_PAN 8
|
||||||
|
#define BASS_CONFIG_FLOATDSP 9
|
||||||
|
#define BASS_CONFIG_3DALGORITHM 10
|
||||||
|
#define BASS_CONFIG_NET_TIMEOUT 11
|
||||||
|
#define BASS_CONFIG_NET_BUFFER 12
|
||||||
|
#define BASS_CONFIG_PAUSE_NOPLAY 13
|
||||||
|
#define BASS_CONFIG_NET_PREBUF 15
|
||||||
|
#define BASS_CONFIG_NET_PASSIVE 18
|
||||||
|
#define BASS_CONFIG_REC_BUFFER 19
|
||||||
|
#define BASS_CONFIG_NET_PLAYLIST 21
|
||||||
|
#define BASS_CONFIG_MUSIC_VIRTUAL 22
|
||||||
|
#define BASS_CONFIG_VERIFY 23
|
||||||
|
#define BASS_CONFIG_UPDATETHREADS 24
|
||||||
|
#define BASS_CONFIG_DEV_BUFFER 27
|
||||||
|
#define BASS_CONFIG_VISTA_TRUEPOS 30
|
||||||
|
#define BASS_CONFIG_IOS_MIXAUDIO 34
|
||||||
|
#define BASS_CONFIG_DEV_DEFAULT 36
|
||||||
|
#define BASS_CONFIG_NET_READTIMEOUT 37
|
||||||
|
#define BASS_CONFIG_VISTA_SPEAKERS 38
|
||||||
|
#define BASS_CONFIG_IOS_SPEAKER 39
|
||||||
|
#define BASS_CONFIG_HANDLES 41
|
||||||
|
#define BASS_CONFIG_UNICODE 42
|
||||||
|
#define BASS_CONFIG_SRC 43
|
||||||
|
#define BASS_CONFIG_SRC_SAMPLE 44
|
||||||
|
#define BASS_CONFIG_ASYNCFILE_BUFFER 45
|
||||||
|
#define BASS_CONFIG_OGG_PRESCAN 47
|
||||||
|
|
||||||
|
// BASS_SetConfigPtr options
|
||||||
|
#define BASS_CONFIG_NET_AGENT 16
|
||||||
|
#define BASS_CONFIG_NET_PROXY 17
|
||||||
|
#define BASS_CONFIG_IOS_NOTIFY 46
|
||||||
|
|
||||||
|
// BASS_Init flags
|
||||||
|
#define BASS_DEVICE_8BITS 1 // 8 bit resolution, else 16 bit
|
||||||
|
#define BASS_DEVICE_MONO 2 // mono, else stereo
|
||||||
|
#define BASS_DEVICE_3D 4 // enable 3D functionality
|
||||||
|
#define BASS_DEVICE_LATENCY 0x100 // calculate device latency (BASS_INFO struct)
|
||||||
|
#define BASS_DEVICE_CPSPEAKERS 0x400 // detect speakers via Windows control panel
|
||||||
|
#define BASS_DEVICE_SPEAKERS 0x800 // force enabling of speaker assignment
|
||||||
|
#define BASS_DEVICE_NOSPEAKER 0x1000 // ignore speaker arrangement
|
||||||
|
#define BASS_DEVICE_DMIX 0x2000 // use ALSA "dmix" plugin
|
||||||
|
#define BASS_DEVICE_FREQ 0x4000 // set device sample rate
|
||||||
|
|
||||||
|
// DirectSound interfaces (for use with BASS_GetDSoundObject)
|
||||||
|
#define BASS_OBJECT_DS 1 // IDirectSound
|
||||||
|
#define BASS_OBJECT_DS3DL 2 // IDirectSound3DListener
|
||||||
|
|
||||||
|
// Device info structure
|
||||||
|
typedef struct {
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
const wchar_t *name; // description
|
||||||
|
const wchar_t *driver; // driver
|
||||||
|
#else
|
||||||
|
const char *name; // description
|
||||||
|
const char *driver; // driver
|
||||||
|
#endif
|
||||||
|
DWORD flags;
|
||||||
|
} BASS_DEVICEINFO;
|
||||||
|
|
||||||
|
// BASS_DEVICEINFO flags
|
||||||
|
#define BASS_DEVICE_ENABLED 1
|
||||||
|
#define BASS_DEVICE_DEFAULT 2
|
||||||
|
#define BASS_DEVICE_INIT 4
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD flags; // device capabilities (DSCAPS_xxx flags)
|
||||||
|
DWORD hwsize; // size of total device hardware memory
|
||||||
|
DWORD hwfree; // size of free device hardware memory
|
||||||
|
DWORD freesam; // number of free sample slots in the hardware
|
||||||
|
DWORD free3d; // number of free 3D sample slots in the hardware
|
||||||
|
DWORD minrate; // min sample rate supported by the hardware
|
||||||
|
DWORD maxrate; // max sample rate supported by the hardware
|
||||||
|
BOOL eax; // device supports EAX? (always FALSE if BASS_DEVICE_3D was not used)
|
||||||
|
DWORD minbuf; // recommended minimum buffer length in ms (requires BASS_DEVICE_LATENCY)
|
||||||
|
DWORD dsver; // DirectSound version
|
||||||
|
DWORD latency; // delay (in ms) before start of playback (requires BASS_DEVICE_LATENCY)
|
||||||
|
DWORD initflags; // BASS_Init "flags" parameter
|
||||||
|
DWORD speakers; // number of speakers available
|
||||||
|
DWORD freq; // current output rate
|
||||||
|
} BASS_INFO;
|
||||||
|
|
||||||
|
// BASS_INFO flags (from DSOUND.H)
|
||||||
|
#define DSCAPS_CONTINUOUSRATE 0x00000010 // supports all sample rates between min/maxrate
|
||||||
|
#define DSCAPS_EMULDRIVER 0x00000020 // device does NOT have hardware DirectSound support
|
||||||
|
#define DSCAPS_CERTIFIED 0x00000040 // device driver has been certified by Microsoft
|
||||||
|
#define DSCAPS_SECONDARYMONO 0x00000100 // mono
|
||||||
|
#define DSCAPS_SECONDARYSTEREO 0x00000200 // stereo
|
||||||
|
#define DSCAPS_SECONDARY8BIT 0x00000400 // 8 bit
|
||||||
|
#define DSCAPS_SECONDARY16BIT 0x00000800 // 16 bit
|
||||||
|
|
||||||
|
// Recording device info structure
|
||||||
|
typedef struct {
|
||||||
|
DWORD flags; // device capabilities (DSCCAPS_xxx flags)
|
||||||
|
DWORD formats; // supported standard formats (WAVE_FORMAT_xxx flags)
|
||||||
|
DWORD inputs; // number of inputs
|
||||||
|
BOOL singlein; // TRUE = only 1 input can be set at a time
|
||||||
|
DWORD freq; // current input rate
|
||||||
|
} BASS_RECORDINFO;
|
||||||
|
|
||||||
|
// BASS_RECORDINFO flags (from DSOUND.H)
|
||||||
|
#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER // device does NOT have hardware DirectSound recording support
|
||||||
|
#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED // device driver has been certified by Microsoft
|
||||||
|
|
||||||
|
// defines for formats field of BASS_RECORDINFO (from MMSYSTEM.H)
|
||||||
|
#ifndef WAVE_FORMAT_1M08
|
||||||
|
#define WAVE_FORMAT_1M08 0x00000001 /* 11.025 kHz, Mono, 8-bit */
|
||||||
|
#define WAVE_FORMAT_1S08 0x00000002 /* 11.025 kHz, Stereo, 8-bit */
|
||||||
|
#define WAVE_FORMAT_1M16 0x00000004 /* 11.025 kHz, Mono, 16-bit */
|
||||||
|
#define WAVE_FORMAT_1S16 0x00000008 /* 11.025 kHz, Stereo, 16-bit */
|
||||||
|
#define WAVE_FORMAT_2M08 0x00000010 /* 22.05 kHz, Mono, 8-bit */
|
||||||
|
#define WAVE_FORMAT_2S08 0x00000020 /* 22.05 kHz, Stereo, 8-bit */
|
||||||
|
#define WAVE_FORMAT_2M16 0x00000040 /* 22.05 kHz, Mono, 16-bit */
|
||||||
|
#define WAVE_FORMAT_2S16 0x00000080 /* 22.05 kHz, Stereo, 16-bit */
|
||||||
|
#define WAVE_FORMAT_4M08 0x00000100 /* 44.1 kHz, Mono, 8-bit */
|
||||||
|
#define WAVE_FORMAT_4S08 0x00000200 /* 44.1 kHz, Stereo, 8-bit */
|
||||||
|
#define WAVE_FORMAT_4M16 0x00000400 /* 44.1 kHz, Mono, 16-bit */
|
||||||
|
#define WAVE_FORMAT_4S16 0x00000800 /* 44.1 kHz, Stereo, 16-bit */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Sample info structure
|
||||||
|
typedef struct {
|
||||||
|
DWORD freq; // default playback rate
|
||||||
|
float volume; // default volume (0-1)
|
||||||
|
float pan; // default pan (-1=left, 0=middle, 1=right)
|
||||||
|
DWORD flags; // BASS_SAMPLE_xxx flags
|
||||||
|
DWORD length; // length (in bytes)
|
||||||
|
DWORD max; // maximum simultaneous playbacks
|
||||||
|
DWORD origres; // original resolution bits
|
||||||
|
DWORD chans; // number of channels
|
||||||
|
DWORD mingap; // minimum gap (ms) between creating channels
|
||||||
|
DWORD mode3d; // BASS_3DMODE_xxx mode
|
||||||
|
float mindist; // minimum distance
|
||||||
|
float maxdist; // maximum distance
|
||||||
|
DWORD iangle; // angle of inside projection cone
|
||||||
|
DWORD oangle; // angle of outside projection cone
|
||||||
|
float outvol; // delta-volume outside the projection cone
|
||||||
|
DWORD vam; // voice allocation/management flags (BASS_VAM_xxx)
|
||||||
|
DWORD priority; // priority (0=lowest, 0xffffffff=highest)
|
||||||
|
} BASS_SAMPLE;
|
||||||
|
|
||||||
|
#define BASS_SAMPLE_8BITS 1 // 8 bit
|
||||||
|
#define BASS_SAMPLE_FLOAT 256 // 32-bit floating-point
|
||||||
|
#define BASS_SAMPLE_MONO 2 // mono
|
||||||
|
#define BASS_SAMPLE_LOOP 4 // looped
|
||||||
|
#define BASS_SAMPLE_3D 8 // 3D functionality
|
||||||
|
#define BASS_SAMPLE_SOFTWARE 16 // not using hardware mixing
|
||||||
|
#define BASS_SAMPLE_MUTEMAX 32 // mute at max distance (3D only)
|
||||||
|
#define BASS_SAMPLE_VAM 64 // DX7 voice allocation & management
|
||||||
|
#define BASS_SAMPLE_FX 128 // old implementation of DX8 effects
|
||||||
|
#define BASS_SAMPLE_OVER_VOL 0x10000 // override lowest volume
|
||||||
|
#define BASS_SAMPLE_OVER_POS 0x20000 // override longest playing
|
||||||
|
#define BASS_SAMPLE_OVER_DIST 0x30000 // override furthest from listener (3D only)
|
||||||
|
|
||||||
|
#define BASS_STREAM_PRESCAN 0x20000 // enable pin-point seeking/length (MP3/MP2/MP1)
|
||||||
|
#define BASS_MP3_SETPOS BASS_STREAM_PRESCAN
|
||||||
|
#define BASS_STREAM_AUTOFREE 0x40000 // automatically free the stream when it stop/ends
|
||||||
|
#define BASS_STREAM_RESTRATE 0x80000 // restrict the download rate of internet file streams
|
||||||
|
#define BASS_STREAM_BLOCK 0x100000 // download/play internet file stream in small blocks
|
||||||
|
#define BASS_STREAM_DECODE 0x200000 // don't play the stream, only decode (BASS_ChannelGetData)
|
||||||
|
#define BASS_STREAM_STATUS 0x800000 // give server status info (HTTP/ICY tags) in DOWNLOADPROC
|
||||||
|
|
||||||
|
#define BASS_MUSIC_FLOAT BASS_SAMPLE_FLOAT
|
||||||
|
#define BASS_MUSIC_MONO BASS_SAMPLE_MONO
|
||||||
|
#define BASS_MUSIC_LOOP BASS_SAMPLE_LOOP
|
||||||
|
#define BASS_MUSIC_3D BASS_SAMPLE_3D
|
||||||
|
#define BASS_MUSIC_FX BASS_SAMPLE_FX
|
||||||
|
#define BASS_MUSIC_AUTOFREE BASS_STREAM_AUTOFREE
|
||||||
|
#define BASS_MUSIC_DECODE BASS_STREAM_DECODE
|
||||||
|
#define BASS_MUSIC_PRESCAN BASS_STREAM_PRESCAN // calculate playback length
|
||||||
|
#define BASS_MUSIC_CALCLEN BASS_MUSIC_PRESCAN
|
||||||
|
#define BASS_MUSIC_RAMP 0x200 // normal ramping
|
||||||
|
#define BASS_MUSIC_RAMPS 0x400 // sensitive ramping
|
||||||
|
#define BASS_MUSIC_SURROUND 0x800 // surround sound
|
||||||
|
#define BASS_MUSIC_SURROUND2 0x1000 // surround sound (mode 2)
|
||||||
|
#define BASS_MUSIC_FT2MOD 0x2000 // play .MOD as FastTracker 2 does
|
||||||
|
#define BASS_MUSIC_PT1MOD 0x4000 // play .MOD as ProTracker 1 does
|
||||||
|
#define BASS_MUSIC_NONINTER 0x10000 // non-interpolated sample mixing
|
||||||
|
#define BASS_MUSIC_SINCINTER 0x800000 // sinc interpolated sample mixing
|
||||||
|
#define BASS_MUSIC_POSRESET 0x8000 // stop all notes when moving position
|
||||||
|
#define BASS_MUSIC_POSRESETEX 0x400000 // stop all notes and reset bmp/etc when moving position
|
||||||
|
#define BASS_MUSIC_STOPBACK 0x80000 // stop the music on a backwards jump effect
|
||||||
|
#define BASS_MUSIC_NOSAMPLE 0x100000 // don't load the samples
|
||||||
|
|
||||||
|
// Speaker assignment flags
|
||||||
|
#define BASS_SPEAKER_FRONT 0x1000000 // front speakers
|
||||||
|
#define BASS_SPEAKER_REAR 0x2000000 // rear/side speakers
|
||||||
|
#define BASS_SPEAKER_CENLFE 0x3000000 // center & LFE speakers (5.1)
|
||||||
|
#define BASS_SPEAKER_REAR2 0x4000000 // rear center speakers (7.1)
|
||||||
|
#define BASS_SPEAKER_N(n) ((n)<<24) // n'th pair of speakers (max 15)
|
||||||
|
#define BASS_SPEAKER_LEFT 0x10000000 // modifier: left
|
||||||
|
#define BASS_SPEAKER_RIGHT 0x20000000 // modifier: right
|
||||||
|
#define BASS_SPEAKER_FRONTLEFT BASS_SPEAKER_FRONT|BASS_SPEAKER_LEFT
|
||||||
|
#define BASS_SPEAKER_FRONTRIGHT BASS_SPEAKER_FRONT|BASS_SPEAKER_RIGHT
|
||||||
|
#define BASS_SPEAKER_REARLEFT BASS_SPEAKER_REAR|BASS_SPEAKER_LEFT
|
||||||
|
#define BASS_SPEAKER_REARRIGHT BASS_SPEAKER_REAR|BASS_SPEAKER_RIGHT
|
||||||
|
#define BASS_SPEAKER_CENTER BASS_SPEAKER_CENLFE|BASS_SPEAKER_LEFT
|
||||||
|
#define BASS_SPEAKER_LFE BASS_SPEAKER_CENLFE|BASS_SPEAKER_RIGHT
|
||||||
|
#define BASS_SPEAKER_REAR2LEFT BASS_SPEAKER_REAR2|BASS_SPEAKER_LEFT
|
||||||
|
#define BASS_SPEAKER_REAR2RIGHT BASS_SPEAKER_REAR2|BASS_SPEAKER_RIGHT
|
||||||
|
|
||||||
|
#define BASS_ASYNCFILE 0x40000000
|
||||||
|
#define BASS_UNICODE 0x80000000
|
||||||
|
|
||||||
|
#define BASS_RECORD_PAUSE 0x8000 // start recording paused
|
||||||
|
|
||||||
|
// DX7 voice allocation & management flags
|
||||||
|
#define BASS_VAM_HARDWARE 1
|
||||||
|
#define BASS_VAM_SOFTWARE 2
|
||||||
|
#define BASS_VAM_TERM_TIME 4
|
||||||
|
#define BASS_VAM_TERM_DIST 8
|
||||||
|
#define BASS_VAM_TERM_PRIO 16
|
||||||
|
|
||||||
|
// Channel info structure
|
||||||
|
typedef struct {
|
||||||
|
DWORD freq; // default playback rate
|
||||||
|
DWORD chans; // channels
|
||||||
|
DWORD flags; // BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags
|
||||||
|
DWORD ctype; // type of channel
|
||||||
|
DWORD origres; // original resolution
|
||||||
|
HPLUGIN plugin; // plugin
|
||||||
|
HSAMPLE sample; // sample
|
||||||
|
const char *filename; // filename
|
||||||
|
} BASS_CHANNELINFO;
|
||||||
|
|
||||||
|
// BASS_CHANNELINFO types
|
||||||
|
#define BASS_CTYPE_SAMPLE 1
|
||||||
|
#define BASS_CTYPE_RECORD 2
|
||||||
|
#define BASS_CTYPE_STREAM 0x10000
|
||||||
|
#define BASS_CTYPE_STREAM_OGG 0x10002
|
||||||
|
#define BASS_CTYPE_STREAM_MP1 0x10003
|
||||||
|
#define BASS_CTYPE_STREAM_MP2 0x10004
|
||||||
|
#define BASS_CTYPE_STREAM_MP3 0x10005
|
||||||
|
#define BASS_CTYPE_STREAM_AIFF 0x10006
|
||||||
|
#define BASS_CTYPE_STREAM_CA 0x10007
|
||||||
|
#define BASS_CTYPE_STREAM_MF 0x10008
|
||||||
|
#define BASS_CTYPE_STREAM_WAV 0x40000 // WAVE flag, LOWORD=codec
|
||||||
|
#define BASS_CTYPE_STREAM_WAV_PCM 0x50001
|
||||||
|
#define BASS_CTYPE_STREAM_WAV_FLOAT 0x50003
|
||||||
|
#define BASS_CTYPE_MUSIC_MOD 0x20000
|
||||||
|
#define BASS_CTYPE_MUSIC_MTM 0x20001
|
||||||
|
#define BASS_CTYPE_MUSIC_S3M 0x20002
|
||||||
|
#define BASS_CTYPE_MUSIC_XM 0x20003
|
||||||
|
#define BASS_CTYPE_MUSIC_IT 0x20004
|
||||||
|
#define BASS_CTYPE_MUSIC_MO3 0x00100 // MO3 flag
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD ctype; // channel type
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
const wchar_t *name; // format description
|
||||||
|
const wchar_t *exts; // file extension filter (*.ext1;*.ext2;etc...)
|
||||||
|
#else
|
||||||
|
const char *name; // format description
|
||||||
|
const char *exts; // file extension filter (*.ext1;*.ext2;etc...)
|
||||||
|
#endif
|
||||||
|
} BASS_PLUGINFORM;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD version; // version (same form as BASS_GetVersion)
|
||||||
|
DWORD formatc; // number of formats
|
||||||
|
const BASS_PLUGINFORM *formats; // the array of formats
|
||||||
|
} BASS_PLUGININFO;
|
||||||
|
|
||||||
|
// 3D vector (for 3D positions/velocities/orientations)
|
||||||
|
typedef struct BASS_3DVECTOR {
|
||||||
|
#ifdef __cplusplus
|
||||||
|
BASS_3DVECTOR() {};
|
||||||
|
BASS_3DVECTOR(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {};
|
||||||
|
#endif
|
||||||
|
float x; // +=right, -=left
|
||||||
|
float y; // +=up, -=down
|
||||||
|
float z; // +=front, -=behind
|
||||||
|
} BASS_3DVECTOR;
|
||||||
|
|
||||||
|
// 3D channel modes
|
||||||
|
#define BASS_3DMODE_NORMAL 0 // normal 3D processing
|
||||||
|
#define BASS_3DMODE_RELATIVE 1 // position is relative to the listener
|
||||||
|
#define BASS_3DMODE_OFF 2 // no 3D processing
|
||||||
|
|
||||||
|
// software 3D mixing algorithms (used with BASS_CONFIG_3DALGORITHM)
|
||||||
|
#define BASS_3DALG_DEFAULT 0
|
||||||
|
#define BASS_3DALG_OFF 1
|
||||||
|
#define BASS_3DALG_FULL 2
|
||||||
|
#define BASS_3DALG_LIGHT 3
|
||||||
|
|
||||||
|
// EAX environments, use with BASS_SetEAXParameters
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
EAX_ENVIRONMENT_GENERIC,
|
||||||
|
EAX_ENVIRONMENT_PADDEDCELL,
|
||||||
|
EAX_ENVIRONMENT_ROOM,
|
||||||
|
EAX_ENVIRONMENT_BATHROOM,
|
||||||
|
EAX_ENVIRONMENT_LIVINGROOM,
|
||||||
|
EAX_ENVIRONMENT_STONEROOM,
|
||||||
|
EAX_ENVIRONMENT_AUDITORIUM,
|
||||||
|
EAX_ENVIRONMENT_CONCERTHALL,
|
||||||
|
EAX_ENVIRONMENT_CAVE,
|
||||||
|
EAX_ENVIRONMENT_ARENA,
|
||||||
|
EAX_ENVIRONMENT_HANGAR,
|
||||||
|
EAX_ENVIRONMENT_CARPETEDHALLWAY,
|
||||||
|
EAX_ENVIRONMENT_HALLWAY,
|
||||||
|
EAX_ENVIRONMENT_STONECORRIDOR,
|
||||||
|
EAX_ENVIRONMENT_ALLEY,
|
||||||
|
EAX_ENVIRONMENT_FOREST,
|
||||||
|
EAX_ENVIRONMENT_CITY,
|
||||||
|
EAX_ENVIRONMENT_MOUNTAINS,
|
||||||
|
EAX_ENVIRONMENT_QUARRY,
|
||||||
|
EAX_ENVIRONMENT_PLAIN,
|
||||||
|
EAX_ENVIRONMENT_PARKINGLOT,
|
||||||
|
EAX_ENVIRONMENT_SEWERPIPE,
|
||||||
|
EAX_ENVIRONMENT_UNDERWATER,
|
||||||
|
EAX_ENVIRONMENT_DRUGGED,
|
||||||
|
EAX_ENVIRONMENT_DIZZY,
|
||||||
|
EAX_ENVIRONMENT_PSYCHOTIC,
|
||||||
|
|
||||||
|
EAX_ENVIRONMENT_COUNT // total number of environments
|
||||||
|
};
|
||||||
|
|
||||||
|
// EAX presets, usage: BASS_SetEAXParameters(EAX_PRESET_xxx)
|
||||||
|
#define EAX_PRESET_GENERIC EAX_ENVIRONMENT_GENERIC,0.5F,1.493F,0.5F
|
||||||
|
#define EAX_PRESET_PADDEDCELL EAX_ENVIRONMENT_PADDEDCELL,0.25F,0.1F,0.0F
|
||||||
|
#define EAX_PRESET_ROOM EAX_ENVIRONMENT_ROOM,0.417F,0.4F,0.666F
|
||||||
|
#define EAX_PRESET_BATHROOM EAX_ENVIRONMENT_BATHROOM,0.653F,1.499F,0.166F
|
||||||
|
#define EAX_PRESET_LIVINGROOM EAX_ENVIRONMENT_LIVINGROOM,0.208F,0.478F,0.0F
|
||||||
|
#define EAX_PRESET_STONEROOM EAX_ENVIRONMENT_STONEROOM,0.5F,2.309F,0.888F
|
||||||
|
#define EAX_PRESET_AUDITORIUM EAX_ENVIRONMENT_AUDITORIUM,0.403F,4.279F,0.5F
|
||||||
|
#define EAX_PRESET_CONCERTHALL EAX_ENVIRONMENT_CONCERTHALL,0.5F,3.961F,0.5F
|
||||||
|
#define EAX_PRESET_CAVE EAX_ENVIRONMENT_CAVE,0.5F,2.886F,1.304F
|
||||||
|
#define EAX_PRESET_ARENA EAX_ENVIRONMENT_ARENA,0.361F,7.284F,0.332F
|
||||||
|
#define EAX_PRESET_HANGAR EAX_ENVIRONMENT_HANGAR,0.5F,10.0F,0.3F
|
||||||
|
#define EAX_PRESET_CARPETEDHALLWAY EAX_ENVIRONMENT_CARPETEDHALLWAY,0.153F,0.259F,2.0F
|
||||||
|
#define EAX_PRESET_HALLWAY EAX_ENVIRONMENT_HALLWAY,0.361F,1.493F,0.0F
|
||||||
|
#define EAX_PRESET_STONECORRIDOR EAX_ENVIRONMENT_STONECORRIDOR,0.444F,2.697F,0.638F
|
||||||
|
#define EAX_PRESET_ALLEY EAX_ENVIRONMENT_ALLEY,0.25F,1.752F,0.776F
|
||||||
|
#define EAX_PRESET_FOREST EAX_ENVIRONMENT_FOREST,0.111F,3.145F,0.472F
|
||||||
|
#define EAX_PRESET_CITY EAX_ENVIRONMENT_CITY,0.111F,2.767F,0.224F
|
||||||
|
#define EAX_PRESET_MOUNTAINS EAX_ENVIRONMENT_MOUNTAINS,0.194F,7.841F,0.472F
|
||||||
|
#define EAX_PRESET_QUARRY EAX_ENVIRONMENT_QUARRY,1.0F,1.499F,0.5F
|
||||||
|
#define EAX_PRESET_PLAIN EAX_ENVIRONMENT_PLAIN,0.097F,2.767F,0.224F
|
||||||
|
#define EAX_PRESET_PARKINGLOT EAX_ENVIRONMENT_PARKINGLOT,0.208F,1.652F,1.5F
|
||||||
|
#define EAX_PRESET_SEWERPIPE EAX_ENVIRONMENT_SEWERPIPE,0.652F,2.886F,0.25F
|
||||||
|
#define EAX_PRESET_UNDERWATER EAX_ENVIRONMENT_UNDERWATER,1.0F,1.499F,0.0F
|
||||||
|
#define EAX_PRESET_DRUGGED EAX_ENVIRONMENT_DRUGGED,0.875F,8.392F,1.388F
|
||||||
|
#define EAX_PRESET_DIZZY EAX_ENVIRONMENT_DIZZY,0.139F,17.234F,0.666F
|
||||||
|
#define EAX_PRESET_PSYCHOTIC EAX_ENVIRONMENT_PSYCHOTIC,0.486F,7.563F,0.806F
|
||||||
|
|
||||||
|
typedef DWORD (CALLBACK STREAMPROC)(HSTREAM handle, void *buffer, DWORD length, void *user);
|
||||||
|
/* User stream callback function. NOTE: A stream function should obviously be as quick
|
||||||
|
as possible, other streams (and MOD musics) can't be mixed until it's finished.
|
||||||
|
handle : The stream that needs writing
|
||||||
|
buffer : Buffer to write the samples in
|
||||||
|
length : Number of bytes to write
|
||||||
|
user : The 'user' parameter value given when calling BASS_StreamCreate
|
||||||
|
RETURN : Number of bytes written. Set the BASS_STREAMPROC_END flag to end
|
||||||
|
the stream. */
|
||||||
|
|
||||||
|
#define BASS_STREAMPROC_END 0x80000000 // end of user stream flag
|
||||||
|
|
||||||
|
// special STREAMPROCs
|
||||||
|
#define STREAMPROC_DUMMY (STREAMPROC*)0 // "dummy" stream
|
||||||
|
#define STREAMPROC_PUSH (STREAMPROC*)-1 // push stream
|
||||||
|
|
||||||
|
// BASS_StreamCreateFileUser file systems
|
||||||
|
#define STREAMFILE_NOBUFFER 0
|
||||||
|
#define STREAMFILE_BUFFER 1
|
||||||
|
#define STREAMFILE_BUFFERPUSH 2
|
||||||
|
|
||||||
|
// User file stream callback functions
|
||||||
|
typedef void (CALLBACK FILECLOSEPROC)(void *user);
|
||||||
|
typedef QWORD (CALLBACK FILELENPROC)(void *user);
|
||||||
|
typedef DWORD (CALLBACK FILEREADPROC)(void *buffer, DWORD length, void *user);
|
||||||
|
typedef BOOL (CALLBACK FILESEEKPROC)(QWORD offset, void *user);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FILECLOSEPROC *close;
|
||||||
|
FILELENPROC *length;
|
||||||
|
FILEREADPROC *read;
|
||||||
|
FILESEEKPROC *seek;
|
||||||
|
} BASS_FILEPROCS;
|
||||||
|
|
||||||
|
// BASS_StreamPutFileData options
|
||||||
|
#define BASS_FILEDATA_END 0 // end & close the file
|
||||||
|
|
||||||
|
// BASS_StreamGetFilePosition modes
|
||||||
|
#define BASS_FILEPOS_CURRENT 0
|
||||||
|
#define BASS_FILEPOS_DECODE BASS_FILEPOS_CURRENT
|
||||||
|
#define BASS_FILEPOS_DOWNLOAD 1
|
||||||
|
#define BASS_FILEPOS_END 2
|
||||||
|
#define BASS_FILEPOS_START 3
|
||||||
|
#define BASS_FILEPOS_CONNECTED 4
|
||||||
|
#define BASS_FILEPOS_BUFFER 5
|
||||||
|
#define BASS_FILEPOS_SOCKET 6
|
||||||
|
|
||||||
|
typedef void (CALLBACK DOWNLOADPROC)(const void *buffer, DWORD length, void *user);
|
||||||
|
/* Internet stream download callback function.
|
||||||
|
buffer : Buffer containing the downloaded data... NULL=end of download
|
||||||
|
length : Number of bytes in the buffer
|
||||||
|
user : The 'user' parameter value given when calling BASS_StreamCreateURL */
|
||||||
|
|
||||||
|
// BASS_ChannelSetSync types
|
||||||
|
#define BASS_SYNC_POS 0
|
||||||
|
#define BASS_SYNC_END 2
|
||||||
|
#define BASS_SYNC_META 4
|
||||||
|
#define BASS_SYNC_SLIDE 5
|
||||||
|
#define BASS_SYNC_STALL 6
|
||||||
|
#define BASS_SYNC_DOWNLOAD 7
|
||||||
|
#define BASS_SYNC_FREE 8
|
||||||
|
#define BASS_SYNC_SETPOS 11
|
||||||
|
#define BASS_SYNC_MUSICPOS 10
|
||||||
|
#define BASS_SYNC_MUSICINST 1
|
||||||
|
#define BASS_SYNC_MUSICFX 3
|
||||||
|
#define BASS_SYNC_OGG_CHANGE 12
|
||||||
|
#define BASS_SYNC_MIXTIME 0x40000000 // FLAG: sync at mixtime, else at playtime
|
||||||
|
#define BASS_SYNC_ONETIME 0x80000000 // FLAG: sync only once, else continuously
|
||||||
|
|
||||||
|
typedef void (CALLBACK SYNCPROC)(HSYNC handle, DWORD channel, DWORD data, void *user);
|
||||||
|
/* Sync callback function. NOTE: a sync callback function should be very
|
||||||
|
quick as other syncs can't be processed until it has finished. If the sync
|
||||||
|
is a "mixtime" sync, then other streams and MOD musics can't be mixed until
|
||||||
|
it's finished either.
|
||||||
|
handle : The sync that has occured
|
||||||
|
channel: Channel that the sync occured in
|
||||||
|
data : Additional data associated with the sync's occurance
|
||||||
|
user : The 'user' parameter given when calling BASS_ChannelSetSync */
|
||||||
|
|
||||||
|
typedef void (CALLBACK DSPPROC)(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user);
|
||||||
|
/* DSP callback function. NOTE: A DSP function should obviously be as quick as
|
||||||
|
possible... other DSP functions, streams and MOD musics can not be processed
|
||||||
|
until it's finished.
|
||||||
|
handle : The DSP handle
|
||||||
|
channel: Channel that the DSP is being applied to
|
||||||
|
buffer : Buffer to apply the DSP to
|
||||||
|
length : Number of bytes in the buffer
|
||||||
|
user : The 'user' parameter given when calling BASS_ChannelSetDSP */
|
||||||
|
|
||||||
|
typedef BOOL (CALLBACK RECORDPROC)(HRECORD handle, const void *buffer, DWORD length, void *user);
|
||||||
|
/* Recording callback function.
|
||||||
|
handle : The recording handle
|
||||||
|
buffer : Buffer containing the recorded sample data
|
||||||
|
length : Number of bytes
|
||||||
|
user : The 'user' parameter value given when calling BASS_RecordStart
|
||||||
|
RETURN : TRUE = continue recording, FALSE = stop */
|
||||||
|
|
||||||
|
// BASS_ChannelIsActive return values
|
||||||
|
#define BASS_ACTIVE_STOPPED 0
|
||||||
|
#define BASS_ACTIVE_PLAYING 1
|
||||||
|
#define BASS_ACTIVE_STALLED 2
|
||||||
|
#define BASS_ACTIVE_PAUSED 3
|
||||||
|
|
||||||
|
// Channel attributes
|
||||||
|
#define BASS_ATTRIB_FREQ 1
|
||||||
|
#define BASS_ATTRIB_VOL 2
|
||||||
|
#define BASS_ATTRIB_PAN 3
|
||||||
|
#define BASS_ATTRIB_EAXMIX 4
|
||||||
|
#define BASS_ATTRIB_NOBUFFER 5
|
||||||
|
#define BASS_ATTRIB_CPU 7
|
||||||
|
#define BASS_ATTRIB_SRC 8
|
||||||
|
#define BASS_ATTRIB_MUSIC_AMPLIFY 0x100
|
||||||
|
#define BASS_ATTRIB_MUSIC_PANSEP 0x101
|
||||||
|
#define BASS_ATTRIB_MUSIC_PSCALER 0x102
|
||||||
|
#define BASS_ATTRIB_MUSIC_BPM 0x103
|
||||||
|
#define BASS_ATTRIB_MUSIC_SPEED 0x104
|
||||||
|
#define BASS_ATTRIB_MUSIC_VOL_GLOBAL 0x105
|
||||||
|
#define BASS_ATTRIB_MUSIC_VOL_CHAN 0x200 // + channel #
|
||||||
|
#define BASS_ATTRIB_MUSIC_VOL_INST 0x300 // + instrument #
|
||||||
|
|
||||||
|
// BASS_ChannelGetData flags
|
||||||
|
#define BASS_DATA_AVAILABLE 0 // query how much data is buffered
|
||||||
|
#define BASS_DATA_FLOAT 0x40000000 // flag: return floating-point sample data
|
||||||
|
#define BASS_DATA_FFT256 0x80000000 // 256 sample FFT
|
||||||
|
#define BASS_DATA_FFT512 0x80000001 // 512 FFT
|
||||||
|
#define BASS_DATA_FFT1024 0x80000002 // 1024 FFT
|
||||||
|
#define BASS_DATA_FFT2048 0x80000003 // 2048 FFT
|
||||||
|
#define BASS_DATA_FFT4096 0x80000004 // 4096 FFT
|
||||||
|
#define BASS_DATA_FFT8192 0x80000005 // 8192 FFT
|
||||||
|
#define BASS_DATA_FFT16384 0x80000006 // 16384 FFT
|
||||||
|
#define BASS_DATA_FFT_INDIVIDUAL 0x10 // FFT flag: FFT for each channel, else all combined
|
||||||
|
#define BASS_DATA_FFT_NOWINDOW 0x20 // FFT flag: no Hanning window
|
||||||
|
#define BASS_DATA_FFT_REMOVEDC 0x40 // FFT flag: pre-remove DC bias
|
||||||
|
#define BASS_DATA_FFT_COMPLEX 0x80 // FFT flag: return complex data
|
||||||
|
|
||||||
|
// BASS_ChannelGetTags types : what's returned
|
||||||
|
#define BASS_TAG_ID3 0 // ID3v1 tags : TAG_ID3 structure
|
||||||
|
#define BASS_TAG_ID3V2 1 // ID3v2 tags : variable length block
|
||||||
|
#define BASS_TAG_OGG 2 // OGG comments : series of null-terminated UTF-8 strings
|
||||||
|
#define BASS_TAG_HTTP 3 // HTTP headers : series of null-terminated ANSI strings
|
||||||
|
#define BASS_TAG_ICY 4 // ICY headers : series of null-terminated ANSI strings
|
||||||
|
#define BASS_TAG_META 5 // ICY metadata : ANSI string
|
||||||
|
#define BASS_TAG_APE 6 // APE tags : series of null-terminated UTF-8 strings
|
||||||
|
#define BASS_TAG_MP4 7 // MP4/iTunes metadata : series of null-terminated UTF-8 strings
|
||||||
|
#define BASS_TAG_VENDOR 9 // OGG encoder : UTF-8 string
|
||||||
|
#define BASS_TAG_LYRICS3 10 // Lyric3v2 tag : ASCII string
|
||||||
|
#define BASS_TAG_CA_CODEC 11 // CoreAudio codec info : TAG_CA_CODEC structure
|
||||||
|
#define BASS_TAG_MF 13 // Media Foundation tags : series of null-terminated UTF-8 strings
|
||||||
|
#define BASS_TAG_WAVEFORMAT 14 // WAVE format : WAVEFORMATEEX structure
|
||||||
|
#define BASS_TAG_RIFF_INFO 0x100 // RIFF "INFO" tags : series of null-terminated ANSI strings
|
||||||
|
#define BASS_TAG_RIFF_BEXT 0x101 // RIFF/BWF "bext" tags : TAG_BEXT structure
|
||||||
|
#define BASS_TAG_RIFF_CART 0x102 // RIFF/BWF "cart" tags : TAG_CART structure
|
||||||
|
#define BASS_TAG_RIFF_DISP 0x103 // RIFF "DISP" text tag : ANSI string
|
||||||
|
#define BASS_TAG_APE_BINARY 0x1000 // + index #, binary APE tag : TAG_APE_BINARY structure
|
||||||
|
#define BASS_TAG_MUSIC_NAME 0x10000 // MOD music name : ANSI string
|
||||||
|
#define BASS_TAG_MUSIC_MESSAGE 0x10001 // MOD message : ANSI string
|
||||||
|
#define BASS_TAG_MUSIC_ORDERS 0x10002 // MOD order list : BYTE array of pattern numbers
|
||||||
|
#define BASS_TAG_MUSIC_INST 0x10100 // + instrument #, MOD instrument name : ANSI string
|
||||||
|
#define BASS_TAG_MUSIC_SAMPLE 0x10300 // + sample #, MOD sample name : ANSI string
|
||||||
|
|
||||||
|
// ID3v1 tag structure
|
||||||
|
typedef struct {
|
||||||
|
char id[3];
|
||||||
|
char title[30];
|
||||||
|
char artist[30];
|
||||||
|
char album[30];
|
||||||
|
char year[4];
|
||||||
|
char comment[30];
|
||||||
|
BYTE genre;
|
||||||
|
} TAG_ID3;
|
||||||
|
|
||||||
|
// Binary APE tag structure
|
||||||
|
typedef struct {
|
||||||
|
const char *key;
|
||||||
|
const void *data;
|
||||||
|
DWORD length;
|
||||||
|
} TAG_APE_BINARY;
|
||||||
|
|
||||||
|
// BWF "bext" tag structure
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4200)
|
||||||
|
#endif
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct {
|
||||||
|
char Description[256]; // description
|
||||||
|
char Originator[32]; // name of the originator
|
||||||
|
char OriginatorReference[32]; // reference of the originator
|
||||||
|
char OriginationDate[10]; // date of creation (yyyy-mm-dd)
|
||||||
|
char OriginationTime[8]; // time of creation (hh-mm-ss)
|
||||||
|
QWORD TimeReference; // first sample count since midnight (little-endian)
|
||||||
|
WORD Version; // BWF version (little-endian)
|
||||||
|
BYTE UMID[64]; // SMPTE UMID
|
||||||
|
BYTE Reserved[190];
|
||||||
|
#if defined(__GNUC__) && __GNUC__<3
|
||||||
|
char CodingHistory[0]; // history
|
||||||
|
#elif 1 // change to 0 if compiler fails the following line
|
||||||
|
char CodingHistory[]; // history
|
||||||
|
#else
|
||||||
|
char CodingHistory[1]; // history
|
||||||
|
#endif
|
||||||
|
} TAG_BEXT;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
// BWF "cart" tag structures
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
DWORD dwUsage; // FOURCC timer usage ID
|
||||||
|
DWORD dwValue; // timer value in samples from head
|
||||||
|
} TAG_CART_TIMER;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char Version[4]; // version of the data structure
|
||||||
|
char Title[64]; // title of cart audio sequence
|
||||||
|
char Artist[64]; // artist or creator name
|
||||||
|
char CutID[64]; // cut number identification
|
||||||
|
char ClientID[64]; // client identification
|
||||||
|
char Category[64]; // category ID, PSA, NEWS, etc
|
||||||
|
char Classification[64]; // classification or auxiliary key
|
||||||
|
char OutCue[64]; // out cue text
|
||||||
|
char StartDate[10]; // yyyy-mm-dd
|
||||||
|
char StartTime[8]; // hh:mm:ss
|
||||||
|
char EndDate[10]; // yyyy-mm-dd
|
||||||
|
char EndTime[8]; // hh:mm:ss
|
||||||
|
char ProducerAppID[64]; // name of vendor or application
|
||||||
|
char ProducerAppVersion[64]; // version of producer application
|
||||||
|
char UserDef[64]; // user defined text
|
||||||
|
DWORD dwLevelReference; // sample value for 0 dB reference
|
||||||
|
TAG_CART_TIMER PostTimer[8]; // 8 time markers after head
|
||||||
|
char Reserved[276];
|
||||||
|
char URL[1024]; // uniform resource locator
|
||||||
|
#if defined(__GNUC__) && __GNUC__<3
|
||||||
|
char TagText[0]; // free form text for scripts or tags
|
||||||
|
#elif 1 // change to 0 if compiler fails the following line
|
||||||
|
char TagText[]; // free form text for scripts or tags
|
||||||
|
#else
|
||||||
|
char TagText[1]; // free form text for scripts or tags
|
||||||
|
#endif
|
||||||
|
} TAG_CART;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// CoreAudio codec info structure
|
||||||
|
typedef struct {
|
||||||
|
DWORD ftype; // file format
|
||||||
|
DWORD atype; // audio format
|
||||||
|
const char *name; // description
|
||||||
|
} TAG_CA_CODEC;
|
||||||
|
|
||||||
|
#ifndef _WAVEFORMATEX_
|
||||||
|
#define _WAVEFORMATEX_
|
||||||
|
#pragma pack(push,1)
|
||||||
|
typedef struct tWAVEFORMATEX
|
||||||
|
{
|
||||||
|
WORD wFormatTag;
|
||||||
|
WORD nChannels;
|
||||||
|
DWORD nSamplesPerSec;
|
||||||
|
DWORD nAvgBytesPerSec;
|
||||||
|
WORD nBlockAlign;
|
||||||
|
WORD wBitsPerSample;
|
||||||
|
WORD cbSize;
|
||||||
|
} WAVEFORMATEX, *PWAVEFORMATEX, *LPWAVEFORMATEX;
|
||||||
|
typedef const WAVEFORMATEX *LPCWAVEFORMATEX;
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BASS_ChannelGetLength/GetPosition/SetPosition modes
|
||||||
|
#define BASS_POS_BYTE 0 // byte position
|
||||||
|
#define BASS_POS_MUSIC_ORDER 1 // order.row position, MAKELONG(order,row)
|
||||||
|
#define BASS_POS_OGG 3 // OGG bitstream number
|
||||||
|
#define BASS_POS_DECODE 0x10000000 // flag: get the decoding (not playing) position
|
||||||
|
#define BASS_POS_DECODETO 0x20000000 // flag: decode to the position instead of seeking
|
||||||
|
|
||||||
|
// BASS_RecordSetInput flags
|
||||||
|
#define BASS_INPUT_OFF 0x10000
|
||||||
|
#define BASS_INPUT_ON 0x20000
|
||||||
|
|
||||||
|
#define BASS_INPUT_TYPE_MASK 0xff000000
|
||||||
|
#define BASS_INPUT_TYPE_UNDEF 0x00000000
|
||||||
|
#define BASS_INPUT_TYPE_DIGITAL 0x01000000
|
||||||
|
#define BASS_INPUT_TYPE_LINE 0x02000000
|
||||||
|
#define BASS_INPUT_TYPE_MIC 0x03000000
|
||||||
|
#define BASS_INPUT_TYPE_SYNTH 0x04000000
|
||||||
|
#define BASS_INPUT_TYPE_CD 0x05000000
|
||||||
|
#define BASS_INPUT_TYPE_PHONE 0x06000000
|
||||||
|
#define BASS_INPUT_TYPE_SPEAKER 0x07000000
|
||||||
|
#define BASS_INPUT_TYPE_WAVE 0x08000000
|
||||||
|
#define BASS_INPUT_TYPE_AUX 0x09000000
|
||||||
|
#define BASS_INPUT_TYPE_ANALOG 0x0a000000
|
||||||
|
|
||||||
|
// DX8 effect types, use with BASS_ChannelSetFX
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BASS_FX_DX8_CHORUS,
|
||||||
|
BASS_FX_DX8_COMPRESSOR,
|
||||||
|
BASS_FX_DX8_DISTORTION,
|
||||||
|
BASS_FX_DX8_ECHO,
|
||||||
|
BASS_FX_DX8_FLANGER,
|
||||||
|
BASS_FX_DX8_GARGLE,
|
||||||
|
BASS_FX_DX8_I3DL2REVERB,
|
||||||
|
BASS_FX_DX8_PARAMEQ,
|
||||||
|
BASS_FX_DX8_REVERB
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float fWetDryMix;
|
||||||
|
float fDepth;
|
||||||
|
float fFeedback;
|
||||||
|
float fFrequency;
|
||||||
|
DWORD lWaveform; // 0=triangle, 1=sine
|
||||||
|
float fDelay;
|
||||||
|
DWORD lPhase; // BASS_DX8_PHASE_xxx
|
||||||
|
} BASS_DX8_CHORUS;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float fGain;
|
||||||
|
float fAttack;
|
||||||
|
float fRelease;
|
||||||
|
float fThreshold;
|
||||||
|
float fRatio;
|
||||||
|
float fPredelay;
|
||||||
|
} BASS_DX8_COMPRESSOR;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float fGain;
|
||||||
|
float fEdge;
|
||||||
|
float fPostEQCenterFrequency;
|
||||||
|
float fPostEQBandwidth;
|
||||||
|
float fPreLowpassCutoff;
|
||||||
|
} BASS_DX8_DISTORTION;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float fWetDryMix;
|
||||||
|
float fFeedback;
|
||||||
|
float fLeftDelay;
|
||||||
|
float fRightDelay;
|
||||||
|
BOOL lPanDelay;
|
||||||
|
} BASS_DX8_ECHO;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float fWetDryMix;
|
||||||
|
float fDepth;
|
||||||
|
float fFeedback;
|
||||||
|
float fFrequency;
|
||||||
|
DWORD lWaveform; // 0=triangle, 1=sine
|
||||||
|
float fDelay;
|
||||||
|
DWORD lPhase; // BASS_DX8_PHASE_xxx
|
||||||
|
} BASS_DX8_FLANGER;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD dwRateHz; // Rate of modulation in hz
|
||||||
|
DWORD dwWaveShape; // 0=triangle, 1=square
|
||||||
|
} BASS_DX8_GARGLE;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int lRoom; // [-10000, 0] default: -1000 mB
|
||||||
|
int lRoomHF; // [-10000, 0] default: 0 mB
|
||||||
|
float flRoomRolloffFactor; // [0.0, 10.0] default: 0.0
|
||||||
|
float flDecayTime; // [0.1, 20.0] default: 1.49s
|
||||||
|
float flDecayHFRatio; // [0.1, 2.0] default: 0.83
|
||||||
|
int lReflections; // [-10000, 1000] default: -2602 mB
|
||||||
|
float flReflectionsDelay; // [0.0, 0.3] default: 0.007 s
|
||||||
|
int lReverb; // [-10000, 2000] default: 200 mB
|
||||||
|
float flReverbDelay; // [0.0, 0.1] default: 0.011 s
|
||||||
|
float flDiffusion; // [0.0, 100.0] default: 100.0 %
|
||||||
|
float flDensity; // [0.0, 100.0] default: 100.0 %
|
||||||
|
float flHFReference; // [20.0, 20000.0] default: 5000.0 Hz
|
||||||
|
} BASS_DX8_I3DL2REVERB;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float fCenter;
|
||||||
|
float fBandwidth;
|
||||||
|
float fGain;
|
||||||
|
} BASS_DX8_PARAMEQ;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float fInGain; // [-96.0,0.0] default: 0.0 dB
|
||||||
|
float fReverbMix; // [-96.0,0.0] default: 0.0 db
|
||||||
|
float fReverbTime; // [0.001,3000.0] default: 1000.0 ms
|
||||||
|
float fHighFreqRTRatio; // [0.001,0.999] default: 0.001
|
||||||
|
} BASS_DX8_REVERB;
|
||||||
|
|
||||||
|
#define BASS_DX8_PHASE_NEG_180 0
|
||||||
|
#define BASS_DX8_PHASE_NEG_90 1
|
||||||
|
#define BASS_DX8_PHASE_ZERO 2
|
||||||
|
#define BASS_DX8_PHASE_90 3
|
||||||
|
#define BASS_DX8_PHASE_180 4
|
||||||
|
|
||||||
|
typedef void (CALLBACK IOSNOTIFYPROC)(DWORD status);
|
||||||
|
/* iOS notification callback function.
|
||||||
|
status : The notification (BASS_IOSNOTIFY_xxx) */
|
||||||
|
|
||||||
|
#define BASS_IOSNOTIFY_INTERRUPT 1 // interruption started
|
||||||
|
#define BASS_IOSNOTIFY_INTERRUPT_END 2 // interruption ended
|
||||||
|
|
||||||
|
BOOL BASSDEF(BASS_SetConfig)(DWORD option, DWORD value);
|
||||||
|
DWORD BASSDEF(BASS_GetConfig)(DWORD option);
|
||||||
|
BOOL BASSDEF(BASS_SetConfigPtr)(DWORD option, const void *value);
|
||||||
|
void *BASSDEF(BASS_GetConfigPtr)(DWORD option);
|
||||||
|
DWORD BASSDEF(BASS_GetVersion)();
|
||||||
|
int BASSDEF(BASS_ErrorGetCode)();
|
||||||
|
BOOL BASSDEF(BASS_GetDeviceInfo)(DWORD device, BASS_DEVICEINFO *info);
|
||||||
|
#if defined(_WIN32) && !defined(_WIN32_WCE)
|
||||||
|
BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, HWND win, const GUID *dsguid);
|
||||||
|
#else
|
||||||
|
BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, void *win, void *dsguid);
|
||||||
|
#endif
|
||||||
|
BOOL BASSDEF(BASS_SetDevice)(DWORD device);
|
||||||
|
DWORD BASSDEF(BASS_GetDevice)();
|
||||||
|
BOOL BASSDEF(BASS_Free)();
|
||||||
|
#if defined(_WIN32) && !defined(_WIN32_WCE)
|
||||||
|
void *BASSDEF(BASS_GetDSoundObject)(DWORD object);
|
||||||
|
#endif
|
||||||
|
BOOL BASSDEF(BASS_GetInfo)(BASS_INFO *info);
|
||||||
|
BOOL BASSDEF(BASS_Update)(DWORD length);
|
||||||
|
float BASSDEF(BASS_GetCPU)();
|
||||||
|
BOOL BASSDEF(BASS_Start)();
|
||||||
|
BOOL BASSDEF(BASS_Stop)();
|
||||||
|
BOOL BASSDEF(BASS_Pause)();
|
||||||
|
BOOL BASSDEF(BASS_SetVolume)(float volume);
|
||||||
|
float BASSDEF(BASS_GetVolume)();
|
||||||
|
|
||||||
|
HPLUGIN BASSDEF(BASS_PluginLoad)(const char *file, DWORD flags);
|
||||||
|
BOOL BASSDEF(BASS_PluginFree)(HPLUGIN handle);
|
||||||
|
const BASS_PLUGININFO *BASSDEF(BASS_PluginGetInfo)(HPLUGIN handle);
|
||||||
|
|
||||||
|
BOOL BASSDEF(BASS_Set3DFactors)(float distf, float rollf, float doppf);
|
||||||
|
BOOL BASSDEF(BASS_Get3DFactors)(float *distf, float *rollf, float *doppf);
|
||||||
|
BOOL BASSDEF(BASS_Set3DPosition)(const BASS_3DVECTOR *pos, const BASS_3DVECTOR *vel, const BASS_3DVECTOR *front, const BASS_3DVECTOR *top);
|
||||||
|
BOOL BASSDEF(BASS_Get3DPosition)(BASS_3DVECTOR *pos, BASS_3DVECTOR *vel, BASS_3DVECTOR *front, BASS_3DVECTOR *top);
|
||||||
|
void BASSDEF(BASS_Apply3D)();
|
||||||
|
#if defined(_WIN32) && !defined(_WIN32_WCE)
|
||||||
|
BOOL BASSDEF(BASS_SetEAXParameters)(int env, float vol, float decay, float damp);
|
||||||
|
BOOL BASSDEF(BASS_GetEAXParameters)(DWORD *env, float *vol, float *decay, float *damp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HMUSIC BASSDEF(BASS_MusicLoad)(BOOL mem, const void *file, QWORD offset, DWORD length, DWORD flags, DWORD freq);
|
||||||
|
BOOL BASSDEF(BASS_MusicFree)(HMUSIC handle);
|
||||||
|
|
||||||
|
HSAMPLE BASSDEF(BASS_SampleLoad)(BOOL mem, const void *file, QWORD offset, DWORD length, DWORD max, DWORD flags);
|
||||||
|
HSAMPLE BASSDEF(BASS_SampleCreate)(DWORD length, DWORD freq, DWORD chans, DWORD max, DWORD flags);
|
||||||
|
BOOL BASSDEF(BASS_SampleFree)(HSAMPLE handle);
|
||||||
|
BOOL BASSDEF(BASS_SampleSetData)(HSAMPLE handle, const void *buffer);
|
||||||
|
BOOL BASSDEF(BASS_SampleGetData)(HSAMPLE handle, void *buffer);
|
||||||
|
BOOL BASSDEF(BASS_SampleGetInfo)(HSAMPLE handle, BASS_SAMPLE *info);
|
||||||
|
BOOL BASSDEF(BASS_SampleSetInfo)(HSAMPLE handle, const BASS_SAMPLE *info);
|
||||||
|
HCHANNEL BASSDEF(BASS_SampleGetChannel)(HSAMPLE handle, BOOL onlynew);
|
||||||
|
DWORD BASSDEF(BASS_SampleGetChannels)(HSAMPLE handle, HCHANNEL *channels);
|
||||||
|
BOOL BASSDEF(BASS_SampleStop)(HSAMPLE handle);
|
||||||
|
|
||||||
|
HSTREAM BASSDEF(BASS_StreamCreate)(DWORD freq, DWORD chans, DWORD flags, STREAMPROC *proc, void *user);
|
||||||
|
HSTREAM BASSDEF(BASS_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
|
||||||
|
HSTREAM BASSDEF(BASS_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user);
|
||||||
|
HSTREAM BASSDEF(BASS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *proc, void *user);
|
||||||
|
BOOL BASSDEF(BASS_StreamFree)(HSTREAM handle);
|
||||||
|
QWORD BASSDEF(BASS_StreamGetFilePosition)(HSTREAM handle, DWORD mode);
|
||||||
|
DWORD BASSDEF(BASS_StreamPutData)(HSTREAM handle, const void *buffer, DWORD length);
|
||||||
|
DWORD BASSDEF(BASS_StreamPutFileData)(HSTREAM handle, const void *buffer, DWORD length);
|
||||||
|
|
||||||
|
BOOL BASSDEF(BASS_RecordGetDeviceInfo)(DWORD device, BASS_DEVICEINFO *info);
|
||||||
|
BOOL BASSDEF(BASS_RecordInit)(int device);
|
||||||
|
BOOL BASSDEF(BASS_RecordSetDevice)(DWORD device);
|
||||||
|
DWORD BASSDEF(BASS_RecordGetDevice)();
|
||||||
|
BOOL BASSDEF(BASS_RecordFree)();
|
||||||
|
BOOL BASSDEF(BASS_RecordGetInfo)(BASS_RECORDINFO *info);
|
||||||
|
const char *BASSDEF(BASS_RecordGetInputName)(int input);
|
||||||
|
BOOL BASSDEF(BASS_RecordSetInput)(int input, DWORD flags, float volume);
|
||||||
|
DWORD BASSDEF(BASS_RecordGetInput)(int input, float *volume);
|
||||||
|
HRECORD BASSDEF(BASS_RecordStart)(DWORD freq, DWORD chans, DWORD flags, RECORDPROC *proc, void *user);
|
||||||
|
|
||||||
|
double BASSDEF(BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos);
|
||||||
|
QWORD BASSDEF(BASS_ChannelSeconds2Bytes)(DWORD handle, double pos);
|
||||||
|
DWORD BASSDEF(BASS_ChannelGetDevice)(DWORD handle);
|
||||||
|
BOOL BASSDEF(BASS_ChannelSetDevice)(DWORD handle, DWORD device);
|
||||||
|
DWORD BASSDEF(BASS_ChannelIsActive)(DWORD handle);
|
||||||
|
BOOL BASSDEF(BASS_ChannelGetInfo)(DWORD handle, BASS_CHANNELINFO *info);
|
||||||
|
const char *BASSDEF(BASS_ChannelGetTags)(DWORD handle, DWORD tags);
|
||||||
|
DWORD BASSDEF(BASS_ChannelFlags)(DWORD handle, DWORD flags, DWORD mask);
|
||||||
|
BOOL BASSDEF(BASS_ChannelUpdate)(DWORD handle, DWORD length);
|
||||||
|
BOOL BASSDEF(BASS_ChannelLock)(DWORD handle, BOOL lock);
|
||||||
|
BOOL BASSDEF(BASS_ChannelPlay)(DWORD handle, BOOL restart);
|
||||||
|
BOOL BASSDEF(BASS_ChannelStop)(DWORD handle);
|
||||||
|
BOOL BASSDEF(BASS_ChannelPause)(DWORD handle);
|
||||||
|
BOOL BASSDEF(BASS_ChannelSetAttribute)(DWORD handle, DWORD attrib, float value);
|
||||||
|
BOOL BASSDEF(BASS_ChannelGetAttribute)(DWORD handle, DWORD attrib, float *value);
|
||||||
|
BOOL BASSDEF(BASS_ChannelSlideAttribute)(DWORD handle, DWORD attrib, float value, DWORD time);
|
||||||
|
BOOL BASSDEF(BASS_ChannelIsSliding)(DWORD handle, DWORD attrib);
|
||||||
|
BOOL BASSDEF(BASS_ChannelSet3DAttributes)(DWORD handle, int mode, float min, float max, int iangle, int oangle, float outvol);
|
||||||
|
BOOL BASSDEF(BASS_ChannelGet3DAttributes)(DWORD handle, DWORD *mode, float *min, float *max, DWORD *iangle, DWORD *oangle, float *outvol);
|
||||||
|
BOOL BASSDEF(BASS_ChannelSet3DPosition)(DWORD handle, const BASS_3DVECTOR *pos, const BASS_3DVECTOR *orient, const BASS_3DVECTOR *vel);
|
||||||
|
BOOL BASSDEF(BASS_ChannelGet3DPosition)(DWORD handle, BASS_3DVECTOR *pos, BASS_3DVECTOR *orient, BASS_3DVECTOR *vel);
|
||||||
|
QWORD BASSDEF(BASS_ChannelGetLength)(DWORD handle, DWORD mode);
|
||||||
|
BOOL BASSDEF(BASS_ChannelSetPosition)(DWORD handle, QWORD pos, DWORD mode);
|
||||||
|
QWORD BASSDEF(BASS_ChannelGetPosition)(DWORD handle, DWORD mode);
|
||||||
|
DWORD BASSDEF(BASS_ChannelGetLevel)(DWORD handle);
|
||||||
|
DWORD BASSDEF(BASS_ChannelGetData)(DWORD handle, void *buffer, DWORD length);
|
||||||
|
HSYNC BASSDEF(BASS_ChannelSetSync)(DWORD handle, DWORD type, QWORD param, SYNCPROC *proc, void *user);
|
||||||
|
BOOL BASSDEF(BASS_ChannelRemoveSync)(DWORD handle, HSYNC sync);
|
||||||
|
HDSP BASSDEF(BASS_ChannelSetDSP)(DWORD handle, DSPPROC *proc, void *user, int priority);
|
||||||
|
BOOL BASSDEF(BASS_ChannelRemoveDSP)(DWORD handle, HDSP dsp);
|
||||||
|
BOOL BASSDEF(BASS_ChannelSetLink)(DWORD handle, DWORD chan);
|
||||||
|
BOOL BASSDEF(BASS_ChannelRemoveLink)(DWORD handle, DWORD chan);
|
||||||
|
HFX BASSDEF(BASS_ChannelSetFX)(DWORD handle, DWORD type, int priority);
|
||||||
|
BOOL BASSDEF(BASS_ChannelRemoveFX)(DWORD handle, HFX fx);
|
||||||
|
|
||||||
|
BOOL BASSDEF(BASS_FXSetParameters)(HFX handle, const void *params);
|
||||||
|
BOOL BASSDEF(BASS_FXGetParameters)(HFX handle, void *params);
|
||||||
|
BOOL BASSDEF(BASS_FXReset)(HFX handle);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static inline HPLUGIN BASS_PluginLoad(const WCHAR *file, DWORD flags)
|
||||||
|
{
|
||||||
|
return BASS_PluginLoad((const char*)file, flags|BASS_UNICODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HMUSIC BASS_MusicLoad(BOOL mem, const WCHAR *file, QWORD offset, DWORD length, DWORD flags, DWORD freq)
|
||||||
|
{
|
||||||
|
return BASS_MusicLoad(mem, (const void*)file, offset, length, flags|BASS_UNICODE, freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HSAMPLE BASS_SampleLoad(BOOL mem, const WCHAR *file, QWORD offset, DWORD length, DWORD max, DWORD flags)
|
||||||
|
{
|
||||||
|
return BASS_SampleLoad(mem, (const void*)file, offset, length, max, flags|BASS_UNICODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HSTREAM BASS_StreamCreateFile(BOOL mem, const WCHAR *file, QWORD offset, QWORD length, DWORD flags)
|
||||||
|
{
|
||||||
|
return BASS_StreamCreateFile(mem, (const void*)file, offset, length, flags|BASS_UNICODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HSTREAM BASS_StreamCreateURL(const WCHAR *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user)
|
||||||
|
{
|
||||||
|
return BASS_StreamCreateURL((const char*)url, offset, flags|BASS_UNICODE, proc, user);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,301 @@
|
||||||
|
/*
|
||||||
|
BASSMIDI 2.4 C/C++ header file
|
||||||
|
Copyright (c) 2006-2013 Un4seen Developments Ltd.
|
||||||
|
|
||||||
|
See the BASSMIDI.CHM file for more detailed documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BASSMIDI_H
|
||||||
|
#define BASSMIDI_H
|
||||||
|
|
||||||
|
#include "bass.h"
|
||||||
|
|
||||||
|
#if BASSVERSION!=0x204
|
||||||
|
#error conflicting BASS and BASSMIDI versions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BASSMIDIDEF
|
||||||
|
#define BASSMIDIDEF(f) WINAPI f
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef DWORD HSOUNDFONT; // soundfont handle
|
||||||
|
|
||||||
|
// Additional BASS_SetConfig options
|
||||||
|
#define BASS_CONFIG_MIDI_COMPACT 0x10400
|
||||||
|
#define BASS_CONFIG_MIDI_VOICES 0x10401
|
||||||
|
#define BASS_CONFIG_MIDI_AUTOFONT 0x10402
|
||||||
|
|
||||||
|
// Additional BASS_SetConfigPtr options
|
||||||
|
#define BASS_CONFIG_MIDI_DEFFONT 0x10403
|
||||||
|
|
||||||
|
// Additional sync types
|
||||||
|
#define BASS_SYNC_MIDI_MARK 0x10000
|
||||||
|
#define BASS_SYNC_MIDI_MARKER 0x10000
|
||||||
|
#define BASS_SYNC_MIDI_CUE 0x10001
|
||||||
|
#define BASS_SYNC_MIDI_LYRIC 0x10002
|
||||||
|
#define BASS_SYNC_MIDI_TEXT 0x10003
|
||||||
|
#define BASS_SYNC_MIDI_EVENT 0x10004
|
||||||
|
#define BASS_SYNC_MIDI_TICK 0x10005
|
||||||
|
#define BASS_SYNC_MIDI_TIMESIG 0x10006
|
||||||
|
#define BASS_SYNC_MIDI_KEYSIG 0x10007
|
||||||
|
|
||||||
|
// Additional BASS_MIDI_StreamCreateFile/etc flags
|
||||||
|
#define BASS_MIDI_DECAYEND 0x1000
|
||||||
|
#define BASS_MIDI_NOFX 0x2000
|
||||||
|
#define BASS_MIDI_DECAYSEEK 0x4000
|
||||||
|
#define BASS_MIDI_NOCROP 0x8000
|
||||||
|
#define BASS_MIDI_SINCINTER 0x800000
|
||||||
|
|
||||||
|
// BASS_MIDI_FontInit flags
|
||||||
|
#define BASS_MIDI_FONT_MEM 0x10000
|
||||||
|
#define BASS_MIDI_FONT_MMAP 0x20000
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
HSOUNDFONT font; // soundfont
|
||||||
|
int preset; // preset number (-1=all)
|
||||||
|
int bank;
|
||||||
|
} BASS_MIDI_FONT;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
HSOUNDFONT font; // soundfont
|
||||||
|
int spreset; // source preset number
|
||||||
|
int sbank; // source bank number
|
||||||
|
int dpreset; // destination preset/program number
|
||||||
|
int dbank; // destination bank number
|
||||||
|
int dbanklsb; // destination bank number LSB
|
||||||
|
} BASS_MIDI_FONTEX;
|
||||||
|
|
||||||
|
// BASS_MIDI_StreamSet/GetFonts flag
|
||||||
|
#define BASS_MIDI_FONT_EX 0x1000000 // BASS_MIDI_FONTEX
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
const char *copyright;
|
||||||
|
const char *comment;
|
||||||
|
DWORD presets; // number of presets/instruments
|
||||||
|
DWORD samsize; // total size (in bytes) of the sample data
|
||||||
|
DWORD samload; // amount of sample data currently loaded
|
||||||
|
DWORD samtype; // sample format (CTYPE) if packed
|
||||||
|
} BASS_MIDI_FONTINFO;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD track; // track containing marker
|
||||||
|
DWORD pos; // marker position
|
||||||
|
const char *text; // marker text
|
||||||
|
} BASS_MIDI_MARK;
|
||||||
|
|
||||||
|
// Marker types
|
||||||
|
#define BASS_MIDI_MARK_MARKER 0 // marker
|
||||||
|
#define BASS_MIDI_MARK_CUE 1 // cue point
|
||||||
|
#define BASS_MIDI_MARK_LYRIC 2 // lyric
|
||||||
|
#define BASS_MIDI_MARK_TEXT 3 // text
|
||||||
|
#define BASS_MIDI_MARK_TIMESIG 4 // time signature
|
||||||
|
#define BASS_MIDI_MARK_KEYSIG 5 // key signature
|
||||||
|
#define BASS_MIDI_MARK_COPY 6 // copyright notice
|
||||||
|
#define BASS_MIDI_MARK_TRACK 7 // track name
|
||||||
|
#define BASS_MIDI_MARK_INST 8 // instrument name
|
||||||
|
#define BASS_MIDI_MARK_TICK 0x10000 // FLAG: get position in ticks (otherwise bytes)
|
||||||
|
|
||||||
|
// MIDI events
|
||||||
|
#define MIDI_EVENT_NOTE 1
|
||||||
|
#define MIDI_EVENT_PROGRAM 2
|
||||||
|
#define MIDI_EVENT_CHANPRES 3
|
||||||
|
#define MIDI_EVENT_PITCH 4
|
||||||
|
#define MIDI_EVENT_PITCHRANGE 5
|
||||||
|
#define MIDI_EVENT_DRUMS 6
|
||||||
|
#define MIDI_EVENT_FINETUNE 7
|
||||||
|
#define MIDI_EVENT_COARSETUNE 8
|
||||||
|
#define MIDI_EVENT_MASTERVOL 9
|
||||||
|
#define MIDI_EVENT_BANK 10
|
||||||
|
#define MIDI_EVENT_MODULATION 11
|
||||||
|
#define MIDI_EVENT_VOLUME 12
|
||||||
|
#define MIDI_EVENT_PAN 13
|
||||||
|
#define MIDI_EVENT_EXPRESSION 14
|
||||||
|
#define MIDI_EVENT_SUSTAIN 15
|
||||||
|
#define MIDI_EVENT_SOUNDOFF 16
|
||||||
|
#define MIDI_EVENT_RESET 17
|
||||||
|
#define MIDI_EVENT_NOTESOFF 18
|
||||||
|
#define MIDI_EVENT_PORTAMENTO 19
|
||||||
|
#define MIDI_EVENT_PORTATIME 20
|
||||||
|
#define MIDI_EVENT_PORTANOTE 21
|
||||||
|
#define MIDI_EVENT_MODE 22
|
||||||
|
#define MIDI_EVENT_REVERB 23
|
||||||
|
#define MIDI_EVENT_CHORUS 24
|
||||||
|
#define MIDI_EVENT_CUTOFF 25
|
||||||
|
#define MIDI_EVENT_RESONANCE 26
|
||||||
|
#define MIDI_EVENT_RELEASE 27
|
||||||
|
#define MIDI_EVENT_ATTACK 28
|
||||||
|
#define MIDI_EVENT_REVERB_MACRO 30
|
||||||
|
#define MIDI_EVENT_CHORUS_MACRO 31
|
||||||
|
#define MIDI_EVENT_REVERB_TIME 32
|
||||||
|
#define MIDI_EVENT_REVERB_DELAY 33
|
||||||
|
#define MIDI_EVENT_REVERB_LOCUTOFF 34
|
||||||
|
#define MIDI_EVENT_REVERB_HICUTOFF 35
|
||||||
|
#define MIDI_EVENT_REVERB_LEVEL 36
|
||||||
|
#define MIDI_EVENT_CHORUS_DELAY 37
|
||||||
|
#define MIDI_EVENT_CHORUS_DEPTH 38
|
||||||
|
#define MIDI_EVENT_CHORUS_RATE 39
|
||||||
|
#define MIDI_EVENT_CHORUS_FEEDBACK 40
|
||||||
|
#define MIDI_EVENT_CHORUS_LEVEL 41
|
||||||
|
#define MIDI_EVENT_CHORUS_REVERB 42
|
||||||
|
#define MIDI_EVENT_DRUM_FINETUNE 50
|
||||||
|
#define MIDI_EVENT_DRUM_COARSETUNE 51
|
||||||
|
#define MIDI_EVENT_DRUM_PAN 52
|
||||||
|
#define MIDI_EVENT_DRUM_REVERB 53
|
||||||
|
#define MIDI_EVENT_DRUM_CHORUS 54
|
||||||
|
#define MIDI_EVENT_DRUM_CUTOFF 55
|
||||||
|
#define MIDI_EVENT_DRUM_RESONANCE 56
|
||||||
|
#define MIDI_EVENT_DRUM_LEVEL 57
|
||||||
|
#define MIDI_EVENT_SOFT 60
|
||||||
|
#define MIDI_EVENT_SYSTEM 61
|
||||||
|
#define MIDI_EVENT_TEMPO 62
|
||||||
|
#define MIDI_EVENT_SCALETUNING 63
|
||||||
|
#define MIDI_EVENT_CONTROL 64
|
||||||
|
#define MIDI_EVENT_CHANPRES_VIBRATO 65
|
||||||
|
#define MIDI_EVENT_CHANPRES_PITCH 66
|
||||||
|
#define MIDI_EVENT_CHANPRES_FILTER 67
|
||||||
|
#define MIDI_EVENT_CHANPRES_VOLUME 68
|
||||||
|
#define MIDI_EVENT_MODRANGE 69
|
||||||
|
#define MIDI_EVENT_BANK_LSB 70
|
||||||
|
#define MIDI_EVENT_MIXLEVEL 0x10000
|
||||||
|
#define MIDI_EVENT_TRANSPOSE 0x10001
|
||||||
|
#define MIDI_EVENT_SYSTEMEX 0x10002
|
||||||
|
|
||||||
|
#define MIDI_EVENT_END 0
|
||||||
|
#define MIDI_EVENT_END_TRACK 0x10003
|
||||||
|
|
||||||
|
#define MIDI_SYSTEM_DEFAULT 0
|
||||||
|
#define MIDI_SYSTEM_GM1 1
|
||||||
|
#define MIDI_SYSTEM_GM2 2
|
||||||
|
#define MIDI_SYSTEM_XG 3
|
||||||
|
#define MIDI_SYSTEM_GS 4
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DWORD event; // MIDI_EVENT_xxx
|
||||||
|
DWORD param;
|
||||||
|
DWORD chan;
|
||||||
|
DWORD tick; // event position (ticks)
|
||||||
|
DWORD pos; // event position (bytes)
|
||||||
|
} BASS_MIDI_EVENT;
|
||||||
|
|
||||||
|
// BASS_MIDI_StreamEvents modes
|
||||||
|
#define BASS_MIDI_EVENTS_STRUCT 0 // BASS_MIDI_EVENT structures
|
||||||
|
#define BASS_MIDI_EVENTS_RAW 0x10000 // raw MIDI event data
|
||||||
|
#define BASS_MIDI_EVENTS_SYNC 0x1000000 // FLAG: trigger event syncs
|
||||||
|
|
||||||
|
// BASS_CHANNELINFO type
|
||||||
|
#define BASS_CTYPE_STREAM_MIDI 0x10d00
|
||||||
|
|
||||||
|
// Additional attributes
|
||||||
|
#define BASS_ATTRIB_MIDI_PPQN 0x12000
|
||||||
|
#define BASS_ATTRIB_MIDI_CPU 0x12001
|
||||||
|
#define BASS_ATTRIB_MIDI_CHANS 0x12002
|
||||||
|
#define BASS_ATTRIB_MIDI_VOICES 0x12003
|
||||||
|
#define BASS_ATTRIB_MIDI_VOICES_ACTIVE 0x12004
|
||||||
|
#define BASS_ATTRIB_MIDI_TRACK_VOL 0x12100 // + track #
|
||||||
|
|
||||||
|
// Additional tag type
|
||||||
|
#define BASS_TAG_MIDI_TRACK 0x11000 // + track #, track text : array of null-terminated ANSI strings
|
||||||
|
|
||||||
|
// BASS_ChannelGetLength/GetPosition/SetPosition mode
|
||||||
|
#define BASS_POS_MIDI_TICK 2 // tick position
|
||||||
|
|
||||||
|
// BASS_MIDI_FontPack flags
|
||||||
|
#define BASS_MIDI_PACK_NOHEAD 1 // don't send a WAV header to the encoder
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name; // description
|
||||||
|
DWORD id;
|
||||||
|
DWORD flags;
|
||||||
|
} BASS_MIDI_DEVICEINFO;
|
||||||
|
|
||||||
|
typedef void (CALLBACK MIDIINPROC)(DWORD device, double time, const void *buffer, DWORD length, void *user);
|
||||||
|
/* User MIDI input callback function.
|
||||||
|
device : MIDI input device
|
||||||
|
time : Timestamp
|
||||||
|
buffer : Buffer containing MIDI data
|
||||||
|
length : Number of bytes of data
|
||||||
|
user : The 'user' parameter value given when calling BASS_MIDI_InInit */
|
||||||
|
|
||||||
|
HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreate)(DWORD channels, DWORD flags, DWORD freq);
|
||||||
|
HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags, DWORD freq);
|
||||||
|
HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user, DWORD freq);
|
||||||
|
HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user, DWORD freq);
|
||||||
|
HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateEvents)(const BASS_MIDI_EVENT *events, DWORD ppqn, DWORD flags, DWORD freq);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_StreamGetMark)(HSTREAM handle, DWORD type, DWORD index, BASS_MIDI_MARK *mark);
|
||||||
|
DWORD BASSMIDIDEF(BASS_MIDI_StreamGetMarks)(HSTREAM handle, int track, DWORD type, BASS_MIDI_MARK *marks);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_StreamSetFonts)(HSTREAM handle, const void *fonts, DWORD count);
|
||||||
|
DWORD BASSMIDIDEF(BASS_MIDI_StreamGetFonts)(HSTREAM handle, void *fonts, DWORD count);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_StreamLoadSamples)(HSTREAM handle);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_StreamEvent)(HSTREAM handle, DWORD chan, DWORD event, DWORD param);
|
||||||
|
DWORD BASSMIDIDEF(BASS_MIDI_StreamEvents)(HSTREAM handle, DWORD mode, const void *events, DWORD length);
|
||||||
|
DWORD BASSMIDIDEF(BASS_MIDI_StreamGetEvent)(HSTREAM handle, DWORD chan, DWORD event);
|
||||||
|
DWORD BASSMIDIDEF(BASS_MIDI_StreamGetEvents)(HSTREAM handle, int track, DWORD filter, BASS_MIDI_EVENT *events);
|
||||||
|
HSTREAM BASSMIDIDEF(BASS_MIDI_StreamGetChannel)(HSTREAM handle, DWORD chan);
|
||||||
|
|
||||||
|
HSOUNDFONT BASSMIDIDEF(BASS_MIDI_FontInit)(const void *file, DWORD flags);
|
||||||
|
HSOUNDFONT BASSMIDIDEF(BASS_MIDI_FontInitUser)(const BASS_FILEPROCS *procs, void *user, DWORD flags);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontFree)(HSOUNDFONT handle);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontGetInfo)(HSOUNDFONT handle, BASS_MIDI_FONTINFO *info);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontGetPresets)(HSOUNDFONT handle, DWORD *presets);
|
||||||
|
const char *BASSMIDIDEF(BASS_MIDI_FontGetPreset)(HSOUNDFONT handle, int preset, int bank);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontLoad)(HSOUNDFONT handle, int preset, int bank);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontUnload)(HSOUNDFONT handle, int preset, int bank);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontCompact)(HSOUNDFONT handle);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontPack)(HSOUNDFONT handle, const void *outfile, const void *encoder, DWORD flags);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontUnpack)(HSOUNDFONT handle, const void *outfile, DWORD flags);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_FontSetVolume)(HSOUNDFONT handle, float volume);
|
||||||
|
float BASSMIDIDEF(BASS_MIDI_FontGetVolume)(HSOUNDFONT handle);
|
||||||
|
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_InGetDeviceInfo)(DWORD device, BASS_MIDI_DEVICEINFO *info);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_InInit)(DWORD device, MIDIINPROC *proc, void *user);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_InFree)(DWORD device);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_InStart)(DWORD device);
|
||||||
|
BOOL BASSMIDIDEF(BASS_MIDI_InStop)(DWORD device);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline BOOL BASS_MIDI_StreamSetFonts(HSTREAM handle, const BASS_MIDI_FONTEX *fonts, DWORD count)
|
||||||
|
{
|
||||||
|
return BASS_MIDI_StreamSetFonts(handle, (const void*)fonts, count|BASS_MIDI_FONT_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline DWORD BASS_MIDI_StreamGetFonts(HSTREAM handle, BASS_MIDI_FONTEX *fonts, DWORD count)
|
||||||
|
{
|
||||||
|
return BASS_MIDI_StreamGetFonts(handle, (void*)fonts, count|BASS_MIDI_FONT_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static inline HSTREAM BASS_MIDI_StreamCreateFile(BOOL mem, const WCHAR *file, QWORD offset, QWORD length, DWORD flags, DWORD freq)
|
||||||
|
{
|
||||||
|
return BASS_MIDI_StreamCreateFile(mem, (const void*)file, offset, length, flags|BASS_UNICODE, freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HSTREAM BASS_MIDI_StreamCreateURL(const WCHAR *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user, DWORD freq)
|
||||||
|
{
|
||||||
|
return BASS_MIDI_StreamCreateURL((const char*)url, offset, flags|BASS_UNICODE, proc, user, freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline HSOUNDFONT BASS_MIDI_FontInit(const WCHAR *file, DWORD flags)
|
||||||
|
{
|
||||||
|
return BASS_MIDI_FontInit((const void*)file, flags|BASS_UNICODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline BOOL BASS_MIDI_FontPack(HSOUNDFONT handle, const WCHAR *outfile, const WCHAR *encoder, DWORD flags)
|
||||||
|
{
|
||||||
|
return BASS_MIDI_FontPack(handle, (const void*)outfile, (const void*)encoder, flags|BASS_UNICODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline BOOL BASS_MIDI_FontUnpack(HSOUNDFONT handle, const WCHAR *outfile, DWORD flags)
|
||||||
|
{
|
||||||
|
return BASS_MIDI_FontUnpack(handle, (const void*)outfile, flags|BASS_UNICODE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue