0% found this document useful (0 votes)
262 views3 pages

Arduino Realtime Audio Spectrum Analyzer With Video Out!

A brilliant bit of code, the TVout library for Arduino, allows you to generate composite NTSC monochrome video with only two pins and two resistors.

Uploaded by

Marcelo Rambaud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
262 views3 pages

Arduino Realtime Audio Spectrum Analyzer With Video Out!

A brilliant bit of code, the TVout library for Arduino, allows you to generate composite NTSC monochrome video with only two pins and two resistors.

Uploaded by

Marcelo Rambaud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

13/3/2015

ArduinoRealtimeAudioSpectrumAnalyzerwithVideoout!

MakeRadioLocmanYourHomepage!

All News Articles Circuits Sites Datasheets Devices Forum


Search

AdvancedSearch+

SchematicsAudioVideoMeasurementMCUopensourceplatformsMicrocontrollersusage
12172010

ArduinoRealtimeAudioSpectrumAnalyzerwithVideoout!

eNewsletterSubscription
ContactUs
RadioLocmanontheSocialWeb:

PaulBishop
Onceagain,IdecidedtoputtheoldtravelDVDplayer'sscreentogoodusebyusingasanoutput
devicefortheArduino.ThoughtheDVDmechanismisbroken,thescreenallowsforstandardNTSC
compositevideoinput..runsonanattachedrechargeablebatterypack(canalsopowertheArduino.)

Imakenoguarantees,andyoudosoATYOUROWNRISK,butitshouldworkwithanyTVordevice
thatallowsNTSCVideoIn.Iaminnowayresponsibleifyoudamageyourselforyourequipment.This
isaprototypebuiltbyanamateur,keepthatinmind.

Abrilliantbitofcode,theTVoutlibraryforArduino,allowsyoutogeneratecompositeNTSC
monochromevideowithonlytwopinsandtworesistors.Igenerallyleavetheresolutionatthedefault
12896,whichtranslatesto1612textwiththedefault88font.Runningunderthedefaultsseemsto
givetheleastamountoftroublewiththislibrary,whichisaworkinprogress.Notethatduetothislibrary
beingactivelyworkedon,there'snoguaranteethecodeIamusingwillworkwithotherIDEorLibrary
versions.Thishasbeendevelopedusingversion0019,thoughIwillbetestingshortlyonthemost
recentreleases.Inaddition,thoughitshouldnotmatter,Iamusinga5vAdafruitBoarduino.There
shouldbenodifferences,aslongasyourArduinoisa5vdevice.AlsonotethatoldversionsofArduino
whichuseanAtmelATmega168won'tbeabletorunthis,theydon'thaveenoughmemory.

http://www.radiolocman.com/shem/schematics.html?di=71070

1/3

13/3/2015

ArduinoRealtimeAudioSpectrumAnalyzerwithVideoout!

Clicktoenlarge
Theotherpieceofthepuzzleiscollectingandprocessingaudio,sowehavesomethingtodisplayon
ourlittledisplay.
Thefirstpiecedatacollectionisfairlystandard.Iuseanelectretmicrophone(whichaloneonly
producesafewmVoutput,fartoolowforourArduinotousedirectly)withatransistoramplifierasthe
signalsource,whichisthensampledviatheADContheAnalog0pinoftheArduino.
Todospectrumanalysishowever,youneedtocapturesignalovertime,thenprocessthatdatawith
whatisknownasaFourierTransformation.Thismagicalprocesstakesasignalandbreaksitdowninto
bucketsbaseduponfrequenciesfoundwithinthesample.Thisproducesaremarkablygoodpictureof
thesignalandifdisplayed,functionsasavisualspectrumanalyzerifloopedoverandover.
Inthisproject,I'veusedcodepostedbyausertotheArduinoforums
ThispostcontainsalibrarywhichperformsboththesamplingandtheFastFourierTransformation
completelyinCin8bits,amazingfastconsideringthatfact,andusesafewtrickstobereallystingyon
memory,whichisatapremiumonArduinoespeciallywiththeTVoutdataspaceeatingupquiteabit.
SincetheAtmega328onlyhas2kofRAM,everybytecounts.Matrixmathdonelikethisisnothingshort
ofawesome.Bestofall,it'susableasalibrary.Cutandpastethe.cppand.hintoanewfoldernamed
"FFT"intheLibrariesdirectory.MyArduinoprojectcodeisadaptedfromtheoriginalcodefromthe
forumpostedArduinoprogram.
So,toproduceourdesiredoutcome,wejustneedtogetthewholeshowtogetherandhopeitcan
perform.Withonlyahandfulofcheapcomponents(afewdollarsatmost),itproducesaperfectlyusable
andquiteentertainingrealtime64bandvideospectrumanalyzer.Thoughnotreally"useful"foranyreal
purposes,itmakesanentertainingpartydisplayoutofanytelevisionwithavideoinput...
Therearealotofimprovementswhichcanbemadethefirstbeingtheamplifiergaintomakeitabit
moreresponsive,andoptimizationoftheFFTcode.Inreality,it'sthedrawingofthebarswhichtakes
themosttimepersample/displaycycle..notthematrixmath!
Thecircuitrequiredisasimplemicrophoneandtransistoramplifier,aswellastworesistorsconnected
toD8andD9toprovidevideosignal..drawingisamuchbiggerpainthanyou'dthink!

Clicktoenlarge
Sourcecode(Arduino)
#include TVout.h
#include fix_fft.h
TVoutTV;

http://www.radiolocman.com/shem/schematics.html?di=71070

2/3

13/3/2015

ArduinoRealtimeAudioSpectrumAnalyzerwithVideoout!

charim[128],data[128],lastpass[64];
charx=32,ylim=90;
inti=0,val;
voidsetup()
{
TV.begin(_NTSC,128,96);//InitializeTVoutput,128x96.
TV.print_str(2,2,"RealtimeArduino");//TVoutlibusesx,yforprint
TV.print_str(2,11,"SpectrumAnalyzer");//statements.8x8defaultfont.
analogReference(DEFAULT);//Usedefault(5v)arefvoltage.
for(intz=0;z<64;z++){lastpass[z]=80;};//fillthelastpass[]arraywithdummydata
};
voidloop()
{
for(i=0;i<128;i++){//Wedon'tgoforcleantiminghere,it's
val=analogRead(0);//bettertogetsomewhatdirtydatafast
data[i]=val/4128;//thantogetdatathat'slabaccurate
im[i]=0;//buttooslow,forthisapplication.
};
fix_fft(data,im,7,0);

for(i=1;i<64;i++){//Inthecurrentdesign,60Hzandnoise
data[i]=sqrt(data[i]*data[i]+im[i]*im[i]);//ingeneralareaproblem.Futuredesigns
TV.draw_line(i+x,lastpass[i],i+x,ylim,0);//andcodemayfixthis,butfornow,I
TV.draw_line(i+x,ylim,i+x,ylimdata[i],1);//skipdisplayingthe0500hzbandcompletely.
lastpass[i]=ylimdata[i];//ifyouinsist,initializetheloopwith0
};//ratherthan1.
};

blurtime.blogspot.com
Youmayhavetoregisterbeforeyoucanpostcommentsandget
fullaccesstoforum.

UserName UserName
Password

RememberMe?
Login

Schematicsontheme:

AudiospectrumanalyzeronPIC32
ImplementingDiscreteFourierTransforminAtmega32tomakeanaudiospectrumanalyzer
Handheld2.4GHzSpectrumAnalyzer.Part1
Handheld2.4GHzSpectrumAnalyzer.Part2
AudioSpectrumMonitor

RadioLocmanMedia

FreeServiceManualsFreeelectronicProjects

http://www.radiolocman.com/shem/schematics.html?di=71070

3/3

You might also like