1
使用FM8。MIDI:通過通道音量消息進行交叉淡入?
我想在第0聲道播放第2聲道上的長笛,並且第3聲道上的聲音在全音量上播放。 然後我想逐漸減少器官的體積,並提高長笛的音量。
問題是我聽不到笛聲完全升高,但只有器官音量下降。
我可能會誤解一些關於MIDI的非常基礎的東西嗎?
我用下面的'MUTE'替換0代替0(在擔心0可能被解釋爲某種「註釋」)而無濟於事。
下面的代碼的相關部分:
#define ORGAN 1
#define FLUTE 2
#define FULL 63
#define MUTE 1
#define BASE 0
#define M2nd 2
#define M3rd 4
#define M4th 5
#define M5th 7
#define FLUTE_CHANNEL 2
#define ORGAN_CHANNEL 3
#define CHANNEL_VOLUME 7
typedef enum {
MIDIStatusBytesNotOff = 0x80
, MIDIStatusBytesNotOn = 0x90
, MIDIStatusBytesAfterTouch = 0xa0
, MIDIStatusBytesControlChange = 0xb0
, MIDIStatusBytesProgramChange = 0xc0
, MIDIStatusBytesChannelPressure = 0xd0
, MIDIStatusBytesPitchWheel = 0xe0
} MIDIStatusBytes ;
- (void) sendSlowMo {
const UInt8 baseNote = 69 ;
const UInt8 start[] = {
MIDIStatusBytesProgramChange + FLUTE_CHANNEL, FLUTE
, MIDIStatusBytesProgramChange + ORGAN_CHANNEL, ORGAN
, MIDIStatusBytesNotOn + FLUTE_CHANNEL, baseNote+M4th, MUTE
, MIDIStatusBytesNotOn + ORGAN_CHANNEL, baseNote+BASE, FULL
} ;
const UInt8 stop[] = {
MIDIStatusBytesNotOff + FLUTE_CHANNEL, baseNote+M4th, MUTE
, MIDIStatusBytesNotOff + ORGAN_CHANNEL, baseNote+BASE, MUTE
, MIDIStatusBytesControlChange + FLUTE_CHANNEL, CHANNEL_VOLUME, FULL
, MIDIStatusBytesControlChange + ORGAN_CHANNEL, CHANNEL_VOLUME, FULL
} ;
UInt8 stepUpDown[] = {
MIDIStatusBytesControlChange + FLUTE_CHANNEL, CHANNEL_VOLUME, MUTE
, MIDIStatusBytesControlChange + ORGAN_CHANNEL, CHANNEL_VOLUME, FULL
} ;
[midi sendBytes:start size:sizeof(start)];
for (int i = 1 ; i < 128 ; ++i) {
stepUpDown[2] = (UInt8) i ;
stepUpDown[5] = (UInt8) (127 - i) ;
[midi sendBytes:stepUpDown size:sizeof(stepUpDown)];
[NSThread sleepForTimeInterval:0.10];
}
[midi sendBytes:stop size:sizeof(stop)];
}
我使用Pete Goodliffe's Excellent sample code爲出發點。
有什麼想法?