Android signal generator app

This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
I have wasted some serious nights programming my first free Android app. It is a signal generator that can create sine, triangle, square, white noise and pink noise signals. They can also be AM, FM or PM modulated in any combination and swept in frequency. The modulation waveform is either a sine, triangle or square and the frequency sweep can be linear or logarithmic. The noise signals do not repeat.

By default the triangle and square wave are anti-aliased and are recalculated upon a frequency change.

As an future upgrade I plan to add (the non-functioning button is already present) an arbitrary waveform function that lets you generate signals built from mathematical primitives. So if you want a sinc signal for example you just type in sin(x)/x and your sinc signal is there.

The link to the android market is: FuncGen Signal Generator - Android td.attachrow { font: 11px Verdana,Arial,Helvetica,sans-serif; color: rgb(0, 0, 0); border-color: rgb(0, 0, 0); }td.attachheader { font: 11px Verdana,Arial,Helvetica,sans-serif; color: rgb(0, 0, 0); border-color: rgb(0, 0, 0); background-color: rgb(209, 215, 220); }table.attachtable { font: 12px Verdana,Arial,Helvetica,sans-serif; color: rgb(0, 0, 0); border-color: rgb(0, 0, 0); border-collapse: collapse; }
Its limited by the 44.1KHz sample rate of the phone DAC so currently it is hardware and software limited from 1Hz to 20KHz. Additionally on my G1 there seems to be a pretty bad high pass characteristic that cuts off the low end. Your mileage may vary on other phones.
Joined 2004
Paid Member
Man, I simply love this app. And I just found out that it's from a fellow diyaudio member, so it's even more cool. Was looking at the waveform with my Lithuanian oscilloscope the other day...looks very promising. The square wave @1kHz still looks quite usable, the sines and triangle look very good.
Have you made any %THD measurements?
I think I have noticed a couple of mV offset on my SGS, but that's probably the output stage. Nothing that a cap wouldn't fix...

Apparently the "SpectralPro Analyzer" app goes up to 24kHz (48kHz sampling rate), so maybe there's a way to make the output go faster? I have to add that I'm in no way affiliated to the author of said app, just wanted to mention it.

Now if I only found a way to run a signal generator app together with a spectral analyzer app...
I haven't made any THD measurements but the internal math is double precision so the distortion is going to be limited by the phone's DAC.

I am working on an update, so in the options I can put an adjustable upper frequency limit instead of an hard coded constant.
I like the app a lot! Nice job!

Are you, by any chance, willing to share some of your code? I am developing an app that includes some pitch generation, in order to play tones that a musician can use to tune to. It's not quite as extensive as yours, just a simple sine wave, which I have mostly working, but for some reason, the pitch is not completely steady, and will occasionally shift up or down in a pretty noticeable matter. Yours does not seem to do this though, so I am wondering what you did different.

I got my pitch generation code from this tutorial: Badlogic Games Fun with AudioTrack

Totally fine if you don't feel like sharing your code, but any help would be greatly appreciated!

I actually started with the same piece of code that you found, the difference is how I generate the frequencies. This is how I do it:

1) I set the sample rate at 44100, even it the hardware allows a higher sample rate, this just makes the programming easier.
2) Define an array of shorts with length 44100
3) Fill the array with exactly one period of the signal you want to generate, in your case a sine
4) Now in a separate thread step though this array in a circular fashion (index = (index + step) % 44099) and write the value you land on to the audio buffer.

The frequency of the generated signal is controlled with the value of the step, if the step is 1 the output frequency is 1Hz, with a step of two the output frequency will be 2Hz etc. This way you can generate frequencies in steps of 1Hz.

The basic code looks like: (sorry for the crappy formatting)

public class ifillbuff implements Runnable{
public void run()

while( play )
for( int i = 0; i < samples.length; i++ )
samples = AndroidAudioDevice.sigBuffer[angle];
catch (ArrayIndexOutOfBoundsException e){
angle = (angle + ifreq) % 44099;

where samples is the audiodevice sample buffer and sigBuffer is the short array of length 44100 filled with a sine wave.

I hope this clarifies the procedure.
I have wasted some more serious time updating the FuncGen program, it is now called ArbGen and it has the following additional features:

- Frequency resolution less than 1mHz
- Automatic saving and restoring of setings and parameters
- Manual saving and restoring of user profiles
- Completely flexible signal generation using 33 mathetical functions and operations including noise. Example a sinc function "sin(5*x)/x" or an AM modulated signal 0.5*sin(x)*sin(10*x)
- Automatic and manual saving of the formulas

So this was all the good stuff, the bad stuff is that it isn't free anymore.
Hi everybody. I' m trying to create an Android app where you draw any graphic with intensity on Vertical axis and time on horizontal one. From this graphic the app have to create a mp3 file. Playing this file with a music player the intensity measured with an oscilloscope will have to coincide with the graphic created. I don't know how to do it and if it's possible. So if you have any information about it please contact me
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.