|
|||||||
| Home | Forums | Rules | Articles | Store | Gallery | Blogs | Register | Donations | FAQ | Calendar | Search | Today's Posts | Mark Forums Read | Search |
| 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 |
|
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
diyAudio Member
Join Date: Feb 2010
|
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; } |
|
|
|
#3 |
|
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.
|
|
|
|
#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"
|
|
|
|
#5 |
|
diyAudio Member
Join Date: Feb 2010
|
That would indeed be cool.
|
|
|
|
#6 |
|
diyAudio 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...
__________________
Gravity - Making the G since 13.7 billion B.C. |
|
|
|
#7 |
|
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. |
|
|
|
#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! |
|
|
|
#9 |
|
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. |
|
|
|
#10 |
|
diyAudio Member
Join Date: Aug 2011
|
Thanks. That makes a lot of sense. It's working great now!
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
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? |