Android Sine Wave Synthesis
Part 5 -
Preceding tutorials in this series:
Tutorials in that series that follow:
The final programming task in this set of tutorials is to complete the MainActivity.java class. There is very little to do here other than create an instance of the PlayWave class and program the toggle button to turn the sound on and off.
Add the following code with the other variables to create an instance if the PlayWave class:
PlayWave wave = new PlayWave();
The only other programming to do is within the onClick method for the toggle button. The frequency is sent to the TextView to display the set frequency. Finally, a boolean variable ‘on’ is declared such that if it is true the sound is started and if it is false the sound is turned off.
On completion, your MainActivity.java class should look similar to the one below.
The project is now ready to test. For the next and final tutorial in this series, the project is loaded as an App on an Android device and the fidelity of the wave examined through an oscilloscope. The limits of PCM are also explored.
Download Download the Project files