Skip to content

Commit 7c21f12

Browse files
first commit
0 parents  commit 7c21f12

File tree

2,496 files changed

+314056
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,496 files changed

+314056
-0
lines changed

Diff for: Ch 1 Tutorial/Ch1code.rtf

+976
Large diffs are not rendered by default.

Diff for: Ch 1 Tutorial/Ch1code.scd

+969
Large diffs are not rendered by default.

Diff for: Ch 1 Tutorial/extra examples.rtf

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
2+
{\fonttbl\f0\fnil\fcharset0 Monaco;}
3+
{\colortbl;\red255\green255\blue255;\red191\green0\blue0;\red0\green0\blue191;\red96\green96\blue96;
4+
\red0\green115\blue0;}
5+
\deftab720
6+
\pard\tx360\tx720\tx1080\tx1440\tx1800\tx2160\tx2520\tx2880\tx3240\tx3600\tx3960\tx4320\pardeftab720\ri0\ql\qnatural
7+
8+
\f0\fs18 \cf0 \
9+
\cf2 // Decaying bell. Run several concurrently. \cf0 \
10+
\
11+
(\
12+
\{\
13+
\cf3 var\cf0 aenv, fenv, out, trig, dur, base;\
14+
dur = rrand(1.0, 6.0);\
15+
base = exprand(100, 1000);\
16+
trig = \cf3 Impulse\cf0 .kr(1/6);\
17+
out = \cf3 Mix\cf0 .ar(\
18+
\cf3 Array\cf0 .fill(15,\{\
19+
\cf3 arg\cf0 count;\
20+
\cf3 var\cf0 thisDur;\
21+
thisDur = dur * rrand(0.5, 1.0);\
22+
aenv = \cf3 EnvGen\cf0 .kr(\
23+
\cf3 Env\cf0 .new([0, 1, 0.4, 1, 0], [0, 0.5, 0.5, 0]), trig, \
24+
timeScale: thisDur);\
25+
fenv = \cf3 EnvGen\cf0 .kr(\
26+
\cf3 Env\cf0 .new([0, 0, 0.5, 0.5, 0], [0.25, 0.5, 0.25, 0]), \
27+
trig, timeScale: thisDur);\
28+
\cf3 Pan2\cf0 .ar(\cf3 SinOsc\cf0 .ar( \cf3 Rand\cf0 (base, base * 12) * \
29+
\cf3 LFNoise1\cf0 .kr(10, mul: 0.1 * fenv, add: 1), \cf2 // freq\cf0 \
30+
mul: aenv \cf2 // amp\cf0 \
31+
), ([1, -1].choose) * fenv)\
32+
\})\
33+
) * \cf3 EnvGen\cf0 .kr(\cf3 Env\cf0 .linen(0, dur, 0), \cf3 Impulse\cf0 .kr(6), timeScale: dur, \
34+
levelScale: 0.05, doneAction: 2);\
35+
out*0.3;\
36+
\}.play;\
37+
)\
38+
\
39+
\
40+
\cf2 // Repeating gestures using PM crotales.\cf0 \
41+
\
42+
(\
43+
\cf3 SynthDef\cf0 (\cf4 "crotale"\cf0 , \{\
44+
\cf3 arg\cf0 param = #[500, 3, 2, 0, 6, 5, 0, 0.9]; \
45+
\cf3 var\cf0 factor, env, out, freq, index, dur;\
46+
\cf3 var\cf0 bus, ratioa, ratiob, attack, decay, panCont;\
47+
freq = param.at(0); index = param.at(1); dur = param.at(2);\
48+
bus = param.at(3); ratioa = param.at(4); ratiob = param.at(5);\
49+
attack = param.at(6); decay = param.at(7);\
50+
\
51+
env = \cf3 Env\cf0 .perc(attack, decay);\
52+
factor = gcd(ratioa, ratiob);\
53+
ratioa = div(ratioa, factor); \
54+
ratiob = div(ratiob, factor);\
55+
\
56+
panCont = (\cf3 EnvGen\cf0 .kr(env, timeScale: dur*1.1, \
57+
levelBias: -1, levelScale: 2))\
58+
* (\cf3 IRand\cf0 (0, 1) * 2 - 1); \cf2 // 0*2-1 = -1, 1*2-1 = 1\cf0 \
59+
\
60+
out = \cf3 PMOsc\cf0 .ar(\
61+
ratioa*freq, \cf2 //or try ratioa*freqCont,\cf0 \
62+
ratiob*freq, \cf2 //or try ratioa*freqCont,\cf0 \
63+
pmindex: \cf3 EnvGen\cf0 .kr(env, timeScale: dur, \
64+
levelBias: 1, levelScale: index), \
65+
mul: \cf3 EnvGen\cf0 .kr(env, timeScale: dur, levelScale: 0.3));\
66+
\
67+
out = \cf3 Pan2\cf0 .ar(out, panCont);\
68+
\
69+
out = out * \cf3 EnvGen\cf0 .kr(env, timeScale: 1.3*dur, \
70+
levelScale: \cf3 Rand\cf0 (0.1, 0.5), doneAction:2); \
71+
\cf3 Out\cf0 .ar(0, out); \cf2 //Out.ar(bus, out);\cf0 \
72+
\
73+
\}).add;\
74+
)\
75+
\
76+
\cf2 // Define the instrument by running the code\cf0 \
77+
\cf2 // above, then run this task to actually play \cf0 \
78+
\cf2 // the instrument. Run several concurrently.\cf0 \
79+
\
80+
\
81+
(\
82+
r = \cf3 Task\cf0 (\{\
83+
\cf3 var\cf0 freq, indexDepth, indexRange, synthIndex, dur, repeat;\
84+
\cf3 var\cf0 next, count, countDown, offset, ratioa, ratiob, envs, env;\
85+
\cf3 var\cf0 range = 60, outBus = 0;\
86+
count = 0; countDown = 0; offset = 0;\
87+
envs = [[0, 0.9], [0.01, 0.9], [0.1, 0.8], [0.8, 0.01]];\
88+
repeat = \cf3 Array\cf0 .fill(10, \
89+
\{[rrand(range, range+24).round(1).midicps, 3, \
90+
2.1 - exprand(0.1, 2.0), 0, 1, 1, 0, 0.9]\});\
91+
next = \cf3 Array\cf0 .fill(10, \{[3, 0.75, 0.5, 0.25, 0.125].choose\});\
92+
freq = rrand(range, range*2); \cf2 // these two are just starting points\cf0 \
93+
indexDepth = 1;\
94+
\
95+
\cf3 inf\cf0 .do(\{\
96+
if(countDown <= 0,\
97+
\{\
98+
env = envs.choose;\
99+
next.put(count%10, [3, 0.5, 0.25, 0.125, 0.125].choose); \
100+
repeat.put(count%10, [\
101+
rrand(range, range + 24).round(1).midicps, \
102+
rrand(0.1, 12.0),\
103+
2.1 - exprand(0.1, 2.0), outBus, rrand(1, 12), \
104+
rrand(1, 12), env.at(0), env.at(1)]);\
105+
\});\
106+
\
107+
\cf3 Synth\cf0 (\cf4 "crotale"\cf0 ).setn(\cf5 \\param\cf0 , repeat.wrapAt(count));\
108+
next.wrapAt(count).wait; \
109+
if((count > 10).and(countDown <= 0), \
110+
\{offset = countDown = [0, 3.rand, 6.rand].choose; \
111+
count = count - offset\});\
112+
count = count + 1;\
113+
countDown = countDown - 1;\
114+
\});\
115+
\}).play(\cf3 SystemClock\cf0 );\
116+
)\
117+
\
118+
\
119+
\
120+
}

Diff for: Ch 1 Tutorial/extra examples.scd

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
2+
// Decaying bell. Run several concurrently.
3+
4+
(
5+
{
6+
var aenv, fenv, out, trig, dur, base;
7+
dur = rrand(1.0, 6.0);
8+
base = exprand(100, 1000);
9+
trig = Impulse.kr(1/6);
10+
out = Mix.ar(
11+
Array.fill(15,{
12+
arg count;
13+
var thisDur;
14+
thisDur = dur * rrand(0.5, 1.0);
15+
aenv = EnvGen.kr(
16+
Env.new([0, 1, 0.4, 1, 0], [0, 0.5, 0.5, 0]), trig,
17+
timeScale: thisDur);
18+
fenv = EnvGen.kr(
19+
Env.new([0, 0, 0.5, 0.5, 0], [0.25, 0.5, 0.25, 0]),
20+
trig, timeScale: thisDur);
21+
Pan2.ar(SinOsc.ar( Rand(base, base * 12) *
22+
LFNoise1.kr(10, mul: 0.1 * fenv, add: 1), // freq
23+
mul: aenv // amp
24+
), ([1, -1].choose) * fenv)
25+
})
26+
) * EnvGen.kr(Env.linen(0, dur, 0), Impulse.kr(6), timeScale: dur,
27+
levelScale: 0.05, doneAction: 2);
28+
out*0.3;
29+
}.play;
30+
)
31+
32+
33+
// Repeating gestures using PM crotales.
34+
35+
(
36+
SynthDef("crotale", {
37+
arg param = #[500, 3, 2, 0, 6, 5, 0, 0.9];
38+
var factor, env, out, freq, index, dur;
39+
var bus, ratioa, ratiob, attack, decay, panCont;
40+
freq = param.at(0); index = param.at(1); dur = param.at(2);
41+
bus = param.at(3); ratioa = param.at(4); ratiob = param.at(5);
42+
attack = param.at(6); decay = param.at(7);
43+
44+
env = Env.perc(attack, decay);
45+
factor = gcd(ratioa, ratiob);
46+
ratioa = div(ratioa, factor);
47+
ratiob = div(ratiob, factor);
48+
49+
panCont = (EnvGen.kr(env, timeScale: dur*1.1,
50+
levelBias: -1, levelScale: 2))
51+
* (IRand(0, 1) * 2 - 1); // 0*2-1 = -1, 1*2-1 = 1
52+
53+
out = PMOsc.ar(
54+
ratioa*freq, //or try ratioa*freqCont,
55+
ratiob*freq, //or try ratioa*freqCont,
56+
pmindex: EnvGen.kr(env, timeScale: dur,
57+
levelBias: 1, levelScale: index),
58+
mul: EnvGen.kr(env, timeScale: dur, levelScale: 0.3));
59+
60+
out = Pan2.ar(out, panCont);
61+
62+
out = out * EnvGen.kr(env, timeScale: 1.3*dur,
63+
levelScale: Rand(0.1, 0.5), doneAction:2);
64+
Out.ar(0, out); //Out.ar(bus, out);
65+
66+
}).add;
67+
)
68+
69+
// Define the instrument by running the code
70+
// above, then run this task to actually play
71+
// the instrument. Run several concurrently.
72+
73+
74+
(
75+
r = Task({
76+
var freq, indexDepth, indexRange, synthIndex, dur, repeat;
77+
var next, count, countDown, offset, ratioa, ratiob, envs, env;
78+
var range = 60, outBus = 0;
79+
count = 0; countDown = 0; offset = 0;
80+
envs = [[0, 0.9], [0.01, 0.9], [0.1, 0.8], [0.8, 0.01]];
81+
repeat = Array.fill(10,
82+
{[rrand(range, range+24).round(1).midicps, 3,
83+
2.1 - exprand(0.1, 2.0), 0, 1, 1, 0, 0.9]});
84+
next = Array.fill(10, {[3, 0.75, 0.5, 0.25, 0.125].choose});
85+
freq = rrand(range, range*2); // these two are just starting points
86+
indexDepth = 1;
87+
88+
inf.do({
89+
if(countDown <= 0,
90+
{
91+
env = envs.choose;
92+
next.put(count%10, [3, 0.5, 0.25, 0.125, 0.125].choose);
93+
repeat.put(count%10, [
94+
rrand(range, range + 24).round(1).midicps,
95+
rrand(0.1, 12.0),
96+
2.1 - exprand(0.1, 2.0), outBus, rrand(1, 12),
97+
rrand(1, 12), env.at(0), env.at(1)]);
98+
});
99+
100+
Synth("crotale").setn(\param, repeat.wrapAt(count));
101+
next.wrapAt(count).wait;
102+
if((count > 10).and(countDown <= 0),
103+
{offset = countDown = [0, 3.rand, 6.rand].choose;
104+
count = count - offset});
105+
count = count + 1;
106+
countDown = countDown - 1;
107+
});
108+
}).play(SystemClock);
109+
)
110+
111+
112+

Diff for: Ch 10 SwingOSC/JSCSoundFileChooser.sc

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
JSCSoundFileChooser : JSCView {
2+
var <path; // String : current file selection (or nil)
3+
var <directory; // String : currently visible directory
4+
var chResp; // OSCpathResponder for ChangeResponder
5+
6+
path_ { arg value;
7+
path = value;
8+
server.sendMsg( '/set', this.id, \selectedPath, value );
9+
}
10+
11+
directory_ { arg value;
12+
directory = value;
13+
server.sendMsg( '/set', this.id, \currentDirectoryPath, value );
14+
}
15+
16+
prInitView {
17+
chResp = OSCpathResponder( server.addr, [ '/change', this.id ], {
18+
arg time, resp, msg; var oldPath = path;
19+
path = if( msg[ 4 ] !== '', { msg[ 4 ].asString });
20+
directory = msg[ 6 ].asString;
21+
if( oldPath != path, {{ this.doAction }.defer });
22+
}).add;
23+
^this.prSCViewNew([[ '/local', this.id, '[', '/new', "SoundFileChooser", ']', "ch" ++ this.id, '[', '/new', "de.sciss.swingosc.ChangeResponder", this.id, '[', '/array', \selectedPath, \currentDirectoryPath, ']', ']' ]]);
24+
}
25+
26+
prClose {
27+
chResp.remove;
28+
^super.prClose([[ '/method', "ch" ++ this.id, \remove ],
29+
[ '/free', "ch" ++ this.id ]]);
30+
}
31+
}

Diff for: Ch 10 SwingOSC/SoundFileChooser.jar

1.71 KB
Binary file not shown.

Diff for: Ch 10 SwingOSC/SoundFileChooser.java

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import java.io.File;
2+
import javax.swing.filechooser.FileFilter;
3+
import javax.swing.event.ChangeEvent;
4+
import javax.swing.event.ChangeListener;
5+
6+
public class SoundFileChooser extends javax.swing.JFileChooser
7+
implements java.beans.PropertyChangeListener
8+
{
9+
private final java.util.List listeners = new java.util.ArrayList();
10+
11+
public SoundFileChooser() {
12+
super();
13+
final FileFilter filter = new FileFilter() {
14+
public boolean accept( File f ) {
15+
if( f.isDirectory() ) return true;
16+
try {
17+
return( de.sciss.io.AudioFile.retrieveType( f ) !=
18+
de.sciss.io.AudioFileDescr.TYPE_UNKNOWN );
19+
}
20+
catch( java.io.IOException e ) { return false; }
21+
}
22+
23+
public String getDescription() { return "Audio Files"; }
24+
};
25+
addChoosableFileFilter( filter );
26+
setFileFilter( filter );
27+
setControlButtonsAreShown( false );
28+
addPropertyChangeListener( SELECTED_FILE_CHANGED_PROPERTY, this );
29+
addPropertyChangeListener( DIRECTORY_CHANGED_PROPERTY, this );
30+
}
31+
32+
public String getSelectedPath() {
33+
final File f = getSelectedFile();
34+
return f == null ? "" : f.getAbsolutePath();
35+
}
36+
37+
public void setSelectedPath( String path ) {
38+
setSelectedFile( new File( path ));
39+
}
40+
41+
public String getCurrentDirectoryPath() {
42+
return getCurrentDirectory().getAbsolutePath();
43+
}
44+
45+
public void setCurrentDirectoryPath( String path ) {
46+
setCurrentDirectory( new File( path ));
47+
}
48+
49+
public void addChangeListener( ChangeListener l ) { listeners.add( l ); }
50+
public void removeChangeListener( ChangeListener l ) { listeners.remove( l ); }
51+
52+
public void propertyChange( java.beans.PropertyChangeEvent pce ) {
53+
final ChangeEvent ce = new ChangeEvent( this );
54+
for( int i = 0; i < listeners.size(); i++ ) {
55+
((ChangeListener) listeners.get( i )).stateChanged( ce );
56+
}
57+
}
58+
}

Diff for: Ch 10 SwingOSC/SwingOSC/.classpath

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.4.2"/>
5+
<classpathentry kind="lib" path="JNITablet/build/TabletWrapper.jar" sourcepath="JNITablet/src"/>
6+
<classpathentry kind="lib" path="libraries/MRJAdapter.jar" sourcepath="/Users/rutz/Desktop/MRJAdapter/src"/>
7+
<classpathentry kind="lib" path="libraries/ScissLib.jar" sourcepath="/ScissLib/src"/>
8+
<classpathentry kind="lib" path="libraries/JCollider.jar" sourcepath="/JCollider/src"/>
9+
<classpathentry kind="output" path="build/classes"/>
10+
</classpath>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
3+
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
4+
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
5+
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
6+
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="SwingOSC"/>
7+
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
8+
<listEntry value="1"/>
9+
</listAttribute>
10+
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
11+
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
12+
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
13+
<listEntry value="/SwingOSC/build.xml"/>
14+
</listAttribute>
15+
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/SwingOSC/build.xml}"/>
16+
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
17+
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
18+
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
19+
</launchConfiguration>

Diff for: Ch 10 SwingOSC/SwingOSC/.project

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>SwingOSC</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
15+
<triggers>full,incremental,</triggers>
16+
<arguments>
17+
<dictionary>
18+
<key>LaunchConfigHandle</key>
19+
<value>&lt;project&gt;/.externalToolBuilders/Ant Builder.launch</value>
20+
</dictionary>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.jdt.core.javanature</nature>
26+
</natures>
27+
</projectDescription>

0 commit comments

Comments
 (0)