Csound Csound-dev Csound-tekno Search About

[Csnd] record in CsoundPerformanceThread - ctcsound, python API

Date2023-01-09 09:10
FromCordelia <00000c641a512f08-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] record in CsoundPerformanceThread - ctcsound, python API
What's the correct way of using record inside the CsoundPerformanceThread?
I'm using this sequence but my wav file is always corrupted and I cannot figure out where I'm wrong.

---

cs_return = cs.start()
pt = ctcsound.CsoundPerformanceThread(cs.csound())

if cs_return == ctcsound.CSOUND_SUCCESS:
		print('CSOUND is ON!')

		filename = '/Users/j/Desktop/out.wav'
		bits = 24
		numbufs = 2

		print('Record ON') 
		pt.record(filename, bits, numbufs)
		
		pt.play()

		while pt.status() == 0:
			pass

		pt.stopRecord()
		print('Record OFF') 
		cs.cleanup()

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

Date2023-01-09 09:49
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] record in CsoundPerformanceThread - ctcsound, python API
Not sure whether it’s where the problem lies, but I would expect to see a pt.join() call after pt.stop() to synchronise the threads before cleanup.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 9 Jan 2023, at 09:10, Cordelia <00000c641a512f08-dmarc-request@LISTSERV.HEANET.IE> 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.
> 
> What's the correct way of using record inside the CsoundPerformanceThread?
> I'm using this sequence but my wav file is always corrupted and I cannot figure out where I'm wrong.
> 
> ---
> 
> cs_return = cs.start()
> pt = ctcsound.CsoundPerformanceThread(cs.csound())
> 
> if cs_return == ctcsound.CSOUND_SUCCESS:
>                print('CSOUND is ON!')
> 
>                filename = '/Users/j/Desktop/out.wav'
>                bits = 24
>                numbufs = 2
> 
>                print('Record ON')
>                pt.record(filename, bits, numbufs)
> 
>                pt.play()
> 
>                while pt.status() == 0:
>                        pass
> 
>                pt.stopRecord()
>                print('Record OFF')
>                cs.cleanup()
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C719c8468ea9f4109a88408daf220d410%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638088520051094591%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=z8o752CE9DXnTq35zSqItMqavVh%2FbJPfAeI0xqsAEYs%3D&reserved=0
> Send bugs reports to
>        https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C719c8468ea9f4109a88408daf220d410%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638088520051097732%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mukIymYirmi5n4g0OWzmNLDASr0TZbXVRVTU8VwkXoQ%3D&reserved=0
> 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

Date2023-01-09 10:07
FromGerard Power
SubjectRe: [Csnd] [EXTERNAL] [Csnd] record in CsoundPerformanceThread - ctcsound, python API
Im having problems unsubscribing to csound.  Im not sure why

On Mon, Jan 9, 2023 at 9:49 AM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
Not sure whether it’s where the problem lies, but I would expect to see a pt.join() call after pt.stop() to synchronise the threads before cleanup.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 9 Jan 2023, at 09:10, Cordelia <00000c641a512f08-dmarc-request@LISTSERV.HEANET.IE> 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.
>
> What's the correct way of using record inside the CsoundPerformanceThread?
> I'm using this sequence but my wav file is always corrupted and I cannot figure out where I'm wrong.
>
> ---
>
> cs_return = cs.start()
> pt = ctcsound.CsoundPerformanceThread(cs.csound())
>
> if cs_return == ctcsound.CSOUND_SUCCESS:
>                print('CSOUND is ON!')
>
>                filename = '/Users/j/Desktop/out.wav'
>                bits = 24
>                numbufs = 2
>
>                print('Record ON')
>                pt.record(filename, bits, numbufs)
>
>                pt.play()
>
>                while pt.status() == 0:
>                        pass
>
>                pt.stopRecord()
>                print('Record OFF')
>                cs.cleanup()
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C719c8468ea9f4109a88408daf220d410%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638088520051094591%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=z8o752CE9DXnTq35zSqItMqavVh%2FbJPfAeI0xqsAEYs%3D&reserved=0
> Send bugs reports to
>        https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7C719c8468ea9f4109a88408daf220d410%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638088520051097732%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mukIymYirmi5n4g0OWzmNLDASr0TZbXVRVTU8VwkXoQ%3D&reserved=0
> 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


--

39 Bridgewater Court
Grove Lane
Leeds
LS64AQ

Tel:07952638445
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