Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] per-event input/output

Date2007-12-17 19:47
Fromvictor
SubjectRe: [Cs-dev] per-event input/output
use csoundInputMessage()
----- Original Message ----- 
From: "Jonatan Liljedahl" 
To: "Developer discussions" 
Sent: Monday, December 17, 2007 7:31 PM
Subject: Re: [Cs-dev] per-event input/output


> Jonatan Liljedahl wrote:
>> matt ingalls wrote:
>> ...
>>> btw, i have used "fractional" i statements for this kind of thing 
>>> before:
>>>
>>> i 2.3847 0 10 .
>>> i 2.3848 +
>>> i 2.3849 +
>>>
>>> instr 2
>>>    outvalue "id", p1
>>>    k1 ...something
>>>    outvalue "value", k1
>>> endif
>>>
>>>
>>> if i am not missing something,
>>> i don't think you could use the software bus to do something like this!!
>>
>> It worked fine! Here's an example of a graphical score with amplitude
>> envelope plotting for each event. (attached PDF)
>>
>> Thanks for your help.
>
> There's still one problem... Instrument tags is encoded as the
> fractional part of p1, but since it's a simple 32-bit float there's a
> lot of problems with rounding errors, see this example:
>
> int main(void) {
>    float f;
>    int last = 9999;
>    for(f=1;f<2;f+=0.0001) {
>        int i = 0.5 + f * 10000;
>        printf("%d %g %f ",i,f,f);
>        if(i!=last+1) printf("ERROR!\n");
>        else printf("OK\n");
>        last=i;
>    }
> }
>
> $ foo | grep -B 1 ERROR
> 13013 1.30135 1.301350 OK
> 13015 1.30145 1.301450 ERROR!
> --
> 19040 1.90405 1.904050 OK
> 19042 1.90415 1.904150 ERROR!
>
> Which means that with tags from .0001 to .9999 there's two numbers that
> can't be represented? And then one can only have 9998 tagged events,
> increasing it to one more decimal gives 136 errors.
>
> Is there a way to tag instrument with strings instead? is there a way to
> send string p-args with csoundScoreEvent()?
>
> -- 
> /Jonatan         [ http://kymatica.com ]
>
> -------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services
> for just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel 


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-17 20:01
FromJonatan Liljedahl
SubjectRe: [Cs-dev] per-event input/output
victor wrote:
> use csoundInputMessage()

Ok, that lets me send events as strings instead, but is a p1 value of
1.4 actually read as a string or is it converted to float?

I can have named instrument instead of numbers, but then I can't give
them tags.

> ----- Original Message ----- 
> From: "Jonatan Liljedahl" 
> To: "Developer discussions" 
> Sent: Monday, December 17, 2007 7:31 PM
> Subject: Re: [Cs-dev] per-event input/output
> 
> 
>> Jonatan Liljedahl wrote:
>>> matt ingalls wrote:
>>> ...
>>>> btw, i have used "fractional" i statements for this kind of thing 
>>>> before:
>>>>
>>>> i 2.3847 0 10 .
>>>> i 2.3848 +
>>>> i 2.3849 +
>>>>
>>>> instr 2
>>>>    outvalue "id", p1
>>>>    k1 ...something
>>>>    outvalue "value", k1
>>>> endif
>>>>
>>>>
>>>> if i am not missing something,
>>>> i don't think you could use the software bus to do something like this!!
>>> It worked fine! Here's an example of a graphical score with amplitude
>>> envelope plotting for each event. (attached PDF)
>>>
>>> Thanks for your help.
>> There's still one problem... Instrument tags is encoded as the
>> fractional part of p1, but since it's a simple 32-bit float there's a
>> lot of problems with rounding errors, see this example:
>>
>> int main(void) {
>>    float f;
>>    int last = 9999;
>>    for(f=1;f<2;f+=0.0001) {
>>        int i = 0.5 + f * 10000;
>>        printf("%d %g %f ",i,f,f);
>>        if(i!=last+1) printf("ERROR!\n");
>>        else printf("OK\n");
>>        last=i;
>>    }
>> }
>>
>> $ foo | grep -B 1 ERROR
>> 13013 1.30135 1.301350 OK
>> 13015 1.30145 1.301450 ERROR!
>> --
>> 19040 1.90405 1.904050 OK
>> 19042 1.90415 1.904150 ERROR!
>>
>> Which means that with tags from .0001 to .9999 there's two numbers that
>> can't be represented? And then one can only have 9998 tagged events,
>> increasing it to one more decimal gives 136 errors.
>>
>> Is there a way to tag instrument with strings instead? is there a way to
>> send string p-args with csoundScoreEvent()?
>>
>> -- 
>> /Jonatan         [ http://kymatica.com ]
>>
>> -------------------------------------------------------------------------
>> SF.Net email is sponsored by:
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services
>> for just about anything Open Source.
>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel 
> 
> 
> -------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services
> for just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


-- 
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-17 20:06
Frommatt ingalls
SubjectRe: [Cs-dev] per-event input/output
maybe your idea of passing an ID# in an additional p-field
is better?

On Dec 17, 2007, at 12:01 PM, Jonatan Liljedahl wrote:

> victor wrote:
>> use csoundInputMessage()
>
> Ok, that lets me send events as strings instead, but is a p1 value of
> 1.4 actually read as a string or is it converted to float?
>
> I can have named instrument instead of numbers, but then I can't give
> them tags.
>
>> ----- Original Message -----
>> From: "Jonatan Liljedahl" 
>> To: "Developer discussions" 
>> Sent: Monday, December 17, 2007 7:31 PM
>> Subject: Re: [Cs-dev] per-event input/output
>>
>>
>>> Jonatan Liljedahl wrote:
>>>> matt ingalls wrote:
>>>> ...
>>>>> btw, i have used "fractional" i statements for this kind of thing
>>>>> before:
>>>>>
>>>>> i 2.3847 0 10 .
>>>>> i 2.3848 +
>>>>> i 2.3849 +
>>>>>
>>>>> instr 2
>>>>>    outvalue "id", p1
>>>>>    k1 ...something
>>>>>    outvalue "value", k1
>>>>> endif
>>>>>
>>>>>
>>>>> if i am not missing something,
>>>>> i don't think you could use the software bus to do something  
>>>>> like this!!
>>>> It worked fine! Here's an example of a graphical score with  
>>>> amplitude
>>>> envelope plotting for each event. (attached PDF)
>>>>
>>>> Thanks for your help.
>>> There's still one problem... Instrument tags is encoded as the
>>> fractional part of p1, but since it's a simple 32-bit float  
>>> there's a
>>> lot of problems with rounding errors, see this example:
>>>
>>> int main(void) {
>>>    float f;
>>>    int last = 9999;
>>>    for(f=1;f<2;f+=0.0001) {
>>>        int i = 0.5 + f * 10000;
>>>        printf("%d %g %f ",i,f,f);
>>>        if(i!=last+1) printf("ERROR!\n");
>>>        else printf("OK\n");
>>>        last=i;
>>>    }
>>> }
>>>
>>> $ foo | grep -B 1 ERROR
>>> 13013 1.30135 1.301350 OK
>>> 13015 1.30145 1.301450 ERROR!
>>> --
>>> 19040 1.90405 1.904050 OK
>>> 19042 1.90415 1.904150 ERROR!
>>>
>>> Which means that with tags from .0001 to .9999 there's two  
>>> numbers that
>>> can't be represented? And then one can only have 9998 tagged events,
>>> increasing it to one more decimal gives 136 errors.
>>>
>>> Is there a way to tag instrument with strings instead? is there a  
>>> way to
>>> send string p-args with csoundScoreEvent()?
>>>
>>> -- 
>>> /Jonatan         [ http://kymatica.com ]
>>>
>>> -------------------------------------------------------------------- 
>>> -----
>>> SF.Net email is sponsored by:
>>> Check out the new SourceForge.net Marketplace.
>>> It's the best place to buy or sell services
>>> for just about anything Open Source.
>>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ 
>>> marketplace
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> --------------------------------------------------------------------- 
>> ----
>> SF.Net email is sponsored by:
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services
>> for just about anything Open Source.
>> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ 
>> marketplace
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> -- 
> /Jonatan         [ http://kymatica.com ]
>
> ---------------------------------------------------------------------- 
> ---
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services
> for just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ 
> marketplace
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

-m
___________________
matt ingalls
development@gvox.com




-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-17 20:18
FromJonatan Liljedahl
SubjectRe: [Cs-dev] per-event input/output
I think it was my test-code that was wrong, here's another test that
constructs a floating point number of instrument number (3 in this
example) and the tag id (i). then it decodes the tag back from this
floating point. It printed no errors, so it seems to work.

int main(void) {
    float f;
    int i,i2;
    char buf[64];
    for(i=0;i<100000;i++) {
        sprintf(buf,"3.%05d",i);
        f = atof(buf);
        i2 = (int)(0.5 + f * 100000) % 100000;
        printf("%d %d %g %f ",i,i2,f,f);
        if(i!=i2) printf("ERROR!\n");
        else printf("OK\n");
    }
}

matt ingalls wrote:
> maybe your idea of passing an ID# in an additional p-field
> is better?
> 
> On Dec 17, 2007, at 12:01 PM, Jonatan Liljedahl wrote:
> 
>> victor wrote:
>>> use csoundInputMessage()
>> Ok, that lets me send events as strings instead, but is a p1 value of
>> 1.4 actually read as a string or is it converted to float?
>>
>> I can have named instrument instead of numbers, but then I can't give
>> them tags.
>>
>>> ----- Original Message -----
>>> From: "Jonatan Liljedahl" 
>>> To: "Developer discussions" 
>>> Sent: Monday, December 17, 2007 7:31 PM
>>> Subject: Re: [Cs-dev] per-event input/output
>>>
>>>
>>>> Jonatan Liljedahl wrote:
>>>>> matt ingalls wrote:
>>>>> ...
>>>>>> btw, i have used "fractional" i statements for this kind of thing
>>>>>> before:
>>>>>>
>>>>>> i 2.3847 0 10 .
>>>>>> i 2.3848 +
>>>>>> i 2.3849 +
>>>>>>
>>>>>> instr 2
>>>>>>    outvalue "id", p1
>>>>>>    k1 ...something
>>>>>>    outvalue "value", k1
>>>>>> endif
>>>>>>
>>>>>>
>>>>>> if i am not missing something,
>>>>>> i don't think you could use the software bus to do something  
>>>>>> like this!!
>>>>> It worked fine! Here's an example of a graphical score with  
>>>>> amplitude
>>>>> envelope plotting for each event. (attached PDF)
>>>>>
>>>>> Thanks for your help.
>>>> There's still one problem... Instrument tags is encoded as the
>>>> fractional part of p1, but since it's a simple 32-bit float  
>>>> there's a
>>>> lot of problems with rounding errors, see this example:
>>>>
>>>> int main(void) {
>>>>    float f;
>>>>    int last = 9999;
>>>>    for(f=1;f<2;f+=0.0001) {
>>>>        int i = 0.5 + f * 10000;
>>>>        printf("%d %g %f ",i,f,f);
>>>>        if(i!=last+1) printf("ERROR!\n");
>>>>        else printf("OK\n");
>>>>        last=i;
>>>>    }
>>>> }
>>>>
>>>> $ foo | grep -B 1 ERROR
>>>> 13013 1.30135 1.301350 OK
>>>> 13015 1.30145 1.301450 ERROR!
>>>> --
>>>> 19040 1.90405 1.904050 OK
>>>> 19042 1.90415 1.904150 ERROR!
>>>>
>>>> Which means that with tags from .0001 to .9999 there's two  
>>>> numbers that
>>>> can't be represented? And then one can only have 9998 tagged events,
>>>> increasing it to one more decimal gives 136 errors.
>>>>
>>>> Is there a way to tag instrument with strings instead? is there a  
>>>> way to
>>>> send string p-args with csoundScoreEvent()?
>>>>
>>>> -- 
>>>> /Jonatan         [ http://kymatica.com ]

-- 
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-17 23:12
FromJonatan Liljedahl
Subject[Cs-dev] first outvalue zero? (was per-event input/output)
I discovered that the data generated from outvalue for each event meant
too much memory usage for my app to handle! And since I'm only using it
for graphical representation there's no need for such high resolution,
so I thought I might use a divisor to send the value only the 100th
k-rate cycle:

instr 1
    a1 oscil 0.3, p4, gisine
    kamp transeg 1, p3, -2, 0

    kcnt init 0
    if kcnt == 0 then
        outvalue "tag", p1
        outvalue "amp", kamp
        kcnt = 100
    else
        kcnt = kcnt - 1
    endif

    outch p5, a1*kamp
endin

but for some reason the first value I get in my outvalue-callback is
always zero! doing a printk of kamp right after the outvalue opcode
above shows that it really should be 1.0 and not 0.

Jonatan Liljedahl wrote:
> I think it was my test-code that was wrong, here's another test that
> constructs a floating point number of instrument number (3 in this
> example) and the tag id (i). then it decodes the tag back from this
> floating point. It printed no errors, so it seems to work.
> 
> int main(void) {
>     float f;
>     int i,i2;
>     char buf[64];
>     for(i=0;i<100000;i++) {
>         sprintf(buf,"3.%05d",i);
>         f = atof(buf);
>         i2 = (int)(0.5 + f * 100000) % 100000;
>         printf("%d %d %g %f ",i,i2,f,f);
>         if(i!=i2) printf("ERROR!\n");
>         else printf("OK\n");
>     }
> }
> 
> matt ingalls wrote:
>> maybe your idea of passing an ID# in an additional p-field
>> is better?
>>
>> On Dec 17, 2007, at 12:01 PM, Jonatan Liljedahl wrote:
>>
>>> victor wrote:
>>>> use csoundInputMessage()
>>> Ok, that lets me send events as strings instead, but is a p1 value of
>>> 1.4 actually read as a string or is it converted to float?
>>>
>>> I can have named instrument instead of numbers, but then I can't give
>>> them tags.
>>>
>>>> ----- Original Message -----
>>>> From: "Jonatan Liljedahl" 
>>>> To: "Developer discussions" 
>>>> Sent: Monday, December 17, 2007 7:31 PM
>>>> Subject: Re: [Cs-dev] per-event input/output
>>>>
>>>>
>>>>> Jonatan Liljedahl wrote:
>>>>>> matt ingalls wrote:
>>>>>> ...
>>>>>>> btw, i have used "fractional" i statements for this kind of thing
>>>>>>> before:
>>>>>>>
>>>>>>> i 2.3847 0 10 .
>>>>>>> i 2.3848 +
>>>>>>> i 2.3849 +
>>>>>>>
>>>>>>> instr 2
>>>>>>>    outvalue "id", p1
>>>>>>>    k1 ...something
>>>>>>>    outvalue "value", k1
>>>>>>> endif
>>>>>>>
>>>>>>>
>>>>>>> if i am not missing something,
>>>>>>> i don't think you could use the software bus to do something  
>>>>>>> like this!!
>>>>>> It worked fine! Here's an example of a graphical score with  
>>>>>> amplitude
>>>>>> envelope plotting for each event. (attached PDF)
>>>>>>
>>>>>> Thanks for your help.
>>>>> There's still one problem... Instrument tags is encoded as the
>>>>> fractional part of p1, but since it's a simple 32-bit float  
>>>>> there's a
>>>>> lot of problems with rounding errors, see this example:
>>>>>
>>>>> int main(void) {
>>>>>    float f;
>>>>>    int last = 9999;
>>>>>    for(f=1;f<2;f+=0.0001) {
>>>>>        int i = 0.5 + f * 10000;
>>>>>        printf("%d %g %f ",i,f,f);
>>>>>        if(i!=last+1) printf("ERROR!\n");
>>>>>        else printf("OK\n");
>>>>>        last=i;
>>>>>    }
>>>>> }
>>>>>
>>>>> $ foo | grep -B 1 ERROR
>>>>> 13013 1.30135 1.301350 OK
>>>>> 13015 1.30145 1.301450 ERROR!
>>>>> --
>>>>> 19040 1.90405 1.904050 OK
>>>>> 19042 1.90415 1.904150 ERROR!
>>>>>
>>>>> Which means that with tags from .0001 to .9999 there's two  
>>>>> numbers that
>>>>> can't be represented? And then one can only have 9998 tagged events,
>>>>> increasing it to one more decimal gives 136 errors.
>>>>>
>>>>> Is there a way to tag instrument with strings instead? is there a  
>>>>> way to
>>>>> send string p-args with csoundScoreEvent()?
>>>>>
>>>>> -- 
>>>>> /Jonatan         [ http://kymatica.com ]
> 


-- 
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-17 23:54
Frommatt ingalls
SubjectRe: [Cs-dev] first outvalue zero? (was per-event input/output)
the zero is probably from the i-pass

On Dec 17, 2007, at 3:12 PM, Jonatan Liljedahl wrote:

> I discovered that the data generated from outvalue for each event  
> meant
> too much memory usage for my app to handle! And since I'm only  
> using it
> for graphical representation there's no need for such high resolution,
> so I thought I might use a divisor to send the value only the 100th
> k-rate cycle:
>
> instr 1
>     a1 oscil 0.3, p4, gisine
>     kamp transeg 1, p3, -2, 0
>
>     kcnt init 0
>     if kcnt == 0 then
>         outvalue "tag", p1
>         outvalue "amp", kamp
>         kcnt = 100
>     else
>         kcnt = kcnt - 1
>     endif
>
>     outch p5, a1*kamp
> endin
>
> but for some reason the first value I get in my outvalue-callback is
> always zero! doing a printk of kamp right after the outvalue opcode
> above shows that it really should be 1.0 and not 0.
>
> Jonatan Liljedahl wrote:
>> I think it was my test-code that was wrong, here's another test that
>> constructs a floating point number of instrument number (3 in this
>> example) and the tag id (i). then it decodes the tag back from this
>> floating point. It printed no errors, so it seems to work.
>>
>> int main(void) {
>>     float f;
>>     int i,i2;
>>     char buf[64];
>>     for(i=0;i<100000;i++) {
>>         sprintf(buf,"3.%05d",i);
>>         f = atof(buf);
>>         i2 = (int)(0.5 + f * 100000) % 100000;
>>         printf("%d %d %g %f ",i,i2,f,f);
>>         if(i!=i2) printf("ERROR!\n");
>>         else printf("OK\n");
>>     }
>> }
>>
>> matt ingalls wrote:
>>> maybe your idea of passing an ID# in an additional p-field
>>> is better?
>>>
>>> On Dec 17, 2007, at 12:01 PM, Jonatan Liljedahl wrote:
>>>
>>>> victor wrote:
>>>>> use csoundInputMessage()
>>>> Ok, that lets me send events as strings instead, but is a p1  
>>>> value of
>>>> 1.4 actually read as a string or is it converted to float?
>>>>
>>>> I can have named instrument instead of numbers, but then I can't  
>>>> give
>>>> them tags.
>>>>
>>>>> ----- Original Message -----
>>>>> From: "Jonatan Liljedahl" 
>>>>> To: "Developer discussions" 
>>>>> Sent: Monday, December 17, 2007 7:31 PM
>>>>> Subject: Re: [Cs-dev] per-event input/output
>>>>>
>>>>>
>>>>>> Jonatan Liljedahl wrote:
>>>>>>> matt ingalls wrote:
>>>>>>> ...
>>>>>>>> btw, i have used "fractional" i statements for this kind of  
>>>>>>>> thing
>>>>>>>> before:
>>>>>>>>
>>>>>>>> i 2.3847 0 10 .
>>>>>>>> i 2.3848 +
>>>>>>>> i 2.3849 +
>>>>>>>>
>>>>>>>> instr 2
>>>>>>>>    outvalue "id", p1
>>>>>>>>    k1 ...something
>>>>>>>>    outvalue "value", k1
>>>>>>>> endif
>>>>>>>>
>>>>>>>>
>>>>>>>> if i am not missing something,
>>>>>>>> i don't think you could use the software bus to do something
>>>>>>>> like this!!
>>>>>>> It worked fine! Here's an example of a graphical score with
>>>>>>> amplitude
>>>>>>> envelope plotting for each event. (attached PDF)
>>>>>>>
>>>>>>> Thanks for your help.
>>>>>> There's still one problem... Instrument tags is encoded as the
>>>>>> fractional part of p1, but since it's a simple 32-bit float
>>>>>> there's a
>>>>>> lot of problems with rounding errors, see this example:
>>>>>>
>>>>>> int main(void) {
>>>>>>    float f;
>>>>>>    int last = 9999;
>>>>>>    for(f=1;f<2;f+=0.0001) {
>>>>>>        int i = 0.5 + f * 10000;
>>>>>>        printf("%d %g %f ",i,f,f);
>>>>>>        if(i!=last+1) printf("ERROR!\n");
>>>>>>        else printf("OK\n");
>>>>>>        last=i;
>>>>>>    }
>>>>>> }
>>>>>>
>>>>>> $ foo | grep -B 1 ERROR
>>>>>> 13013 1.30135 1.301350 OK
>>>>>> 13015 1.30145 1.301450 ERROR!
>>>>>> --
>>>>>> 19040 1.90405 1.904050 OK
>>>>>> 19042 1.90415 1.904150 ERROR!
>>>>>>
>>>>>> Which means that with tags from .0001 to .9999 there's two
>>>>>> numbers that
>>>>>> can't be represented? And then one can only have 9998 tagged  
>>>>>> events,
>>>>>> increasing it to one more decimal gives 136 errors.
>>>>>>
>>>>>> Is there a way to tag instrument with strings instead? is there a
>>>>>> way to
>>>>>> send string p-args with csoundScoreEvent()?
>>>>>>
>>>>>> -- 
>>>>>> /Jonatan         [ http://kymatica.com ]
>>
>
>
> -- 
> /Jonatan         [ http://kymatica.com ]
>
> ---------------------------------------------------------------------- 
> ---
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services
> for just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ 
> marketplace
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

-m
___________________
matt ingalls
development@gvox.com




-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-17 23:58
FromJonatan Liljedahl
SubjectRe: [Cs-dev] first outvalue zero? (was per-event input/output)
matt ingalls wrote:
> the zero is probably from the i-pass

I see, is it possible to avoid it? Should outvalue really output in the
i-pass?

Also, is there some simpler way to execute a block of code at some
divisor of k-rate?

>> I discovered that the data generated from outvalue for each event  
>> meant
>> too much memory usage for my app to handle! And since I'm only  
>> using it
>> for graphical representation there's no need for such high resolution,
>> so I thought I might use a divisor to send the value only the 100th
>> k-rate cycle:
>>
>> instr 1
>>     a1 oscil 0.3, p4, gisine
>>     kamp transeg 1, p3, -2, 0
>>
>>     kcnt init 0
>>     if kcnt == 0 then
>>         outvalue "tag", p1
>>         outvalue "amp", kamp
>>         kcnt = 100
>>     else
>>         kcnt = kcnt - 1
>>     endif
>>
>>     outch p5, a1*kamp
>> endin
>>
>> but for some reason the first value I get in my outvalue-callback is
>> always zero! doing a printk of kamp right after the outvalue opcode
>> above shows that it really should be 1.0 and not 0.
>>
>> Jonatan Liljedahl wrote:
>>> I think it was my test-code that was wrong, here's another test that
>>> constructs a floating point number of instrument number (3 in this
>>> example) and the tag id (i). then it decodes the tag back from this
>>> floating point. It printed no errors, so it seems to work.
>>>
>>> int main(void) {
>>>     float f;
>>>     int i,i2;
>>>     char buf[64];
>>>     for(i=0;i<100000;i++) {
>>>         sprintf(buf,"3.%05d",i);
>>>         f = atof(buf);
>>>         i2 = (int)(0.5 + f * 100000) % 100000;
>>>         printf("%d %d %g %f ",i,i2,f,f);
>>>         if(i!=i2) printf("ERROR!\n");
>>>         else printf("OK\n");
>>>     }
>>> }
>>>
>>> matt ingalls wrote:
>>>> maybe your idea of passing an ID# in an additional p-field
>>>> is better?
>>>>
>>>> On Dec 17, 2007, at 12:01 PM, Jonatan Liljedahl wrote:
>>>>
>>>>> victor wrote:
>>>>>> use csoundInputMessage()
>>>>> Ok, that lets me send events as strings instead, but is a p1  
>>>>> value of
>>>>> 1.4 actually read as a string or is it converted to float?
>>>>>
>>>>> I can have named instrument instead of numbers, but then I can't  
>>>>> give
>>>>> them tags.
>>>>>
>>>>>> ----- Original Message -----
>>>>>> From: "Jonatan Liljedahl" 
>>>>>> To: "Developer discussions" 
>>>>>> Sent: Monday, December 17, 2007 7:31 PM
>>>>>> Subject: Re: [Cs-dev] per-event input/output
>>>>>>
>>>>>>
>>>>>>> Jonatan Liljedahl wrote:
>>>>>>>> matt ingalls wrote:
>>>>>>>> ...
>>>>>>>>> btw, i have used "fractional" i statements for this kind of  
>>>>>>>>> thing
>>>>>>>>> before:
>>>>>>>>>
>>>>>>>>> i 2.3847 0 10 .
>>>>>>>>> i 2.3848 +
>>>>>>>>> i 2.3849 +
>>>>>>>>>
>>>>>>>>> instr 2
>>>>>>>>>    outvalue "id", p1
>>>>>>>>>    k1 ...something
>>>>>>>>>    outvalue "value", k1
>>>>>>>>> endif
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> if i am not missing something,
>>>>>>>>> i don't think you could use the software bus to do something
>>>>>>>>> like this!!
>>>>>>>> It worked fine! Here's an example of a graphical score with
>>>>>>>> amplitude
>>>>>>>> envelope plotting for each event. (attached PDF)
>>>>>>>>
>>>>>>>> Thanks for your help.
>>>>>>> There's still one problem... Instrument tags is encoded as the
>>>>>>> fractional part of p1, but since it's a simple 32-bit float
>>>>>>> there's a
>>>>>>> lot of problems with rounding errors, see this example:
>>>>>>>
>>>>>>> int main(void) {
>>>>>>>    float f;
>>>>>>>    int last = 9999;
>>>>>>>    for(f=1;f<2;f+=0.0001) {
>>>>>>>        int i = 0.5 + f * 10000;
>>>>>>>        printf("%d %g %f ",i,f,f);
>>>>>>>        if(i!=last+1) printf("ERROR!\n");
>>>>>>>        else printf("OK\n");
>>>>>>>        last=i;
>>>>>>>    }
>>>>>>> }
>>>>>>>
>>>>>>> $ foo | grep -B 1 ERROR
>>>>>>> 13013 1.30135 1.301350 OK
>>>>>>> 13015 1.30145 1.301450 ERROR!
>>>>>>> --
>>>>>>> 19040 1.90405 1.904050 OK
>>>>>>> 19042 1.90415 1.904150 ERROR!
>>>>>>>
>>>>>>> Which means that with tags from .0001 to .9999 there's two
>>>>>>> numbers that
>>>>>>> can't be represented? And then one can only have 9998 tagged  
>>>>>>> events,
>>>>>>> increasing it to one more decimal gives 136 errors.
>>>>>>>
>>>>>>> Is there a way to tag instrument with strings instead? is there a
>>>>>>> way to
>>>>>>> send string p-args with csoundScoreEvent()?
>>>>>>>
>>>>>>> -- 
>>>>>>> /Jonatan         [ http://kymatica.com ]
-- 
/Jonatan         [ http://kymatica.com ]

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2007-12-18 00:09
Frommatt ingalls
SubjectRe: [Cs-dev] first outvalue zero? (was per-event input/output)
On Dec 17, 2007, at 3:58 PM, Jonatan Liljedahl wrote:

>
> I see, is it possible to avoid it? Should outvalue really output in  
> the
> i-pass?

none other than initing the value to some 0xFFFF or something and
have your host ignore that value.

it does seem kind of weird, doesn't it? - i don't know if i put that  
in for a reason,
  or without thinking. (most likely the latter!)
i know i *did* need 'invalue' to request a value during the i-pass,  
which
is often useful..

>
> Also, is there some simpler way to execute a block of code at some
> divisor of k-rate?

what you are doing is something i do ALL the time.

i guess you could use a 'metro' opcode or something, but you would
still need an 'if' statement and so it is pretty much
the same amount of work...

-m
___________________
matt ingalls
development@gvox.com




-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net