| 1 |
/* |
| 2 |
* MDCalibrator.h |
| 3 |
* |
| 4 |
* Created by Toshi Nagata on Sun Jun 17 2001. |
| 5 |
|
| 6 |
Copyright (c) 2000-2011 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 __MDCalibrator__ |
| 19 |
#define __MDCalibrator__ |
| 20 |
|
| 21 |
/* |
| 22 |
MDCalibrator は、メタイベントが持っている情報をキャッシュしておき「現在位置」での情報を |
| 23 |
すばやく取りだせるようにする。 |
| 24 |
tempo, time signature については内部データ(それぞれそのイベント位置での絶対時間、小節番号) |
| 25 |
を同時に管理する。それ以外のイベントについては data1 フィールドだけを管理する。data1 以外のフィールド |
| 26 |
が意味をもつイベント(テキスト系メタイベントなど)の場合はイベントへのポインタそのものを取り出して利用できる。 */ |
| 27 |
|
| 28 |
typedef struct MDCalibrator MDCalibrator; |
| 29 |
|
| 30 |
#ifndef __MDCommon__ |
| 31 |
#include "MDCommon.h" |
| 32 |
#endif |
| 33 |
|
| 34 |
#ifndef __MDSequence__ |
| 35 |
#include "MDSequence.h" |
| 36 |
#endif |
| 37 |
|
| 38 |
#ifdef __cplusplus |
| 39 |
extern "C" { |
| 40 |
#endif |
| 41 |
|
| 42 |
/* ------------------------------------------------------------------- |
| 43 |
MDCalibrator functions |
| 44 |
------------------------------------------------------------------- */ |
| 45 |
/* inKind が kMDEventTempo または kMDEventTimeSignature のときは、inTrack は NULL でよい。 |
| 46 |
(自動的にコンダクタートラックが使われる) |
| 47 |
inCode は code でイベント種類が指定される(できる)以下のイベントについて指定する: |
| 48 |
kMDEventMeta, kMDEventMetaText, kMDEventMetaMessage, kMDEventNoteOff, kMDEventNoteOn, |
| 49 |
kMDEventNote, kMDEventControl, kMDEventKeyPres, kMDEventData, kMDEventObject. |
| 50 |
code を問わずどのイベントも認識させるためには inCode に -1 を渡す。 |
| 51 |
*/ |
| 52 |
MDCalibrator * MDCalibratorNew(MDSequence *inSequence, MDTrack *inTrack, MDEventKind inKind, short inCode); |
| 53 |
void MDCalibratorRetain(MDCalibrator *inCalib); |
| 54 |
void MDCalibratorRelease(MDCalibrator *inCalib); |
| 55 |
|
| 56 |
/* MDCalibrator は1つのインスタンスについて複数の情報を管理できる(実際には複数のレコードを |
| 57 |
リストにしてつないでいるだけ)。 */ |
| 58 |
MDStatus MDCalibratorAppend(MDCalibrator *inCalib, MDTrack *inTrack, MDEventKind inKind, short inCode); |
| 59 |
|
| 60 |
/* MDCalibrator の index 番目のレコードが管理している情報を得る。index が不正な値の場合は kMDErrorBadParameter を返す。 */ |
| 61 |
MDStatus MDCalibratorGetInfo(MDCalibrator *inCalib, int index, MDTrack **outTrack, MDEventKind *outKind, short *outCode); |
| 62 |
|
| 63 |
/* MDCalibrator の index 番目のレコードを破棄する。 */ |
| 64 |
MDStatus MDCalibratorRemoveAtIndex(MDCalibrator *inCalib, int index); |
| 65 |
|
| 66 |
/* inCalib がある track/kind/code の情報を管理しているか */ |
| 67 |
int MDCalibratorIsSupporting(MDCalibrator *inCalib, MDTrack *inTrack, MDEventKind inKind, short inCode); |
| 68 |
|
| 69 |
/* リセット。内部にキャッシュされている情報を破棄する */ |
| 70 |
void MDCalibratorReset(MDCalibrator *inCalib); |
| 71 |
|
| 72 |
/* inCalib->next (inCalib->chain ではなく) を返す。内部的にのみ使われる。 */ |
| 73 |
MDCalibrator * MDCalibratorNextInList(MDCalibrator *inCalib); |
| 74 |
void MDCalibratorSetNextInList(MDCalibrator *inCalib, MDCalibrator *inNextCalib); |
| 75 |
|
| 76 |
/* inTick の位置に移動する */ |
| 77 |
void MDCalibratorJumpToTick(MDCalibrator *inCalib, MDTickType inTick); |
| 78 |
|
| 79 |
/* 指定したトラックの inPosition の位置に移動する。指定トラック以外の情報については、そのイベントの tick 位置に移動する */ |
| 80 |
void MDCalibratorJumpToPositionInTrack(MDCalibrator *inCalib, int32_t inPosition, MDTrack *inTrack); |
| 81 |
|
| 82 |
/* 小節・拍・カウント表記 <-> tick 変換 */ |
| 83 |
MDTickType MDCalibratorMeasureToTick(MDCalibrator *inCalib, int32_t inMeasure, int32_t inBeat, int32_t inTick); |
| 84 |
void MDCalibratorTickToMeasure(MDCalibrator *inCalib, MDTickType inTick, int32_t *outMeasure, int32_t *outBeat, int32_t *outTick); |
| 85 |
|
| 86 |
float MDCalibratorGetTempo(MDCalibrator *inCalib); |
| 87 |
MDTickType MDCalibratorTimeToTick(MDCalibrator *inCalib, MDTimeType inTime); |
| 88 |
MDTimeType MDCalibratorTickToTime(MDCalibrator *inCalib, MDTickType inTick); |
| 89 |
|
| 90 |
MDEvent * MDCalibratorGetEvent(MDCalibrator *inCalib, MDTrack *inTrack, MDEventKind inKind, short inCode); |
| 91 |
MDEvent * MDCalibratorGetNextEvent(MDCalibrator *inCalib, MDTrack *inTrack, MDEventKind inKind, short inCode); |
| 92 |
int32_t MDCalibratorGetEventPosition(MDCalibrator *inCalib, MDTrack *inTrack, MDEventKind inKind, short inCode); |
| 93 |
MDPointer * MDCalibratorCopyPointer(MDCalibrator *inCalib, MDTrack *inTrack, MDEventKind inKind, short inCode); |
| 94 |
|
| 95 |
#ifdef __cplusplus |
| 96 |
} |
| 97 |
#endif |
| 98 |
|
| 99 |
#endif /* __MDCalibrator__ */ |