README
The
REFCODES.ORGcodes 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>4.1.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
Below find some code snippets which demonstrate the various aspects of using the refcodes-audio artifact (and , if applicable, its offsprings). See also the example source codes of this artifact for further information on the usage of this artifact.
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
- Report issues
- Finding bugs
- Helping fixing bugs
- Making code and documentation better
- Enhance the code
Who do I talk to?
- Siegfried Steiner (steiner@refcodes.org)
Licensing Philosophy
This project follows a dual-licensing model designed to balance openness, pragmatism and fair attribution.
You may choose between the LGPL v3.0 or later and the Apache License v2.0 when using this software.
The intention behind this model is simple:
- Enable use in both open-source and proprietary projects
- Keep the codebase approachable and reusable
- Ensure that improvements to the library itself remain available to the community
- Preserve clear attribution to the original author and the ecosystem
Under the LGPL v3.0+, you are free to use this library in any application. If you modify the library itself, those modifications must be made available under the same license and must retain proper attribution.
Alternatively, the Apache License v2.0 allows broad use, modification and distribution, including commercial usage, provided that copyright notices and the accompanying NOTICE file are preserved.
This dual-licensing approach intentionally avoids artificial barriers while discouraging closed, uncredited forks of the core library. Contributions, improvements and refinements are encouraged to flow back into the project, benefiting both the community and downstream users.
For licensing questions, alternative licensing arrangements or commercial inquiries, please contact the copyright holder.
