Android signal generator app - diyAudio
Go Back   Home > Forums > Design & Build > Software Tools

Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 30th October 2010, 03:12 AM   #1
beun is offline beun  United States
diyAudio Member
 
Join Date: Feb 2010
Default Android signal generator app

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; }
  Reply With Quote
Old 30th October 2010, 03:26 AM   #2
SY is offline SY  United States
diyAudio Moderator
 
SY's Avatar
 
Join Date: Oct 2002
Location: Chicagoland
Blog Entries: 1
Very cool! What's the bandwidth you can get?
__________________
You might be screaming "No, no, no" and all they hear is "Who wants cake?" Let me tell you something: They all do. They all want cake.- Wilford Brimley
  Reply With Quote
Old 30th October 2010, 03:44 AM   #3
beun is offline beun  United States
diyAudio Member
 
Join Date: Feb 2010
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.
  Reply With Quote
Old 3rd December 2010, 06:15 AM   #4
diyAudio Member
 
Join Date: Oct 2010
1hz is pretty low.... that would be cool if those smartphones had an moduel to have the vibrator run as a subwoofer from 30hz down. "Set your phone on a firm pillow for an acoustic experience"
  Reply With Quote
Old 7th December 2010, 03:14 AM   #5
beun is offline beun  United States
diyAudio Member
 
Join Date: Feb 2010
That would indeed be cool.
  Reply With Quote
Old 17th February 2011, 01:40 PM   #6
hates ground loops
diyAudio Member
 
Rodeodave's Avatar
 
Join Date: Dec 2004
Location: in the alps
Blog Entries: 1
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...
__________________
Gravity - Making the G since 13.7 billion B.C.
  Reply With Quote
Old 2nd March 2011, 04:08 AM   #7
beun is offline beun  United States
diyAudio Member
 
Join Date: Feb 2010
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.
  Reply With Quote
Old 27th August 2011, 02:16 AM   #8
diyAudio Member
 
Join Date: Aug 2011
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!
  Reply With Quote
Old 27th August 2011, 04:05 AM   #9
beun is offline beun  United States
diyAudio Member
 
Join Date: Feb 2010
rproch,

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()
{
android.os.Process.setThreadPriority(android.os.Pr ocess.THREAD_PRIORITY_URGENT_AUDIO);

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

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.
  Reply With Quote
Old 27th August 2011, 04:19 PM   #10
diyAudio Member
 
Join Date: Aug 2011
Thanks. That makes a lot of sense. It's working great now!
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
spdif signal generator Nikon1975 Digital Source 3 23rd August 2010 02:18 AM
Signal Generator Help Bengali Equipment & Tools 12 24th April 2008 04:20 PM
looking for a signal generator Ahmad_tbp Solid State 21 8th September 2006 11:37 PM
DIY signal generator? Loial Parts 13 19th September 2005 10:36 AM
signal generator help hizz_eye Solid State 2 3rd March 2005 10:25 AM


New To Site? Need Help?

All times are GMT. The time now is 08:37 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2