| 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 |