Csound Csound-dev Csound-tekno Search About

midifile evaluation problem

Date1998-08-24 00:59
FromNicola Bernardini
Subjectmidifile evaluation problem
We have experienced some problems in reading midifiles under linux.
Reading a Midifile with an orchestra with kr running at 441 results in an
exceedingly slower tempo than what expected (ca. 5 times slower).

A little investigation brought out that the Midifile gets evaluated
before the orchestra (musmon.c, line 162) and thus the ticksperseconds
value gets calculated on the default kr DFLT_KR which happens to be 4410.
Exchanging lines between the call to oload() and the call to
FMidiOpen() results in a correct evaluation of the ekr variable.
Still, the speed is not perfect, and as a matter of fact, it ends up
being ca. twice as fast than expected! There is a suspect passage
in midirecv.c at line 260

            short Qticks = natshort(*(short *)(inbytes+4));
            printf("Metrical timing, Qtempo = 120.0, Qticks = %d\n", Qticks);
            ekrdQmil = ekr / Qticks / 1000000.;
            tickspersec = Qticks * 2;	<====== THIS ONE
        }
        kprdspertick = ekr / tickspersec;
        printf("kperiods/tick = %7.3f\n", kprdspertick);

in which the Qticks get indeed multiplied by two. Removing that multiplication
produces the correct tempo.

Does anybody know the reason of that multiplication?

At any rate, I add the diff file for musmon.c and midirecv.c.

Nicola

------------------------------------------------------------------------
Nicola Bernardini
E-mail: nicb@axnet.it
 
Re graphics: A picture is worth 10K words -- but only those to describe
the picture.  Hardly any sets of 10K words can be adequately described
with pictures.
------------------------------------------------------------------------
*** musmon.c.orig	Mon Aug 24 01:20:16 1998
--- musmon.c	Mon Aug 24 01:20:19 1998
***************
*** 162,169 ****
  #else
  	  MidiOpen();      /*   alloc bufs & open files    */
  #endif
-         if (O.FMidiin) FMidiOpen();
          oload();                        /* set globals and run inits */
          printf("orch now loaded\n");
  #ifdef __MWERKS__
          fflush(stdout);
--- 162,169 ----
  #else
  	  MidiOpen();      /*   alloc bufs & open files    */
  #endif
          oload();                        /* set globals and run inits */
+         if (O.FMidiin) FMidiOpen();
          printf("orch now loaded\n");
  #ifdef __MWERKS__
          fflush(stdout);
*** midirecv.c.orig	Mon Aug 24 01:25:45 1998
--- midirecv.c	Mon Aug 24 01:25:51 1998
***************
*** 260,266 ****
              short Qticks = natshort(*(short *)(inbytes+4));
              printf("Metrical timing, Qtempo = 120.0, Qticks = %d\n", Qticks);
              ekrdQmil = ekr / Qticks / 1000000.;
!             tickspersec = Qticks * 2;
          }
          kprdspertick = ekr / tickspersec;
          printf("kperiods/tick = %7.3f\n", kprdspertick);
--- 260,266 ----
              short Qticks = natshort(*(short *)(inbytes+4));
              printf("Metrical timing, Qtempo = 120.0, Qticks = %d\n", Qticks);
              ekrdQmil = ekr / Qticks / 1000000.;
!             tickspersec = Qticks;
          }
          kprdspertick = ekr / tickspersec;
          printf("kperiods/tick = %7.3f\n", kprdspertick);



Received: from stork.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa18190;
          24 Aug 98 8:08 BST
Received: from pat.bath.ac.uk by stork.maths.Bath.AC.UK id aa14734;
          24 Aug 98 8:08 BST
Received: (qmail 3285 invoked from network); 24 Aug 1998 07:08:39 -0000
Received: from hermes.ex.ac.uk (HELO exeter.ac.uk) (144.173.6.14)
  by pat.bath.ac.uk with SMTP; 24 Aug 1998 07:08:39 -0000
Received: from noether [144.173.8.10] by hermes via SMTP (IAA07902); Mon, 24 Aug 1998 08:00:12 +0100 (BST)
Received: from exeter.ac.uk by maths.ex.ac.uk; Mon, 24 Aug 1998 08:00:02 +0100
Received: from root@mailc.telia.com [194.22.190.4] by hermes via ESMTP (IAA09093); Mon, 24 Aug 1998 08:00:01 +0100 (BST)
Received: from d1o211.telia.com (root@d1o211.telia.com [195.204.228.241])
	by mailc.telia.com (8.8.8/8.8.8) with ESMTP id IAA04332;
	Mon, 24 Aug 1998 08:59:55 +0200 (MET DST)
Received: from roger (t5o211p1.telia.com [195.204.229.1]) by d1o211.telia.com (8.8.8/8.6.12) with SMTP id IAA08926; Mon, 24 Aug 1998 08:59:54 +0200 (MET DST)
Message-ID: <004201bdcf2c$857e4ec0$0300a8c0@roger.apas.no>
From: roger k 
To: csound , David Schuyeteneer 
Subject: Re: [??] Japanese Noise site 
Date: Mon, 24 Aug 1998 08:56:54 +0200
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3007.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3007.0
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

>any www site dedicated to this Japanese Noise ????
Extreme music has records and some info on Merzbow and other artists  ( not
japanese though )
http://www.xtr.com/

--------
 \            f(roger klaveness) = roger@apas.no +
http://home.c2i.net/roklaven/
    --------



Received: from stork.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa18280;
          24 Aug 98 9:55 BST
Received: from pat.bath.ac.uk by stork.maths.Bath.AC.UK id aa16548;
          24 Aug 98 9:55 BST
Received: (qmail 8518 invoked from network); 24 Aug 1998 08:55:14 -0000
Received: from hermes.ex.ac.uk (HELO exeter.ac.uk) (144.173.6.14)
  by pat.bath.ac.uk with SMTP; 24 Aug 1998 08:55:14 -0000
Received: from noether [144.173.8.10] by hermes via SMTP (JAA22640); Mon, 24 Aug 1998 09:47:20 +0100 (BST)
Received: from exeter.ac.uk by maths.ex.ac.uk; Mon, 24 Aug 1998 09:47:07 +0100
Received: from ds9.sci.fi [195.74.0.54] by hermes via ESMTP (JAA09655); Mon, 24 Aug 1998 09:47:06 +0100 (BST)
Received: from sci.fi (root@MCCXCV.dyn.saunalahti.fi [195.197.4.95]) by ds9.sci.fi (8.8.3/8.8.3) with ESMTP id LAA08646 for ; Mon, 24 Aug 1998 11:47:08 +0300 (EET DST)
Message-ID: <35E1282A.FF173D61@sci.fi>
Date: Mon, 24 Aug 1998 11:45:30 +0300
From: Matti Koskinen 
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.0.33 i586)
MIME-Version: 1.0
To: csound@maths.ex.ac.uk
Subject: butterbp broken?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

Hello

	using butterbp as follows

	k1 line p4,p3,p5
	a1 butterbp ain,k1,k1/10
	a2 balance a1,ain
	out a2

	gives sometimes zero output, but shows samples out of range
	using reson, everything works ok. 

	Does butterbp start to oscillate under some conditions?
	(just a wild guess)

	these both with linux 3.482 and Nicola's 3.484

-matti

mjkoskin@sci.fi


Received: from stork.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa18306;
          24 Aug 98 10:18 BST
Received: from pat.bath.ac.uk by stork.maths.Bath.AC.UK id aa16967;
          24 Aug 98 10:18 BST
Received: (qmail 10232 invoked from network); 24 Aug 1998 09:18:24 -0000
Received: from hermes.ex.ac.uk (HELO exeter.ac.uk) (144.173.6.14)
  by pat.bath.ac.uk with SMTP; 24 Aug 1998 09:18:24 -0000
Received: from noether [144.173.8.10] by hermes via SMTP (KAA14236); Mon, 24 Aug 1998 10:14:09 +0100 (BST)
Received: from exeter.ac.uk by maths.ex.ac.uk; Mon, 24 Aug 1998 10:13:58 +0100
Received: from nicb@ax-nicb.axnet.it [194.184.60.149] by hermes via ESMTP (KAA09148); Mon, 24 Aug 1998 10:13:57 +0100 (BST)
Received: (from nicb@localhost)
	by ax-nicb.axnet.it (8.8.8/8.8.8) id KAA05100;
	Mon, 24 Aug 1998 10:58:01 +0200
Date: Mon, 24 Aug 1998 10:58:00 +0200 (MET DST)
From: Nicola Bernardini 
To: Matti Koskinen 
cc: csound@maths.ex.ac.uk
Subject: Re: butterbp broken?
In-Reply-To: <35E1282A.FF173D61@sci.fi>
Message-ID: 
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

On Mon, 24 Aug 1998, Matti Koskinen wrote:

[snip]
> 	using butterbp as follows
> 
> 	k1 line p4,p3,p5
> 	a1 butterbp ain,k1,k1/10
> 	a2 balance a1,ain
> 	out a2
> 
> 	gives sometimes zero output, but shows samples out of range
> 	using reson, everything works ok. 
> 
> 	Does butterbp start to oscillate under some conditions?
> 	(just a wild guess)
> 
> 	these both with linux 3.482 and Nicola's 3.484

can you give us an idea of what numbers you set in p4 and p5 (if you
could send a demo orc and sco of what creates the problem, that would be
great)

thank you

Nicola

------------------------------------------------------------------------
Nicola Bernardini
E-mail: nicb@axnet.it
 
Re graphics: A picture is worth 10K words -- but only those to describe
the picture.  Hardly any sets of 10K words can be adequately described
with pictures.



Received: from stork.maths.bath.ac.uk by omphalos.maths.Bath.AC.UK id aa18500;
          24 Aug 98 11:50 BST
Received: from mercury.bath.ac.uk by stork.maths.Bath.AC.UK id aa24312;
          24 Aug 98 11:49 BST
Received: (qmail 21048 invoked from network); 24 Aug 1998 10:49:53 -0000
Received: from hermes.ex.ac.uk (HELO exeter.ac.uk) (144.173.6.14)
  by mercury.bath.ac.uk with SMTP; 24 Aug 1998 10:49:53 -0000
Received: from noether [144.173.8.10] by hermes via SMTP (LAA08050); Mon, 24 Aug 1998 11:41:26 +0100 (BST)
Received: from exeter.ac.uk by maths.ex.ac.uk; Mon, 24 Aug 1998 11:41:15 +0100
Received: from nicb@ax-nicb.axnet.it [194.184.60.149] by hermes via ESMTP (LAA04925); Mon, 24 Aug 1998 11:41:02 +0100 (BST)
Received: (from nicb@localhost)
	by ax-nicb.axnet.it (8.8.8/8.8.8) id MAA05639;
	Mon, 24 Aug 1998 12:24:24 +0200
Date: Mon, 24 Aug 1998 12:24:22 +0200 (MET DST)
From: Nicola Bernardini 
To: Matti Koskinen 
cc: Csound Linux/Unix Development Group , 
    Csound mailing list 
Subject: Re: butterbp broken?
In-Reply-To: <35E13FC7.3F95EFB4@sci.fi>
Message-ID: 
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: owner-csound-outgoing@maths.ex.ac.uk
Precedence: bulk

On Mon, 24 Aug 1998, Matti Koskinen wrote:

[snip]
> Using hp gives truly out of range samples and the output is distorted,
> but bp gives just samples out of range with no output.

I can't look until tonight. But I'll give a look tonight...

[snip]
> Also another question, as you know about csound-code. Why some
> instruments above 200 are undefined when compiling orc. E.g. i had
> instr 201 and instr 202 and csound said that instr 201 is undefined
> giving some number in parenthesis after error text. Also the same came
> out with ftables > 60. I debugged a bit csound and the routine that
> checks ftable goes ok for few first rounds, then it returns an error.
> As this code is unfamiliar, i just let it be, and changed my orc/scores.
> Any ideas?

Tonight...

ciao

Nicola

------------------------------------------------------------------------
Nicola Bernardini
E-mail: nicb@axnet.it
 
Re graphics: A picture is worth 10K words -- but only those to describe
the picture.  Hardly any sets of 10K words can be adequately described
with pictures.