Csound Csound-dev Csound-tekno Search About

[Csnd] Csound tidy up: Segmentation fault when running for 2nd or 3d time

Date2014-06-15 10:01
Fromzappfinger
Subject[Csnd] Csound tidy up: Segmentation fault when running for 2nd or 3d time
I am creating a SQLite database with drum patterns (Csound scores converted
from midi files).
Via a GUI I can select a pattern, like "Bossa" or "Rock3" and play it via
csound.

When executing the following code for the second or third time, I get the
seg fault:
 
	def play(self):
		prepplay(playsco)            # prepare the csd from the template
		c = csnd6.Csound()          # Create an instance of the Csound object
		c.Compile(playnow)          # Compile a pre-defined csd
		c.Perform()                 # This call runs Csound to completion
		c.Stop()

The "playnow.csd" file is also quite simple:

;
;   playsco play score file
;



--logfile=null -odac -iadc -m0  -B256 -b64
-T



sr = 44100
nchnls = 2
0dbfs = 1
ksmps = 10

alwayson 2001

; drums
giengine10 fluidEngine
isfnum10	 fluidLoad "/Users/richard/Desktop/MyPython/Lists/samples/003.3mg
GS Roland Sound Set 16 bit Bank.SF2", giengine10, 1
		fluidProgramSelect giengine10, 10, isfnum10, 128, 32

instr 10
mididefault   60, p3
midinoteonkey p5, p4
ikey	init p5
iVel	init p4
fluidNote giengine10, 10, ikey, iVel
endin

instr 2001 ; play drums
imvol  init 7
asigl, asigr fluidOut giengine10
       outs asigl*imvol, asigr*imvol
endin



#include "./scores/track10.sco"
e




I tried with and without the -T flag, no difference.
Also tried without the 'e' in the score.

Richard



--
View this message in context: http://csound.1045644.n5.nabble.com/Csound-tidy-up-Segmentation-fault-when-running-for-2nd-or-3d-time-tp5735836.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-06-15 11:02
Fromzappfinger
Subject[Csnd] Re: Csound tidy up: Segmentation fault when running for 2nd or 3d time
Ok, changing the code to this solved it:

	def play(self):
		self.c = csnd6.Csound()          # Create an instance of the Csound object
		self.c.Compile(playnow)          # Compile a pre-defined csd
		self.c.Perform()                 # This call runs Csound to completion
		self.c.Stop()

I was actually using the c object outside of my class (not so neat, but I
think it should have worked)
So, no problems..

Richard 



--
View this message in context: http://csound.1045644.n5.nabble.com/Csound-tidy-up-Segmentation-fault-when-running-for-2nd-or-3d-time-tp5735836p5735837.html
Sent from the Csound - General mailing list archive at Nabble.com.

Date2014-06-15 11:06
FromVictor Lazzarini
SubjectRe: [Csnd] Csound tidy up: Segmentation fault when running for 2nd or
I tested a similar script here (with a different CSD, as I don’t have your include or soundfont dependencies) and I could
not reproduce it:

for i in range(0, 5):
 print "========== START %d ============" % (i+1)
 cs=csnd6.Csound()
 cs.Compile("pp.csd")
 cs.Perform()
 cs.Stop()
 print "========== END %d ============" % (i+1)


I think the call to cs.Stop() is not really needed here. You can try replacing it with a call to cs.Reset() or cs.Cleanup() to force the
cleanup there and then.

If you can show the problem with a minimal script and CSD (no dependencies), then we can tackle it.

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 15 Jun 2014, at 10:01, zappfinger  wrote:

> I am creating a SQLite database with drum patterns (Csound scores converted
> from midi files).
> Via a GUI I can select a pattern, like "Bossa" or "Rock3" and play it via
> csound.
> 
> When executing the following code for the second or third time, I get the
> seg fault:
> 
> 	def play(self):
> 		prepplay(playsco)            # prepare the csd from the template
> 		c = csnd6.Csound()          # Create an instance of the Csound object
> 		c.Compile(playnow)          # Compile a pre-defined csd
> 		c.Perform()                 # This call runs Csound to completion
> 		c.Stop()
> 
> The "playnow.csd" file is also quite simple:
> 
> ;
> ;   playsco play score file
> ;
> 
> 
> 
> --logfile=null -odac -iadc -m0  -B256 -b64
> -T
> 
> 
> 
> sr = 44100
> nchnls = 2
> 0dbfs = 1
> ksmps = 10
> 
> alwayson 2001
> 
> ; drums
> giengine10 fluidEngine
> isfnum10	 fluidLoad "/Users/richard/Desktop/MyPython/Lists/samples/003.3mg
> GS Roland Sound Set 16 bit Bank.SF2", giengine10, 1
> 		fluidProgramSelect giengine10, 10, isfnum10, 128, 32
> 
> instr 10
> mididefault   60, p3
> midinoteonkey p5, p4
> ikey	init p5
> iVel	init p4
> fluidNote giengine10, 10, ikey, iVel
> endin
> 
> instr 2001 ; play drums
> imvol  init 7
> asigl, asigr fluidOut giengine10
>       outs asigl*imvol, asigr*imvol
> endin
> 
> 
> 
> #include "./scores/track10.sco"
> e
> 
> 
> 
> 
> I tried with and without the -T flag, no difference.
> Also tried without the 'e' in the score.
> 
> Richard
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Csound-tidy-up-Segmentation-fault-when-running-for-2nd-or-3d-time-tp5735836.html
> Sent from the Csound - General mailing list archive at Nabble.com.
> 
> 
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
> 
> 
>