Debian Codegraph @

src/Examples/CsoundQt/Getting Started/Language_Features/Console_Print.csd

raw
1 /* Getting started.. Console Output
2
3 Csound offers opcodes to print out values and strings to the console. This can be done by using one of the opcodes starting with the word "print".
4
5 'print ' - displays values at i-rate. See instr 1.
6
7 'printf ' - prints various data with formatted output. The usage is quite similar to the C-Language expression "printf". This might sound complicated for beginners, but isn't! There are just a few things to know, and you get a very flexible tool, for formated data-output. See description below, and usage in "instr 2".
8
9 'printf_i ' - same like printf, but prints only at init-time
10
11 'prints ' - same like printf_i, but %s is not allowed
12 'printks ' - same at k-rate
13
14 'printk ' - prints values from control variables at specific time intervalls (instr 3)
15 'printk2 ' - prints a new value every time a control variable changes (this can crash with continous changes)
16
17 To write the output into a file use:
18
19 'fprints ' - similar to 'prints' but prints to a file
20 'fprintks ' - similar to 'printks' but prints to a file
21
22 To write the output into a string-variable use: (instr 4)
23 'sprintf ' - printf-style formatted output to a string variable
24 'sprintfk ' - printf-style formatted output to a string variable at k-rate
25 'puts ' - print a string constant or variable to the console
26
27 Value specifier:
28 %i - integer number
29 %f - floating point number
30 %s - prints a character sting
31 %e - prints a float in standard form ([-]d.ddd e[+/-]ddd)
32
33 Output modification:
34 %n or \n - new line
35 %t or \t - write a tab character
36
37 For more information concerning the C value specifiers, go into the terminal, and read the C-Programming Languge 'printf' manual page. Type: "man -s3 printf"
38 Or see:
39 http://en.wikipedia.org/wiki/Printf#printf_format_placeholders
40 In the Csound Manual you will also find some information under: printks
41 */
42 <CsoundSynthesizer>
43 <CsOptions>
44 -m0
45 </CsOptions>
46 <CsInstruments>
47
48 instr 1
49 print p4
50 endin
51
52 instr 2
53 iNumber = 21.234512
54 prints "Here is the number: %i %n", iNumber ; print as integer and go to next line
55 prints "Here is the number: %f %n", iNumber ; print as float value
56 prints "Here is the number: %.3f %n", iNumber ; print with 3 digits after the point
57 prints "Here is the number: %t %.3f %n", iNumber ;insert a tab
58 prints "Here is the number: %t %.3f %t %.2f %n ", iNumber, iNumber ; insert to tabs print value, put a tab and again
59 endin
60
61 instr 3
62 kLine line 0, 2, 100
63 printk 0.2, kLine
64 endin
65
66
67 instr 4
68 Scity = "Hannover"
69 iPopulation = 516000
70 Sname sprintf "The name is : '%s' and has around %i inhabitants.", Scity, iPopulation
71 puts Sname, 1
72 endin
73
74 </CsInstruments>
75
76 <CsScore>
77 f 1 0 1024 10 1
78
79 i 1 0 2 9999 ; print will printout p4
80 i 2 2 2
81 i 3 4 2
82 i 4 6 2
83 e
84 </CsScore>
85 </CsoundSynthesizer>
86 ; written by Alex Hofmann (Mar. 2010) - Incontri HMT-Hannover
87
88 <bsbPanel>
89 <label>Widgets</label>
90 <objectName/>
91 <x>840</x>
92 <y>59</y>
93 <width>608</width>
94 <height>769</height>
95 <visible>true</visible>
96 <uuid/>
97 <bgcolor mode="background">
98 <r>255</r>
99 <g>255</g>
100 <b>255</b>
101 </bgcolor>
102 <bsbObject version="2" type="BSBLabel">
103 <objectName/>
104 <x>12</x>
105 <y>8</y>
106 <width>576</width>
107 <height>752</height>
108 <uuid>{195541a2-8754-488f-9033-adadea125166}</uuid>
109 <visible>true</visible>
110 <midichan>0</midichan>
111 <midicc>-3</midicc>
112 <label>Csound offers opcodes to print out values and strings to the console. This can be done by using one of the opcodes starting with the word "print".
113
114 'print ' - displays values at i-rate. See instr 1.
115
116 'printf ' - prints various data with formatted output. The usage is quite similar to the C-Language expression "printf". This might sound complicated for beginners, but isn't! There are just a few things to know, and you get a very flexible tool, for formated data-output. See description below, and usage in "instr 2".
117
118 'printf_i ' - same like printf, but prints only at init-time
119
120 'prints ' - same like printf_i, but %s is not allowed
121 'printks ' - same at k-rate
122
123 'printk ' - prints values from control variables at specific time intervalls (instr 3)
124 'printk2 ' - prints a new value every time a control variable changes (this can crash with continous changes)
125
126 To write the output into a file use:
127
128 'fprints ' - similar to 'prints' but prints to a file
129 'fprintks ' - similar to 'printks' but prints to a file
130
131 To write the output into a string-variable use: (instr 4)
132 'sprintf ' - printf-style formatted output to a string variable
133 'sprintfk ' - printf-style formatted output to a string variable at k-rate
134 'puts ' - print a string constant or variable to the console
135
136 Value specifier:
137 %i - integer number
138 %f - floating point number
139 %s - prints a character sting
140 %e - prints a float in standard form ([-]d.ddd e[+/-]ddd)
141
142 Output modification:
143 %n or \n - new line
144 %t or \t - write a tab character
145
146 For more information concerning the C value specifiers, go into the terminal, and read the C-Programming Languge 'printf' manual page. Type: "man -s3 printf"
147 Or see:
148 http://en.wikipedia.org/wiki/Printf#printf_format_placeholders
149 In the Csound Manual you find some information under: printks </label>
150 <alignment>left</alignment>
151 <font>Lucida Grande</font>
152 <fontsize>14</fontsize>
153 <precision>3</precision>
154 <color>
155 <r>0</r>
156 <g>0</g>
157 <b>0</b>
158 </color>
159 <bgcolor mode="nobackground">
160 <r>255</r>
161 <g>255</g>
162 <b>255</b>
163 </bgcolor>
164 <bordermode>noborder</bordermode>
165 <borderradius>1</borderradius>
166 <borderwidth>1</borderwidth>
167 </bsbObject>
168 </bsbPanel>
169 <bsbPresets>
170 </bsbPresets>
171 <MacOptions>
172 Version: 3
173 Render: Real
174 Ask: Yes
175 Functions: ioObject
176 Listing: Window
177 WindowBounds: 840 59 608 769
178 CurrentView: io
179 IOViewEdit: On
180 Options: -b128 -A -s -m167 -R
181 </MacOptions>
182 <MacGUI>
183 ioView background {65535, 65535, 65535}
184 ioText {12, 8} {566, 893} label 0.000000 0.00100 "" left "Lucida Grande" 14 {0, 0, 0} {65280, 65280, 65280} nobackground noborder Csound offers opcodes to print out values and strings to the console. This can be done by using one of the opcodes starting with the word "print".¬¬'print ' - displays values at i-rate. See instr 1.¬¬'printf ' - prints various data with formatted output. The usage is quite similar to the C-Language expression "printf". This might sound complicated for beginners, but isn't! There are just a few things to know, and you get a very flexible tool, for formated data-output. See description below, and usage in "instr 2".¬¬'printf_i ' - same like printf, but prints only at init-time¬¬'prints ' - same like printf_i, but %s is not allowed¬'printks ' - same at k-rate¬¬'printk ' - prints values from control variables at specific time intervalls (instr 3)¬'printk2 ' - prints a new value every time a control variable changes (this can crash with continous changes)¬¬To write the output into a file use:¬¬'fprints ' - similar to 'prints' but prints to a file¬'fprintks ' - similar to 'printks' but prints to a file¬¬To write the output into a string-variable use: (instr 4)¬'sprintf ' - printf-style formatted output to a string variable¬'sprintfk ' - printf-style formatted output to a string variable at k-rate¬'puts ' - print a string constant or variable to the console¬¬Value specifier:¬%i - integer number¬%f - floating point number¬%s - prints a character sting¬%e - prints a float in standard form ([-]d.ddd e[+/-]ddd)¬¬Output modification:¬%n or \n - new line¬%t or \t - write a tab character¬¬For more information concerning the C value specifiers, go into the terminal, and read the C-Programming Languge 'printf' manual page. Type: "man -s3 printf"¬Or see:¬http://en.wikipedia.org/wiki/Printf#printf_format_placeholders¬In the Csound Manual you find some information under: printks
185 </MacGUI>
186 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="320" y="218" width="604" height="322" visible="true" loopStart="0" loopEnd="0"> </EventPanel>