Re: [Cs-dev] per-event input/output
| Date | 2007-12-17 19:47 |
| From | victor |
| Subject | Re: [Cs-dev] per-event input/output |
use csoundInputMessage() ----- Original Message ----- From: "Jonatan Liljedahl" |
| Date | 2007-12-17 20:01 |
| From | Jonatan Liljedahl |
| Subject | Re: [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" |
| Date | 2007-12-17 20:06 |
| From | matt ingalls |
| Subject | Re: [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" |
| Date | 2007-12-17 20:18 |
| From | Jonatan Liljedahl |
| Subject | Re: [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" |
| Date | 2007-12-17 23:12 |
| From | Jonatan 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" |
| Date | 2007-12-17 23:54 |
| From | matt ingalls |
| Subject | Re: [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" |
| Date | 2007-12-17 23:58 |
| From | Jonatan Liljedahl |
| Subject | Re: [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" |
| Date | 2007-12-18 00:09 |
| From | matt ingalls |
| Subject | Re: [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 |