Csound Csound-dev Csound-tekno Search About

[Cs-dev] Csound API OutputValueCallback

Date2010-12-17 05:03
From4g63gsx
Subject[Cs-dev] Csound API OutputValueCallback
I am writing a Java program that uses the Csound API. Thanks everyone for
helping me get through some of my initial problems. I gave up on trying to
get the Csound API to work on a 64-bit Mac, and have now switchd over to
using a Windows machine with no problems.

I am trying to use the CsoundCallbackWrapper class to gain access to
variables in my Csound program but am having some issues. Inside of Csound,
I am not sure whether I should be using the chnset or outvalue (or chnsend?
which I haven't gotten to compile properly). In Java I have tried using both
the OutputValueCallback and ControlChannelOutputCallback (just for the hell
of it) methods, but have had no success in getting the values into my Java
program.

Here is my CSD file:



-odevaudio -b400



/* pvs bus interface example, works with pvsbus.c
   Copies a fsig to the pvs out bus and retrieves
   it in the pvs in bus.
*/
sr = 44100
ksmps=100
nchnls=2

instr 1

asigL asigR diskin2 "Seashore.wav", 1, 0, 1
fsi pvsanal asigL, 1024, 256, 1024, 1
pvsout fsi,0
kamp,kfrq pvsbin fsi, 2


;assign channels for the amp and frq values
chn_k "amplitude1", 2
chn_k "amplitude2", 2
chn_k "frequency1", 2
chn_k "frequency2", 2

;---option1---
;use the chnset opcode to send the values to a channel
chnset kamp, "amplitude1"
chnset kfrq, "frequency1"

;---option2---
;use the outvalue opcode to send the values to a channel
outvalue "amplitude2", kamp
outvalue "frequency2", kfrq


;send the values to a csv file
fprintks "output.csv", "%f,%f\n", kamp, kfrq
a1 pvsynth fsi

outs a1, a1
   

endin



f1 0 1024 10 1 0.5 0.33 0.25 0.2 0.16 0.125
i1 0 100




Here is my Java program:
import csnd.*;

public class eqrun {
	public static void main(String args[]) {
		Csound cs = new Csound();
		CsoundArgVList argm = new CsoundArgVList();

		
		argm.Append("csound");
        argm.Append("-d32");
        argm.Append("-odevaudio");

        //Load CSD file
		cs.Compile("C:/Documents and
Settings/S311/Nathan/workspace2/eqrun2/src/pvsbus.csd");
		
		//Make a callback wrapper
		CsoundCallbackWrapper wrapper = new CsoundCallbackWrapper(cs);
		
		//Is this necessary?
		wrapper.SetOutputValueCallback();
		
		//doubles to hold the callback values
		double ampCCOC1 = 0.0, ampCCOC2 = 0.0, frqCCOC1 = 0.0, frqCCOC2 = 0.0;
		double ampOVC1 = 0.0, ampOVC2 = 0.0, frqOVC1 = 0.0, frqOVC2 = 0.0;

		int result = 0;
		
		while(result == 0) {
			result = cs.PerformKsmps();
			
			/*---------Get amp and frq values-----------*/
			
			//ControlChannelOutputCallback
			wrapper.ControlChannelOutputCallback("amplitude1", ampCCOC1);
			wrapper.ControlChannelOutputCallback("amplitude2", ampCCOC2);
			wrapper.ControlChannelOutputCallback("amplitude1", frqCCOC1);
			wrapper.ControlChannelOutputCallback("amplitude2", frqCCOC2);
			
			//OutputValueCallback
			wrapper.OutputValueCallback("amplitude1", ampOVC1);
			wrapper.OutputValueCallback("amplitude2", ampOVC2);
			wrapper.OutputValueCallback("frequency1", frqOVC1);
			wrapper.OutputValueCallback("frequency2", frqOVC2);
			
			System.out.println(ampCCOC1 + " " + ampCCOC2 + " " + frqCCOC1 + " " +
frqCCOC2 + " " + ampOVC1 + " " + ampOVC2 + " " + frqOVC1 + " " + frqOVC2);
		}
	}
}

Is there something I am missing about using the CsoundCallbackWrapper class?
Or, alternatively is there a better way to access variables from inside of
my Csound program?

-- 
View this message in context: http://csound.1045644.n5.nabble.com/Csound-API-OutputValueCallback-tp3308961p3308961.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-12-17 09:35
FromVictor Lazzarini
SubjectRe: [Cs-dev] Csound API OutputValueCallback
I would suggest using chnget / chnset_ opcodes and  
Csound::GetChannel() / Csound::SetChannel(). They are the easiest for
controls.

Victor
On 17ec 2010, at 05:03, 4g63gsx wrote:

>
> I am writing a Java program that uses the Csound API. Thanks  
> everyone for
> helping me get through some of my initial problems. I gave up on  
> trying to
> get the Csound API to work on a 64-bit Mac, and have now switchd  
> over to
> using a Windows machine with no problems.
>
> I am trying to use the CsoundCallbackWrapper class to gain access to
> variables in my Csound program but am having some issues. Inside of  
> Csound,
> I am not sure whether I should be using the chnset or outvalue (or  
> chnsend?
> which I haven't gotten to compile properly). In Java I have tried  
> using both
> the OutputValueCallback and ControlChannelOutputCallback (just for  
> the hell
> of it) methods, but have had no success in getting the values into  
> my Java
> program.
>
> Here is my CSD file:
>
> 
> 
> -odevaudio -b400
> 
>
> 
> /* pvs bus interface example, works with pvsbus.c
>   Copies a fsig to the pvs out bus and retrieves
>   it in the pvs in bus.
> */
> sr = 44100
> ksmps=100
> nchnls=2
>
> instr 1
>
> asigL asigR diskin2 "Seashore.wav", 1, 0, 1
> fsi pvsanal asigL, 1024, 256, 1024, 1
> pvsout fsi,0
> kamp,kfrq pvsbin fsi, 2
>
>
> ;assign channels for the amp and frq values
> chn_k "amplitude1", 2
> chn_k "amplitude2", 2
> chn_k "frequency1", 2
> chn_k "frequency2", 2
>
> ;---option1---
> ;use the chnset opcode to send the values to a channel
> chnset kamp, "amplitude1"
> chnset kfrq, "frequency1"
>
> ;---option2---
> ;use the outvalue opcode to send the values to a channel
> outvalue "amplitude2", kamp
> outvalue "frequency2", kfrq
>
>
> ;send the values to a csv file
> fprintks "output.csv", "%f,%f\n", kamp, kfrq
> a1 pvsynth fsi
>
> outs a1, a1
>
>
> endin
> 
>
> 
> f1 0 1024 10 1 0.5 0.33 0.25 0.2 0.16 0.125
> i1 0 100
> 
> 
>
>
> Here is my Java program:
> import csnd.*;
>
> public class eqrun {
> 	public static void main(String args[]) {
> 		Csound cs = new Csound();
> 		CsoundArgVList argm = new CsoundArgVList();
>
> 		
> 		argm.Append("csound");
>        argm.Append("-d32");
>        argm.Append("-odevaudio");
>
>        //Load CSD file
> 		cs.Compile("C:/Documents and
> Settings/S311/Nathan/workspace2/eqrun2/src/pvsbus.csd");
> 		
> 		//Make a callback wrapper
> 		CsoundCallbackWrapper wrapper = new CsoundCallbackWrapper(cs);
> 		
> 		//Is this necessary?
> 		wrapper.SetOutputValueCallback();
> 		
> 		//doubles to hold the callback values
> 		double ampCCOC1 = 0.0, ampCCOC2 = 0.0, frqCCOC1 = 0.0, frqCCOC2 =  
> 0.0;
> 		double ampOVC1 = 0.0, ampOVC2 = 0.0, frqOVC1 = 0.0, frqOVC2 = 0.0;
>
> 		int result = 0;
> 		
> 		while(result == 0) {
> 			result = cs.PerformKsmps();
> 			
> 			/*---------Get amp and frq values-----------*/
> 			
> 			//ControlChannelOutputCallback
> 			wrapper.ControlChannelOutputCallback("amplitude1", ampCCOC1);
> 			wrapper.ControlChannelOutputCallback("amplitude2", ampCCOC2);
> 			wrapper.ControlChannelOutputCallback("amplitude1", frqCCOC1);
> 			wrapper.ControlChannelOutputCallback("amplitude2", frqCCOC2);
> 			
> 			//OutputValueCallback
> 			wrapper.OutputValueCallback("amplitude1", ampOVC1);
> 			wrapper.OutputValueCallback("amplitude2", ampOVC2);
> 			wrapper.OutputValueCallback("frequency1", frqOVC1);
> 			wrapper.OutputValueCallback("frequency2", frqOVC2);
> 			
> 			System.out.println(ampCCOC1 + " " + ampCCOC2 + " " + frqCCOC1 + "  
> " +
> frqCCOC2 + " " + ampOVC1 + " " + ampOVC2 + " " + frqOVC1 + " " +  
> frqOVC2);
> 		}
> 	}
> }
>
> Is there something I am missing about using the  
> CsoundCallbackWrapper class?
> Or, alternatively is there a better way to access variables from  
> inside of
> my Csound program?
>
> -- 
> View this message in context: http://csound.1045644.n5.nabble.com/Csound-API-OutputValueCallback-tp3308961p3308961.html
> Sent from the Csound - Dev mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Lotusphere 2011
> Register now for Lotusphere 2011 and learn how
> to connect the dots, take your collaborative environment
> to the next level, and enter the era of Social Business.
> http://p.sf.net/sfu/lotusphere-d2d
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-12-17 09:47
From4g63gsx
SubjectRe: [Cs-dev] Csound API OutputValueCallback
I have never seen the :: at being used in Java. Am I right in saying that it
is a C++ operator?
-- 
View this message in context: http://csound.1045644.n5.nabble.com/Csound-API-OutputValueCallback-tp3308961p3309185.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-12-19 13:52
From"Dale Stewart"
SubjectRe: [Cs-dev] Csound API OutputValueCallback
http://en.wikipedia.org/wiki/Scope_resolution_operator


-----Original Message-----
From: 4g63gsx [mailto:mulletlibido@gmail.com] 
Sent: Friday, December 17, 2010 3:47 AM
To: csound-devel@lists.sourceforge.net
Subject: Re: [Cs-dev] Csound API OutputValueCallback


I have never seen the :: at being used in Java. Am I right in saying that it
is a C++ operator?
-- 
View this message in context:
http://csound.1045644.n5.nabble.com/Csound-API-OutputValueCallback-tp3308961
p3309185.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-12-19 16:26
FromVictor Lazzarini
SubjectRe: [Cs-dev] Csound API OutputValueCallback
Or whatever is equivalent in Java. I mean the GetChannel()  
SetChannel() methods of Csound.

Victor

On 17 Dec 2010, at 09:47, 4g63gsx wrote:

>
> I have never seen the :: at being used in Java. Am I right in saying  
> that it
> is a C++ operator?
> -- 
> View this message in context: http://csound.1045644.n5.nabble.com/Csound-API-OutputValueCallback-tp3308961p3309185.html
> Sent from the Csound - Dev mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Lotusphere 2011
> Register now for Lotusphere 2011 and learn how
> to connect the dots, take your collaborative environment
> to the next level, and enter the era of Social Business.
> http://p.sf.net/sfu/lotusphere-d2d
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2011-02-02 09:38
From4g63gsx
SubjectRe: [Cs-dev] Csound API OutputValueCallback
Thanks for the reply. That worked perfectly. I used the GetChannel() method
in the Csound class. 

Thanks again.
-- 
View this message in context: http://csound.1045644.n5.nabble.com/Csound-API-OutputValueCallback-tp3308961p3367556.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net