Csound Csound-dev Csound-tekno Search About

[Cs-dev] API question/request

Date2006-03-19 09:11
FromIain Duncan
Subject[Cs-dev] API question/request
Just wondering if anyone has thought of having a csoundGetTempo() api
function. I think this would be a useful addition if it's easy to do.

Also, can anyone point me at further docs on how the midicallback
functions work?

Thanks
Iain


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-03-19 17:11
FromOeyvind Brandtsegg
Subject[Cs-dev] midiin bug ?
I wonder if there's a bug in midiin,
it seems to register midi note data incorrectly.

Upon receving a midi note on, it reports status byte 144 twice,
where the first one is correct,
and the second one seems to be note off of the previous note played (kstatus = 144, kdata2 = 0).

When I run the following code inside an instr:

kstatus, kchan, kdata1, kdata2 midiin
printk2	kstatus
if kstatus == 0 kgoto noprint
printks "midi in note:%d velocity:%d %n", 1, kdata1, kdata2
noprint:

If I play the note 48, (on, then off), 
then note 50 (on, then off,
it will print this:

 i1     0.00000
 i1   144.00000
midi in note:48 velocity:10
 i1   144.00000
midi in note:48 velocity:10
 i1     0.00000
 i1     0.00000
 i1   144.00000
midi in note:48 velocity:0
 i1     0.00000
 i1   144.00000
midi in note:52 velocity:30
 i1   144.00000
midi in note:48 velocity:0
 i1     0.00000
 i1     0.00000
 i1   144.00000
midi in note:52 velocity:0
 i1     0.00000

best
Oeyvind

Date2006-03-19 17:45
FromOeyvind Brandtsegg
Subjectre: [Cs-dev] midiin bug ?
Sorry,
my mistake,
I had forgotten to set 
massign 1, -1

It seems this is an easy error to make,
perhaps it should be mentioned in the documentation.

Oeyvind





> From: Oeyvind Brandtsegg [obrandts@online.no]
> Sent: 2006-03-19 18:11:50 CET
> To: csound-devel@lists.sourceforge.net
> Subject: [Cs-dev] midiin bug ?
> 
> I wonder if there's a bug in midiin,
> it seems to register midi note data incorrectly.
> 
> Upon receving a midi note on, it reports status byte 144 twice,
> where the first one is correct,
> and the second one seems to be note off of the previous note played (kstatus = 144, kdata2 = 0).
> 
> When I run the following code inside an instr:
> 
> kstatus, kchan, kdata1, kdata2 midiin
> printk2	kstatus
> if kstatus == 0 kgoto noprint
> printks "midi in note:%d velocity:%d %n", 1, kdata1, kdata2
> noprint:
> 
> If I play the note 48, (on, then off), 
> then note 50 (on, then off,
> it will print this:
> 
>  i1     0.00000
>  i1   144.00000
> midi in note:48 velocity:10
>  i1   144.00000
> midi in note:48 velocity:10
>  i1     0.00000
>  i1     0.00000
>  i1   144.00000
> midi in note:48 velocity:0
>  i1     0.00000
>  i1   144.00000
> midi in note:52 velocity:30
>  i1   144.00000
> midi in note:48 velocity:0
>  i1     0.00000
>  i1     0.00000
>  i1   144.00000
> midi in note:52 velocity:0
>  i1     0.00000
> 
> best
> Oeyvind

Date2006-03-19 21:28
FromDavid Akbari
SubjectRe: [Cs-dev] API question/request
Perhaps not as low-level an approach as you would maybe like but there 
is an opcode that exists in Csound5 for over one year by Istvan Varga

http://www.csounds.com/manual/html/miditempo.html

You may find some interesting clues in examining the source code for 
this opcode, possibly.


-David

On Mar 19, 2006, at 4:11 AM, Iain Duncan wrote:

> Just wondering if anyone has thought of having a csoundGetTempo() api
> function. I think this would be a useful addition if it's easy to do.



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-03-20 00:44
FromDavid Akbari
SubjectRe: [Cs-dev] API question/request
On Mar 20, 2006, at 1:45 AM, Iain Duncan wrote:

> Sorry, perhaps I wasn't clear.

No, I can see what you're getting at quite clearly.

>  I meant an API function that would return
> the current tempo to the host. ie
> csoundGetTempo();

So what I am saying to you is that it would be probably easiest to 
examine Istvan's code from

InOut/midifile.c

for maximum ease in implementing this idea as an API structure.

the opcode itself is quite simply

int midiTempoOpcode(CSOUND *csound, MIDITEMPO *p)
{
     if (MIDIFILE == NULL)
       *(p->kResult) = (MYFLT) (60.0 / csound->beatTime);
     else
       *(p->kResult) = (MYFLT) MF(currentTempo);
     return OK;
}

which should be trivial to adapt to an API structure, if you choose to 
do so.

> In the meantime one can of course encode the tempo in a global variable
> and check that from the host, but that seems a bit ugly.

It's not as ugly as you think, since miditempo returns only 1 k-rate 
variable and has no input. I find this quite easy and simple to use. 
Although I'm sure you have big plans for a much lower level approach.

Good luck,


-David



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-03-20 06:45
FromIain Duncan
SubjectRe: [Cs-dev] API question/request
Sorry, perhaps I wasn't clear. I meant an API function that would return
the current tempo to the host. ie
csoundGetTempo();

In the meantime one can of course encode the tempo in a global variable
and check that from the host, but that seems a bit ugly.

Iain

David Akbari wrote:
> Perhaps not as low-level an approach as you would maybe like but there
> is an opcode that exists in Csound5 for over one year by Istvan Varga
> 
> http://www.csounds.com/manual/html/miditempo.html
> 
> You may find some interesting clues in examining the source code for
> this opcode, possibly.
> 
> 
> -David
> 
> On Mar 19, 2006, at 4:11 AM, Iain Duncan wrote:
> 
>> Just wondering if anyone has thought of having a csoundGetTempo() api
>> function. I think this would be a useful addition if it's easy to do.
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2006-03-20 12:38
FromIstvan Varga
SubjectRe: [Cs-dev] API question/request
AttachmentsNone  

Date2006-03-20 12:43
FromIstvan Varga
SubjectRe: [Cs-dev] midiin bug ?
AttachmentsNone  

Date2006-03-21 03:37
FromIain Duncan
SubjectRe: [Cs-dev] API question/request
>I think it is only possible for MIDI files, and the (buggy and not
recommended
> to use) "beat mode". Unfortunately, most of the tempo information is lost when
> the score is sorted and time warped in the normal way. The same limitation also
> applies to the 'miditempo' opcode.

I was thinking of the aforementioned beat mode. Did not know that it is
still buggy, which is too bad. Were it to work properly, I would find it
quite useful as for my projects I like to mix scores, midi, and internal
sequencing with dynamic tempo controls. But I can continue to hack
around that ok. ; )

Iain


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net