FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

updated minim binaries and examples for Minim release 2.2.0 · soochankim/processing@7cac454 · GitHub

Repository navigation

Commit 7cac454

Browse files
committed
updated minim binaries and examples for Minim release 2.2.0
1 parent e951de1 commit 7cac454

20 files changed

Lines changed: 304 additions & 94 deletions

File tree

‎java/libraries/minim/examples/AnalyzeSound/AnalyzeSound.pde‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* the frequency content of a signal. You've seen
88
* visualizations like this before in music players
99
* and car stereos.
10+
* <p>
11+
* For more information about Minim and additional features,
12+
* visit http://code.compartmental.net/minim/
1013
*/
1114

1215
import ddf.minim.analysis.*;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* This sketch demonstrates how to create synthesized sound with Minim using an AudioOutput and
3+
* an Instrument we define. By using the playNote method you can schedule notes to played
4+
* at some point in the future, essentially allowing to you create musical scores with code.
5+
* Because they are constructed with code, they can be either deterministic or different every time.
6+
* This sketch creates a deterministic score, meaning it is the same every time you run the sketch.
7+
* <p>
8+
* For more complex examples of using playNote check out algorithmicCompExample and compositionExample
9+
* in the Synthesis folder.
10+
* <p>
11+
* For more information about Minim and additional features, visit http://code.compartmental.net/minim/
12+
*/
13+
14+
import ddf.minim.*;
15+
import ddf.minim.ugens.*;
16+
17+
Minim minim;
18+
AudioOutput out;
19+
20+
// to make an Instrument we must define a class
21+
// that implements the Instrument interface.
22+
class SineInstrument implements Instrument
23+
{
24+
Oscil wave;
25+
Line ampEnv;
26+
27+
SineInstrument( float frequency )
28+
{
29+
// make a sine wave oscillator
30+
// the amplitude is zero because
31+
// we are going to patch a Line to it anyway
32+
wave = new Oscil( frequency, 0, Waves.SINE );
33+
ampEnv = new Line();
34+
ampEnv.patch( wave.amplitude );
35+
}
36+
37+
// this is called by the sequencer when this instrument
38+
// should start making sound. the duration is expressed in seconds.
39+
void noteOn( float duration )
40+
{
41+
// start the amplitude envelope
42+
ampEnv.activate( duration, 0.5f, 0 );
43+
// attach the oscil to the output so it makes sound
44+
wave.patch( out );
45+
}
46+
47+
// this is called by the sequencer when the instrument should
48+
// stop making sound
49+
void noteOff()
50+
{
51+
wave.unpatch( out );
52+
}
53+
}
54+
55+
void setup()
56+
{
57+
size(512, 200, P3D);
58+
59+
minim = new Minim(this);
60+
61+
// use the getLineOut method of the Minim object to get an AudioOutput object
62+
out = minim.getLineOut();
63+
64+
// when providing an Instrument, we always specify start time and duration
65+
out.playNote( 0.0, 0.9, new SineInstrument( 97.99 ) );
66+
out.playNote( 1.0, 0.9, new SineInstrument( 123.47 ) );
67+
68+
// we can use the Frequency class to create frequencies from pitch names
69+
out.playNote( 2.0, 2.9, new SineInstrument( Frequency.ofPitch( "C3" ).asHz() ) );
70+
out.playNote( 3.0, 1.9, new SineInstrument( Frequency.ofPitch( "E3" ).asHz() ) );
71+
out.playNote( 4.0, 0.9, new SineInstrument( Frequency.ofPitch( "G3" ).asHz() ) );
72+
}
73+
74+
void draw()
75+
{
76+
background(0);
77+
stroke(255);
78+
79+
// draw the waveforms
80+
for(int i = 0; i < out.bufferSize() - 1; i++)
81+
{
82+
line( i, 50 + out.left.get(i)*50, i+1, 50 + out.left.get(i+1)*50 );
83+
line( i, 150 + out.right.get(i)*50, i+1, 150 + out.right.get(i+1)*50 );
84+
}
85+
}

‎java/libraries/minim/examples/GetMetaData/GetMetaData.pde‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
* If you load WAV file or other non-tagged file, most of the metadata
1111
* will be empty, but you will still have information like the filename
1212
* and the length.
13+
* <p>
14+
* For more information about Minim and additional features,
15+
* visit http://code.compartmental.net/minim/
1316
*/
1417

1518
import ddf.minim.*;
@@ -52,14 +55,3 @@ void draw()
5255
text("Publisher: " + meta.publisher(), 5, y+=yi);
5356
text("Encoded: " + meta.encoded(), 5, y+=yi);
5457
}
55-
56-
57-
void stop()
58-
{
59-
// always close Minim audio classes when you are done with them
60-
groove.close();
61-
// always stop Minim before exiting
62-
minim.stop();
63-
64-
super.stop();
65-
}
0 Bytes
Binary file not shown.

‎java/libraries/minim/examples/MonitorInput/MonitorInput.pde‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
/**
22
* This sketch demonstrates how to monitor the currently active audio input
3-
* of the computer using an <code>AudioInput</code>. What you will actually
3+
* of the computer using an AudioInput. What you will actually
44
* be monitoring depends on the current settings of the machine the sketch is running on.
55
* Typically, you will be monitoring the built-in microphone, but if running on a desktop
6-
* its feasible that the user may have the actual audio output of the computer
6+
* it's feasible that the user may have the actual audio output of the computer
77
* as the active audio input, or something else entirely.
88
* <p>
9-
* When you run your sketch as an applet you will need to sign it in order to get an input.
9+
* Press 'm' to toggle monitoring on and off.
10+
* <p>
11+
* When you run your sketch as an applet you will need to sign it in order to get an input.
12+
* <p>
13+
* For more information about Minim and additional features,
14+
* visit http://code.compartmental.net/minim/
1015
*/
1116

1217
import ddf.minim.*;
@@ -22,9 +27,6 @@ void setup()
2227

2328
// use the getLineIn method of the Minim object to get an AudioInput
2429
in = minim.getLineIn();
25-
26-
// uncomment this line to *hear* what is being monitored, in addition to seeing it
27-
in.enableMonitoring();
2830
}
2931

3032
void draw()
@@ -38,4 +40,22 @@ void draw()
3840
line( i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50 );
3941
line( i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50 );
4042
}
43+
44+
String monitoringState = in.isMonitoring() ? "enabled" : "disabled";
45+
text( "Input monitoring is currently " + monitoringState + ".", 5, 15 );
46+
}
47+
48+
void keyPressed()
49+
{
50+
if ( key == 'm' || key == 'M' )
51+
{
52+
if ( in.isMonitoring() )
53+
{
54+
in.disableMonitoring();
55+
}
56+
else
57+
{
58+
in.enableMonitoring();
59+
}
60+
}
4161
}

‎java/libraries/minim/examples/PatchingAnInput/PatchingAnInput.pde‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* a UGen. In this case, we patch an Oscil generating a sine wave into
55
* the amplitude input of an Oscil generating a square wave. The result
66
* is known as amplitude modulation.
7+
* <p>
8+
* For more information about Minim and additional features,
9+
* visit http://code.compartmental.net/minim/
710
*/
811

912
import ddf.minim.*;

‎java/libraries/minim/examples/PlayAFile/PlayAFile.pde‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
22
* This sketch demonstrates how to play a file with Minim using an AudioPlayer. <br />
33
* It's also a good example of how to draw the waveform of the audio.
4+
* <p>
5+
* For more information about Minim and additional features,
6+
* visit http://code.compartmental.net/minim/
47
*/
58

69
import ddf.minim.*;
@@ -20,7 +23,9 @@ void setup()
2023
// sketch folder. you can also pass an absolute path, or a URL.
2124
player = minim.loadFile("marcus_kellis_theme.mp3");
2225

23-
// play the file
26+
// play the file from start to finish.
27+
// if you want to play the file again,
28+
// you need to call rewind() first.
2429
player.play();
2530
}
2631

‎java/libraries/minim/examples/RecordAudioInput/RecordAudioInput.pde‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
/**
22
* This sketch demonstrates how to an <code>AudioRecorder</code> to record audio to disk.
3-
* To use this sketch you need to have something plugged into the line-in on your computer, or else be working on a
4-
* laptop with an active built-in microphone. Press 'r' to toggle recording on and off and the press 's' to save to disk.
3+
* To use this sketch you need to have something plugged into the line-in on your computer,
4+
* or else be working on a laptop with an active built-in microphone.
5+
* <p>
6+
* Press 'r' to toggle recording on and off and the press 's' to save to disk.
57
* The recorded file will be placed in the sketch folder of the sketch.
8+
* <p>
9+
* For more information about Minim and additional features,
10+
* visit http://code.compartmental.net/minim/
611
*/
712

813
import ddf.minim.*;
@@ -18,11 +23,9 @@ void setup()
1823
minim = new Minim(this);
1924

2025
in = minim.getLineIn();
21-
// create a recorder that will record from the input to the filename specified, using buffered recording
22-
// buffered recording means that all captured audio will be written into a sample buffer
23-
// then when save() is called, the contents of the buffer will actually be written to a file
26+
// create a recorder that will record from the input to the filename specified
2427
// the file will be located in the sketch's root folder.
25-
recorder = minim.createRecorder(in, "myrecording.wav", true);
28+
recorder = minim.createRecorder(in, "myrecording.wav");
2629

2730
textFont(createFont("Arial", 12));
2831
}

‎java/libraries/minim/examples/RecordAudioOutput/RecordAudioOutput.pde‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* This sketch demonstrates how to use an <code>AudioRecorder</code> to record audio to disk.
33
* Press 'r' to toggle recording on and off and the press 's' to save to disk.
44
* The recorded file will be placed in the sketch folder of the sketch.
5+
* <p>
6+
* For more information about Minim and additional features,
7+
* visit http://code.compartmental.net/minim/
58
*/
69

710
import ddf.minim.*;
@@ -19,11 +22,9 @@ void setup()
1922

2023
out = minim.getLineOut();
2124

22-
// create a recorder that will record from the input to the filename specified, using buffered recording
23-
// buffered recording means that all captured audio will be written into a sample buffer
24-
// then when save() is called, the contents of the buffer will actually be written to a file
25+
// create a recorder that will record from the output to the filename specified
2526
// the file will be located in the sketch's root folder.
26-
recorder = minim.createRecorder(out, "myrecording.wav", true);
27+
recorder = minim.createRecorder(out, "myrecording.wav");
2728

2829
// patch some sound into the output so we have something to record
2930
Oscil wave = new Oscil( 440.f, 1.0f );

‎java/libraries/minim/examples/Scrubbing/Scrubbing.pde‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* But the end result is convincing enough.
66
* <p>
77
* The positioning code is inside of the Play, Rewind, and Forward classes, which are in button.pde.
8+
* <p>
9+
* For more information about Minim and additional features,
10+
* visit http://code.compartmental.net/minim/
811
*/
912

1013
import ddf.minim.*;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL