Csound Csound-dev Csound-tekno Search About

[Cs-dev] Porting to csnd6: InputMessage or ScoreEvent

Date2015-06-12 23:49
FromGonzalo Odiard
Subject[Cs-dev] Porting to csnd6: InputMessage or ScoreEvent
AttachmentsNone  None  
I continue working in the port of TamTam (a python application)  from csound 5 to csound 6.
Now I found the app used csoundScoreEvent to play notes.
I get a error with the arguments then I have two questions:

1) It's possible use InputMessage to substitute the use of ScoreEvent?

2) If not, how I should define the array at the python side?
  
c.ScoreEvent.__doc__

returns:

'ScoreEvent(Csound self, char type, double const * pFields, long numFields) -> int'

but modifying my example to use it:

from gi.repository import Gtk
import csnd6
import array

orc = """
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
   kamp = 30000
   kcps = 1
   ifn = 1
   ibas = 1

   ; Play the audio sample stored in Table #1.
   a1 loscil kamp, kcps, ifn, ibas
   out a1
endin"""

c = csnd6.Csound()
c.SetOption("-odac")
c.CompileOrc(orc)
c.Start()
c.InputMessage('f 1 0 131072 1 "beats.wav" 0 4 0')

perfThread = csnd6.CsoundPerformanceThread(c)
perfThread.Play()

def clicked_cb(button, c):
    a = array.array('d', [1.0, 0.0, 2.0])
    print a, len(a)
    c.ScoreEvent('i', a, len(a))

win = Gtk.Window()
btn = Gtk.Button('Play')
btn.connect('clicked', clicked_cb, c)
win.add(btn)
win.show_all()
win.connect("destroy", Gtk.main_quit)
Gtk.main()

I get the following error:

Traceback (most recent call last):
  File "button_se.py", line 36, in clicked_cb
    c.ScoreEvent('i', a, len(a))
  File "/usr/lib64/python2.7/site-packages/csnd6.py", line 2180, in ScoreEvent
    return _csnd6.Csound_ScoreEvent(self, *args)
TypeError: in method 'Csound_ScoreEvent', argument 3 of type 'double const *'

Thanks in advance,

--
Gonzalo Odiard

SugarLabs - Software for children learning 

Date2015-06-15 21:38
FromGonzalo Odiard
SubjectRe: [Cs-dev] Porting to csnd6: InputMessage or ScoreEvent
AttachmentsNone  None  
I found csnd6.doubleArray and solved this issue.
Thanks


On Fri, Jun 12, 2015 at 7:49 PM, Gonzalo Odiard <godiard@sugarlabs.org> wrote:
I continue working in the port of TamTam (a python application)  from csound 5 to csound 6.
Now I found the app used csoundScoreEvent to play notes.
I get a error with the arguments then I have two questions:

1) It's possible use InputMessage to substitute the use of ScoreEvent?

2) If not, how I should define the array at the python side?
  
c.ScoreEvent.__doc__

returns:

'ScoreEvent(Csound self, char type, double const * pFields, long numFields) -> int'

but modifying my example to use it:

from gi.repository import Gtk
import csnd6
import array

orc = """
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
   kamp = 30000
   kcps = 1
   ifn = 1
   ibas = 1

   ; Play the audio sample stored in Table #1.
   a1 loscil kamp, kcps, ifn, ibas
   out a1
endin"""

c = csnd6.Csound()
c.SetOption("-odac")
c.CompileOrc(orc)
c.Start()
c.InputMessage('f 1 0 131072 1 "beats.wav" 0 4 0')

perfThread = csnd6.CsoundPerformanceThread(c)
perfThread.Play()

def clicked_cb(button, c):
    a = array.array('d', [1.0, 0.0, 2.0])
    print a, len(a)
    c.ScoreEvent('i', a, len(a))

win = Gtk.Window()
btn = Gtk.Button('Play')
btn.connect('clicked', clicked_cb, c)
win.add(btn)
win.show_all()
win.connect("destroy", Gtk.main_quit)
Gtk.main()

I get the following error:

Traceback (most recent call last):
  File "button_se.py", line 36, in clicked_cb
    c.ScoreEvent('i', a, len(a))
  File "/usr/lib64/python2.7/site-packages/csnd6.py", line 2180, in ScoreEvent
    return _csnd6.Csound_ScoreEvent(self, *args)
TypeError: in method 'Csound_ScoreEvent', argument 3 of type 'double const *'

Thanks in advance,

--
Gonzalo Odiard

SugarLabs - Software for children learning 



--
Gonzalo Odiard

SugarLabs - Software for children learning 

Date2015-06-15 21:44
FromVictor Lazzarini
SubjectRe: [Cs-dev] Porting to csnd6: InputMessage or ScoreEvent
AttachmentsNone  None  
Yes, it is possible to use inputMessage instead of ScoreEvent. In Python, it might even be handier.

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

On 15 Jun 2015, at 21:38, Gonzalo Odiard <godiard@sugarlabs.org> wrote:

I found csnd6.doubleArray and solved this issue.
Thanks


On Fri, Jun 12, 2015 at 7:49 PM, Gonzalo Odiard <godiard@sugarlabs.org> wrote:
I continue working in the port of TamTam (a python application)  from csound 5 to csound 6.
Now I found the app used csoundScoreEvent to play notes.
I get a error with the arguments then I have two questions:

1) It's possible use InputMessage to substitute the use of ScoreEvent?

2) If not, how I should define the array at the python side?
  
c.ScoreEvent.__doc__

returns:

'ScoreEvent(Csound self, char type, double const * pFields, long numFields) -> int'

but modifying my example to use it:

from gi.repository import Gtk
import csnd6
import array

orc = """
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
   kamp = 30000
   kcps = 1
   ifn = 1
   ibas = 1

   ; Play the audio sample stored in Table #1.
   a1 loscil kamp, kcps, ifn, ibas
   out a1
endin"""

c = csnd6.Csound()
c.SetOption("-odac")
c.CompileOrc(orc)
c.Start()
c.InputMessage('f 1 0 131072 1 "beats.wav" 0 4 0')

perfThread = csnd6.CsoundPerformanceThread(c)
perfThread.Play()

def clicked_cb(button, c):
    a = array.array('d', [1.0, 0.0, 2.0])
    print a, len(a)
    c.ScoreEvent('i', a, len(a))

win = Gtk.Window()
btn = Gtk.Button('Play')
btn.connect('clicked', clicked_cb, c)
win.add(btn)
win.show_all()
win.connect("destroy", Gtk.main_quit)
Gtk.main()

I get the following error:

Traceback (most recent call last):
  File "button_se.py", line 36, in clicked_cb
    c.ScoreEvent('i', a, len(a))
  File "/usr/lib64/python2.7/site-packages/csnd6.py", line 2180, in ScoreEvent
    return _csnd6.Csound_ScoreEvent(self, *args)
TypeError: in method 'Csound_ScoreEvent', argument 3 of type 'double const *'

Thanks in advance,

--
Gonzalo Odiard

SugarLabs - Software for children learning 



--
Gonzalo Odiard

SugarLabs - Software for children learning 
------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel