| 1 |
/* |
| 2 |
* MDPlayer_MacOSX.h |
| 3 |
* |
| 4 |
* Created by Toshi Nagata on Sun Jul 01 2001. |
| 5 |
|
| 6 |
Copyright (c) 2000-2016 Toshi Nagata. All rights reserved. |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation version 2 of the License. |
| 11 |
|
| 12 |
This program is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef __MDPlayer_MacOSX__ |
| 19 |
#define __MDPlayer_MacOSX__ |
| 20 |
|
| 21 |
#include "MDSequence.h" |
| 22 |
#include "MDAudio.h" |
| 23 |
|
| 24 |
typedef struct MetronomeInfoRecord { |
| 25 |
int32_t dev; |
| 26 |
int channel; |
| 27 |
int note1; |
| 28 |
int vel1; |
| 29 |
int note2; |
| 30 |
int vel2; |
| 31 |
char enableWhenPlay; |
| 32 |
char enableWhenRecord; |
| 33 |
int32_t duration; |
| 34 |
} MetronomeInfoRecord; |
| 35 |
|
| 36 |
extern MetronomeInfoRecord gMetronomeInfo; |
| 37 |
|
| 38 |
typedef struct MDPlayer MDPlayer; |
| 39 |
|
| 40 |
typedef signed char MDPlayerStatus; |
| 41 |
enum { |
| 42 |
kMDPlayer_idle = 0, |
| 43 |
kMDPlayer_ready, |
| 44 |
kMDPlayer_playing, |
| 45 |
kMDPlayer_suspended, |
| 46 |
kMDPlayer_exhausted |
| 47 |
}; |
| 48 |
|
| 49 |
//#define GetHostTimeInMDTimeType() ((MDTimeType)((AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()) / 1000))) |
| 50 |
#define ConvertMDTimeTypeToHostTime(tm) AudioConvertNanosToHostTime((UInt64)(tm) * 1000) |
| 51 |
#define ConvertHostTimeToMDTimeType(tm) ((MDTimeType)(AudioConvertHostTimeToNanos(tm) / 1000)) |
| 52 |
#define GetHostTimeInMDTimeType() ConvertHostTimeToMDTimeType(AudioGetCurrentHostTime()) |
| 53 |
|
| 54 |
|
| 55 |
/* ------------------------------------------------------------------- |
| 56 |
MDPlayer functions |
| 57 |
------------------------------------------------------------------- */ |
| 58 |
|
| 59 |
/*void MDPlayerInitMIDIDevices(void); */ |
| 60 |
|
| 61 |
MDPlayer * MDPlayerNew(MDSequence *inSequence); |
| 62 |
void MDPlayerRetain(MDPlayer *inPlayer); |
| 63 |
void MDPlayerRelease(MDPlayer *inPlayer); |
| 64 |
|
| 65 |
MDStatus MDPlayerSetSequence(MDPlayer *inPlayer, MDSequence *inSequence); |
| 66 |
MDStatus MDPlayerRefreshTrackDestinations(MDPlayer *inPlayer); |
| 67 |
MDStatus MDPlayerJumpToTick(MDPlayer *inPlayer, MDTickType inTick); |
| 68 |
MDStatus MDPlayerPreroll(MDPlayer *inPlayer, MDTickType inTick, int backtrack); |
| 69 |
MDStatus MDPlayerStart(MDPlayer *inPlayer); |
| 70 |
MDStatus MDPlayerStop(MDPlayer *inPlayer); |
| 71 |
MDStatus MDPlayerSuspend(MDPlayer *inPlayer); |
| 72 |
MDStatus MDPlayerStartRecording(MDPlayer *inPlayer); |
| 73 |
MDStatus MDPlayerSetRecordingStopTick(MDPlayer *inPlayer, MDTickType inTick); |
| 74 |
MDStatus MDPlayerStopRecording(MDPlayer *inPlayer); |
| 75 |
|
| 76 |
MDPlayerStatus MDPlayerGetStatus(MDPlayer *inPlayer); |
| 77 |
int MDPlayerIsRecording(MDPlayer *inPlayer); |
| 78 |
MDPlayer * MDPlayerRecordingPlayer(void); |
| 79 |
|
| 80 |
MDTimeType MDPlayerGetTime(MDPlayer *inPlayer); |
| 81 |
MDTickType MDPlayerGetTick(MDPlayer *inPlayer); |
| 82 |
|
| 83 |
void MDPlayerSetMIDIThruDeviceAndChannel(int32_t dev, int ch); |
| 84 |
void MDPlayerSetMIDIThruTranspose(int transpose); |
| 85 |
void MDPlayerSetCountOffSettings(MDPlayer *inPlayer, MDTimeType duration, MDTimeType bar, MDTimeType beat); |
| 86 |
MDStatus MDPlayerBacktrackEvents(MDPlayer *inPlayer, MDTickType inTick, const int32_t *inEventType, const int32_t *inEventTypeLastOnly); |
| 87 |
int MDPlayerSendRawMIDI(MDPlayer *player, const unsigned char *p, int size, int destDevice, MDTimeType scheduledTime); |
| 88 |
void MDPlayerRingMetronomeClick(MDPlayer *inPlayer, MDTimeType atTime, int isPrincipal); |
| 89 |
|
| 90 |
void MDPlayerReloadDeviceInformation(void); |
| 91 |
int32_t MDPlayerGetNumberOfDestinations(void); |
| 92 |
MDStatus MDPlayerGetDestinationName(int32_t dev, char *name, int32_t sizeof_name); |
| 93 |
int32_t MDPlayerGetDestinationNumberFromName(const char *name); |
| 94 |
int32_t MDPlayerGetDestinationUniqueID(int32_t dev); |
| 95 |
int32_t MDPlayerGetDestinationNumberFromUniqueID(int32_t uniqueID); |
| 96 |
int32_t MDPlayerGetNumberOfSources(void); |
| 97 |
MDStatus MDPlayerGetSourceName(int32_t dev, char *name, int32_t sizeof_name); |
| 98 |
int32_t MDPlayerGetSourceNumberFromName(const char *name); |
| 99 |
//int32_t MDPlayerGetSourceUniqueID(int32_t dev); |
| 100 |
//int32_t MDPlayerGetSourceNumberFromUniqueID(int32_t uniqueID); |
| 101 |
int32_t MDPlayerAddDestinationName(const char *name); |
| 102 |
int32_t MDPlayerAddSourceName(const char *name); |
| 103 |
|
| 104 |
int MDPlayerUpdatePatchNames(int32_t dev); |
| 105 |
int MDPlayerGetNumberOfPatchNames(int32_t dev); |
| 106 |
int MDPlayerGetPatchName(int32_t dev, int bank, int progno, char *name, int32_t sizeof_name); |
| 107 |
|
| 108 |
int MDPlayerGetRecordedEvents(MDPlayer *inPlayer, MDEvent **outEvent, int *outEventBufSiz); |
| 109 |
void MDPlayerClearRecordedEvents(MDPlayer *inPlayer); |
| 110 |
|
| 111 |
/*MDAudio * MDPlayerGetAudioPlayer(MDPlayer *inPlayer); */ |
| 112 |
|
| 113 |
/* These are only for internal (and debugging) use. Use MDPlayerGetRecordedEvent() to retreave recorded data. */ |
| 114 |
int MDPlayerPutRecordingData(MDPlayer *inPlayer, MDTimeType timeStamp, int32_t size, const unsigned char *buf); |
| 115 |
int MDPlayerGetRecordingData(MDPlayer *inPlayer, MDTimeType *outTimeStamp, int32_t *outSize, unsigned char **outBuf, int32_t *outBufSize); |
| 116 |
|
| 117 |
/* Defined in MyAppController.m; will be called when any of the MIDI setup is modified */ |
| 118 |
extern void MDPlayerNotificationCallback(void); |
| 119 |
|
| 120 |
/* Utility function */ |
| 121 |
int my_usleep(uint32_t useconds); |
| 122 |
|
| 123 |
#endif /* __MDPlayer_MacOSX__ */ |