File: liveCoder.cpp

package info (click to toggle)
csound 1%3A6.18.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,260 kB
  • sloc: ansic: 192,643; cpp: 14,149; javascript: 9,654; objc: 9,181; python: 3,376; java: 3,337; sh: 1,840; yacc: 1,255; xml: 985; perl: 635; lisp: 411; tcl: 341; lex: 217; makefile: 128
file content (74 lines) | stat: -rw-r--r-- 1,689 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * live coding demo for Csound 6
 * Author: Rory Walsh 2013
 * 
 * 
 */ 

#include "liveCoder.hpp"
uintptr_t csThread(void *clientData);
int main(int argc, char *argv[])
{
  liveCsound* csound;
  void *iD;

  csound = new liveCsound();	
  csound->SetOption((char *)"-odac");
  csound->SetOption((char *)"-dm0");
  csound->InputMessage("f2 0 16 2 .00 .02 .04 .05 .07 .08 .09 .11");
  csound->Start();

  if(!csound->result){
    csound->perf_status=1;
    iD = csoundCreateThread(csThread, (void*)csound);
  }
  else
    return 0;

  string usage = 
    "\n\n============================\n\
CSOUND LIVE CODE DEMO\n\
============================\n\
Usage: \n\
After starting the program add an instrument definition such as:\n\
\ninstr 1\n\
a1 oscil 10000, 400, 1\n\
endin\n\n\
To update the orchestra type uorc and hit enter.\n\n\
The following commands are also available\n\
usco - updates the score, follows a score line\n\
orchist - displays the entire orch history\n\
scohist - displays the entire score histroy\n\
ends - ends session\n\n\
chnset can also be used to update any channels by simply\n\
writing it as you would in a normal instrument definition, e.g\n\n\
chnset 5, \"tempo\"\n\n\
============================\n\n\n";
  cout << usage;
  while(csound->runLiveCodeSession());

  csound->perf_status=0;
  csoundJoinThread(iD);
  delete csound;
  return 1;

  return 0;
}	


//Csound performance thread
uintptr_t csThread(void *data)
{
  liveCsound* csound = (liveCsound*)data;
  if(!csound->result)
    {
      while((csoundPerformKsmps(csound->GetCsound()) == 0)
	    &&(csound->perf_status==1)){
				
      }
      csound->perf_status = 0; 
		
    }       
  return 1;
}