[linux-audio-user] midi timings

Florian Schmidt mista.tapas at gmx.net
Fri Jan 26 18:43:55 EST 2007

On Saturday 27 January 2007 00:20, James Stone wrote:
> On Sat, Jan 27, 2007 at 10:00:13AM +1100, we are wrote:
> > hey crew.
> >
> > just a quick question, i have had a lot of pain figuring out this midi
> > timing issue but got it thanks to this page
> > http://tapas.affenbande.org/wordpress/?page_id=40
> >
> > when i
> > cat /proc/sys/dev/rtc/max-user-freq
> >
> > it returns
> > 64
> >
> > which is always useless for midi audio work. so as suggested i simply
> > echo 8192 > /proc/sys/dev/rtc/max-user-freq
> >
> > which brings it back up 8192.
> >
> > so, how do i make this a permanent thing so i don't have to type it in
> > at every startup.
> You can just add the line
> dev.rtc.max-user-freq=8192
> to /etc/sysctl.conf
> > also,
> >
> > is this the best/standard way to fix my midi timing issue, it works
> > but is there any diadvantage to it. i only wonder this because it
> > defualts to 64.
> I think the higher frequency puts more load on the system, though
> 64 sounds very low. The default is usually 250. IIRC this was
> chosen by Linus et al. in order to not drain laptop batteries too
> quickly... It is possible to set it to 1000Hz if you compile the
> kernel yourself, but to get it to 8192 (if that is even
> possible), the max-user-freq must be used.
> As an aside: does anyone know if it makes any difference if it is
> 1000Hz or 8000Hz?

You are confusing the system timer with the realtime clock (RTC). Those are 
two different timers. 

The system timer (the CONFIG_HZ) setting cannot be changed at runtime. It runs 
with the frequency set at compile time (250hz is preconfigured). This is what 
drives the kernel scheduler (there are some other things triggering it 
though, processes going to sleep for example, etc.) and thus this is what 
determines timer granularity if you use ordinary sleep() or posix timers.

Different apps use either the system timer or RTC to do their timing. Muse 
afaik uses RTC. Rosegarden works best with the system timer..

The value in /proc/sys/dev/rtc/max-user-freq determines to what maximum 
frequency ordinary users can set the RTC. You usually want to have your app 
decide that, so set it to 8192, so the app can use whatever freq it wishes.

So to have your system prepared for all situations make sure your kernel is 
configured with CONFIG_HZ set to 1000 AND setup max-user-freq. So whatever 
timing mechanism the app choooses to use, the system will be ready.

You might also have to check the permissions on /dev/rtc to see whether 
ordinary users may open it at all.

RTC has the drawback that only one app can use it at a time. But it can be 
used as timing source with great success.


Palimm Palimm!

More information about the linux-audio-user mailing list