mirror of
https://github.com/kyleneideck/BackgroundMusic
synced 2024-12-03 17:29:28 +00:00
Add support for Decibel
This commit is contained in:
parent
e87c43dc52
commit
5981e05bb1
4 changed files with 307 additions and 0 deletions
|
@ -54,6 +54,7 @@
|
|||
27D643BE1C9FB84C00737F6E /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 27D643BB1C9FB84C00737F6E /* Info.plist */; };
|
||||
27D643C01C9FB99200737F6E /* BGMXPCHelperService.m in Sources */ = {isa = PBXBuildFile; fileRef = 27D643BA1C9FB84C00737F6E /* BGMXPCHelperService.m */; };
|
||||
27D643C11C9FB99200737F6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 27D643BC1C9FB84C00737F6E /* main.m */; };
|
||||
C3B2D08C1CC5D04300F27601 /* BGMDecibel.m in Sources */ = {isa = PBXBuildFile; fileRef = C3B2D08B1CC5D04300F27601 /* BGMDecibel.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -173,6 +174,9 @@
|
|||
27D643BB1C9FB84C00737F6E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = BGMXPCHelper/Info.plist; sourceTree = SOURCE_ROOT; };
|
||||
27D643BC1C9FB84C00737F6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = BGMXPCHelper/main.m; sourceTree = SOURCE_ROOT; };
|
||||
27D643C41C9FBE5600737F6E /* BGM_TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BGM_TestUtils.h; path = ../SharedSource/BGM_TestUtils.h; sourceTree = "<group>"; };
|
||||
C3B2D0891CC5D01C00F27601 /* Decibel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Decibel.h; sourceTree = "<group>"; };
|
||||
C3B2D08A1CC5D03800F27601 /* BGMDecibel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BGMDecibel.h; sourceTree = "<group>"; };
|
||||
C3B2D08B1CC5D04300F27601 /* BGMDecibel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BGMDecibel.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -284,6 +288,8 @@
|
|||
1C4699461BD5C0E400F78043 /* BGMiTunes.m */,
|
||||
1C2336DD1BEAE10C004C1C4E /* BGMSpotify.h */,
|
||||
1C2336DE1BEAE10C004C1C4E /* BGMSpotify.m */,
|
||||
C3B2D08A1CC5D03800F27601 /* BGMDecibel.h */,
|
||||
C3B2D08B1CC5D04300F27601 /* BGMDecibel.m */,
|
||||
27379B881C7C562D0084A24C /* BGMVLC.h */,
|
||||
27379B891C7C562D0084A24C /* BGMVLC.m */,
|
||||
273F10DD1CC3D0B900C1C6DA /* BGMVox.h */,
|
||||
|
@ -387,6 +393,7 @@
|
|||
27379B841C7C53BE0084A24C /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C3B2D0891CC5D01C00F27601 /* Decibel.h */,
|
||||
27379B851C7C54870084A24C /* iTunes.h */,
|
||||
27379B861C7C54870084A24C /* Spotify.h */,
|
||||
27379B871C7C552A0084A24C /* VLC.h */,
|
||||
|
@ -606,6 +613,7 @@
|
|||
1CC1DF811BE5068A00FB8FE4 /* CACFArray.cpp in Sources */,
|
||||
1C0BD0A81BF1B029004F4CF5 /* BGMPreferencesMenu.mm in Sources */,
|
||||
1C1962F41BCABFC5008A4DF7 /* CAHALAudioObject.cpp in Sources */,
|
||||
C3B2D08C1CC5D04300F27601 /* BGMDecibel.m in Sources */,
|
||||
1C2336DA1BEAB6E7004C1C4E /* BGMMusicPlayer.m in Sources */,
|
||||
1C1962F61BCABFC5008A4DF7 /* CAHALAudioSystemObject.cpp in Sources */,
|
||||
1CC1DF821BE5068A00FB8FE4 /* CACFDictionary.cpp in Sources */,
|
||||
|
|
30
BGMApp/BGMApp/BGMDecibel.h
Normal file
30
BGMApp/BGMApp/BGMDecibel.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
// This file is part of Background Music.
|
||||
//
|
||||
// Background Music is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// Background Music is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Background Music. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//
|
||||
// BGMDecibel.h
|
||||
// BGMApp
|
||||
//
|
||||
// Copyright © 2016 Kyle Neideck
|
||||
//
|
||||
|
||||
// Superclass/Protocol Import
|
||||
#import "BGMMusicPlayer.h"
|
||||
|
||||
|
||||
@interface BGMDecibel : BGMMusicPlayer
|
||||
|
||||
@end
|
||||
|
91
BGMApp/BGMApp/BGMDecibel.m
Normal file
91
BGMApp/BGMApp/BGMDecibel.m
Normal file
|
@ -0,0 +1,91 @@
|
|||
// This file is part of Background Music.
|
||||
//
|
||||
// Background Music is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// Background Music is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Background Music. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//
|
||||
// BGMDecibel.m
|
||||
// BGMApp
|
||||
//
|
||||
// Copyright © 2016 Kyle Neideck
|
||||
//
|
||||
|
||||
// Self Include
|
||||
#import "BGMDecibel.h"
|
||||
|
||||
// Auto-generated Scripting Bridge header
|
||||
#import "Decibel.h"
|
||||
|
||||
// PublicUtility Includes
|
||||
#undef CoreAudio_ThreadStampMessages
|
||||
#define CoreAudio_ThreadStampMessages 0 // Requires C++
|
||||
#include "CADebugMacros.h"
|
||||
|
||||
|
||||
@implementation BGMDecibel
|
||||
|
||||
BGM_MUSIC_PLAYER_DEFAULT_LOAD_METHOD
|
||||
|
||||
+ (NSString*) name {
|
||||
return @"Decibel";
|
||||
}
|
||||
|
||||
- (CFNumberRef) pid {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ (CFStringRef) bundleID {
|
||||
return CFSTR("org.sbooth.Decibel");
|
||||
}
|
||||
|
||||
- (DecibelApplication* __nullable) decibel {
|
||||
return (DecibelApplication*) self.sbApplication;
|
||||
}
|
||||
|
||||
- (BOOL) isRunning {
|
||||
return self.decibel && [self.decibel isRunning];
|
||||
}
|
||||
|
||||
- (BOOL) pause {
|
||||
// isPlaying checks isRunning, so we don't need to check it here and waste an Apple event
|
||||
BOOL wasPlaying = [self isPlaying];
|
||||
|
||||
if (wasPlaying) {
|
||||
DebugMsg("BGMDecibel::pause: Pausing Decibel");
|
||||
[self.decibel pause];
|
||||
}
|
||||
|
||||
return wasPlaying;
|
||||
}
|
||||
|
||||
- (BOOL) unpause {
|
||||
// isPaused checks isRunning, so we don't need to check it here and waste an Apple event
|
||||
BOOL wasPaused = [self isPaused];
|
||||
|
||||
if (wasPaused) {
|
||||
DebugMsg("BGMDecibel::unpause: Unpausing Decibel");
|
||||
[self.decibel playPause];
|
||||
}
|
||||
|
||||
return wasPaused;
|
||||
}
|
||||
|
||||
- (BOOL) isPlaying {
|
||||
return [self isRunning] && [self.decibel playing];
|
||||
}
|
||||
|
||||
- (BOOL) isPaused {
|
||||
return [self isRunning] && ![self.decibel playing];
|
||||
}
|
||||
|
||||
@end
|
178
BGMApp/BGMApp/Decibel.h
Normal file
178
BGMApp/BGMApp/Decibel.h
Normal file
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* Decibel.h
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <ScriptingBridge/ScriptingBridge.h>
|
||||
|
||||
|
||||
@class DecibelApplication, DecibelDocument, DecibelWindow, DecibelApplication, DecibelTrack;
|
||||
|
||||
enum DecibelSaveOptions {
|
||||
DecibelSaveOptionsYes = 'yes ' /* Save the file. */,
|
||||
DecibelSaveOptionsNo = 'no ' /* Do not save the file. */,
|
||||
DecibelSaveOptionsAsk = 'ask ' /* Ask the user whether or not to save the file. */
|
||||
};
|
||||
typedef enum DecibelSaveOptions DecibelSaveOptions;
|
||||
|
||||
enum DecibelPrintingErrorHandling {
|
||||
DecibelPrintingErrorHandlingStandard = 'lwst' /* Standard PostScript error handling */,
|
||||
DecibelPrintingErrorHandlingDetailed = 'lwdt' /* print a detailed report of PostScript errors */
|
||||
};
|
||||
typedef enum DecibelPrintingErrorHandling DecibelPrintingErrorHandling;
|
||||
|
||||
enum DecibelShuffleMode {
|
||||
DecibelShuffleModeOff = 'off ' /* Off */,
|
||||
DecibelShuffleModeTrack = 'trck' /* Track */,
|
||||
DecibelShuffleModeAlbum = 'albm' /* Album */,
|
||||
DecibelShuffleModeArtist = 'arts' /* Artist */
|
||||
};
|
||||
typedef enum DecibelShuffleMode DecibelShuffleMode;
|
||||
|
||||
enum DecibelRepeatMode {
|
||||
DecibelRepeatModeOff = 'off ' /* Off */,
|
||||
DecibelRepeatModeTrack = 'trck' /* Track */,
|
||||
DecibelRepeatModeAlbum = 'albm' /* Album */,
|
||||
DecibelRepeatModeArtist = 'arts' /* Artist */,
|
||||
DecibelRepeatModeAll = 'all ' /* All */
|
||||
};
|
||||
typedef enum DecibelRepeatMode DecibelRepeatMode;
|
||||
|
||||
@protocol DecibelGenericMethods
|
||||
|
||||
- (void) closeSaving:(DecibelSaveOptions)saving savingIn:(NSURL *)savingIn; // Close a document.
|
||||
- (void) saveIn:(NSURL *)in_ as:(id)as; // Save a document.
|
||||
- (void) printWithProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog; // Print a document.
|
||||
- (void) delete; // Delete an object.
|
||||
- (void) duplicateTo:(SBObject *)to withProperties:(NSDictionary *)withProperties; // Copy an object.
|
||||
- (void) moveTo:(SBObject *)to; // Move an object to a new location.
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Standard Suite
|
||||
*/
|
||||
|
||||
// The application's top-level scripting object.
|
||||
@interface DecibelApplication : SBApplication
|
||||
|
||||
- (SBElementArray<DecibelDocument *> *) documents;
|
||||
- (SBElementArray<DecibelWindow *> *) windows;
|
||||
|
||||
@property (copy, readonly) NSString *name; // The name of the application.
|
||||
@property (readonly) BOOL frontmost; // Is this the active application?
|
||||
@property (copy, readonly) NSString *version; // The version number of the application.
|
||||
|
||||
- (id) open:(id)x; // Open a document.
|
||||
- (void) print:(id)x withProperties:(NSDictionary *)withProperties printDialog:(BOOL)printDialog; // Print a document.
|
||||
- (void) quitSaving:(DecibelSaveOptions)saving; // Quit the application.
|
||||
- (BOOL) exists:(id)x; // Verify that an object exists.
|
||||
- (void) play; // Begin audio playback
|
||||
- (void) pause; // Suspend audio playback
|
||||
- (void) stop; // Stop audio playback
|
||||
- (void) playPause; // Begin or suspend audio playback
|
||||
- (void) seekForward; // Seek forward three seconds
|
||||
- (void) seekBackward; // Seek backward three seconds
|
||||
- (void) playSelection; // Play the selected track, or the first track if more than one are selected
|
||||
- (void) playPreviousTrack; // Play the previous logical track in the playlist
|
||||
- (void) playNextTrack; // Play the next logical track in the playlist
|
||||
- (void) addFile:(NSURL *)x; // Add a file to the playlist
|
||||
- (void) playFile:(NSURL *)x; // Add a file to the playlist and play it
|
||||
- (void) playTrackAtIndex:(NSInteger)x; // Play a track in the playlist
|
||||
- (void) increaseDeviceVolume; // Increase the device volume
|
||||
- (void) decreaseDeviceVolume; // Decrease the device volume
|
||||
- (void) increaseDigitalVolume; // Increase the digital volume
|
||||
- (void) decreaseDigitalVolume; // Decrease the digital volume
|
||||
- (void) clearPlaylist; // Clear the playlist
|
||||
- (void) scramblePlaylist; // Scramble the playlist
|
||||
|
||||
@end
|
||||
|
||||
// A document.
|
||||
@interface DecibelDocument : SBObject <DecibelGenericMethods>
|
||||
|
||||
@property (copy, readonly) NSString *name; // Its name.
|
||||
@property (readonly) BOOL modified; // Has it been modified since the last save?
|
||||
@property (copy, readonly) NSURL *file; // Its location on disk, if it has one.
|
||||
|
||||
|
||||
@end
|
||||
|
||||
// A window.
|
||||
@interface DecibelWindow : SBObject <DecibelGenericMethods>
|
||||
|
||||
@property (copy, readonly) NSString *name; // The title of the window.
|
||||
- (NSInteger) id; // The unique identifier of the window.
|
||||
@property NSInteger index; // The index of the window, ordered front to back.
|
||||
@property NSRect bounds; // The bounding rectangle of the window.
|
||||
@property (readonly) BOOL closeable; // Does the window have a close button?
|
||||
@property (readonly) BOOL miniaturizable; // Does the window have a minimize button?
|
||||
@property BOOL miniaturized; // Is the window minimized right now?
|
||||
@property (readonly) BOOL resizable; // Can the window be resized?
|
||||
@property BOOL visible; // Is the window visible right now?
|
||||
@property (readonly) BOOL zoomable; // Does the window have a zoom button?
|
||||
@property BOOL zoomed; // Is the window zoomed right now?
|
||||
@property (copy, readonly) DecibelDocument *document; // The document whose contents are displayed in the window.
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Decibel Scripting Suite
|
||||
*/
|
||||
|
||||
// The Decibel application class.
|
||||
@interface DecibelApplication (DecibelScriptingSuite)
|
||||
|
||||
- (SBElementArray<DecibelTrack *> *) tracks;
|
||||
|
||||
@property (readonly) BOOL playing; // Is the player currently playing?
|
||||
@property (readonly) BOOL shuffling; // Is the player currently shuffling?
|
||||
@property (readonly) BOOL repeating; // Is the player currently repeating?
|
||||
@property (copy, readonly) DecibelTrack *nowPlaying; // The track that is currently playing?
|
||||
@property double deviceVolume; // The current device volume
|
||||
@property double digitalVolume; // The current digital volume
|
||||
@property double playbackPosition; // The current playback position [0, 1]
|
||||
@property double playbackTime; // The current playback time in seconds
|
||||
@property (readonly) BOOL canPlay; // Is the player currently playing?
|
||||
@property (readonly) BOOL canPlayPreviousTrack; // Is the player currently playing?
|
||||
@property (readonly) BOOL canPlayNextTrack; // Is the player currently playing?
|
||||
@property (readonly) BOOL canAdjustDeviceVolume; // Can the device volume be adjusted?
|
||||
@property DecibelShuffleMode shuffleMode; // Player shuffle mode
|
||||
@property DecibelRepeatMode repeatMode; // Player repeat mode
|
||||
@property (copy, readonly) SBObject *currentPlaylist; // The current playlist
|
||||
|
||||
@end
|
||||
|
||||
// A track in the playlist
|
||||
@interface DecibelTrack : SBObject <DecibelGenericMethods>
|
||||
|
||||
- (NSString *) id; // The track's ID
|
||||
@property (copy, readonly) NSURL *file; // The track's location
|
||||
@property (readonly) double duration; // The track's duration in seconds
|
||||
@property (readonly) double sampleRate; // The track's sample rate in Hz
|
||||
@property (readonly) NSInteger bitDepth; // The bit depth
|
||||
@property (readonly) NSInteger channels; // The track's channels
|
||||
@property (copy) NSString *title; // The track's title
|
||||
@property (copy) NSString *artist; // The track's artist
|
||||
@property (copy) NSString *albumTitle; // The track's album title
|
||||
@property (copy) NSString *albumArtist; // The track's album artist
|
||||
@property NSInteger trackNumber; // The track's track number
|
||||
@property NSInteger trackTotal; // The total number of tracks on the album
|
||||
@property NSInteger discNumber; // The disc number containing the track
|
||||
@property NSInteger discTotal; // The total number of discs (for multidisc albums)
|
||||
@property BOOL partOfACompilation; // Is the track part of a compilation?
|
||||
@property (copy) NSString *genre; // The track's genre
|
||||
@property (copy) NSString *composer; // The track's composer
|
||||
@property (copy) NSString *releaseDate; // The track's release date
|
||||
@property (copy) NSString *ISRC; // The track's ISRC
|
||||
@property (copy) id MCN; // The track's MCN
|
||||
|
||||
- (void) playTrack; // Play a track in the playlist
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in a new issue