Found a neat tool for making icons and such. Here goes the PCR list! This is my working list I'm using to built the app. The basics are working, next I need to build the polished app. I pasted the genTone() function into the slider and toggle listeners, and ba da bing! The UI is a tad bit laggy and I'll work on that, but now the slider changes the tone as it plays, and the tone is continuous with no clicks or gaps. So this math needs to be done in the UI thread and passed to the audio playing thread. Unfortunately the tone is interrupted when the genTone function runs, I guess it is taking too long and the buffer empties. I put a new tone generation step in the loop. Hopefully the lag won't be so great the user gets annoyed. What will actually happen is the slider bar will change the variables for tone gen function that will calculate the data, and then that will get queued into the audio playback. The second half of the proof of concept that the slider bar can control the tone while it plays. Just proof of concept, the buttons all say the wrong thing, etc. Now the radio buttons play different tones and the slider sets the tone frequency. With a few minutes hacking I replaced the light blinking with the tone generation in my previous app. The tone turns on and off with the toggle switch and the background thread is working great, the UI doesn't lock up. That variable is controlled by the GUI and breaks the loop when the user pushes the button. I copied over my light blinking app and pasted this function into the Asynctask, and it worked great. This mod made a nice continuous tone:Īwesome, I have the soul of the app. Need to write continuously to the audio track, turns out the buffer is blocking so you just keep writing. In order to make the tone continuous, and not a series of chopped tones, I need to use STREAM not STATIC mode. SampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO,ĪudioFormat.ENCODING_PCM_16BIT, numSamples,ĪudioTrack.write(generatedSnd, 0, generatedSnd.length) I started with these functions to generate a toneįinal AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, It does seem that the loading in the emulator leads to more interruptions in the sound playback than on a real device. But it works now, I can hear the tones from the PC. My PC has been rebooted and maybe the soundcard was just out to lunch. Previously I could play tones from my phone, but the emulator was mute. One big help is that suddenly the tone generator works in the emulator. I want to be able to make a continuous tone, and modulate it with the slider bar and have it running in a background thread. The previous app just made a tone for a short duration and locked up the UI while it did so. I'll use the background thread asynctask function from the light blinker app to generate the tone. Plus I don't want to be accused of copying anything. It is much more exciting to maintain the illusion of being creative. The way to learn is to do, so I'm making apps that I feel would be useful. That is way too depressing because everything imaginable has already been written. I'm making a point not to search for apps like the one I want to develop. This app sticks to commonly compatible hardware. The flashlight strobe app had the issue that many phones use different hardware, and I got a lot of complaints that it didn't work on certain phones. I thought this would go well with my hobby electronics bent. I need to master playing mathematically generated audio files.įirst I decided to expand the audio tone generator functions in my starter app to make a publishable signal generator and audio test app. I'm still polishing my skills and entertaining myself, so I'm developing simple Android apps in preparation for some killer app ideas down the road. In the end I published a scale down app just so I could hold my head up and not have to declare failure. I leaned a lot about Android audio, but the app took so long it was no longer fun. Finally published my audio app today, this turned out to be be a long and painful road.
0 Comments
Leave a Reply. |