| Maybe we should place these examples in the sources.
Victor
On 24 Feb 2010, at 18:59, jhearon wrote:
>
> Hi,
> I read the 'accessing spout etc from a wrapper' thread with
> interest. While
> not exactly related to that thread, I wondered if these files I had
> were
> useful in someway.
>
> Python script was Victor's from that thread. Java was my previous
> example
> on list of reinterpretation of Victor's c code in/out example with
> Michael's
> help from Brinkman code, and Lua is mine.
>
> ====Python============
> =====================
> from csnd import *
> from pylab import *
>
> cs = Csound()
> res = cs.Compile("sine.csd", "-n")
> spoutlen = cs.GetKsmps()*cs.GetNchnls()
> spout = CsoundMYFLTArray();
> spout.SetPtr(cs.GetSpout())
>
> a = []
> while(res==0):
> res = cs.PerformKsmps()
> for i in range(0, spoutlen):
> a.append(spout.GetValue(i))
>
> t = arange(len(a))
>
> plot(t[0:100]/cs.GetSr(), a[0:100])
> show()
> ====Java=============
> =====================
> import csnd.*;
>
> public class Main {
> public static void main(String[] args) {
>
> Csound sender = new Csound();
> Csound receiver = new Csound();
> CsoundMYFLTArray myspout = new CsoundMYFLTArray();
> CsoundMYFLTArray myspin = new CsoundMYFLTArray();
> int ksmps = sender.GetKsmps();
> float psend_array[] = new float[ksmps];
> int nchnls = sender.GetNchnls();
>
> String nosound = "-n";
> // compile sender & retrieve kr & sr
> sender.PreCompile();
> int sender_res = sender.Compile("sender.csd", nosound);
> myspout.SetPtr(sender.GetSpout());
>
> String sar = "--sample-rate= " + Double.toString(sender.GetSr());
> String kar = "--control-rate= " + Double.toString(sender.GetKr());
>
> // compile receiver & force kr & sr
> receiver.PreCompile();
> int receiver_res = receiver.Compile("receiver.csd", kar, sar);
> myspin.SetPtr(receiver.GetSpin());
>
> if (sender_res == 0) {
> while (sender.PerformKsmps() == 0) {
> for(int j=0; j psend_array[j]=
> (float)myspout.GetValue(j);
> myspin.SetValue(j, psend_array[j]);
> }
> receiver.PerformKsmps();
> if (sender_res != 0) sender.PerformKsmps();
> }
> }
> sender.Reset();
> receiver.Reset();
> java.lang.System.exit(1);
> }
> }
> -------------
> ;receiver.csd
>
>
>
>
> csound -s -d -+rtaudio=ALSA -odac:hw:0,0 -b1024 -B16384
>
>
>
>
>
> sr=44100
> ksmps=64
> nchnls=2
>
> instr 1
> aoutL, aoutR ins
> outs aoutL, aoutR
>
> endin
>
> instr 2
> kenv linseg 0.01,p3*.33,1,p3*.33,1,p3*.33,0.01
>
> a1 oscil 5000 * kenv, 440, p4
> outs a1, a1
> endin
>
>
>
> ; One period of an approximate sawtooth wave
>
> f 2 0 8192 10 1 0.5 0.333 0.25 0.2 0.1667 0.1429 0.125 0.111 0.1
>
> i1 0 12
>
> ------------
> ;sender.csd
>
>
>
>
> csound -s -d -+rtaudio=ALSA -odac:hw:0,0 -b1024 -B16384
>
>
>
>
> sr=44100
> ksmps=64
> nchnls=2
>
> instr 1
> asig,asig1 diskin "beats2.wav", 1, 0, 1
> outs asig, asig1
> endin
>
>
>
> i1 0 12
> e
>
>
> ====Lua==============
> =====================
> require "luaCsnd"
>
> csound = luaCsnd.Csound()
> args = luaCsnd.CsoundArgVList()
>
> args.Append(args, "csound")
> args.Append(args, "-s")
> args.Append(args, "-d")
> args.Append(args, "-+rtaudio=ALSA")
> args.Append(args, "-odac:hw:0,0")
> args.Append(args, "-b1024")
> args.Append(args, "-B16384")
> csd = "spout_test.csd"
> args.Append(args, csd)
>
> result = csound:Compile(args.argc(args), args.argv(args))
> pvalue = csound:GetSpout()
>
> if result == 0 then
> while csound:PerformKsmps()== 0 do
>
> end
> end
>
> csound:Reset()
> args:Clear()
> -------------
> ;spout_test.csd
>
> sr = 44100
> ksmps = 10
> nchnls = 2
> 0dbfs = 1
>
> instr 1
> a1 oscil 5000, 200, 1
> outs a1, a1
> endin
>
>
>
> ;* sine wave table
> f1 0 8192 10 1
>
> f2 0 8 -2 1 2 3 4 5 6 7 8
>
> i1 0 3
> e
>
>
> --
> View this message in context: http://old.nabble.com/spout-and-wrappers-tp27714282p27714282.html
> Sent from the Csound - Dev mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |