Beruflich Dokumente
Kultur Dokumente
Letshaveacloserlookattheexampleprojectfromlasttime.Themostimportantfilesare
resource.h,MyFirstPlugin.handMyFirstPlugin.cpp.Thepluginisasimplegainknobitchanges
thevolumeoftheaudiopassingthrough.
TheIDisimportantforcatalogingplugins.Youcanregisterithere.
Line56+definesanIDandimagepathfortheknobyouseewhenyouruntheApp:
Intheprojectnavigator,openResourcesimgknob.png.Itsaspritewith60differentknob
positionseachofthemis48x48Pixels.Sowhenyouruntheappandturntheknob,itdoesnt
rotatetheimage,butrathershowsacertain48x48Pixelportionofit.
Whynotjustrotateasingleimage?Imagineyouwantyourknobgraphictohaveaglossylookanda
dropshadow.Ifyouweretorotatethegraphic,theglossandshadowwouldalsoberotated,whichis
nothowitlooksintherealworld.
Furtherdowninresource.h,youcansetthesizeofyourpluginswindow:
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 1/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
Trychangingthevaluesandruntheapp.
Resetiscalledwhenthesamplerateischanged.
OnParamChangeiscalledwhenapluginparameterchanges,forexamplewhenyouturn
theknob.
ProcessDoubleReplacingisthecoreofyourplugin.Inthisfunctionyoucanprocess
incomingaudio.
Intheprivatesectiontheresjustadoubleholdingthecurrentgainvalue.
TheImplementation
Nowfortheinterestingpart!OpenMyFirstPlugin.cpp.Firstofallwecanseeanicetrickforenums:
enum EParams
{
kGain = 0,
kNumParams
};
Bysettingthefirstoptionto0andkNumParamsattheend,kNumParamsbecomesthenumberof
options(1inthiscase).
Thefollowingenumusestheconstantsdescribedinresource.handsetsthepositionoftheknobin
thepluginswindow:
enum ELayout
{
kWidth = GUI_WIDTH,
kHeight = GUI_HEIGHT,
kGainX = 100,
kGainY = 100,
kKnobFrames = 60
};
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 2/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
Italsodefinesthenumberofframesinknob.pngas60.
Belowthat,theconstructorimplementationstartsbysettingupthepluginsattributes:
WecantseethevalueandpercentsignintheGUI,butthevaluecanbebetween0and100,the
defaultbeing50.Youmayhavenoticed,though,thattheknobisntattwelveoclock.Thisisbecause
oftheSetShape(2.)below.Setitto1.0andtheknobwillbeasyouexpect.SetShapegivesaknoba
nonlinearbehaviour.
Next,theconstructorcreatesagraphiccontextwiththerightsizeandcreatestheredbackground:
Itthenloadstheknob.png,createsanewIKnobMultiControlwiththeimage,andattachesittothe
GUI.IKnobMultiControlistheC++classfortheGUIknob.NotehowkKnobFramesispassedto
indicatethatthespritecontains60frames.
Finally,theconstructorattachesthegraphicscontext,anditcreatesadefaultpresetfortheplugin:
LetslookatOnParamChange(bottomofthefile).TheIMutexLockensuresThreadSafety,aconcept
wewilldiveintolater.Therestisjustaswitchtodotherightthingdependingonwhichparameter
waschanged:
case kGain:
mGain = GetParam(kGain)->Value() / 100.;
break;
Remember,thekGainparameterhasvaluesbetween0and100.Soafterdividingby100,weassign
theresult(between0and1)totheprivatemembermGain.
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 3/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
Sofar,wehavelookedathowaGUIiscreatedandhowitcanbelinkedtoparameterslikemGain.
Letsnowlookathowtheplugincanprocessincomingaudio.Inourcase,anaudiostreamisa
sequenceofdoublesamples,eachcontainingtheamplitudeatagivenpointintime.
ThefirstparametertoProcessDoubleReplacingisdouble** inputs.Asequenceofdoublevalues
canbepassedusingdouble*.Thepluginprocessestwo(stereo)orevenmorechannelsatonce,so
wehaveseveralsequencesofdoublesamples,thatis,double**.Thefirsttwolinesinthefunction
makeitmoreclear:
Now,in1pointstothefirstsequenceofsamples(leftchannel),in2tothesamplesfortheright
channel.Afterdoingthesamefortheoutputbuffer,wecaniterateovertheinputandoutputbuffers
toprocessthem:
Foreverysample,wetaketheinputvalue,multiplyitbymGainandwriteittotheoutputbuffer.
nFramestellsushowmanysamplesthereareperchannelsoweknowhowlongthebuffersare.
Youmayhavenoticedthatwhenyouruntheapp,youcanhearyourselfthroughyourcomputer
speakers.Thisisbecausebydefault,thestandaloneapptakesyourcomputersmicrophoneasinput.
Tochangethis(andsomeotheraudiopreferences),gototheappspreferences:
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 4/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
SetabreakpointintheResetfunction.ChangetheSamplingRateontherightandclickApply.The
debuggerwillbreakinsideReset.Inthelowerrightwherelldbisrunning,enter
print GetSampleRate().
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 5/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
Noticehowyoucancallanyfunctionfromthedebuggeranditwillshowthecorrectreturnvalue.
PressStopintheupperleftcornerwhenyourereadytomoveon.
Nowitstimetoactuallycreatepluginversionsofourappandloadthemintoahost.Wellcover
thatinthenextpost!
FurtherReading
Tofillsomegaps,readtheseslidesbytheingeniusMr.OliLarkin.Theyexplainalotofthingsabout
WDLOL.
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 6/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
Ifyoufoundthisuseful,pleasefeelfreeto !
Megusta 36
17Comments MartinFinke'sBlog
1 Login
Jointhediscussion
thackerthanthis3yearsago
Hello!yourtutorialseriesisincredible!I'vebeensearchingaroundforaninroadintomaking
AU'sforAGES!...IwonderifyoucanhelponsomethingprobablysosimpleWhenItry
changingtheManufactureID,orPLuginIDalthoughitrunsokAUlab,theplugindoesnot
validatewithinLogicorunderthevalidationscript.Igetanerror
ERROR:ViewComponentspecified,butcan'tbefound...
??I'evtriedlookingtoseeifandwhereimightneedtochangethenameofwhatI'mnow
specifying,butnoluck..
Best,
Nick
Reply Share
olilarkin>thackerthanthis3yearsago
hinick,
whenindoubtreduplicateoneoftheexampleprojectsandchangethingsonestepata
time.
itshouldbesufficientto:
supplyyourmanufacturernameasanargumenttotheduplicatescripte.g.
"./duplicate.pyIPlugEffect/MyNewPluginMyManufacturerName".Avoidspacesor
strangecharacters.
theneditthePLUG_UNIQUE_IDandPLUG_MFR_IDinresource.h
aslongasthoseIDSareuniquesandinthecorrectformatitshouldwork
ifyoutryandchangeanythingelse,e.g.bydirectlyeditingtheinfo.plistfilesyoumay
breakvalidation
hopethathelps
olilarkin
Reply Share
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 7/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
alfred3yearsago
whenitrytoaccessthepreferenceswindowmyapplicationgetsabortedbyafatalerrorsaying
thatvectoroutofbounds..
Firstchanceexceptionat0x7507c41finMyFirstPlugin.exe:MicrosoftC++exception:RtErrorat
memorylocation0x0016f378..
MyFirstPlugin.exehastriggeredabreakpoint
MicrosoftVisualStudioCRuntimeLibraryhasdetectedafatalerrorinMyFirstPlugin.exe.
thisiswhatsinthedebugwindow...
theerrorwhichcomesisvectorsubscriptoutofrange..canuhelpme?
Reply Share
Hello!Sorryfortheinconvenience!ThisseemstobethesameproblemreportedbyFabio
before.Pleaseseethiscomment:http://www.martinfinke.de/...
Reply Share
PerQA3yearsago
Hello!Icanonlyagreewitheveryoneelsehere.Thisisoneofthebesttutorialsever,allcategories!
However,Ihaverunintoaweirdproblem.Ican'tgetmyXcodeconsoletodisplayanydebug
output.Itseemsimpossibletochoosewhichthreadtowatch...The"busy"symbolinthedebug
navigatorontheleftneverstops.I'musingXcode5,butI'mnotveryexperiencedwithXcode.
ThereasonI'mpostingthequestionhereisthatIsuspecttheproblemisrelatedtothisproject,
sinceIhavebeenabletousetheconsoleinotherprojects.
Screenshot:
https://www.dropbox.com/s/a...
Reply Share
Thankyouforthekindwords!:)
Ihaven'tusedXcode5,butitlookslikeyou'reonthewrongtab.Tryclickingthethreads
button,markedonthispicture:https://www.dropbox.com/s/u...
Hopethathelps,
Martin
Reply Share
PerQA>MartinFinke3yearsago
Yes,thishasbeenresolved.
Reply Share
PerQA3yearsago
Thistutorialisgreat!Everythinghasworkedsmoothly,butIcan'tgettheconsolecommandsto
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 8/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
Thistutorialisgreat!Everythinghasworkedsmoothly,butIcan'tgettheconsolecommandsto
work:
(lldb)printGetSampleRate()
error:useofundeclaredidentifier'GetSampleRate'
error:1errorsparsingexpression
Anyideaswhatcouldbecausingthis?
Reply Share
Hello!Itsoundslike"GetSampleRate"isn'tvisibleinthatscope...areyousurethe
breakpointissetinsidethebodyofMyFirstPlugin::Reset?
Reply Share
PerQA>MartinFinke3yearsago
Yes,thebreakpointisthere.However,whenIruntheprogram,thereisnothing
displayedintheconsole.Theexecutiondoesnotstopatthebreakpointbyitself.If
Itype"printGetSampleRate()"intheconsolenothinghappens.IfImanually
pauseexecution,Igetthe(lldb)prompt,buttyping"printGetSampleRate()"
resultsinanerror:
(lldb)printGetSampleRate()
error:useofundeclaredidentifier'GetSampleRate'
error:1errorsparsingexpression
I'manXcodenewbie,soI'mprobablyjustdoingsomethingwronghere.
Reply Share
leedleleedlelee3yearsago
Hi!asothershavebeensaying,byfarthebesttutorialoutthere.Thankyouforthat.WhenItry
toruntheproject(Xcode5)buildfailsbecause"error:ThereisnoSDKwiththenameorpath
'/Users/tobalope/plugindev/wdlol/VST3_SDK/base/mac/macosx10.7'"anyIdeasonwhatit's
tryingtosay?I'monosxMavericksandalltheSDKswereinstalledproperly.
Reply Share
Hello!Thanksforthefeedback!
That'sastrangeerror,becausethedirectory"wdlol/VST3_SDK/base/mac/macosx10.7"
isn'tsupposedtoexist.
Whenyougotoyourproject's"BuildSettings",whatoptionsareavailableforthe"Base
SDK"entryinthelist?
Reply Share
leedleleedlelee>MartinFinke3yearsago
thereare3,andosx10.7isn'tanyofthem...thoroughlyconfused:
OSX10.5$(BASE_SDK)
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 9/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
OSX10.5$(BASE_SDK)
OSX10.8
OSX10.9
andtheLatestoption(OSX10.9)
Reply Share
leedleleedlelee>MartinFinke3yearsago
Andthanksabunchforthereply,honestlywasn'texpectingone,asusuallyyou
don'tgetthem.Thankyouverymuch!
Reply Share
snacach3yearsago
Heydoesanyoneknowhowtodelaytheaudiobufferifiwanttoaddadelaytooneofthe
channels?Itsjustafewsamplesnothingbig,andtheamountisuserdefinedcontinouslybya
knob.Thanks
Reply Share
monkeyman32yearsago
Thisisbrilliant,thankssomuch,youarethebest
Reply Share
Andrew10monthsago
Howtochangepreferenceunderwindows?
Reply Share
Index
2015MartinFinkeImpressum
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 10/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 11/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 12/13
30/3/2017 MakingAudioPluginsPart3:ExaminingtheCodeMartinFinke'sBlog
http://www.martinfinke.de/blog/articles/audioplugins003examiningthecode/ 13/13