Question

Recently I've been playing with the haskell ALSA interface, and I had to notice, that I do not really understand the concepts of tempo and PPQ.

Earlier I've written a Swig-Python interface to ALSA and in there I find the following piece of code (probably copied from somewhere else):

1    void  AlsaMidiIfc::setTempo (int bpm) {
2       int queue = this->getOutQueue();
3       snd_seq_queue_tempo_t *tempo;
4       snd_seq_queue_tempo_alloca (&tempo);
5       snd_seq_queue_tempo_set_tempo(tempo, 60 * 1000000 / bpm);
6       snd_seq_queue_tempo_set_ppq(tempo, PPQ);
7       snd_seq_set_queue_tempo (mySeq, queue, tempo);
8    }

When I put an event into a queue, the time is always specified in ticks, right? So the only timing question to answer is "how long is a tick?".

  • What is the point of specifying two values, i.e. tempo and PPQ?

  • What would be the effect of changing the tempo, but leaving PPQ as it is?

  • If I don't set PPQ at all, but only the tempo, what would be the result?

Was it helpful?

Solution

  • Standard MIDI Files use these two values (tempo and PPQ) to specify the tempo. The ALSA sequencer just uses the same mechanism.

  • The tempo value is the number of microseconds per quarter note. Increasing it will increase the length of a tick, i.e., make playback slower.

  • A PPQ value of zero would be invalid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top