Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+11 votes

In my code, a method that is supposed to be playing static noise has been implemented and added to all the places necessary for it to work. However, when I run the app nothing can be heard (even when the volume is at the highest level) and no errors are being shown either which leads me to believe that there might be something wrong with the base code itself, and so I was wondering if there is a way that we can output what sound is playing when on the console to double check it.

I am also using the link below as my base code:

https://www.brownnoiseradio.com/resources/generate-white-noise-in-java:-simple-steps-and-explanation

asked in CSC 305 Fall 2024 by (3k points)

1 Answer

+6 votes
 
Best answer

This might not be the answer you are looking for but when I encounter this kind of problem in my code I usually (1) Add debugging code to output information. I'm not sure if you are using AudioLine but if you are you can add print statements around the code where the audio line is opened, started, and data is written to it. This will confirm whether the audio line is being used as expected. (2) If you have a method generating white noise (e.g., an array of random values or an audio buffer), print out the first few samples of the array to see if they are generated as expected.

answered by (4.4k points)
selected by
...