Google
 

Open Sound System
OSS 4.x Programmer's Guide

Do you have problems with sound/audio application development? Don't panic! Click here for help!

SNDCTL_MIDI_MTCINPUT

Turn on MTC input mode

Usage

int mtcrate=The MTC/SMPTE frame rate;
ioctl(fs, SNDCTL_MIDI_MTCINPUT, &mtcrate);

The above code fragment lacks all error checks for clarity. Real world applications must always check for the errors and handle them as described below. Also most OSS ioctl calls will return information in the argument variable and it's usually necessary to check it too.

Description

This ioctl call can be used to turn on generation of MTC quarter frame messages on a MIDI input device. Applications wanting to do software synthesis on real-time MIDI input may want to turn on this mode to get precise timing information. Without this information there is likely to be some amount of jitter in the audio output produced by the synhesizer program.

Note that this information is generated by the local OSS driver and inserted in the incoming MIDI byte stream. This may cause problems if the input stream already contains MTC messages generated by some external device. For this reason applications using this mode should provide some kind of method to disable it.

For best precision the 25 fps MTC rate is recommended because this provides least amount of jitter. Since 4 quarter frame messages will be sent for each frame this will result in a MTC message on every 1/100 seconds.

At this moment this mechanism is under construction and it should not be used in applications. Current OSS version will output MIDI timer tick messages at 100Hz rate instead of generating a MTC stream.

The SMPTE time reported by the MTC messages will start from 0 when the device is opened. However it's also possible that the time stops and restarts if this is forced by some other application. Applications using MTC timing should be able to detect if the time jumps back to zero. This is used to signal situations such as the end of a song and the start of a new one.

Compatibility issues

This call is new in OSS 4.0. No earlier OSS versions support it (errno=EINVAL will be returned.

OSS ioctl return values

The return value from the OSS ioctl calls will be -1 if a fatal error occurred. Other values mean that the ioctl call was more or less successful. However in most cases the application must check the value returned in the argument to see what was the accepted value.

Please see the Possible error codes (errno) returned by OSS calls section for more info about the error codes returned by OSS.

Sample programs

softsynth_gtk.cA simple software MIDI synthesizer program with GTK GUI.


Copyright (C) 4Front Technologies, 2007. All rights reserved.
Back to index OSS web site