Csound Csound-dev Csound-tekno Search About

question about SerialWrite

Date2016-12-11 15:16
FromRichard
Subjectquestion about SerialWrite

I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in								;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255						;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)			;must be in range: 0-255

Date2016-12-11 15:24
FromJohn ff
SubjectRe: question about SerialWrite
I do not understand.  kRms could be anything so checking that it is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-12-11 15:31
FromRichard
SubjectRe: question about SerialWrite

As I print kRms, it is a float. I understood that all csound k and a variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1, Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:
I do not understand.  kRms could be anything so checking that it is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Date2016-12-11 15:33
FromDave Seidel
SubjectRe: question about SerialWrite
I think the point here is not the data type as much as scaling the value to fall within a reasonable range.

On Sun, Dec 11, 2016 at 10:31 AM, Richard <zappfinger@gmail.com> wrote:

As I print kRms, it is a float. I understood that all csound k and a variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1, Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:
I do not understand.  kRms could be anything so checking that it is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-12-11 15:36
FromRichard
SubjectRe: question about SerialWrite

I understand that, but a float between 0 and 255 is not the same as an integer (or byte) within that range.


On 11/12/16 16:33, Dave Seidel wrote:
I think the point here is not the data type as much as scaling the value to fall within a reasonable range.

On Sun, Dec 11, 2016 at 10:31 AM, Richard <zappfinger@gmail.com> wrote:

As I print kRms, it is a float. I understood that all csound k and a variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1, Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:
I do not understand.  kRms could be anything so checking that it is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Date2016-12-11 15:49
FromRichard
SubjectRe: question about SerialWrite

Or to put it differently: how and where does the kRms value (a float as far as I can see) get converted to a byte?



On 11/12/16 16:33, Dave Seidel wrote:
I think the point here is not the data type as much as scaling the value to fall within a reasonable range.

On Sun, Dec 11, 2016 at 10:31 AM, Richard <zappfinger@gmail.com> wrote:

As I print kRms, it is a float. I understood that all csound k and a variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1, Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:
I do not understand.  kRms could be anything so checking that it is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Date2016-12-11 15:52
FromVictor Lazzarini
SubjectRe: question about SerialWrite
inside the opcode, I would guess. A simple cast.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 11 Dec 2016, at 15:50, Richard <zappfinger@GMAIL.COM> wrote:

Or to put it differently: how and where does the kRms value (a float as far as I can see) get converted to a byte?



On 11/12/16 16:33, Dave Seidel wrote:
I think the point here is not the data type as much as scaling the value to fall within a reasonable range.

On Sun, Dec 11, 2016 at 10:31 AM, Richard <zappfinger@gmail.com> wrote:

As I print kRms, it is a float. I understood that all csound k and a variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1, Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:
I do not understand.  kRms could be anything so checking that it is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-12-11 15:59
FromSteven Yi
SubjectRe: question about SerialWrite
I think there's a disconect here.  Within Csound, the values are
floats/doubles.  When serialWrite operates, it casts the value to a
byte (unsigned char), then writes the byte to the serial out.
serialRead also reads a byte from the port, then converts it to a
float/double.

On Sun, Dec 11, 2016 at 10:36 AM, Richard  wrote:
> I understand that, but a float between 0 and 255 is not the same as an
> integer (or byte) within that range.
>
>
> On 11/12/16 16:33, Dave Seidel wrote:
>
> I think the point here is not the data type as much as scaling the value to
> fall within a reasonable range.
>
> On Sun, Dec 11, 2016 at 10:31 AM, Richard  wrote:
>>
>> As I print kRms, it is a float. I understood that all csound k and a
>> variables are a float.
>> So it says in the floss article about python inside csound:
>>
>> Csound always works with numbers which are not integers (to represent a 1,
>> Csound actually uses 1.0).
>>
>>
>> On 11/12/16 16:24, John ff wrote:
>>
>> I do not understand.  kRms could be anything so checking that it is in
>> range seems sane.  Or have I misunderstood?
>>
>> Sent from TypeApp
>> On 11 Dec 2016, at 15:17, Richard  wrote:
>>>
>>> I do not understand the example given with SerialWrite:
>>> Since all csound variables are floats (if I understand correctly), how
>>> can kRms ever be different from a float?
>>> The corresponding Arduino code Serial.Read() returns a byte..
>>>
>>> aSig in        ;get our audio input and get its rms
>>> kRms rms aSig*kGain
>>>
>>> kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and
>>> send it out
>>> serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
>>>
>>> Csound mailing list Csound@listserv.heanet.ie
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>> https://github.com/csound/csound/issues Discussions of bugs and features can
>>> be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features can
>> be posted here
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features can
>> be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-12-11 16:13
FromRichard
SubjectRe: question about SerialWrite

Ok, makes sense, but then the documentation is confusing, it says

 serialWrite iPort, iByte
 serialWrite iPort, kByte
 serialWrite iPort, SBytes

And as far as I know Csound has no byte type. What it should say he second argument a 'i' or 'k' type, knowing that it is a float that gets converted internally.

Richard


On 11/12/16 16:59, Steven Yi wrote:
I think there's a disconect here.  Within Csound, the values are
floats/doubles.  When serialWrite operates, it casts the value to a
byte (unsigned char), then writes the byte to the serial out.
serialRead also reads a byte from the port, then converts it to a
float/double.

On Sun, Dec 11, 2016 at 10:36 AM, Richard <zappfinger@gmail.com> wrote:
I understand that, but a float between 0 and 255 is not the same as an
integer (or byte) within that range.


On 11/12/16 16:33, Dave Seidel wrote:

I think the point here is not the data type as much as scaling the value to
fall within a reasonable range.

On Sun, Dec 11, 2016 at 10:31 AM, Richard <zappfinger@gmail.com> wrote:
As I print kRms, it is a float. I understood that all csound k and a
variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1,
Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:

I do not understand.  kRms could be anything so checking that it is in
range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:
I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how
can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and
send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255

Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here

Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here


Date2016-12-11 16:15
FromVictor Lazzarini
SubjectRe: question about SerialWrite
it is just the variable name, not a type. 

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 11 Dec 2016, at 16:13, Richard <zappfinger@GMAIL.COM> wrote:

Ok, makes sense, but then the documentation is confusing, it says

 serialWrite iPort, iByte
 serialWrite iPort, kByte
 serialWrite iPort, SBytes

And as far as I know Csound has no byte type. What it should say he second argument a 'i' or 'k' type, knowing that it is a float that gets converted internally.

Richard


On 11/12/16 16:59, Steven Yi wrote:
I think there's a disconect here.  Within Csound, the values are
floats/doubles.  When serialWrite operates, it casts the value to a
byte (unsigned char), then writes the byte to the serial out.
serialRead also reads a byte from the port, then converts it to a
float/double.

On Sun, Dec 11, 2016 at 10:36 AM, Richard <zappfinger@gmail.com> wrote:
I understand that, but a float between 0 and 255 is not the same as an
integer (or byte) within that range.


On 11/12/16 16:33, Dave Seidel wrote:

I think the point here is not the data type as much as scaling the value to
fall within a reasonable range.

On Sun, Dec 11, 2016 at 10:31 AM, Richard <zappfinger@gmail.com> wrote:
As I print kRms, it is a float. I understood that all csound k and a
variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1,
Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:

I do not understand.  kRms could be anything so checking that it is in
range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:
I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how
can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and
send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255

Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-12-11 16:26
FromRichard
SubjectRe: question about SerialWrite

Yes, I know, but it suggests a type...


On 11/12/16 17:15, Victor Lazzarini wrote:
it is just the variable name, not a type. 

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 11 Dec 2016, at 16:13, Richard <zappfinger@GMAIL.COM> wrote:

Ok, makes sense, but then the documentation is confusing, it says

 serialWrite iPort, iByte
 serialWrite iPort, kByte
 serialWrite iPort, SBytes

And as far as I know Csound has no byte type. What it should say he second argument a 'i' or 'k' type, knowing that it is a float that gets converted internally.

Richard


On 11/12/16 16:59, Steven Yi wrote:
I think there's a disconect here.  Within Csound, the values are
floats/doubles.  When serialWrite operates, it casts the value to a
byte (unsigned char), then writes the byte to the serial out.
serialRead also reads a byte from the port, then converts it to a
float/double.

On Sun, Dec 11, 2016 at 10:36 AM, Richard <zappfinger@gmail.com> wrote:
I understand that, but a float between 0 and 255 is not the same as an
integer (or byte) within that range.


On 11/12/16 16:33, Dave Seidel wrote:

I think the point here is not the data type as much as scaling the value to
fall within a reasonable range.

On Sun, Dec 11, 2016 at 10:31 AM, Richard <zappfinger@gmail.com> wrote:
As I print kRms, it is a float. I understood that all csound k and a
variables are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1,
Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:

I do not understand.  kRms could be anything so checking that it is in
range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:
I do not understand the example given with SerialWrite:
Since all csound variables are floats (if I understand correctly), how
can kRms ever be different from a float?
The corresponding Arduino code Serial.Read() returns a byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and
send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255

Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Date2016-12-11 17:00
FromSteven Yi
SubjectRe: question about SerialWrite
For what it's worth, I don't think the documentation is confusing nor
suggests a type. All of csound's variables (prior to CS7) use the
first letter to denote type, which is what the documentation shows.
Are you suggesting something else, like the documentation should say
"ival, kval, Sval" instead?

On Sun, Dec 11, 2016 at 11:26 AM, Richard  wrote:
> Yes, I know, but it suggests a type...
>
>
> On 11/12/16 17:15, Victor Lazzarini wrote:
>
> it is just the variable name, not a type.
>
> Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy
> Maynooth University
> Ireland
>
> On 11 Dec 2016, at 16:13, Richard  wrote:
>
> Ok, makes sense, but then the documentation is confusing, it says
>
>  serialWrite iPort, iByte
>
>  serialWrite iPort, kByte
>
>  serialWrite iPort, SBytes
>
> And as far as I know Csound has no byte type. What it should say he second
> argument a 'i' or 'k' type, knowing that it is a float that gets converted
> internally.
>
> Richard
>
>
> On 11/12/16 16:59, Steven Yi wrote:
>
> I think there's a disconect here.  Within Csound, the values are
> floats/doubles.  When serialWrite operates, it casts the value to a
> byte (unsigned char), then writes the byte to the serial out.
> serialRead also reads a byte from the port, then converts it to a
> float/double.
>
> On Sun, Dec 11, 2016 at 10:36 AM, Richard  wrote:
>
> I understand that, but a float between 0 and 255 is not the same as an
> integer (or byte) within that range.
>
>
> On 11/12/16 16:33, Dave Seidel wrote:
>
> I think the point here is not the data type as much as scaling the value to
> fall within a reasonable range.
>
> On Sun, Dec 11, 2016 at 10:31 AM, Richard  wrote:
>
> As I print kRms, it is a float. I understood that all csound k and a
> variables are a float.
> So it says in the floss article about python inside csound:
>
> Csound always works with numbers which are not integers (to represent a 1,
> Csound actually uses 1.0).
>
>
> On 11/12/16 16:24, John ff wrote:
>
> I do not understand.  kRms could be anything so checking that it is in
> range seems sane.  Or have I misunderstood?
>
> Sent from TypeApp
> On 11 Dec 2016, at 15:17, Richard  wrote:
>
> I do not understand the example given with SerialWrite:
> Since all csound variables are floats (if I understand correctly), how
> can kRms ever be different from a float?
> The corresponding Arduino code Serial.Read() returns a byte..
>
> aSig in        ;get our audio input and get its rms
> kRms rms aSig*kGain
>
> kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and
> send it out
> serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
>
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-12-11 17:01
Fromjpff
SubjectRe: question about SerialWrite
Yes but what is your point?  All i, k, a, f variables are floating point. 
Cannot see how your example relates


On Sun, 11 Dec 2016, Richard wrote:

> 
> As I print kRms, it is a float. I understood that all csound k and a variables
> are a float.
> So it says in the floss article about python inside csound:
> 
> Csound always works with numbers which are not integers (to represent a 1,
> Csound actually uses 1.0).
> 
> 
> On 11/12/16 16:24, John ff wrote:
>       I do not understand.  kRms could be anything so checking that it
>       is in range seems sane.  Or have I misunderstood?
> 
> Sent from TypeApp
> On 11 Dec 2016, at 15:17, Richard  wrote:
>
>       I do not understand the example given with SerialWrite:
>       Since all csound variables are floats (if I understand
>       correctly), how can kRms ever be different from a float?
>       The corresponding Arduino code Serial.Read() returns a
>       byte..
> 
> aSig in        ;get our audio input and get its rms
> kRms rms aSig*kGain
> 
> kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send 
> it out
> serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
>       Csound mailing list Csound@listserv.heanet.ie
>       https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs
>       reports to https://github.com/csound/csound/issues
>       Discussions of bugs and features can be posted here
> 
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here
> 
> 
> Csound mailing list Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-12-11 17:37
FromRichard
SubjectRe: question about SerialWrite
Never mind, I was just confused by the kByte variable name...


On 11/12/16 18:01, jpff wrote:
> Yes but what is your point?  All i, k, a, f variables are floating 
> point. Cannot see how your example relates
>
>
> On Sun, 11 Dec 2016, Richard wrote:
>
>>
>> As I print kRms, it is a float. I understood that all csound k and a 
>> variables
>> are a float.
>> So it says in the floss article about python inside csound:
>>
>> Csound always works with numbers which are not integers (to represent 
>> a 1,
>> Csound actually uses 1.0).
>>
>>
>> On 11/12/16 16:24, John ff wrote:
>>       I do not understand.  kRms could be anything so checking that it
>>       is in range seems sane.  Or have I misunderstood?
>>
>> Sent from TypeApp
>> On 11 Dec 2016, at 15:17, Richard  wrote:
>>
>>       I do not understand the example given with SerialWrite:
>>       Since all csound variables are floats (if I understand
>>       correctly), how can kRms ever be different from a float?
>>       The corresponding Arduino code Serial.Read() returns a
>>       byte..
>>
>> aSig in        ;get our audio input and get its rms
>> kRms rms aSig*kGain
>>
>> kRms = kRms*kRms*255      ;scale the rms to a good value for the LED 
>> and send it out
>> serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
>>       Csound mailing list Csound@listserv.heanet.ie
>>       https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs
>>       reports to https://github.com/csound/csound/issues
>>       Discussions of bugs and features can be posted here
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and 
>> features can
>> be posted here
>>
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2016-12-11 17:44
FromRory Walsh
SubjectRe: question about SerialWrite
I believe you have a point. 

On 11 December 2016 at 17:37, Richard <zappfinger@gmail.com> wrote:
Never mind, I was just confused by the kByte variable name...



On 11/12/16 18:01, jpff wrote:
Yes but what is your point?  All i, k, a, f variables are floating point. Cannot see how your example relates


On Sun, 11 Dec 2016, Richard wrote:


As I print kRms, it is a float. I understood that all csound k and a variables
are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1,
Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:
      I do not understand.  kRms could be anything so checking that it
      is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

      I do not understand the example given with SerialWrite:
      Since all csound variables are floats (if I understand
      correctly), how can kRms ever be different from a float?
      The corresponding Arduino code Serial.Read() returns a
      byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
      Csound mailing list Csound@listserv.heanet.ie
      https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs
      reports to https://github.com/csound/csound/issues
      Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features
can be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2016-12-11 20:15
FromPaul Batchelor
SubjectRe: question about SerialWrite
I've recently glanced at the source code for this, and it does provide clarification (yay open source). This is the actual line that does the writing, which is just a standard write call for anything non-windows:


The "kByte" variable name refers to the fact that you are writing a serial message one byte at a time, which would imply the 0-255 range. 

By the way, this opcode is an amazing reference for anyone interested in reading/writing serial from C on Linux. Really really glad it existed for me this quarter!

Cheers,

-P

On Sun, Dec 11, 2016 at 9:44 AM, Rory Walsh <rorywalsh@ear.ie> wrote:
I believe you have a point. 

On 11 December 2016 at 17:37, Richard <zappfinger@gmail.com> wrote:
Never mind, I was just confused by the kByte variable name...



On 11/12/16 18:01, jpff wrote:
Yes but what is your point?  All i, k, a, f variables are floating point. Cannot see how your example relates


On Sun, 11 Dec 2016, Richard wrote:


As I print kRms, it is a float. I understood that all csound k and a variables
are a float.
So it says in the floss article about python inside csound:

Csound always works with numbers which are not integers (to represent a 1,
Csound actually uses 1.0).


On 11/12/16 16:24, John ff wrote:
      I do not understand.  kRms could be anything so checking that it
      is in range seems sane.  Or have I misunderstood?

Sent from TypeApp
On 11 Dec 2016, at 15:17, Richard <zappfinger@GMAIL.COM> wrote:

      I do not understand the example given with SerialWrite:
      Since all csound variables are floats (if I understand
      correctly), how can kRms ever be different from a float?
      The corresponding Arduino code Serial.Read() returns a
      byte..

aSig in        ;get our audio input and get its rms
kRms rms aSig*kGain

kRms = kRms*kRms*255      ;scale the rms to a good value for the LED and send it out
serialWrite iPort, (kRms < 255 ? kRms : 255)   ;must be in range: 0-255
      Csound mailing list Csound@listserv.heanet.ie
      https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs
      reports to https://github.com/csound/csound/issues
      Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features
can be posted here


Csound mailing list Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here