Orinj version 7.0.0
Note: This page is not for the users of Orinj, but for developers who want to create generators for Orinj.
Downloads
squarewave.zip | January 12, 2019 | The source code for the square wave generator (5 KB). |
This code was developed using the Orinj generator framework. If this code is compiled and placed in a Java JAR file, the resulting JAR file can be copied into the orinj/generators folder of the Orinj installation. Upon startup, Orinj will recognize this JAR file and the generator in it (the Square Wave). Orinj will then create a menu item in its menu for generators and will thus allow users to create wave files with this generator.
Code for the square wave generator
Square Wave can be used to create simple square waves. When you create a square wave with this generator, Orinj will place the audio data for the square wave in a wave file and open that file in its single wave view.
The code for the Square Wave contains three files:
- SquareWave.java – this is the implementation of the square wave generator. The most interesting function in this class is getData(). This function produces the byte buffers that contain the audio data for the square wave.
- SquareWavePanel.java – this is the graphical user interface for the square wave generator. It contains the controls that the user can modify to change the resulting square wave.
- generator.xml – this XML file describes the generator to Orinj, so that Orinj can actually use the generator.
These are the files required for creating generators in Orinj. A generator package (a JAR file) may contain other files as well.
Choice of package name
Both Java classes above are placed in the package com.recordingblogs.squarewave. Using a URL for the package name is a good idea, as it helps in making sure that generator names are not duplicated (e.g., two designers could create two generators with the same name).
Compiling the square wave generator
The commands to compile this source code are as follows.
javac "SquareWave\src\com\recordingblogs\squarewave\SquareWave.java" -d "SquareWave\class" -classpath "SquareWave\class;orinj\orgenerator.jar"
javac "SquareWave\src\com\recordingblogs\squarewave\SquareWavePanel.java" -d "SquareWave\class" -classpath "SquareWave\class;orinj\orgenerator.jar"
copy SquareWave\src\generator.xml SquareWave\class\generator.xml
jar cf "orinj\generators\squarewave.jar" -C "SquareWave\class" .
The first two lines compile the Java source code. Note that this source code uses orgenerator.jar, which defines the interfaces that the classes have to implement. The third line from the top copies the file generator.xml at the appropriate place. The last line prepares the generator package JAR file.
See also:
Orinj Generator framework
Add new comment