Csound Csound-dev Csound-tekno Search About

[Csnd] Strtodk won't convert string from OSCraw

Date2020-06-09 20:30
FromAndreas Bergsland
Subject[Csnd] Strtodk won't convert string from OSCraw

Hi

I am trying to understand how I can use OSCraw to receive floats.

I started out from the manual example and can see that OSCraw receives all messages nicely, but when I try to convert my float numbers, I get an error saying

INIT ERROR in instr 1 line 16: strtodk: empty string

I am on OSX 10.14.6 with Csound 6.14.

Best, Andreas

 

instr     1

Smess[] init     3

top:

Smess,ka OSCraw 6160

kn = 0

ktrig init 0

while kn < ka do

if strcmpk(Smess[kn],"/my/OSC/address")==0 then

  printf "%s\n", ktrig, Smess[kn+2]

  klen strlenk Smess[kn+2]

  if klen > 0 then

  kval strtodk Smess[kn+2]

  endif

endif

kn += 1

ktrig += 1

od

;printf "%d items\n", ka, kn

if ka > 0 kgoto top

endin

 

-- 

Andreas Bergsland

 

Associate professor - førsteamanuensis

Study Programme Leader - studieprogramleder

Music Technology Programme - Musikkteknologiseksjonen

Department of Music - Institutt for musikk

Olavskvartalet

NTNU (Norwegian University of Science and Technology)

7491 Trondheim, NORWAY

 

Visiting address/besøksadresse: Fjordgt.1 (3.etg.)

e-mail: andreas.bergsland@ntnu.no

Office phone (Skype for business):7359 0096

Mobil: 4566 3316

http://folk.ntnu.no/andbe

https://www.vibra.no/

https://www.ntnu.edu/studies/mmct

https://www.ntnu.no/studier/mmust


Date2020-06-09 21:08
FromEduardo Moguillansky
SubjectRe: [Csnd] Strtodk won't convert string from OSCraw

This is because strtodk, like many string opcodes, was badly thought, and executes both at init and k time. So you put your strtodk very wisely inside an if-clause, but the init part of strtodk executes nevertheless, to find an empty string.
The solution is to revise all k-time string opcodes and solve this mess (but you will find many other messes, like memory allocation at performance time all over the place). 

On 09.06.20 21:30, Andreas Bergsland wrote:

Hi

I am trying to understand how I can use OSCraw to receive floats.

I started out from the manual example and can see that OSCraw receives all messages nicely, but when I try to convert my float numbers, I get an error saying

INIT ERROR in instr 1 line 16: strtodk: empty string

I am on OSX 10.14.6 with Csound 6.14.

Best, Andreas

 

instr     1

Smess[] init     3

top:

Smess,ka OSCraw 6160

kn = 0

ktrig init 0

while kn < ka do

if strcmpk(Smess[kn],"/my/OSC/address")==0 then

  printf "%s\n", ktrig, Smess[kn+2]

  klen strlenk Smess[kn+2]

  if klen > 0 then

  kval strtodk Smess[kn+2]

  endif

endif

kn += 1

ktrig += 1

od

;printf "%d items\n", ka, kn

if ka > 0 kgoto top

endin

 

-- 

Andreas Bergsland

 

Associate professor - førsteamanuensis

Study Programme Leader - studieprogramleder

Music Technology Programme - Musikkteknologiseksjonen

Department of Music - Institutt for musikk

Olavskvartalet

NTNU (Norwegian University of Science and Technology)

7491 Trondheim, NORWAY

 

Visiting address/besøksadresse: Fjordgt.1 (3.etg.)

e-mail: andreas.bergsland@ntnu.no

Office phone (Skype for business):7359 0096

Mobil: 4566 3316

http://folk.ntnu.no/andbe

https://www.vibra.no/

https://www.ntnu.edu/studies/mmct

https://www.ntnu.no/studier/mmust

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

Date2020-06-10 08:35
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] Strtodk won't convert string from OSCraw
you're absolutely right. Strings were hacked into Csound sometime back and we have spent the last fifteen years trying to fix it. I think it's another area that will need another pass and redesign in Csound 7 (further to what we had already done in 6). In particular, these reallocations at perf time have to go.

Prof. Victor Lazzarini
Maynooth University
Ireland

On 9 Jun 2020, at 21:09, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:



*Warning*

This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.

This is because strtodk, like many string opcodes, was badly thought, and executes both at init and k time. So you put your strtodk very wisely inside an if-clause, but the init part of strtodk executes nevertheless, to find an empty string.
The solution is to revise all k-time string opcodes and solve this mess (but you will find many other messes, like memory allocation at performance time all over the place). 

On 09.06.20 21:30, Andreas Bergsland wrote:

Hi

I am trying to understand how I can use OSCraw to receive floats.

I started out from the manual example and can see that OSCraw receives all messages nicely, but when I try to convert my float numbers, I get an error saying

INIT ERROR in instr 1 line 16: strtodk: empty string

I am on OSX 10.14.6 with Csound 6.14.

Best, Andreas

 

instr     1

Smess[] init     3

top:

Smess,ka OSCraw 6160

kn = 0

ktrig init 0

while kn < ka do

if strcmpk(Smess[kn],"/my/OSC/address")==0 then

  printf "%s\n", ktrig, Smess[kn+2]

  klen strlenk Smess[kn+2]

  if klen > 0 then

  kval strtodk Smess[kn+2]

  endif

endif

kn += 1

ktrig += 1

od

;printf "%d items\n", ka, kn

if ka > 0 kgoto top

endin

 

-- 

Andreas Bergsland

 

Associate professor - førsteamanuensis

Study Programme Leader - studieprogramleder

Music Technology Programme - Musikkteknologiseksjonen

Department of Music - Institutt for musikk

Olavskvartalet

NTNU (Norwegian University of Science and Technology)

7491 Trondheim, NORWAY

 

Visiting address/besøksadresse: Fjordgt.1 (3.etg.)

e-mail: andreas.bergsland@ntnu.no

Office phone (Skype for business):7359 0096

Mobil: 4566 3316

http://folk.ntnu.no/andbe

https://www.vibra.no/

https://www.ntnu.edu/studies/mmct

https://www.ntnu.no/studier/mmust

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