gpt4 book ai didi

ios - 如何将 sysex 数据添加到 MusicTrack? (音频工具箱)

转载 作者:行者123 更新时间:2023-11-30 17:34:06 28 4
gpt4 key购买 nike

我正在尝试用二十一点等编写我的小型 MIDI 音序器,但仍坚持将 sysex 数据写入 MusicTrack。我使用以下代码插入 sysex 事件

// ---- Some code here --- //

PatternData pattern = { sizeof(PatternData), i, signature.numerator, signature.denominator };
CABarBeatTime beattime = CABarBeatTime((i * signature.numerator * signature.denominator) + 1, 1, 0, SUBBEAT_DIVISOR_DEFAULT);
// Convert beattime to timestamp
if ((MusicSequenceBarBeatTimeToBeats(sequence, &beattime, &timestamp)) != noErr)
{
return status;
}
// Add event
if ((status = MusicTrackNewMIDIRawDataEvent(track, timestamp, (MIDIRawData*)&pattern)) != noErr)
{
return status;
}

// ---- Some code here --- //

模式数据是

typedef struct PatternData 
{
UInt32 length; // Struct length
UInt8 index; // Pattern index
UInt8 bars; // Number of bars in patten
UInt8 beats; // Number of beats in pattern
} PatternData;

我做错了什么,因为在调用 MusicSequenceFileCreate 之后我得到了损坏的文件。有人有如何将 sysex 数据添加到音乐轨道的示例吗?

最佳答案

好的。我找到了一个正确的方法,这就是:

    UInt8 data[] = { 0xF0, manufacturerId, databyte1, databyte2, databyte3, 0xF7 };
MIDIRawData raw;
memcpy(raw.data, data, 0, sizeof(data));
raw.length = sizeof(data);

if ((status = MusicTrackNewMIDIRawDataEvent(track, timestamp, &raw)) != noErr)
{
return status;
}

关于ios - 如何将 sysex 数据添加到 MusicTrack? (音频工具箱),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23519892/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com