README
“The
REFCODES.ORG
codes represent a group of artifacts consolidating parts of my work in the past years. Several topics are covered which I consider useful for you, programmers, developers and software engineers.”
What is this repository for?
This artifact provides audio processing functionality such as generating sine waves or writing generated samples to WAV
files or your PC speakers via I/O streams (as of the LineOutSoundSampleWriter
or the WavSoundSampleWriter
types).
How do I get set up?
To get up and running, include the following dependency (without the three dots “…”) in your pom.xml
:
1
2
3
4
5
6
7
8
9
<dependencies>
...
<dependency>
<artifactId>refcodes-audio</artifactId>
<groupId>org.refcodes</groupId>
<version>3.0.0</version>
</dependency>
...
</dependencies>
The artifact is hosted directly at Maven Central. Jump straight to the source codes at Bitbucket. Read the artifact’s javadoc at javadoc.io.
Snippets of interest
Writing WAV files
1
2
3
4
5
6
7
8
9
10
11
import org.refcodes.audio.WavMonoSampleWriter;
// ...
double[] samples = ...;
File outFile = ...;
try (WavMonoSampleWriter theWriter = new WavMonoSampleWriter( outFile ) ) {
theWriter.setSamplingRate( 44100 );
for ( int i = 0; i < samples.length; i++ ) {
aMonoWriter.writeNext( samples[i] );
}
}
// ...
Playing audio
1
2
3
4
5
6
7
8
9
10
import org.refcodes.audio.LineOutMonoSampleWriter;
// ...
double[] samples = ...;
try (LineOutMonoSampleWriter theWriter = new LineOutMonoSampleWriter() ) {
theWriter.setSamplingRate( 44100 );
for ( int i = 0; i < samples.length; i++ ) {
aMonoWriter.writeNext( samples[i] );
}
}
// ...
Examples
See the WAVES applications’ source code as well as the example source codes of this artifact for further information on the usage of this artifact (also see the blog post on Experimenting with sinusoids and overlaying waves).
Contribution guidelines
- Writing tests
- Code review
- Adding functionality
- Fixing bugs
Who do I talk to?
- Siegfried Steiner (steiner@refcodes.org)
Terms and conditions
The REFCODES.ORG
group of artifacts is published under some open source licenses; covered by the refcodes-licensing
(org.refcodes
group) artifact - evident in each artifact in question as of the pom.xml
dependency included in such artifact.