diff --git a/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj b/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj index 9a99515e9..1ffdc6413 100644 --- a/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj +++ b/Plugins/MIDI/MIDI.xcodeproj/project.pbxproj @@ -24,7 +24,7 @@ 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 */; }; + 83B0670C180D6665008E3612 /* BMPlayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83B0670A180D6665008E3612 /* BMPlayer.mm */; }; 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 */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -131,7 +131,7 @@ 83B066DA180D56B9008E3612 /* midi_processing.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = midi_processing.xcodeproj; path = ../../Frameworks/midi_processing/midi_processing.xcodeproj; sourceTree = ""; }; 83B06706180D6471008E3612 /* MIDIPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIPlayer.h; sourceTree = ""; }; 83B06708180D64DA008E3612 /* MIDIPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MIDIPlayer.cpp; sourceTree = ""; }; - 83B0670A180D6665008E3612 /* BMPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BMPlayer.cpp; sourceTree = ""; }; + 83B0670A180D6665008E3612 /* BMPlayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BMPlayer.mm; sourceTree = ""; }; 83B0670B180D6665008E3612 /* BMPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BMPlayer.h; sourceTree = ""; }; 83B0670D180D6F7F008E3612 /* libbass.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbass.dylib; path = ../../ThirdParty/BASS/libbass.dylib; sourceTree = ""; }; 83B0670E180D6F7F008E3612 /* libbassmidi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libbassmidi.dylib; path = ../../ThirdParty/BASS/libbassmidi.dylib; sourceTree = ""; }; @@ -143,6 +143,7 @@ 83B06721180D70FE008E3612 /* MIDIDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MIDIDecoder.mm; sourceTree = ""; }; 83B06723180D714F008E3612 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../../Audio/Plugin.h; sourceTree = ""; }; 83B06724180D792E008E3612 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../../Utils/Logging.h; sourceTree = ""; }; + 83B5CBDE25EBAFCF000B0F8B /* SandboxBroker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SandboxBroker.h; path = ../../../Utils/SandboxBroker.h; sourceTree = ""; }; 83C35700180EDB74007E9DF0 /* MIDIContainer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MIDIContainer.mm; sourceTree = ""; }; 83C35701180EDB74007E9DF0 /* MIDIContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIContainer.h; sourceTree = ""; }; 83C35703180EDD1C007E9DF0 /* MIDIMetadataReader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MIDIMetadataReader.mm; sourceTree = ""; }; @@ -280,6 +281,7 @@ 83B06690180D5668008E3612 /* MIDI */ = { isa = PBXGroup; children = ( + 83B5CBDE25EBAFCF000B0F8B /* SandboxBroker.h */, 830C94CA1D171B30000E404F /* sflist */, 83A09F6E1CFA8D6B001E7D2D /* MSPlayer.cpp */, 83A09F6D1CFA8D6B001E7D2D /* MSPlayer.h */, @@ -306,7 +308,7 @@ 83B06723180D714F008E3612 /* Plugin.h */, 83B06720180D70FE008E3612 /* MIDIDecoder.h */, 83B06721180D70FE008E3612 /* MIDIDecoder.mm */, - 83B0670A180D6665008E3612 /* BMPlayer.cpp */, + 83B0670A180D6665008E3612 /* BMPlayer.mm */, 83B0670B180D6665008E3612 /* BMPlayer.h */, 83B06708180D64DA008E3612 /* MIDIPlayer.cpp */, 83B06706180D6471008E3612 /* MIDIPlayer.h */, @@ -433,7 +435,7 @@ 83B06722180D70FE008E3612 /* MIDIDecoder.mm in Sources */, 83A09F6F1CFA8D6B001E7D2D /* MSPlayer.cpp in Sources */, 83C35702180EDB74007E9DF0 /* MIDIContainer.mm in Sources */, - 83B0670C180D6665008E3612 /* BMPlayer.cpp in Sources */, + 83B0670C180D6665008E3612 /* BMPlayer.mm in Sources */, 83A09F651CFA83F2001E7D2D /* opl3class.cpp in Sources */, 83C35705180EDD1C007E9DF0 /* MIDIMetadataReader.mm in Sources */, 830C94D21D171B65000E404F /* json-builder.c in Sources */, diff --git a/Plugins/MIDI/MIDI/AUPlayer.mm b/Plugins/MIDI/MIDI/AUPlayer.mm index 3f7589c94..f86bbe2ae 100644 --- a/Plugins/MIDI/MIDI/AUPlayer.mm +++ b/Plugins/MIDI/MIDI/AUPlayer.mm @@ -2,6 +2,8 @@ #include +#import "SandboxBroker.h" + #define SF2PACK // #define AUPLAYERVIEW @@ -175,6 +177,13 @@ void AUPlayer::shutdown() free(bufferList); bufferList = NULL; } + + if ( sSoundFontName.length() ) { + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + + [sandboxBroker endFolderAccess:[NSURL fileURLWithPath:[NSString stringWithUTF8String:sSoundFontName.c_str()]]]; + } } void AUPlayer::enumComponents(callback cbEnum) @@ -336,6 +345,11 @@ bool AUPlayer::startup() // Now load instruments if (sSoundFontName.length()) { + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + + [sandboxBroker beginFolderAccess:[NSURL fileURLWithPath:[NSString stringWithUTF8String:sSoundFontName.c_str()]]]; + loadSoundFont( sSoundFontName.c_str() ); } diff --git a/Plugins/MIDI/MIDI/BMPlayer.cpp b/Plugins/MIDI/MIDI/BMPlayer.mm similarity index 88% rename from Plugins/MIDI/MIDI/BMPlayer.cpp rename to Plugins/MIDI/MIDI/BMPlayer.mm index 141cf0e93..7eac0fc4c 100644 --- a/Plugins/MIDI/MIDI/BMPlayer.cpp +++ b/Plugins/MIDI/MIDI/BMPlayer.mm @@ -1,5 +1,8 @@ #include "BMPlayer.h" +#import +#import "SandboxBroker.h" + #include #include @@ -23,6 +26,7 @@ struct Cached_SoundFont std::chrono::steady_clock::time_point time_released; HSOUNDFONT handle; sflist_presets * presetlist; + std::string path; Cached_SoundFont() : handle( 0 ), presetlist( 0 ) { } }; @@ -47,12 +51,17 @@ static void cache_deinit() Cache_Thread->join(); delete Cache_Thread; + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + for ( auto it = Cache_List.begin(); it != Cache_List.end(); ++it ) { if ( it->second.handle ) BASS_MIDI_FontFree( it->second.handle ); if ( it->second.presetlist ) sflist_free( it->second.presetlist ); + + [sandboxBroker endFolderAccess:[NSURL fileURLWithPath:[NSString stringWithUTF8String:it->second.path.c_str()]]]; } } @@ -60,6 +69,11 @@ static HSOUNDFONT cache_open_font( const char * path ) { HSOUNDFONT font = NULL; + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + + [sandboxBroker beginFolderAccess:[NSURL fileURLWithPath:[NSString stringWithUTF8String:path]]]; + std::lock_guard lock( Cache_Lock ); Cached_SoundFont & entry = Cache_List[ path ]; @@ -71,6 +85,7 @@ static HSOUNDFONT cache_open_font( const char * path ) { entry.handle = font; entry.ref_count = 1; + entry.path = path; } else { @@ -132,6 +147,11 @@ static sflist_presets * cache_open_list( const char * path ) { sflist_presets * presetlist = NULL; + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + + [sandboxBroker beginFolderAccess:[NSURL fileURLWithPath:[NSString stringWithUTF8String:path]]]; + std::lock_guard lock( Cache_Lock ); Cached_SoundFont & entry = Cache_List[ path ]; @@ -144,6 +164,7 @@ static sflist_presets * cache_open_list( const char * path ) { entry.presetlist = presetlist; entry.ref_count = 1; + entry.path = path; } else { @@ -191,6 +212,9 @@ static void cache_close_list( sflist_presets * presetlist ) static void cache_run() { + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + std::chrono::milliseconds dura( 250 ); Cache_Running = true; @@ -212,6 +236,9 @@ static void cache_run() BASS_MIDI_FontFree( it->second.handle ); if ( it->second.presetlist ) sflist_free( it->second.presetlist ); + + [sandboxBroker endFolderAccess:[NSURL fileURLWithPath:[NSString stringWithUTF8String:it->second.path.c_str()]]]; + it = Cache_List.erase( it ); continue; } diff --git a/Plugins/MIDI/MIDI/MIDIDecoder.h b/Plugins/MIDI/MIDI/MIDIDecoder.h index f9901a54e..08c93f4d8 100755 --- a/Plugins/MIDI/MIDI/MIDIDecoder.h +++ b/Plugins/MIDI/MIDI/MIDIDecoder.h @@ -18,6 +18,8 @@ class BMPlayer; @interface MIDIDecoder : NSObject { id source; int track_num; + + NSMutableArray* sandboxPaths; BMPlayer* bmplayer; AUPlayer* auplayer; diff --git a/Plugins/MIDI/MIDI/MIDIDecoder.mm b/Plugins/MIDI/MIDI/MIDIDecoder.mm index 802be17db..5c8dd71f2 100755 --- a/Plugins/MIDI/MIDI/MIDIDecoder.mm +++ b/Plugins/MIDI/MIDI/MIDIDecoder.mm @@ -15,10 +15,14 @@ #import "Logging.h" +#import "SandboxBroker.h" + #import #import "PlaylistController.h" +static NSString * scPath = @"/Library/Audio/Plug-Ins/Components/SOUND Canvas VA.component/Contents/Resources/SCCore00.dylib"; + static OSType getOSType(const char * in_) { const unsigned char * in = (const unsigned char *) in_; @@ -117,8 +121,17 @@ static OSType getOSType(const char * in_) { NSString * soundFontPath = @""; + sandboxPaths = [[NSMutableArray alloc] init]; + + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + if ( [[source url] isFileURL] ) { + [sandboxBroker beginFolderAccess:[source url]]; + + [sandboxPaths addObject:[source url]]; + // Let's check for a SoundFont NSArray * extensions = [NSArray arrayWithObjects:@"sflist", @"sf2pack", @"sf2", nil]; NSString * filePath = [[source url] path]; @@ -162,8 +175,9 @@ static OSType getOSType(const char * in_) bmplayer->setSincInterpolation( resampling_sinc ); bmplayer->setSampleRate( 44100 ); - if ( [soundFontPath length] ) + if ( [soundFontPath length] ) { bmplayer->setFileSoundFont( [soundFontPath UTF8String] ); + } player = bmplayer; } @@ -224,8 +238,12 @@ static OSType getOSType(const char * in_) mode = SCPlayer::sc_sc8850; else if ([flavor isEqualToString:@"xg"]) mode = SCPlayer::sc_xg; - - scplayer->set_sccore_path("/Library/Audio/Plug-Ins/Components/SOUND Canvas VA.component/Contents/Resources/SCCore00.dylib"); + + NSURL * scUrl = [NSURL fileURLWithPath:scPath]; + [sandboxBroker beginFolderAccess:scUrl]; + [sandboxPaths addObject:scUrl]; + + scplayer->set_sccore_path([scPath UTF8String]); scplayer->set_mode( mode ); scplayer->setSampleRate( 44100 ); @@ -341,6 +359,13 @@ static OSType getOSType(const char * in_) { delete player; player = NULL; + + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + + for (NSURL * url in sandboxPaths) { + [sandboxBroker endFolderAccess:url]; + } } - (void)dealloc diff --git a/Preferences/Preferences/MIDIPane.m b/Preferences/Preferences/MIDIPane.m index 4bea99e15..19cecba63 100644 --- a/Preferences/Preferences/MIDIPane.m +++ b/Preferences/Preferences/MIDIPane.m @@ -8,6 +8,8 @@ #import "MIDIPane.h" +#import "SandboxBroker.h" + @implementation MIDIPane - (NSString *)title @@ -37,6 +39,14 @@ NSInteger result = [panel runModal]; if(result == NSModalResponseOK) { + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + id sandboxBroker = [sandboxBrokerClass sharedSandboxBroker]; + + NSString * oldPath = [[NSUserDefaults standardUserDefaults] valueForKey:@"soundFontPath"]; + if (oldPath && [oldPath length]) { + [sandboxBroker removeBookmarkForURL:[NSURL fileURLWithPath:oldPath]]; + } + [sandboxBroker addBookmarkToDictionary:[panel URL]]; [[NSUserDefaults standardUserDefaults] setValue:[[panel URL] path] forKey:@"soundFontPath"]; } } diff --git a/Preferences/Preferences/Preferences.xcodeproj/project.pbxproj b/Preferences/Preferences/Preferences.xcodeproj/project.pbxproj index 82e8ee4bf..1a76f01d5 100644 --- a/Preferences/Preferences/Preferences.xcodeproj/project.pbxproj +++ b/Preferences/Preferences/Preferences.xcodeproj/project.pbxproj @@ -124,6 +124,7 @@ 83B06727180D85B8008E3612 /* MIDIPane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIPane.h; sourceTree = ""; }; 83B06728180D85B8008E3612 /* MIDIPane.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIDIPane.m; sourceTree = ""; }; 83B0672A180D8B39008E3612 /* midi.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = midi.png; path = Icons/midi.png; sourceTree = ""; }; + 83B5CBDB25EBAE4B000B0F8B /* SandboxBroker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SandboxBroker.h; path = ../../Utils/SandboxBroker.h; sourceTree = ""; }; 83BC5AB320E4C90F00631CD4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Preferences.xib; sourceTree = ""; }; 83DFEA091CBC94DE00BCC565 /* MIDIFlavorBehaviorArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIDIFlavorBehaviorArrayController.h; sourceTree = ""; }; 83DFEA0A1CBC94DE00BCC565 /* MIDIFlavorBehaviorArrayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIDIFlavorBehaviorArrayController.m; sourceTree = ""; }; @@ -207,6 +208,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 83B5CBDB25EBAE4B000B0F8B /* SandboxBroker.h */, 83F27E711810E41A00CEF538 /* Transformers */, 8384913618081ECB00E7332D /* Logging.h */, 17D503410ABDB1660022D1E8 /* Custom */, @@ -376,7 +378,7 @@ LastUpgradeCheck = 1230; TargetAttributes = { 8D5B49AC048680CD000E48DA = { - DevelopmentTeam = RXH4D9SUXM; + DevelopmentTeam = 4S876G9VCD; ProvisioningStyle = Automatic; }; };