Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5842275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:59:47+00:00 2026-05-22T11:59:47+00:00

I have built a standalone app version of a project that until now was

  • 0

I have built a standalone app version of a project that until now was just a VST/audiounit. I am providing audio support via rtaudio.

I would like to add MIDI support using rtmidi but it’s not clear to me how to synchronise the audio and MIDI parts.

In VST/audiounit land, I am used to MIDI events that have a timestamp indicating their offset in samples from the start of the audio block.

rtmidi provides a delta time in seconds since the previous event, but I am not sure how I should grab those events and how I can work out their time in relation to the current sample in the audio thread.

How do plugin hosts do this?

I can understand how events can be sample accurate on playback, but it’s not clear how they could be sample accurate when using realtime input.

rtaudio gives me a callback function. I will run at a low block size (32 samples). I guess I will pass a pointer to an rtmidi instance as the userdata part of the callback and then call midiin->getMessage( &message ); inside the audio callback, but I am not sure if this is thread-sensible.

Many thanks for any tips you can give me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:59:48+00:00Added an answer on May 22, 2026 at 11:59 am

    In your case, you don’t need to worry about it. Your program should send the MIDI events to the plugin with a timestamp of zero as soon as they arrive. I think you have perhaps misunderstood the idea behind what it means to be “sample accurate”.

    As @Brad noted in his comment to your question, MIDI is indeed very slow. But that’s only part of the problem… when you are working in a block-based environment, incoming MIDI events cannot be processed by the plugin until the start of a block. When computers were slower and block sizes of 512 (or god forbid, >1024) were common, this introduced a non-trivial amount of latency which results in the arrangement not sounding as “tight”. Therefore sequencers came up with a clever way to get around this problem. Since the MIDI events are already known ahead of time, these events can be sent to the instrument one block early with an offset in sample frames. The plugin then receives these events at the start of the block, and knows not to start actually processing them until N samples have passed. This is what “sample accurate” means in sequencers.

    However, if you are dealing with live input from a keyboard or some sort of other MIDI device, there is no way to “schedule” these events. In fact, by the time you receive them, the clock is already ticking! Therefore these events should just be sent to the plugin at the start of the very next block with an offset of 0. Sequencers such as Ableton Live, which allow a plugin to simultaneously receive both pre-sequenced and live events, simply send any live events with an offset of 0 frames.

    Since you are using a very small block size, the worst-case scenario is a latency of .7ms, which isn’t too bad at all. In the case of rtmidi, the timestamp does not represent an offset which you need to schedule around, but rather the time which the event was captured. But since you only intend to receive live events (you aren’t writing a sequencer, are you?), you can simply pass any incoming MIDI to the plugin right away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project where I need to create a desktop app that acts
I have an XML schema that was built with an old version of the
I have a series of Servlets and Servlet Filters in a maven project that
I have built a site that relies on an XML feed that I currently
I'm trying to build the Windows version of my app. The program compiles and
Say I have two models in my Django project. class Project(models.Model): name = models.CharField(max_length=256)
I have a web-application built with GWT (2.0.3) and run on Apache Tomcat 6.
I have a Rails 3 application with several engines containing additional functionality. Each engine
Thinking that to solve a problem I've got this is the fastest solution: Generate
I'm developing a simple, stand-alone, command line Java application. The project is managed by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.