Csound Csound-dev Csound-tekno Search About

[Csnd-dev] multiple calls of csoundPerform?

Date2019-04-14 06:23
FromPete Goodeve
Subject[Csnd-dev] multiple calls of csoundPerform?
AttachmentsNone  

Date2019-04-14 09:07
FromFrancois PINOT
SubjectRe: [Csnd-dev] multiple calls of csoundPerform?
Each instance of Csound has its own memory space. In one instance you'll have to recompile a csd if you want to play it again. A typical sequence in Python would be:

In [1]: import ctcsound

In [2]: cs = ctcsound.Csound()
time resolution is 1000.000 ns
0dBFS level = 32768.0
--Csound version 6.13 beta (double samples) Nov  4 2018
[commit: 77986c77b743659067d486da1d389e4d8bf9d152]
libsndfile-1.0.28

In [3]: cs.compileCsd('myfile.csd')
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
Out[3]: 0

In [4]: cs.start()
rtaudio: ALSA module enabled
rtmidi: ALSA Raw MIDI module enabled
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 256 sample-frame blocks
ALSA output: total buffer size: 1024, period size: 256
writing 512 sample blks of 64-bit floats to dac
SECTION 1:
Out[4]: 0

In [5]: cs.perform()
ftable 1:
new alloc for instr 2:
  rtevent:       T  0.000 TT  0.000 M:  0.00000  0.00000
new alloc for instr 1:
  rtevent:       T  0.100 TT  0.100 M:  0.16000  0.16000
...
Score finished in csoundPerform().
Out[5]: 2

In [6]: cs.reset()
resetting Csound instance
inactive allocs returned to freespace
end of score.           overall amps:  0.88989  0.87681
       overall samples out of range:        0        0
0 errors in performance
Elapsed time at end of performance: real: 41.372s, CPU: 1.887s
WARNING: Buffer underrun in real-time audio output
3113 512 sample blks of 64-bit floats written to dac
0dBFS level = 32768.0
--Csound version 6.13 beta (double samples) Nov  4 2018
[commit: 77986c77b743659067d486da1d389e4d8bf9d152]
libsndfile-1.0.28

In [7]: cs.compileCsd(myfile.csd')
STARTING FILE
Creating options
Creating orchestra
closing tag
Creating score
Out[7]: 0

In [8]: cs.start()
rtaudio: ALSA module enabled
rtmidi: ALSA Raw MIDI module enabled
displays suppressed
0dBFS level = 1.0
orch now loaded
audio buffered in 256 sample-frame blocks
ALSA output: total buffer size: 1024, period size: 256
writing 512 sample blks of 64-bit floats to dac
SECTION 1:
Out[8]: 0

In [9]: cs.perform()
ftable 1:
new alloc for instr 2:
  rtevent:       T  0.000 TT  0.000 M:  0.00000  0.00000
new alloc for instr 1:
  rtevent:       T  0.100 TT  0.100 M:  0.16000  0.16000
...
Score finished in csoundPerform().
Out[9]: 2

In [10]: cs.reset()
resetting Csound instance
inactive allocs returned to freespace
end of score.           overall amps:  0.88989  0.87681
       overall samples out of range:        0        0
0 errors in performance
Elapsed time at end of performance: real: 43.629s, CPU: 1.803s
WARNING: Buffer underrun in real-time audio output
3113 512 sample blks of 64-bit floats written to dac
0dBFS level = 32768.0
--Csound version 6.13 beta (double samples) Nov  4 2018
[commit: 77986c77b743659067d486da1d389e4d8bf9d152]
libsndfile-1.0.28

In [11]: etc

François

Le dim. 14 avr. 2019 à 07:23, Pete Goodeve <pete.goodeve@computer.org> a écrit :
Hi,

I've been writing a front-end for Haiku (mostly for my own interest,
I guess), and -- as it allows one to start multiple instances of csound --
I thought it would be nice if one could run a performance a second
time or more once it has been compiled.

However, I can't find any way to make this work.  Is it possible, or
is the design such that once a csoundPerform has terminated
(not just stopped) it can't be re-run from the beginning?

Thanks,

        -- Pete --

Date2019-04-14 16:39
FromVictor Lazzarini
SubjectRe: [Csnd-dev] multiple calls of csoundPerform?
This is possible alright. You might need to rewind the score, though, as when csoundPerform() reaches the
end of score, it will stop playing. Or you might want to reset, compile and run again. Up to what you
want to do.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 14 Apr 2019, at 06:23, Pete Goodeve  wrote:
> 
> Hi,
> 
> I've been writing a front-end for Haiku (mostly for my own interest,
> I guess), and -- as it allows one to start multiple instances of csound --
> I thought it would be nice if one could run a performance a second
> time or more once it has been compiled.
> 
> However, I can't find any way to make this work.  Is it possible, or
> is the design such that once a csoundPerform has terminated
> (not just stopped) it can't be re-run from the beginning?
> 
> Thanks,
> 

Date2019-04-14 17:18
FromVictor Lazzarini
SubjectRe: [Csnd-dev] multiple calls of csoundPerform?
That’s right. But just so we are clear: if you are playing the same score again, all you need to do is rewind.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 14 Apr 2019, at 09:07, Francois PINOT  wrote:
> 
> Each instance of Csound has its own memory space. In one instance you'll have to recompile a csd if you want to play it again. A typical sequence in Python would be:
> 
> In [1]: import ctcsound
> 
> In [2]: cs = ctcsound.Csound()
> time resolution is 1000.000 ns
> 0dBFS level = 32768.0
> --Csound version 6.13 beta (double samples) Nov  4 2018
> [commit: 77986c77b743659067d486da1d389e4d8bf9d152]
> libsndfile-1.0.28
> 
> In [3]: cs.compileCsd('myfile.csd')
> STARTING FILE
> Creating options
> Creating orchestra
> closing tag
> Creating score
> Out[3]: 0
> 
> In [4]: cs.start()
> rtaudio: ALSA module enabled
> rtmidi: ALSA Raw MIDI module enabled
> displays suppressed
> 0dBFS level = 1.0
> orch now loaded
> audio buffered in 256 sample-frame blocks
> ALSA output: total buffer size: 1024, period size: 256
> writing 512 sample blks of 64-bit floats to dac
> SECTION 1:
> Out[4]: 0
> 
> In [5]: cs.perform()
> ftable 1:
> new alloc for instr 2:
>   rtevent:       T  0.000 TT  0.000 M:  0.00000  0.00000
> new alloc for instr 1:
>   rtevent:       T  0.100 TT  0.100 M:  0.16000  0.16000
> ...
> Score finished in csoundPerform().
> Out[5]: 2
> 
> In [6]: cs.reset()
> resetting Csound instance
> inactive allocs returned to freespace
> end of score.           overall amps:  0.88989  0.87681
>        overall samples out of range:        0        0
> 0 errors in performance
> Elapsed time at end of performance: real: 41.372s, CPU: 1.887s
> WARNING: Buffer underrun in real-time audio output
> 3113 512 sample blks of 64-bit floats written to dac
> 0dBFS level = 32768.0
> --Csound version 6.13 beta (double samples) Nov  4 2018
> [commit: 77986c77b743659067d486da1d389e4d8bf9d152]
> libsndfile-1.0.28
> 
> In [7]: cs.compileCsd(myfile.csd')
> STARTING FILE
> Creating options
> Creating orchestra
> closing tag
> Creating score
> Out[7]: 0
> 
> In [8]: cs.start()
> rtaudio: ALSA module enabled
> rtmidi: ALSA Raw MIDI module enabled
> displays suppressed
> 0dBFS level = 1.0
> orch now loaded
> audio buffered in 256 sample-frame blocks
> ALSA output: total buffer size: 1024, period size: 256
> writing 512 sample blks of 64-bit floats to dac
> SECTION 1:
> Out[8]: 0
> 
> In [9]: cs.perform()
> ftable 1:
> new alloc for instr 2:
>   rtevent:       T  0.000 TT  0.000 M:  0.00000  0.00000
> new alloc for instr 1:
>   rtevent:       T  0.100 TT  0.100 M:  0.16000  0.16000
> ...
> Score finished in csoundPerform().
> Out[9]: 2
> 
> In [10]: cs.reset()
> resetting Csound instance
> inactive allocs returned to freespace
> end of score.           overall amps:  0.88989  0.87681
>        overall samples out of range:        0        0
> 0 errors in performance
> Elapsed time at end of performance: real: 43.629s, CPU: 1.803s
> WARNING: Buffer underrun in real-time audio output
> 3113 512 sample blks of 64-bit floats written to dac
> 0dBFS level = 32768.0
> --Csound version 6.13 beta (double samples) Nov  4 2018
> [commit: 77986c77b743659067d486da1d389e4d8bf9d152]
> libsndfile-1.0.28
> 
> In [11]: etc
> 
> François
> 
> Le dim. 14 avr. 2019 à 07:23, Pete Goodeve  a écrit :
> Hi,
> 
> I've been writing a front-end for Haiku (mostly for my own interest,
> I guess), and -- as it allows one to start multiple instances of csound --
> I thought it would be nice if one could run a performance a second
> time or more once it has been compiled.
> 
> However, I can't find any way to make this work.  Is it possible, or
> is the design such that once a csoundPerform has terminated
> (not just stopped) it can't be re-run from the beginning?
> 
> Thanks,

Date2019-04-14 22:55
FromPete Goodeve
SubjectRe: [Csnd-dev] multiple calls of csoundPerform?
AttachmentsNone  

Date2019-04-15 09:03
FromVictor Lazzarini
SubjectRe: [Csnd-dev] multiple calls of csoundPerform?
Reset is needed to clear the engine if you want to compile a new CSD from the start etc.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 14 Apr 2019, at 22:55, Pete Goodeve  wrote:
> 
> Thanks folks for the insights.
> 
> I had missed the 'csoundRewindScore' feature.  It seems to do
> just what I want.  csound.h sort of indicates that 'csoundSetScoreOffsetSeconds'
> might also be needed, but experimentally it doesn't seem to be.
> I guess the default offset is 0?
> 
> There are some other calls I'm not clear about.  François mentions
> resetting, for instance, but I haven't found a situation where that
> makes any difference.  (I thought it might do what rewind does, but
> found otherwise.)  To shut down a csound instance I'm just using
> 'csoundDesdtroy', which is all that csound_main.c seems to do.
> 
> Thanks,
> 
> 	-- Pete --
> 
> 
> On Sun, Apr 14, 2019 at 03:39:06PM +0000, Victor Lazzarini wrote:
>> This is possible alright. You might need to rewind the score, though, as when csoundPerform() reaches the
>> end of score, it will stop playing. Or you might want to reset, compile and run again. Up to what you
>> want to do.
>> ========================
>> Prof. Victor Lazzarini
>> Dean of Arts, Celtic Studies, and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 353 1 7086952 
>> 
>>> On 14 Apr 2019, at 06:23, Pete Goodeve  wrote:
>>> 
>>> Hi,
>>> 
>>> I've been writing a front-end for Haiku (mostly for my own interest,
>>> I guess), and -- as it allows one to start multiple instances of csound --
>>> I thought it would be nice if one could run a performance a second
>>> time or more once it has been compiled.
>>> 
>>> However, I can't find any way to make this work.  Is it possible, or
>>> is the design such that once a csoundPerform has terminated
>>> (not just stopped) it can't be re-run from the beginning?
>>> 
>>> Than

Date2019-04-15 09:13
Frompete.goodeve@COMPUTER.ORG
SubjectRe: [Csnd-dev] multiple calls of csoundPerform?
AttachmentsNone