ios - 将非常简单的 MusicSequence 保存到 MIDI 中不会重现声音

标签 ios iphone ios5 midi musicsequence

我正在尝试将一个非常基本的单音符 MusicSequence ( MusicSequence Reference ) 保存到 MIDI 文件中。现在正在写入文件,音符的持续时间也正在写入(如果我将持续时间设置为 4,则 MIDI 文件持续 2 秒,如果我将其更改为 2,则它应该持续 1 秒)但是没有声音被再现并且如果我在 Logic 中查看 MIDI 文件,也没有任何信息。似乎音符持续时间被写入,但音符的音符没有。

会发生什么?

+ (MusicSequence)getSequence
{
    MusicSequence mySequence;
    MusicTrack myTrack;
    NewMusicSequence(&mySequence);
    MusicSequenceNewTrack(mySequence, &myTrack);

    MIDINoteMessage noteMessage;
    MusicTimeStamp timestamp = 0;
    noteMessage.channel = 0;
    noteMessage.note = 4;
    noteMessage.velocity = 90;
    noteMessage.releaseVelocity = 0;
    noteMessage.duration = 4;

    if (MusicTrackNewMIDINoteEvent(myTrack, timestamp, &noteMessage) != noErr) NSLog(@"ERROR creating the note");
    else NSLog(@"Note added");

    return mySequence;
}

最佳答案

尝试写一个 > 20 且 < 109 ( midi note range ) 的注释。虽然 4 在技术上可能是有效的,但它超出了正常 MIDI 音符的范围。

此外,与 Core Audio/MusicPlayer 等一起使用的一个有用函数是 CAShow() - 因此请尝试使用 CAShow(sequence) 来查看序列数据。

关于ios - 将非常简单的 MusicSequence 保存到 MIDI 中不会重现声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11803691/

相关文章:

iphone - 如何组合 UIImageViews 并在图库中另存为单个图像作为单个图像

启动画面的 iOS 持续时间(Default.png)

ios - 从 UITableView 出队后的 UITableViewCell View 不为空

iphone - 启动模态 UINavigationController

ios - API图像文件上传iPhone到Ruby on Rails

iphone - 当我想使用outputStream创建文件时,我总是得到-1

iphone - 当我使用 addChildViewController 时未调用 dealloc

javascript - 如何让备用样式表在 iOS5 Safari 上工作?

javascript - 将 NSURLProtocol 与 ReactNative 结合使用

ASP.Net 在 UIWebView 和 ASIHttpRequest 之间形成身份验证 cookie