| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700 |
- #include <cfenv>
- #include <juce_gui_basics/juce_gui_basics.h>
- #include "engine/AraHost.h"
- #include "engine/FileSort.h"
- #include "platform/Paths.h"
- #include "core/SectionOps.h" // round 190ol (P1: the Sections lane)
- #include "core/SignatureEdit.h" // round 190ol (P6)
- #include "ui/SectionsLane190ol.h" // round 190ol (P1: the shot route drives the lane)
- #include "ui/ChordLane190pf.h" // round 190pf (P13: the shot route drives the lane)
- #include "ui/SmartTempo190pf.h" // round 190pf (P12)
- #include "core/SmartTempo.h"
- #include "core/Offline.h"
- #include "core/GrooveAudio.h"
- #include "core/SmartDisableTip.h" // (round 190ok: --smarttipshot190ok)
- #include "core/SimpleTracks.h" // (round 190ot: --simpleduck190otshot)
- #include "core/TrackImport.h" // (round 190pe: --tracks190peshot, --selftest tracks190pe)
- #include "core/TrackVersions.h"
- #include "ui/TrackImportDialog.h"
- #include "core/EditorScale.h"
- #include "core/SimplePads.h"
- #include "core/SimSynth.h" // (round 190om: the selftest's SimSynth channel)
- #include "core/ClipEnvelope.h"
- #include "core/ClipWarp.h"
- #include "core/KeyGuess.h"
- #include "core/EditorPolish.h"
- #include "core/FlpExport.h"
- #include "core/FruityBasicFx.h" // (round 190my: Fruity Balance in --details190myshot)
- #include "core/TrackClips.h"
- #include "core/TrackStates.h"
- #include "core/RangeEdit.h" // round 190pa (P14)
- #include "core/AutomationModes.h" // round 190pa (P21)
- #include "core/Groove.h"
- #include "core/DrawMode.h"
- #include "core/SessionOps.h"
- #include "ui/ClipGridComponent.h"
- #include "ui/ArticulatorTools.h"
- #include "ui/ExternalDrag.h"
- #include "ui/LabelFont.h"
- #include "ui/SessionMixer.h"
- #include "core/FlSamplers.h"
- #include "core/ArrangeOps.h"
- #include "core/ClipSample.h"
- #include "core/WarpModes.h"
- #include "ui/ClipAudioPanel.h"
- #include "core/DetailChain.h"
- #include "core/SessionMixer.h"
- #include "core/PlaylistOps.h"
- #include "core/LastTweaked.h"
- #include "core/ClipOps.h"
- #include "core/TransportEdit.h" // (round 190jz: --issueshot190jz)
- #include "core/SamplerPage.h"
- #include "core/FlTrackMenus.h"
- #include "core/FlClipMenu.h"
- #include "core/OneClickRec.h"
- #include "core/WarpTools.h"
- #include "core/Comping.h"
- #include "core/ExportSilence.h"
- #include "core/Drumaxx.h"
- #include "core/PatternBlocks.h"
- #include "core/LoadTrace.h"
- #include "core/ProjectSafety.h"
- #include "core/Patcher.h"
- #include "core/Rack.h"
- #include "ui/RackEditor.h"
- #include "ui/HelixEditor.h"
- #include "ui/LynxModelEditor.h"
- #include "core/physmod/LynxModel.h"
- #include "core/PluginCatalog.h"
- #include "engine/GeneratorCatalog.h"
- #include "core/AlsDevices.h"
- #include "core/XmlLite.h"
- #include "ui/DrumRackShot.h"
- #include "ui/GroovePoolComponent.h"
- #include "core/Patcherize.h"
- #include "core/Performance.h"
- #include "core/VideoPlayer.h"
- #include "core/Effects.h"
- #include "core/MixSuite.h"
- #include "core/LowLifterFl.h" // (rollup step 12: the 0.1.28 copy item)
- #include "core/HardwareInsert.h"
- #include "core/EchoSuite.h"
- #include "core/LuxeVerb.h"
- #include "core/LynxVerbs.h"
- #include "core/LynxTune.h"
- #include "core/FlEffects.h"
- #include "core/FlpImport.h"
- #include "core/NoteEdit.h"
- #include "core/PlaylistTrackOps.h" // round 190jf (FoldersShot190jf.inc)
- #include "ui/DawProjectExport.h" // round 190jf (--dawprojcheck190jf)
- #include "ui/FlmExportDialog.h" // round 190og (--export-flm, --flmexportshot)
- #include "core/NoteNames.h"
- #include "core/MaximusFx.h"
- #include "core/ChainPresets.h"
- #include "core/GoalKnobs.h"
- #include "core/MasterLooks.h"
- #include "core/Harmor.h"
- #include "core/KiloheartsDsp.h" // (rollup step 14: the copy for 0.1.28 self-test)
- #include "core/ThreeOsc.h" // (rollup 0.1.32 step 1: the copy for 0.1.31 self-test)
- #include "core/WavetableSynth.h" // (round 190oc: the copy for 0.1.30 self-test)
- #include "core/AutoLook.h" // (rollup 0.1.31 step 4: the copy for 0.1.30 self-test)
- #include "flp/Flp.h"
- #include "flp/FlpWrite.h" // round 190qs (issue #282 self-test)
- #include "core/DemoSongs.h"
- #include "core/FirstSongTour.h"
- #include "core/PerfProjects.h"
- #include "core/ShowcaseSong.h"
- #include "core/RenderAhead.h"
- #include "core/SynthPresets.h"
- #include "core/FlWrapper.h"
- #include "engine/AudioEngine.h"
- #include "engine/ProjectDowngrade.h"
- #include "engine/RemoteNotes.h" // (round 190pm: --selftest repeats190pm)
- #include "core/NoteConditions.h" // (round 190pm)
- #include "ui/TouchInput.h" // (round 190pm)
- #include "ui/TrackerComponent.h"
- #include "core/ClipLauncher.h"
- #include "core/SimpleSteps.h"
- #include "core/DirectWaveState.h"
- #include "core/MixSnapshots.h"
- #include "core/VoiceShift.h"
- #include "core/PeakShapes.h" // rollup step 7: the copy for 0.1.28 self-test
- #include "core/DynamicsSuite.h"
- #include "core/TempoMarkers.h"
- #include "engine/RemoteControl.h"
- #include "engine/RemoteError.h"
- #include "ui/RemoteControlSettings.h"
- #include "engine/PreviewPlayer.h"
- #include "engine/Metronome.h"
- #include "engine/AudioLogger.h"
- #include "engine/DllAsioDevice.h"
- #include "engine/PipeWireDevice.h"
- #include "platform/LinuxRealtime.h"
- #include "engine/PowerHints.h"
- #include "engine/Exporter.h"
- #include "engine/AacEncoder.h"
- #include "engine/FlStudioExport.h"
- #include "engine/MidiFileIo.h"
- #include "core/MidiPreview.h" // round 190qi
- #include "core/PluginPicks.h" // round 190qi
- #include "engine/PluginHost.h"
- #include "engine/Vst3NoteTuning.h"
- #include "engine/PluginSandbox.h"
- #include "engine/Bridge32Test.h"
- #include "engine/ClapFormat.h"
- #include "engine/JsfxFormat.h"
- #include "engine/ClapTeardownTest.h"
- #include "engine/RenderAgainTest.h"
- #include "engine/Determinism190poTest.h"
- #include "ui/TiltViewport.h"
- #if JUCE_LINUX
- #include <dlfcn.h> // (round 190ou: --hwheel254test presses X11 buttons through XTest)
- #include <sys/prctl.h> // (round 190ou: --multieditor255test LYNX_ME_PTRACE=1)
- #include <sys/socket.h> // (round 190rf: --qa190rfchild display)
- #include <unistd.h>
- #endif
- #include "engine/HostingTests.h"
- #include "engine/Modulators190oxTest.h"
- #include "ui/ModRing.h"
- #include "core/EdisonFx.h"
- #include "engine/ProjectFile.h"
- #include "ui/RemoteControl.h"
- #include "core/FlControlMenus.h"
- #include "core/PlaylistOps.h"
- #include "core/Sha256.h"
- #include "engine/SessionPack.h"
- #include "engine/LiveSessions.h"
- #include "engine/LiveTest.h"
- #include "engine/ShortExportTest.h"
- #include "core/SessionIds.h"
- #include "core/SessionParts.h"
- #include "engine/SampleLibrary.h"
- #include "engine/Text.h"
- #include "platform/FileTypes.h"
- #include "platform/Package.h"
- #include "core/AlsExport.h"
- #include "core/AlsImport.h"
- #include "core/LiveScaleControl.h" // round 190oo (--design190ooshot)
- #include "core/PlaylistViewOptions.h"
- #include "core/PianoRollScript.h"
- #include "ui/ScriptPanel.h"
- #include "ui/AlsExportDialog.h"
- #include "ui/LiveRemoteUi.h"
- #include "ui/GamepadInput.h"
- #include "ui/SettingsPages.h"
- #include "core/ExtrasDefaults.h" // round 190qk (--selftest extras190qk)
- #include "ui/ExtendedHintPanel.h"
- #include "core/FlSettings.h"
- #include "ui/OtherAppsExport.h"
- #include "ui/TimerWhileShowing.h"
- #include "ui/MixerBasicsCheck.h"
- #include "ui/VideoPlayerView.h"
- #include "ui/VideoMedia.h"
- #include "ui/VideoTracks.h"
- #include "ui/AdrWindow.h"
- #include "ui/PluginPicker.h"
- #include "ui/PlaylistComponent.h"
- #include "ui/PictureCheck.h"
- #include "ui/PatternBlocksView.h"
- #include "ui/PaintAB.h"
- #include <typeinfo>
- #include "ui/PatcherEditor.h"
- #include "ui/VisualEditors.h"
- #include "ui/FlExtraEditors.h"
- #include "ui/VisualGl.h"
- #include "ui/DanceView.h"
- #include "ui/PluginPresetMenu.h"
- #include "ui/GeneratorPresetMenu.h"
- #include "core/GeneratorPresets.h"
- #include "ui/PluginWindow.h"
- #include "platform/NativeEmbed.h"
- #include "ui/Motion.h"
- #include "ui/ShotShowing.h"
- #include "ui/SimpleLook.h"
- #include "ui/NativeChild.h"
- #include "ui/FrameTicker.h"
- #include "ui/DockPaintCheck.h"
- #include "ui/Workspace.h"
- #include "ui/PluginThumbs.h"
- #include "ui/ClipProperties.h"
- #include "ui/NewProjectDialog.h"
- #include "ui/PluginMonitorWindow.h"
- #include "ui/TouchKeyboard.h"
- #include "ui/AutomationUi.h"
- #include "core/GrossBeatLocator.h"
- #include "ui/PluginSkin.h"
- #include "ui/ChannelSettings.h"
- #include "ui/TempoDetectionDialog.h"
- #include "ui/AudioClipboard.h"
- #include "ui/FlVoicePanel.h"
- #include "ui/SlicexEditor.h"
- #include "ui/DirectWaveEditor.h"
- #include "ui/FruitySlicerEditor.h"
- #include "core/GrossBeat.h"
- #include "core/LynxBanks.h"
- #include "core/NativeEngines.h"
- #include "ui/ControllerEditors.h"
- #include "ui/NewtoneEditor.h"
- #include "core/NewtoneFx.h"
- #include "core/FormulaController.h"
- #include "core/MidiControls.h"
- #include "core/FlSynths.h"
- #include "core/SoundFont.h"
- #include "core/Sfz.h"
- #include "core/Slicex.h"
- #include "ui/Dialogs.h"
- #include "ui/DialogFrame.h"
- #include "ui/FileChoosers.h"
- #include "ui/TrackIcons.h"
- #include "core/MeterScale.h"
- #include "core/RackOps.h"
- #include "core/RackAutomation.h" // round 190oo (PAT-7, --selftest rackauto190oo)
- #include "core/Layer.h"
- #include "core/XyController.h"
- #include "core/FlCurve.h"
- #include "core/ControlSurface.h"
- #include "core/VoltageController.h"
- #include "ui/Controllers164.h"
- #include "core/StandIns.h"
- #include "ui/ExportDialog.h"
- #include "ui/QuickAddPalette.h"
- #include "ui/I18n.h"
- #include "ui/KeyFocus.h"
- #include "core/TrackIconScale.h"
- #include "core/EscClose.h"
- #include "ui/MainComponent.h"
- #include "ui/LynxWindows.h" // --tabs2test190nz (issue #232 stage 2)
- #include "ui/WindowClipboard.h"
- #include "ui/SimpleDock.h"
- #include "core/ScaleKeys.h"
- #include "core/KeyFollow.h"
- #include "core/SoundLibrary.h"
- #include "ui/MidiToolsPanel.h"
- #include "ui/FrameProbe.h"
- #include "ui/MotionOverlay.h"
- #include "ui/UiTrace.h"
- #include "core/MixerOps.h"
- #include "ui/QuickPick.h"
- #include "core/FolderWatcher.h"
- #include "core/FruityDynamics.h"
- #include "core/PluginDbFolder.h"
- #include "core/NoteTools.h"
- #include "engine/ProjectPackage.h"
- #include "ui/SetupWizard.h"
- #include "ui/DemoMode.h" // (round 190np)
- #if JUCE_LINUX || JUCE_WINDOWS // (rollup 0.1.31 step 2: Windows too, so --onboard190npshot runs its async callbacks there)
- namespace juce::detail { bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages); } // juce_Messaging_linux / _windows.cpp (--onboard190npshot)
- #endif
- #include "ui/Onboarding.h"
- #include "engine/FlStudio.h"
- #include "ui/HistoryPanel.h"
- #include "ui/VersionsPanel.h"
- #include "ui/CleanVoiceMenu.h"
- #include "ui/LyricsPanel.h"
- #include "ui/ReferenceMatchPanel.h"
- #include "ui/StartFromPanel.h"
- #include "ui/FirstSongTour.h"
- #include "ui/PluginsOffPanel.h"
- #include "ui/MissingFilesDialog.h"
- #include "ui/SettingsDialog.h"
- #include "ui/PluginManager.h"
- #include "ui/ShortcutManager.h"
- #include "ui/NoteToolDialogs.h"
- #include "ui/ChordStripView.h" // round 190kd (--prchord190kd)
- #include "ui/ChordHelper.h" // round 190mc (--modal190mc)
- #include "core/KeyRegions.h" // round chord2_190nu (--selftest, --keys190nu)
- #include "core/TransistorBass.h" // round 190mc (--modal190mc)
- #include "core/ModelParams.h" // round 190mc (--modal190mc)
- #include "ui/EventEditor.h"
- #include "ui/AudioEditor.h"
- #include "ui/SampleProperties.h"
- #include "ui/TempoTapper.h"
- #include "ui/ProjectPickerView.h" // (round 190my)
- #include "ui/WindowPlaces.h" // (round 190oa)
- #include "ui/HintBar.h" // (round 190oa)
- #include "core/EventEdit.h"
- #include "core/FacetEq.h"
- #include "core/LimiterLaw.h" // (rollup step 9: the copy for 0.1.28 self-test)
- #include "core/ApexLimiter.h" // (rollup step 10: likewise)
- #include "core/Reeverb2.h"
- #include "core/VoiceTools.h"
- #include "platform/ThreadInstructions.h" // (rollup step 9: --paintbench counts instructions)
- #include "ui/FacetEqEditor.h"
- #include "core/RackRenderer.h"
- #include "ui/ProEditors.h"
- #include "ui/ParametricEqEditor.h"
- #include "ui/PluginEditors.h"
- #include "core/PluginLayout.h"
- #include "core/EffectPresets.h"
- #include "ui/PluginHeader.h"
- #include "core/Vfx.h"
- #include "core/TransistorBass.h"
- #include "ui/Splash.h"
- #include "core/ExportDone.h" // round 190qr (#280)
- #include "core/StartupSound.h" // round 190qr (#280)
- #include "core/ClipHandle.h" // round 190qr (#274)
- #include "core/ZoomAnchor.h" // round 190qr (#276)
- #include "ui/Theme.h"
- #include "ui/ThemeSettings.h"
- #include "ui/AutoLookEditor.h" // (round 190od, issue #239)
- #include "core/StartPage.h" // (round 190oq, issue #252)
- #include "core/MuteKeys.h"
- #include "core/AraRegions.h"
- #include "ui/StartPage.h"
- #include "ui/DeleteFade.h"
- #include "ui/AraMenu.h"
- #include "ui/WaveformView.h"
- #include "ui/WindowOwner.h"
- #include "ui/PluginKeysTest.h"
- #include "ui/ZOrder191Test.h"
- #include "ui/Toolbar.h"
- #include "ui/ToolWindow.h"
- #include "core/Details190mv.h" // (round 190mv)
- #include "platform/CrashGuard.h"
- #include "ui/CrashReporter.h"
- #include "ui/Updater.h"
- #include "ui/AudioCheck.h"
- #include "ui/StemExtract.h"
- #include "core/RegionLoop.h" // round 190jr: --bandlab190jrshot
- #include "core/FactoryContent.h" // round 190ke: --simplegb190keshot
- #include "core/KeyFollow.h" // round 190kx: --loopinfo190kxshot
- #include "core/LoopAnalysis.h"
- #include "../tests/LoopCorpus190kx.h" // (LYNX's own synthetic loops, written for the shot)
- #include "core/SongFade.h"
- #include "core/SoundLibrary.h"
- #include "core/SynthParams.h"
- #include "core/GoalKnobs.h"
- #include "core/DetailChain.h"
- #include "ui/FinishDock.h"
- #include "ui/SimpleDock.h"
- #include "ui/SimpleTuner.h"
- #include "ui/AudioToMidi.h"
- #include "ui/PolyEditor.h"
- #include "core/PolyEdit.h"
- #include "ui/ShotScale.h"
- #include "core/LaneView.h" // round 190iu
- #include "core/PlaylistTrackOps.h"
- #include "core/MidiDrop.h"
- #include "core/TakeCleanup.h"
- #include "core/TrackOnly.h"
- #include "core/WheelZones.h"
- #include "ui/WorkflowExtras.h"
- #include "core/Links.h"
- #include <algorithm>
- #include <set> // (round 190jf: --dawprojcheck190jf)
- #include <atomic>
- #include <exception>
- #include <chrono>
- #include <cstdio>
- #include <ctime>
- #include <cstdlib>
- #include <future>
- #include <mutex>
- #include <thread>
- namespace
- {
- lynx::AudioEngine* crashEngine = nullptr;
- // Startup trace (REA round 116): with LYNX_TRACE_STARTUP set, the time of each startup step since the C++ runtime
- // started is written to %APPDATA%\LYNX\startup.log (the loader's own time before that is not included).
- struct StartupTrace
- {
- using clock = std::chrono::steady_clock;
- const clock::time_point t0 = clock::now(); // static initialisation: no JUCE yet, standard library only
- const std::chrono::system_clock::time_point t0System = std::chrono::system_clock::now(); // (round 190hd: vs the process's creation)
- // (round 190go: always kept, as a field-readable start-up timeline; written to startup.log 5 s and 15 s after the
- // window — with LYNX_TRACE_STARTUP set, at every step as before, so a start that hangs still leaves its last step)
- const bool on = true;
- const bool eachStep = std::getenv ("LYNX_TRACE_STARTUP") != nullptr;
- juce::String text;
- clock::time_point last = t0;
- std::int64_t lastPrivate = 0;
- double seconds() const { return std::chrono::duration<double> (clock::now() - t0).count(); } // since the process started
- void mark (const char* step)
- {
- if (! on)
- return;
- const auto now = clock::now();
- const auto ms = [] (clock::duration d) { return std::chrono::duration<double, std::milli> (d).count(); };
- // (round 190gd: the process's memory after each step too, so the log says where the megabytes of a start go)
- const auto mb = [] (std::int64_t bytes) { return juce::String ((double) bytes / 1048576.0, 1).paddedLeft (' ', 7); };
- const auto priv = lynx::toolbar::PerformanceMeter::processPrivateBytes();
- const auto ws = lynx::toolbar::PerformanceMeter::processMemoryBytes();
- text << juce::String (ms (now - t0), 1).paddedLeft (' ', 8) << " ms +" << juce::String (ms (now - last), 1).paddedLeft (' ', 7)
- << " private " << mb (priv) << " MB (+" << mb (priv - lastPrivate).trim() << ") ws " << mb (ws) << " MB " << step << "\n";
- lastPrivate = priv;
- last = now;
- if (eachStep)
- write();
- }
- void write() const { lynx::platform::settingsFile ("startup.log").replaceWithText (text); }
- };
- StartupTrace startupTrace;
- void startupMarkHook (const char* step) { startupTrace.mark (step); }
- // Round 190rb: a sanitizer build (-DLYNX_SANITIZE) leaves SIGSEGV / SIGBUS / SIGFPE / SIGABRT to ASan and UBSan (their
- // report names the bad access and where the memory came from); LYNX_CRASHGUARD=1 installs LYNX's handlers anyway
- bool sanitizerOwnsSignals()
- {
- #if defined(LYNX_SANITIZER_BUILD)
- return juce::SystemStats::getEnvironmentVariable ("LYNX_CRASHGUARD", {}) != "1";
- #else
- return false;
- #endif
- }
- juce::File crashFolderForTest; // --faulttest: where the crash file goes instead of the settings' autosave folder
- // Crashed: try to save the project and write the backtrace (like FL's "emergency save").
- void onCrash (void* exceptionPointers)
- {
- // round 190oh (Windows): a fault on a hosted plugin's own thread that nothing handled — that thread waits for good
- // inside this call and the main window's timer switches the plugin off (crashguard::parkFaultingPluginThread)
- if (lynx::crashguard::parkFaultingPluginThread (exceptionPointers))
- return;
- // (round 190ci: once. The hook for stacks Windows cannot walk, crashguard::setUnwalkableFaultHandler, may have run
- // this before the top-level filter does)
- static std::atomic<bool> reported { false };
- if (reported.exchange (true))
- return;
- // rollup 0.1.30 step 12 (owner decision after round 190mo): whatever follows, the process ends within the watchdog's
- // time (60 s): after a heap corruption everything below that allocates can wait for ever on the allocator's lock
- lynx::crashguard::armCrashWatchdog (exceptionPointers);
- // ... and after the C library's (or Windows') heap-corruption abort, nothing that allocates runs at all: a crash file
- // written without the heap, no session note, no emergency save (the project in memory may be what was broken)
- if (lynx::crashguard::heapCorruptionCrash (exceptionPointers))
- {
- lynx::crashguard::writeHeapCrashFile (exceptionPointers);
- return;
- }
- const auto folder = crashFolderForTest != juce::File() ? crashFolderForTest : lynx::platform::settingsFile ("autosave");
- folder.createDirectory();
- const auto stamp = juce::Time::getCurrentTime().formatted ("%Y-%m-%d %H-%M-%S");
- // JUCE's backtrace (named frames only), then every frame of the faulting thread as module+offset (round 157a: a
- // release LYNX.exe has no symbols, so its own frames were missing from the file)
- folder.getChildFile ("crash " + stamp + ".txt").replaceWithText (juce::SystemStats::getStackBacktrace() + "\n--- frames (module+offset)\n"
- + juce::String::fromUTF8 (lynx::crashguard::exceptionBacktrace (exceptionPointers).c_str()));
- lynx::crashguard::note (("crashed: backtrace in autosave\\crash " + stamp + ".txt").toStdString());
- if (lynx::crashguard::hangInCrashHandlerForTest()) // (--faulttest hang: a handler that never returns; the watchdog ends it)
- for (;;)
- std::this_thread::sleep_for (std::chrono::seconds (1));
- if (crashEngine != nullptr)
- {
- juce::String error;
- lynx::ProjectFile::save (crashEngine->getSong(), folder.getChildFile ("recovered " + stamp + lynx::ProjectFile::extension), error);
- }
- }
- // Round 190rf (Linux): the X server went away (crashguard::watchDisplayConnection): the project in memory is saved as a
- // recovered project, as after a crash, before the process ends (it cannot go on without a display)
- void onDisplayLost()
- {
- if (crashEngine == nullptr)
- return;
- const auto folder = lynx::platform::settingsFile ("autosave");
- folder.createDirectory();
- juce::String error;
- lynx::ProjectFile::save (crashEngine->getSong(), folder.getChildFile ("recovered " + juce::Time::getCurrentTime().formatted ("%Y-%m-%d %H-%M-%S")
- + lynx::ProjectFile::extension), error);
- }
- juce::File sessionsFolder()
- {
- return lynx::PluginHost::settingsFolder().getChildFile ("sessions");
- }
- // Sessions of earlier runs whose process is gone without closing (a fail-fast, a crash, a forced end): each is appended
- // to %APPDATA%\LYNX\crash-history.log and its file removed. Returns the last step of the newest one ("" when none).
- juce::StringArray uncleanSteps; // the newest unclean session's steps (without their times)
- juce::String uncleanSessionText; // the newest unclean session's whole file (round 159: the crash report reads it)
- // What the newest unclean session tells (round 157a): the plugin whose editor was opening / shown when it ended, and
- // whether its crash file blames a graphics driver
- struct UncleanCause
- {
- juce::String editorPlugin; // the last steps were that plugin's editor
- bool gpuDriver = false; // the crash file's top frames are in a GPU driver / Direct3D / Direct2D module
- juce::String driverModule;
- };
- UncleanCause uncleanCause()
- {
- UncleanCause cause;
- juce::File crashFile;
- for (int i = uncleanSteps.size(); --i >= 0 && i >= uncleanSteps.size() - 4;)
- {
- const auto& step = uncleanSteps[i];
- if (step.startsWith ("crashed: backtrace in "))
- crashFile = lynx::platform::settingsFolder().getChildFile (step.fromFirstOccurrenceOf ("backtrace in ", false, false).replaceCharacter ('\\', '/'));
- for (const auto* prefix : { "opening the editor of ", "editor open: ", "editor shown: " })
- if (cause.editorPlugin.isEmpty() && step.startsWith (prefix))
- cause.editorPlugin = step.fromFirstOccurrenceOf (prefix, false, false).trim();
- if (step.startsWith ("closing the editor of ") || step.startsWith ("loaded plugin") || step.startsWith ("opening project"))
- break; // older steps than these did not end the session
- }
- // issue #32 (round 174a): a plugin whose editor already faulted in this session (caught, LYNX went on) is the
- // likely cause when the session then ended without a word: offer it a separate process too
- for (int i = uncleanSteps.size(); --i >= 0 && cause.editorPlugin.isEmpty();)
- if (const auto editor = lynx::crashreport::parseEditorCrashStep (uncleanSteps[i].toStdString()); ! editor.plugin.empty())
- cause.editorPlugin = juce::String::fromUTF8 (editor.plugin.c_str());
- if (crashFile.existsAsFile())
- {
- // the first frames after the crash handler's own (the "--- frames" part lists the faulting thread)
- auto text = crashFile.loadFileAsString();
- if (text.contains ("--- frames"))
- text = text.fromFirstOccurrenceOf ("--- frames", false, false);
- auto lines = juce::StringArray::fromLines (text);
- int looked = 0;
- for (const auto& line : lines)
- {
- const auto module = line.fromFirstOccurrenceOf (": ", false, false).upToFirstOccurrenceOf ("+", false, false).trim().toLowerCase();
- if (module.isEmpty() || ! module.endsWith (".dll"))
- continue;
- if (++looked > 12)
- break;
- for (const auto* driver : { "igd", "ig9icd", "ig7icd", "igxelp", "nvwgf2um", "nvoglv", "nvd3dum", "atidxx", "atio6axx", "amdxx", "aticfx",
- "d3d11.dll", "d3d10warp", "dxgi.dll", "d2d1.dll", "opengl32.dll", "dcomp.dll" })
- if (module.startsWith (driver))
- {
- cause.gpuDriver = true;
- cause.driverModule = module;
- break;
- }
- if (cause.gpuDriver)
- break;
- }
- }
- return cause;
- }
- juce::String collectUncleanSessions()
- {
- juce::String lastStep;
- juce::Time newest;
- for (const auto& file : sessionsFolder().findChildFiles (juce::File::findFiles, false, "session-*.txt"))
- {
- const auto text = file.loadFileAsString();
- juce::StringPairArray values;
- juce::StringArray steps;
- for (const auto& line : juce::StringArray::fromLines (text))
- {
- if (line.startsWith ("step="))
- steps.add (line.fromFirstOccurrenceOf ("=", false, false));
- else if (line.contains ("="))
- values.set (line.upToFirstOccurrenceOf ("=", false, false), line.fromFirstOccurrenceOf ("=", false, false));
- }
- const auto pid = (std::uint32_t) values["pid"].getLargeIntValue();
- const auto start = (std::uint64_t) values["start"].getLargeIntValue();
- if (pid == lynx::crashguard::processId() || lynx::crashguard::processRunning (pid, start))
- continue; // this run, or another LYNX window still open
- lynx::PluginHost::settingsFolder().getChildFile ("crash-history.log")
- .appendText (juce::Time::getCurrentTime().toISO8601 (true) + " previous session ended without closing\n" + text + "\n");
- file.deleteFile();
- if (const auto modified = file.getLastModificationTime(); lastStep.isEmpty() || modified > newest)
- {
- newest = modified;
- lastStep = steps.isEmpty() ? juce::String ("start-up") : steps[steps.size() - 1].fromFirstOccurrenceOf (" ", false, false);
- uncleanSessionText = text;
- uncleanSteps.clear();
- for (const auto& step : steps)
- uncleanSteps.add (step.fromFirstOccurrenceOf (" ", false, false));
- }
- }
- return lastStep;
- }
- } // namespace
- // --uiperf (round 173f, discussion #10): a mixer fader dragged up and down with the mouse while the pattern plays. A
- // high-resolution timer delivers 125 moves a second to the message thread through the window's own mouse path
- // (ComponentPeer::handleMouseEvent), at most one waiting at a time as Windows does with WM_MOUSEMOVE; every frame the
- // window paints tells whether it covered the fader. Measured: how long a move waited for the message thread, the time
- // from a move to the first frame that shows the fader after it (input → paint), and whether the value stays put when
- // the mouse is released.
- #if JUCE_WINDOWS
- namespace juce
- {
- extern int lynxD2DPresents; // (cmake/LynxPatchJuce.cmake, round 190gv: every Direct2D window present)
- }
- #endif
- // round 190jy: --uiperf's presents per second (190kb's cycles line reads it too)
- static int uiPerfPresents()
- {
- #if JUCE_WINDOWS
- return juce::lynxD2DPresents;
- #else
- return 0;
- #endif
- }
- struct UiPerfDrag final : public std::enable_shared_from_this<UiPerfDrag>,
- private juce::HighResolutionTimer
- {
- ~UiPerfDrag() override { stopTimer(); }
- void start (juce::Component& windowIn, juce::Component& strips, juce::Rectangle<int> rail, lynx::AudioEngine* engineIn, int trackIn)
- {
- window = &windowIn;
- engine = engineIn;
- track = trackIn;
- railInWindow = window->getLocalArea (&strips, rail);
- watch = railInWindow.expanded (6, 40); // the cap, its tip above and the dB read-out below
- visible = strips.isShowing() && window->getLocalArea (&strips, strips.getLocalBounds()).contains (railInWindow.getCentre());
- const auto volume = engine->getSong().mixer[(std::size_t) track].volume;
- x = (float) railInWindow.getCentreX();
- startY = (float) railInWindow.getBottom() - volume * (float) railInWindow.getHeight(); // on the cap: no jump
- amplitude = 0.4f * (float) railInWindow.getHeight();
- centreY = juce::jlimit ((float) railInWindow.getY() + amplitude, (float) railInWindow.getBottom() - amplitude, startY);
- t0 = juce::Time::getMillisecondCounterHiRes();
- inject (x, startY, false);
- juce::ModifierKeys::currentModifiers = juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier);
- inject (x, startY, true);
- active = true;
- startTimer (8);
- }
- // message thread
- void framePainted (double now, juce::Rectangle<int> area)
- {
- if (pending.empty() || ! area.intersects (watch))
- return;
- for (const auto t : pending)
- latencies.push_back (now - t);
- pending.clear();
- ++framesOverFader;
- }
- // the moves end; as in the reporter's clip, the song is stopped while the button is still down
- juce::String stop()
- {
- stopTimer();
- active = false;
- valueAtRelease = engine->getSong().mixer[(std::size_t) track].volume;
- engine->stop();
- juce::String text;
- text << " drag of insert " << track << "'s fader" << (visible ? "" : " (NOT VISIBLE)") << ": " << moves << " moves handled, " << dropped
- << " folded into the next (the message thread still busy with the previous one)\n"
- << " move waited for the message thread: " << describe (queueDelays) << "\n"
- << " input -> paint (move to the first frame over the fader): " << describe (latencies) << ", " << framesOverFader
- << " frames over the fader\n";
- return text;
- }
- juce::String release()
- {
- const auto now = engine->getSong().mixer[(std::size_t) track].volume;
- juce::ModifierKeys::currentModifiers = {};
- inject (x, lastY, false);
- return " song stopped, button still down: fader " + juce::String (now, 4) + " (" + juce::String (valueAtRelease, 4) + " at the last move) "
- + (std::abs (now - valueAtRelease) < 1.0e-4f ? "kept" : "CHANGED") + "\n";
- }
- juce::String released() const
- {
- const auto now = engine->getSong().mixer[(std::size_t) track].volume;
- return " after the release: fader " + juce::String (now, 4) + " (" + juce::String (valueAtRelease, 4) + " when released) "
- + (std::abs (now - valueAtRelease) < 1.0e-4f ? "kept" : "CHANGED") + "\n";
- }
- private:
- juce::Component* window = nullptr;
- lynx::AudioEngine* engine = nullptr;
- int track = 1;
- juce::Rectangle<int> railInWindow, watch;
- bool visible = false;
- float x = 0.0f, startY = 0.0f, centreY = 0.0f, amplitude = 0.0f, lastY = 0.0f;
- double t0 = 0.0;
- std::atomic<bool> active { false }, posted { false };
- std::atomic<int> dropped { 0 };
- int moves = 0, framesOverFader = 0;
- float valueAtRelease = 0.0f;
- std::vector<double> pending, latencies, queueDelays;
- static juce::String describe (std::vector<double> v)
- {
- if (v.empty())
- return "none";
- std::sort (v.begin(), v.end());
- const auto at = [&v] (double q) { return v[std::min (v.size() - 1, (std::size_t) (q * (double) v.size()))]; };
- return "p50 " + juce::String (at (0.5), 1) + " / p95 " + juce::String (at (0.95), 1) + " / p99 " + juce::String (at (0.99), 1) + " / max "
- + juce::String (v.back(), 1) + " ms";
- }
- void inject (float px, float py, bool down)
- {
- lastY = py;
- if (auto* peer = window != nullptr ? window->getPeer() : nullptr)
- {
- const auto local = peer->globalToLocal (window->localPointToGlobal (juce::Point<float> (px, py)));
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, local,
- down ? juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier) : juce::ModifierKeys(),
- juce::MouseInputSource::defaultPressure, juce::MouseInputSource::defaultOrientation,
- juce::Time::currentTimeMillis());
- }
- }
- void hiResTimerCallback() override
- {
- if (! active.load())
- return;
- if (posted.exchange (true))
- {
- ++dropped;
- return;
- }
- const auto postedAt = juce::Time::getMillisecondCounterHiRes();
- juce::MessageManager::callAsync ([self = shared_from_this(), postedAt] {
- self->posted = false;
- if (! self->active.load())
- return;
- const auto now = juce::Time::getMillisecondCounterHiRes();
- self->queueDelays.push_back (now - postedAt);
- // up and down ~1.3 times a second, like the reporter's hand
- const auto y = self->centreY + self->amplitude * (float) std::sin (2.0 * juce::MathConstants<double>::pi * 1.3 * (now - self->t0) / 1000.0);
- self->inject (self->x, y, true);
- self->pending.push_back (postedAt);
- ++self->moves;
- });
- }
- };
- class LynxApplication final : public juce::JUCEApplication
- {
- public:
- const juce::String getApplicationName() override { return JUCE_APPLICATION_NAME_STRING; }
- const juce::String getApplicationVersion() override { return JUCE_APPLICATION_VERSION_STRING; }
- // the plugin scan runs copies of LYNX as child processes
- bool moreThanOneInstanceAllowed() override { return true; }
- // A file handed to the running application. macOS does this for every Finder double-click, "Open With" and Dock drop,
- // also the one that starts LYNX (its argv has no file). On Windows and Linux a second start is a second process
- // (moreThanOneInstanceAllowed) with the file as an argument, so this is not called there. Only the first file of a
- // multiple selection opens: a project replaces the one before it. (D#92, round 180a)
- void anotherInstanceStarted (const juce::String& commandLine) override
- {
- const auto files = lynx::safety::filesInCommandLine (commandLine.toStdString());
- if (files.empty())
- return;
- const auto file = juce::File::getCurrentWorkingDirectory().getChildFile (juce::String::fromUTF8 (files.front().c_str()));
- if (! startupFileHandled) // still starting: openStartupFile takes it, nothing to ask about yet
- {
- fileToOpen = file;
- return;
- }
- if (mainWindow != nullptr)
- {
- mainWindow->toFront (true);
- mainWindow->getContent().openFileRequest (file);
- }
- }
- void initialise (const juce::String& commandLine) override
- {
- // round 190nx: --offline (or LYNX_OFFLINE=1) = no network connection of LYNX's own, before anything can start one
- if (juce::StringArray::fromTokens (commandLine, true).contains ("--offline"))
- lynx::offline::set (true);
- // round 166b: the copy of LYNX.exe that installs an update (ui/Updater.h) waits, installs, starts LYNX again
- if (commandLine.contains ("--apply-update") && lynx::updater::runApplyHelper (juce::StringArray::fromTokens (commandLine, true)))
- {
- updateHelper = true;
- quit();
- return;
- }
- // Windows, LYNX.exe in a folder with accents: run again from its ASCII short path (Waves editors crash otherwise)
- if (int code = 0; lynx::platform::relaunchFromAsciiPath (code))
- {
- relaunched = true;
- setApplicationReturnValue (code);
- quit();
- return;
- }
- // a crash in any mode (UI, command line) writes its backtrace to %APPDATA%\LYNX\autosave. A sanitizer build
- // (-DLYNX_SANITIZE, round 190rb) leaves the fault signals to ASan / UBSan, whose reports name the bad access,
- // unless LYNX_CRASHGUARD=1 asks for LYNX's own handlers (their tests)
- if (! sanitizerOwnsSignals())
- juce::SystemStats::setApplicationCrashHandler (onCrash);
- // rollup step 12: the crash handler's watchdog and its allocation-free crash file (platform/CrashGuard.h)
- lynx::crashguard::prepareCrashWatchdog (lynx::platform::settingsFile ("autosave").getFullPathName().toStdString());
- // rollup 0.1.28 (REA 190hb action 4, FL's "Init DWM"): the compositor on MMCSS, steadier frames under CPU load
- // (Windows; LYNX_DWM_MMCSS=0 leaves it off)
- lynx::powerhints::enableCompositorMmcss();
- // round als190ka (issue #193): a video's sound track for the sample library (a Live set's video clips)
- lynx::SampleLibrary::setVideoSoundDecoder ([] (const juce::File& video) { return lynx::videotracks::soundTrackWav (video); });
- // round 190ci: also for a fault on a stack Windows cannot walk, which never reaches that handler (Windows)
- lynx::crashguard::setUnwalkableFaultHandler (onCrash);
- if (const auto args = juce::StringArray::fromTokens (commandLine, true); args.contains ("--faulttest"))
- {
- // LYNX.exe --faulttest plain|unwalkable <folder> (round 190ci): ends by an access violation on purpose,
- // before any window, so that --selftest can check that the crash file gets written (into <folder>)
- const auto i = args.indexOf ("--faulttest");
- crashFolderForTest = juce::File (args[i + 2].unquoted());
- lynx::crashguard::setCrashFolder (crashFolderForTest.getFullPathName().toStdString());
- lynx::crashguard::quietCrashReports();
- // rollup step 12: heap = the C library's heap-corruption abort (no recovered project may be written: an
- // engine is set for the emergency save on purpose); hang = a crash handler that never returns (the watchdog
- // must end the process: LYNX_CRASH_WATCHDOG_S makes the test short)
- if (args[i + 1] == "heap" || args[i + 1] == "hang")
- {
- static lynx::AudioEngine* engine = new lynx::AudioEngine (false);
- crashEngine = engine;
- if (args[i + 1] == "heap")
- lynx::crashguard::heapCorruptionForTest();
- lynx::crashguard::setHangInCrashHandlerForTest();
- lynx::crashguard::faultForTest (false);
- }
- // round 190dt: guarded / guarded-libc = LYNX's own fault inside a guarded plugin call (Linux / macOS): it must
- // reach the crash handler like any other; a return means the guard swallowed it
- // round 190gg: thread / thread-libc = a fault on a thread of LYNX's own, with LYNX's executable watched as
- // a plugin's module: it must not be parked as a plugin's thread
- if (args[i + 1].startsWith ("thread"))
- {
- lynx::crashguard::faultOnOwnThreadForTest (args[i + 1] == "thread-libc");
- crashFolderForTest.getChildFile ("swallowed.txt").replaceWithText ("parked");
- lynx::crashguard::exitNow (4);
- }
- if (args[i + 1].startsWith ("guarded"))
- {
- const auto code = lynx::crashguard::faultInGuardedCallForTest (args[i + 1] == "guarded-libc");
- crashFolderForTest.getChildFile ("swallowed.txt").replaceWithText (lynx::crashguard::describe (code));
- lynx::crashguard::exitNow (4);
- }
- lynx::crashguard::faultForTest (args[i + 1] == "unwalkable");
- }
- if (! sanitizerOwnsSignals())
- lynx::crashguard::hardenSignals(); // issue #115: stack overflows and SIGTERM / SIGHUP leave a trace (Linux / macOS)
- // SFZ instruments (round 167o): their FLAC / OGG / AIFF / MP3 samples through JUCE's readers
- lynx::sfz::setDecoder ([] (const std::string& path, lynx::sfz::Audio& out) {
- juce::AudioFormatManager formats;
- formats.registerBasicFormats();
- std::unique_ptr<juce::AudioFormatReader> reader (formats.createReaderFor (juce::File (juce::String::fromUTF8 (path.c_str()))));
- if (reader == nullptr || reader->lengthInSamples <= 0 || reader->lengthInSamples > (1 << 28) || reader->numChannels == 0)
- return false;
- const auto frames = (int) reader->lengthInSamples;
- juce::AudioBuffer<float> buffer ((int) std::min (2u, reader->numChannels), frames);
- if (! reader->read (&buffer, 0, frames, 0, true, buffer.getNumChannels() > 1))
- return false;
- out.channels.clear();
- for (int ch = 0; ch < buffer.getNumChannels(); ++ch)
- out.channels.emplace_back (buffer.getReadPointer (ch), buffer.getReadPointer (ch) + frames);
- out.sampleRate = reader->sampleRate;
- out.loopStart = out.loopEnd = -1;
- return true;
- });
- // child process of a sandboxed plugin: no window or audio of its own
- if (lynx::runPluginSandboxWorker (commandLine))
- {
- lynx::crashguard::quietCrashReports();
- sandboxChild = true;
- return;
- }
- // --shot-scale <v> / --shot-suffix <text> (round 190bi, ui/ShotScale.h): the pixel scale and file-name suffix of every
- // picture route, taken out here so the routes' own arguments keep their places
- const auto args = lynx::shot::takeArguments (juce::StringArray::fromTokens (commandLine, true));
- // round 190np: whether this profile already had LYNX's UI settings before this start (an upgrade keeps what it had:
- // no welcome card), and --demo (ui/DemoMode.h: the tutorial-video pipeline's automation mode)
- lynx::onboardui::profileExistedAtStart() = lynx::PluginHost::settingsFolder().getChildFile ("ui-options.txt").existsAsFile();
- if (args.contains ("--demo"))
- lynx::demo::setActive (true);
- // interface language: saved in %APPDATA%\LYNX\language.txt; --lang pt-BR overrides it for this run
- lynx::i18n::initialise (args);
- // interface font: saved in Settings › General; --uifont "Name" overrides it for this run
- const auto uiFontArg = args.indexOf ("--uifont");
- lookAndFeel.applyInterfaceFont (lynx::i18n::current(), uiFontArg >= 0 ? args[uiFontArg + 1].unquoted() : juce::String());
- // text size (issue #189): saved in Settings › General; --textsize 125 overrides it for this run
- const auto textSizeArg = args.indexOf ("--textsize");
- lynx::theme::setTextSize (textSizeArg >= 0 ? args[textSizeArg + 1].getIntValue() : lynx::theme::savedTextSize());
- // bold text (round 190jp): saved in Settings › General; --boldtext 1 (labels) or 2 (all) overrides it for this run
- const auto boldTextArg = args.indexOf ("--boldtext");
- lynx::theme::setBoldText (boldTextArg >= 0 ? args[boldTextArg + 1].getIntValue() : lynx::theme::savedBoldText());
- // round 190je: FL-style condensed labels (Settings › General); --condensedlabels for one run. --menustyle flClassic: FL's
- // light menus for one run (Settings › Theme keeps the saved choice)
- lynx::theme::setCondensedLabels (args.contains ("--condensedlabels") || lynx::theme::savedCondensedLabels());
- if (const auto menuStyleArg = args.indexOf ("--menustyle"); menuStyleArg >= 0)
- {
- lynx::theme::menus::setStyle (lynx::themes::menuStyleFromId (args[menuStyleArg + 1].unquoted().toStdString()));
- lookAndFeel.refreshColours();
- }
- if (args.contains ("--showcase"))
- {
- // LYNX's own demo project (README screenshots): --showcase output.lynx [pattern]
- const auto i = args.indexOf ("--showcase");
- runShowcase (args[i + 1].unquoted(), args[i + 2].getIntValue());
- return;
- }
- if (args.contains ("--demosongs"))
- {
- // round 190dv: LYNX's two short genre demos (core/DemoSongs.h) as .lynx files: --demosongs <folder>
- // (resources/demos/ in the repository)
- const auto i = args.indexOf ("--demosongs");
- runDemoSongs (args[i + 1].unquoted());
- return;
- }
- if (args.contains ("--perfgen"))
- {
- // round perfgate190id: the big-project performance gate's synthetic projects (core/PerfProjects.h) as .lynx
- // files with their WAVs: --perfgen <folder> [report.txt] [name,name...]; the save and load times in the report
- const auto i = args.indexOf ("--perfgen");
- const auto report = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- const auto only = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- runPerfGen (args[i + 1].unquoted(), report, only);
- return;
- }
- if (args.contains ("--sandboxtest"))
- {
- const auto i = args.indexOf ("--sandboxtest");
- runSandboxTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- // round 190jg (BUILD-LIST 11 + 18, engine/HostingTests.h): grouped plugin processes, CLAP extensions, timing
- if (args.contains ("--sandboxgrouptest") || args.contains ("--sandboxbench") || args.contains ("--clapext")
- || args.contains ("--automationtimingtest") || args.contains ("--pluginbench"))
- {
- const auto value = [&args] (const char* name, int fallback) {
- return args.contains (name) ? args[args.indexOf (name) + 1].getIntValue() : fallback;
- };
- auto code = 1;
- if (const auto i = args.indexOf ("--sandboxgrouptest"); i >= 0)
- code = lynx::runSandboxGroupTest (args[i + 1].unquoted(), args[i + 2].unquoted(),
- args.contains ("--crash") ? args[args.indexOf ("--crash") + 1].unquoted() : juce::String());
- else if (const auto b = args.indexOf ("--sandboxbench"); b >= 0)
- code = lynx::runSandboxBench (args[b + 1].unquoted(), args[b + 2].unquoted(), value ("--plugins", 8), value ("--block", 256),
- args.contains ("--seconds") ? args[args.indexOf ("--seconds") + 1].getDoubleValue() : 5.0);
- else if (const auto pb = args.indexOf ("--pluginbench"); pb >= 0) // round 190of: per-plugin cost (engine/HostingTests.h)
- code = lynx::runPluginBench (args[pb + 1].unquoted(), args[pb + 2].unquoted(), value ("--block", 256),
- args.contains ("--rate") ? args[args.indexOf ("--rate") + 1].getDoubleValue() : 48000.0,
- args.contains ("--seconds") ? args[args.indexOf ("--seconds") + 1].getDoubleValue() : 4.0, value ("--types", 8),
- args.contains ("--names") ? args[args.indexOf ("--names") + 1].unquoted() : juce::String(),
- args.contains ("--editors"));
- else if (const auto c = args.indexOf ("--clapext"); c >= 0)
- code = lynx::runClapExtTest (args[c + 1].unquoted(), args[c + 2].unquoted());
- else if (const auto t = args.indexOf ("--automationtimingtest"); t >= 0)
- code = lynx::runAutomationTimingTest (args[t + 1].unquoted(), args[t + 2].unquoted());
- setApplicationReturnValue (code);
- quit();
- return;
- }
- if (args.contains ("--bridge32test"))
- {
- // LYNX.exe --bridge32test "LYNX Test Synth 32.dll" report.txt [--compare "LYNX Test Synth.dll"] (round 176a):
- // the 32-bit plugin bridge (engine/Bridge32Test.cpp)
- const auto i = args.indexOf ("--bridge32test");
- const auto compare = args.contains ("--compare") ? args[args.indexOf ("--compare") + 1].unquoted() : juce::String();
- setApplicationReturnValue (lynx::runBridge32Test (args[i + 1].unquoted(), args[i + 2].unquoted(), compare));
- quit();
- return;
- }
- if (args.contains ("--rtstress"))
- {
- // LYNX.exe --rtstress project.(flp|lynx) report.txt [seconds] [--buffer N] [--type "driver type"] [--device "output"]
- // [--no-window] [--record take.wav]: the real app (window, audio device) plays the project and reports the callbacks
- // that missed their deadline (REA round 87); --type/--device pick another driver for this run only (round 97);
- // --record also records the input during the run, like Rec + Play, and moves the take to take.wav (round 106)
- const auto i = args.indexOf ("--rtstress");
- const auto seconds = args[i + 3].getDoubleValue();
- const auto buffer = args.contains ("--buffer") ? args[args.indexOf ("--buffer") + 1].getIntValue() : 0;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto option = [&args] (const char* name) { return args.contains (name) ? args[args.indexOf (name) + 1].unquoted() : juce::String(); };
- runRealtimeStress (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()), seconds > 0.0 ? seconds : 30.0, buffer,
- option ("--type"), option ("--device"), option ("--record"));
- return;
- }
- if (args.contains ("--renderaheadtest"))
- {
- // LYNX --renderaheadtest report.txt [project.flp|.lynx ...] [--buffer N] [--seconds S] (round 190gq): the engine's
- // own device callback (a stand-in device driven block by block, as --cliplooptest) plays the showcase song (from
- // the start, round a loop region that wraps mid-block, in Pattern mode) and each project with Options › Audio
- // settings › "Render ahead" off, then on. The two outputs must be the same to the bit, nothing rendered ahead
- // may be dropped, and most blocks must come from the ring. No window, no audio device.
- const auto i = args.indexOf ("--renderaheadtest");
- juce::StringArray projects;
- for (int k = i + 2; k < args.size() && ! args[k].startsWith ("--"); ++k)
- projects.add (args[k].unquoted());
- const auto buffer = args.contains ("--buffer") ? args[args.indexOf ("--buffer") + 1].getIntValue() : 128;
- const auto seconds = args.contains ("--seconds") ? args[args.indexOf ("--seconds") + 1].getDoubleValue() : 12.0;
- runRenderAheadTest (juce::File (args[i + 1].unquoted()), projects, juce::jlimit (16, 2048, buffer), seconds > 0.0 ? seconds : 12.0);
- return;
- }
- if (args.contains ("--cliplooptest"))
- {
- // LYNX --cliplooptest report.txt [export.wav] (round 167q, issue #25: 0.1.21 drew the repeats of a stretched
- // pattern clip but played the pattern once). The real engine's device callback (a stand-in device, driven
- // block by block) plays a synth's 1-bar pattern in a 4-bar clip: every repeat must sound as bar 1, also
- // starting inside a repeat, after a jump mid-clip and in a loop region; the WAV export (written to
- // export.wav and read back) the same. With the LYNX extra off, bars 2-4 must be silent (FL's behaviour).
- const auto i = args.indexOf ("--cliplooptest");
- runClipLoopTest (juce::File (args[i + 1].unquoted()), args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? juce::File (args[i + 2].unquoted()) : juce::File());
- return;
- }
- if (args.contains ("--devicechangetest"))
- {
- // LYNX --devicechangetest report.txt [switches] [--plugin file]... (round 190c, issue #134: changing the
- // output device with a project open crashed LYNX). The engine plays a project of every instrument and effect
- // it can make here on stand-in devices with real callback threads, while the output device, its sample
- // rate and its buffer size change the way Settings > Audio changes them (8 kHz mono to 192 kHz, buffers of
- // 32 to 16384 samples, a device plugged in, the open one unplugged, one that refuses to open). After every
- // change the song must sound, finite, at the new rate. No window, no real audio or MIDI device.
- const auto i = args.indexOf ("--devicechangetest");
- const juce::File report (args[i + 1].unquoted());
- const auto switches = args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? args[i + 2].getIntValue() : 0;
- juce::StringArray plugins;
- for (int k = 0; k + 1 < args.size(); ++k)
- if (args[k] == "--plugin")
- plugins.add (args[k + 1].unquoted());
- auto text = std::make_shared<juce::String>();
- // --quick: the selftest's handful of instruments and effects instead of every one
- const auto result = lynx::AudioEngine::deviceChangeSelfTest (switches > 0 ? switches : 40, ! args.contains ("--quick"), plugins, [report, text] (const juce::String& line) {
- *text << line << "\n";
- report.replaceWithText (*text + "(running)\n"); // what was reached, if it crashes
- });
- *text << "device_change=" << result << "\nresult=" << (result.startsWith ("OK") ? "OK" : "FAILED") << "\n";
- report.replaceWithText (*text);
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--exportlivetest"))
- {
- // LYNX --exportlivetest report.txt [--plugin file]... (round 190jb): exports with the live plugin instances (as
- // FL renders) against playback on a stand-in device, the plugins given back afterwards. No window.
- const auto i = args.indexOf ("--exportlivetest");
- const juce::File report (args[i + 1].unquoted());
- juce::StringArray files;
- for (int k = 0; k + 1 < args.size(); ++k)
- if (args[k] == "--plugin")
- files.add (args[k + 1].unquoted());
- juce::String text;
- const auto result = lynx::AudioEngine::exportLiveSelfTest ([&text] (const juce::String& line) { text << line << "\n"; }, files);
- text << "export_live=" << result << "\nresult=" << (result.startsWith ("OK") ? "OK" : "FAILED") << "\n";
- report.replaceWithText (text);
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--sharetest"))
- {
- // LYNX --sharetest <folder> <case> report.txt (round 190ks): the memory 8 identical SoundFont / Sampler channels
- // cost (LYNX_CONTENT_SHARE=0: byte copies held separately, as before). No window.
- const auto i = args.indexOf ("--sharetest");
- const auto result = lynx::AudioEngine::shareMemorySelfTest (juce::File (args[i + 1].unquoted()), args[i + 2].unquoted());
- juce::File (args[i + 3].unquoted()).replaceWithText ("share=" + result + "\nresult=" + (result.startsWith ("OK") ? "OK" : "FAILED") + "\n");
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--padrectest"))
- {
- // LYNX --padrectest "<LYNX Test Pads.vst3>" report.txt (round 190ks, GitHub #198): a take records the notes a
- // hosted plugin plays from its own window (the live engine on a stand-in device). No window.
- const auto i = args.indexOf ("--padrectest");
- const auto result = lynx::AudioEngine::padRecordSelfTest (args[i + 1].unquoted());
- juce::File (args[i + 2].unquoted()).replaceWithText ("pad_record=" + result + "\nresult=" + (result.startsWith ("OK") ? "OK" : "FAILED") + "\n");
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--midiouttest"))
- {
- // LYNX --midiouttest report.txt (round 190jl): MIDI Out channels to the hardware MIDI outputs on their port
- // (the sender's dry run and the live engine on a stand-in device). No window.
- const auto i = args.indexOf ("--midiouttest");
- const auto result = lynx::AudioEngine::midiOutPortSelfTest();
- juce::File (args[i + 1].unquoted()).replaceWithText ("midi_out_ports=" + result + "\nresult=" + (result.startsWith ("OK") ? "OK" : "FAILED") + "\n");
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--aratest"))
- {
- // LYNX --aratest <plugin.vst3> <audio.wav> <out folder> [project.lynx] (round 190kx, engine/AraTest.cpp): ARA 2
- // hosting end to end (a plain clip vs the clip in the ARA plugin, the document archived and restored). No window.
- const auto i = args.indexOf ("--aratest");
- const juce::File out (args[i + 3].unquoted());
- juce::String text;
- const auto result = lynx::araSelfTest (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()), out,
- args.size() > i + 4 ? juce::File (args[i + 4].unquoted()) : juce::File(),
- [&text, out] (const juce::String& line) {
- text << line << "\n";
- out.getChildFile ("aratest.txt").replaceWithText (text + "(running)\n");
- });
- text << "ara=" << result << "\nresult=" << (result.startsWith ("OK") ? "OK" : "FAILED") << "\n";
- out.getChildFile ("aratest.txt").replaceWithText (text);
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--exportparitytest") || args.contains ("--midihotplugtest"))
- {
- // LYNX --exportparitytest report.txt (round 190gh, B7): the export against playback through a stand-in audio
- // device, stems adding up to the mix with one length, the PDC trim. LYNX --midihotplugtest report.txt (B8):
- // MIDI devices plugged in and out (stand-in device lists) while messages arrive. No window.
- const auto parity = args.contains ("--exportparitytest");
- const auto i = args.indexOf (parity ? "--exportparitytest" : "--midihotplugtest");
- const juce::File report (args[i + 1].unquoted());
- juce::String text;
- const auto result = parity ? lynx::AudioEngine::exportParitySelfTest ([&text] (const juce::String& line) { text << line << "\n"; })
- : lynx::AudioEngine::midiHotplugSelfTest();
- text << (parity ? "export_parity=" : "midi_hotplug=") << result << "\nresult=" << (result.startsWith ("OK") ? "OK" : "FAILED") << "\n";
- report.replaceWithText (text);
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--shortexportstress"))
- {
- // LYNX --shortexportstress report.txt [count] [--seed N] [--no-realtime] [--plugin file] (round 190hn, issue #138): `count`
- // random export settings over short sounds at the very start of the song, each exported again a bar later; a
- // file that comes out silent or quieter fails (engine/ShortExportTest.h). No window.
- const auto i = args.indexOf ("--shortexportstress");
- const juce::File report (args[i + 1].unquoted());
- const auto count = args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? args[i + 2].getIntValue() : 200;
- const auto s = args.indexOf ("--seed");
- const auto seed = s >= 0 && s + 1 < args.size() ? args[s + 1].getLargeIntValue() : juce::Time::currentTimeMillis();
- auto text = std::make_shared<juce::String>();
- const auto pl = args.indexOf ("--plugin");
- lynx::shortexport::stress (count, seed, ! args.contains ("--no-realtime"), pl >= 0 && pl + 1 < args.size() ? args[pl + 1].unquoted() : juce::String(),
- [report, text] (const juce::String& line) {
- *text << line << "\n";
- report.replaceWithText (*text + "(running)\n");
- },
- [this, report, text] (juce::String result) {
- *text << "short_export_stress=" << result << "\nresult=" << (result.startsWith ("OK") ? "OK" : "FAILED") << "\n";
- report.replaceWithText (*text);
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- });
- return;
- }
- if (args.contains ("--shortexporttest"))
- {
- // LYNX --shortexporttest report.txt [repeats] [--plugin file]... (round 190c, issue #138: a short note at
- // the very start of the Playlist exported quiet). Every instrument LYNX can make here, and a synth with
- // effects, tail modes, normalising and other rates, exported through the Export window's path (the job
- // made on the message thread, run on its own thread, the message loop running) with a 2-second note at
- // tick 0 and again with it at bar 2: the note must come out the same. No window.
- const auto i = args.indexOf ("--shortexporttest");
- const juce::File report (args[i + 1].unquoted());
- const auto repeats = args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? args[i + 2].getIntValue() : 0;
- juce::StringArray plugins;
- for (int k = 0; k + 1 < args.size(); ++k)
- if (args[k] == "--plugin")
- plugins.add (args[k + 1].unquoted());
- auto text = std::make_shared<juce::String>();
- lynx::shortexport::run (! args.contains ("--quick"), repeats > 0 ? repeats : 3, plugins, // (--quick: a handful of instruments, round 190hn)
- [report, text] (const juce::String& line) {
- *text << line << "\n";
- report.replaceWithText (*text + "(running)\n");
- },
- [this, report, text] (juce::String result) {
- *text << "short_export=" << result << "\nresult=" << (result.startsWith ("OK") ? "OK" : "FAILED") << "\n";
- report.replaceWithText (*text);
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- });
- return;
- }
- if (args.contains ("--slicexedittest"))
- {
- // LYNX --slicexedittest project script.txt report.txt [png-prefix] (round 190aj): the Slicex editor of the
- // project's first Slicex channel, off screen, driven by the script's commands (ui/SlicexEditor.h; mouse
- // gestures at fractions of the deck's width, the menu entries, shortcuts). The report holds each command
- // and what the state held after it; "shot <name>" writes <png-prefix><name>.png.
- const auto i = args.indexOf ("--slicexedittest");
- runSlicexEditTest (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()), juce::File (args[i + 3].unquoted()),
- args.size() > i + 4 ? args[i + 4].unquoted() : juce::String());
- return;
- }
- if (args.contains ("--dwedittest"))
- {
- // LYNX --dwedittest project script.txt report.txt [png-prefix] (round 190hz): the DirectWave editor of the
- // project's first DirectWave channel, off screen, driven by the script's commands (ui/DirectWaveEditor.h);
- // "shot <name>" writes <png-prefix><name>.png. A project path "new" makes a new DirectWave channel.
- const auto i = args.indexOf ("--dwedittest");
- runDirectWaveEditTest (args[i + 1].unquoted(), juce::File (args[i + 2].unquoted()), juce::File (args[i + 3].unquoted()),
- args.size() > i + 4 ? args[i + 4].unquoted() : juce::String());
- return;
- }
- if (args.contains ("--slicexkeytest"))
- {
- // LYNX --slicexkeytest report.txt (round 190ac): what a click on the Slicex editor's keyboard sends
- // (AudioEngine::sendLiveNote on the channel, velocity 100/128) through the real engine's device callback
- // (a stand-in device, driven block by block): the key's region must sound, on the channel's mixer meter
- // too, another key must play another region, and the note-off must end it.
- runSlicexKeyTest (juce::File (args[args.indexOf ("--slicexkeytest") + 1].unquoted()));
- return;
- }
- if (args.contains ("--countinrectest"))
- {
- // LYNX --countinrectest report.txt (round 170d, the Busy Works video: the chord on the downbeat after the
- // pre-count was lost). The real engine's device callback (a stand-in device: 48 kHz, blocks of 512, 256
- // samples of output latency) records a Song-mode take from bar 3 with a 1-bar count-in. Pass 1 finds where
- // the metronome's bar-3 click is heard; pass 2 plays MIDI notes stamped at the times they are heard around
- // it (a chord 15 ms early, a note in the count-in, one 3 ms after beat 2, one a bar for 6 bars) through
- // LYNX's MIDI input. Every note must land on the tick it was heard at (the chord on bar 3).
- const auto i = args.indexOf ("--countinrectest");
- runCountInRecordTest (juce::File (args[i + 1].unquoted()));
- return;
- }
- if (args.contains ("--bendrectest"))
- {
- // LYNX --bendrectest report.txt [song|pattern] (round 167a, issue #12): pitch bend recording end to end. A
- // controller's pitch wheel is injected into LYNX's MIDI input (as a device would send it) while recording
- // plays: a held note and a wheel sweep 0 → full up → full down → centre. The recorded lane (pattern mode) or
- // automation clip (song mode) of the channel's pitch bend must follow the sweep.
- const auto i = args.indexOf ("--bendrectest");
- const auto songMode = args.size() > i + 2 && args[i + 2] == "song";
- runBendRecordTest (juce::File (args[i + 1].unquoted()), songMode);
- return;
- }
- if (args.contains ("--rectest"))
- {
- // LYNX --rectest report.txt [seconds] [--type T] [--device D] [--input I] [--loop] [--buffer N]
- // (round 163): records a click track through a loopback (cable, interface loopback or PipeWire's
- // pw-loopback): pings the round trip, plays a click on every beat from an audio clip, records it on Insert 1,
- // stops, and checks every recorded click's song position on the Playlist against its beat (samples).
- // --loop: loop recording over bars 2-4 (take lanes). --punch: punch in/out on bars 3-4 with 1 bar of pre-roll
- // and 1 of post-roll (playback stops by itself after the post-roll).
- const auto i = args.indexOf ("--rectest");
- const auto option = [&args] (const char* name) { return args.contains (name) ? args[args.indexOf (name) + 1].unquoted() : juce::String(); };
- const auto seconds = args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? args[i + 2].getDoubleValue() : 20.0;
- runRecordTest (juce::File (args[i + 1].unquoted()), seconds > 0.0 ? seconds : 20.0, option ("--type"), option ("--device"), option ("--input"),
- args.contains ("--loop") ? 1 : args.contains ("--punch") ? 2 : 0, option ("--pdc").getIntValue(), option ("--buffer").getIntValue());
- return;
- }
- if (args.contains ("--hwinserttest"))
- {
- // LYNX --hwinserttest report.txt [seconds] [--type T] [--device D] [--input I] [--buffer N] (round 164d): a
- // hardware insert through a loopback cable (output pair 1-2 -> input pair 1-2; the Master plays nowhere, so
- // the cable carries the send only). The same click track plays on two inserts: Insert 1 through the
- // hardware insert (panned left), Insert 2 dry (panned right). The insert's own ping measures the round
- // trip, PDC delays the dry path by it, and every click of the Master's left side must sit on the same
- // sample as the right side's.
- const auto i = args.indexOf ("--hwinserttest");
- const auto option = [&args] (const char* name) { return args.contains (name) ? args[args.indexOf (name) + 1].unquoted() : juce::String(); };
- const auto seconds = args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? args[i + 2].getDoubleValue() : 10.0;
- // round 165c: --patcher puts the insert inside a Patcher on Insert 1; --bounce file.wav then exports the song in real
- // time through the device (Export › "Render through the hardware in real time") and offline, and compares them
- runHwInsertTest (juce::File (args[i + 1].unquoted()), seconds > 0.0 ? seconds : 10.0, option ("--type"), option ("--device"), option ("--input"),
- option ("--buffer").getIntValue(), args.contains ("--patcher"),
- args.contains ("--bounce") ? juce::File (option ("--bounce")) : juce::File());
- return;
- }
- if (args.contains ("--uiperf"))
- {
- // LYNX --uiperf project.(flp|lynx) report.txt: the heavy UI cases in the real window, every frame timed (round 161)
- const auto i = args.indexOf ("--uiperf");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- runUiPerf (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()));
- return;
- }
- if (args.contains ("--cachetest"))
- {
- // LYNX --cachetest project.(flp|lynx) report.txt (round 174f): the Playlist's cached picture against exact
- // paints after zooms, scrolls and repaints, off screen (no window)
- const auto i = args.indexOf ("--cachetest");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- runCacheTest (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()));
- return;
- }
- if (args.contains ("--picturetest"))
- {
- // LYNX --picturetest report.txt [project.(flp|lynx)] (round 190bm): the Playlist and the Mixer drawn through
- // their cached pictures at 100-300 %, into native and software targets, against straight paints; off
- // screen (no window)
- const auto i = args.indexOf ("--picturetest");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- runPictureTest (juce::File (args[i + 1].unquoted()), i + 2 < args.size() ? juce::File (args[i + 2].unquoted()) : juce::File());
- return;
- }
- if (args.contains ("--paintcachetest"))
- {
- // LYNX --paintcachetest report.txt (round 190ki): --selftest's paint_caches item alone (the shape tiles, the
- // cached FL toolbar tiles; LYNX_TILE_DEBUG=<folder> keeps the tiles' pictures as PNGs), off screen
- const auto i = args.indexOf ("--paintcachetest");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- auto result = lynx::theme::paintCacheSelfTest();
- const auto tiles = lynx::flTileCacheSelfTest();
- juce::File (args[i + 1].unquoted()).replaceWithText ("paint_caches=" + result + "\nfl_tiles=" + tiles + "\n");
- setApplicationReturnValue (result.startsWith ("OK") && tiles == "OK" ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--timertest"))
- {
- // LYNX --timertest report.txt (round 174f): ui::TimerWhileShowing through hide / show / minimise (opens a small window)
- runTimerTest (juce::File (args[args.indexOf ("--timertest") + 1].unquoted()));
- return;
- }
- if (args.contains ("--livepeer"))
- {
- // LYNX --livepeer host|guest|rejoin <folder> [--relay URL] [--code CODE|@file]: one computer's side of a live
- // session between two real computers, no window (round 190ah)
- setApplicationReturnValue (lynx::livetest::runPeer (args));
- quit();
- return;
- }
- if (args.contains ("--offlinetest"))
- {
- // LYNX --offlinetest report.txt [--offline] (round 190nx): with LYNX_OFFLINE=1 or --offline every place that
- // would use the network refuses and says so. The test script runs it under `unshare -rn` with strace and counts
- // the connect() calls of internet sockets: zero (tests/offline-network-test.sh)
- const auto report = juce::File::getCurrentWorkingDirectory().getChildFile (args[args.indexOf ("--offlinetest") + 1].unquoted());
- juce::String log;
- bool ok = true;
- auto check = [&] (bool good, const juce::String& what) {
- ok = ok && good;
- log << (good ? "ok " : "FAIL ") << what << "\n";
- };
- check (lynx::offline::enabled(), "offline mode is on");
- {
- std::string why;
- check (! lynx::livelink::Connection::available (&why) && why.find ("offline") != std::string::npos, "live link unavailable: " + juce::String (why));
- check (lynx::livelink::http ("GET", "https://relay.lynx-share.com/v1/health", {}, {}, "LYNX-test", 2).status == 0, "relay HTTP gives no answer, no connection tried");
- }
- {
- lynx::AudioEngine offlineEngine (false);
- lynx::LiveSessionManager live (offlineEngine);
- lynx::LiveSessionManager::Options o;
- o.relay = "https://relay.lynx-share.com";
- o.name = "Offline test";
- o.inlineWork = true;
- live.start (o);
- check (live.getState() == lynx::LiveSessionManager::State::ended && ! live.isActive(), "Start live session refused: " + live.getStatus());
- lynx::LiveSessionManager joiner (offlineEngine);
- joiner.join ("LYNX-AAAA-AAAA-AAAA-AAAA-AAAA", o);
- check (joiner.getState() == lynx::LiveSessionManager::State::ended && ! joiner.isActive(), "Join live session refused: " + joiner.getStatus());
- }
- {
- const auto err = lynx::crashreporter::sendNow ("{\"offline\":\"test\"}");
- check (err.containsIgnoreCase ("offline"), "crash report upload refused: " + err);
- }
- lynx::updater::startAutomaticCheck();
- lynx::updater::checkNow();
- lynx::updater::goBack();
- check (true, "update check, update dialog and go-back opened no connection (see strace)");
- log << (ok ? "RESULT OK\n" : "RESULT FAIL\n");
- report.replaceWithText (log);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--livetest"))
- {
- // LYNX --livetest report.txt [--relay URL]: a live session of four peers over the relay (round 169b)
- setApplicationReturnValue (lynx::livetest::run (args));
- quit();
- return;
- }
- if (args.contains ("--selftest"))
- {
- const auto i = args.indexOf ("--selftest");
- // round 190mo: a temp folder of this run alone (two runs at once shared the fixed temp names of its items),
- // and on Linux room for its main-thread stack (it reached 7.4 of the usual 8 MB: AudioEngines on the stack)
- selfTestTemp = lynx::platform::useOwnTempFolder ("lynx-selftest");
- lynx::platform::allowMainThreadStack ((std::size_t) 64 << 20);
- runSelfTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--scan-one"))
- {
- // child process of the plugin scan (see PluginHost::scan)
- const auto i = args.indexOf ("--scan-one");
- // no crash dialogs from the plugin being examined; and once the result is written, the process ends without
- // unloading it: a Waves shell crashed in its own teardown at exit (Intel GPU driver fail-fast, 0xC0000409),
- // which showed Windows' crash dialog and made the scan reject the whole shell (round 111)
- lynx::crashguard::quietCrashReports();
- lynx::PluginHost::scanOneFile (args[i + 1].unquoted(), args[i + 2].unquoted(), juce::File (args[i + 3].unquoted()));
- lynx::crashguard::exitNow (0);
- }
- if (args.contains ("--splashshot"))
- {
- // LYNX --splashshot <folder> (round 190hd): the splash card drawn as the JUCE card is and as the card on its own
- // thread is (ui/Splash.h), side by side; no window
- const auto shots = lynx::writeSplashShots (juce::File (args[args.indexOf ("--splashshot") + 1].unquoted()));
- setApplicationReturnValue (shots.size() == 20 ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--browser-indexer"))
- {
- // round 190hd: the Browser's indexer, a low-priority child of the LYNX window (BrowserComponent.h): no window,
- // no session, no audio; it ends with its parent
- lynx::crashguard::quietCrashReports();
- lynx::crashguard::exitNow (lynx::BrowserComponent::runIndexerProcess (args));
- }
- if (args.contains ("--packageinfo"))
- {
- // round 165n: the Microsoft Store (MSIX) build's identity and folders (platform/Package.h); the release
- // workflow runs it inside the installed test package
- juce::File (args[args.indexOf ("--packageinfo") + 1].unquoted()).replaceWithText (lynx::platform::packageReport());
- quit();
- return;
- }
- if (args.contains ("--paths"))
- {
- // diagnostics: folders LYNX searches
- const auto programs = juce::File::getSpecialLocation (juce::File::globalApplicationsDirectory);
- juce::String report;
- report << "programs=" << programs.getFullPathName() << "\n";
- for (const auto& dir : programs.getChildFile ("Image-Line").findChildFiles (juce::File::findDirectories, false, "FL Studio*"))
- report << "fl=" << dir.getFullPathName() << " packs=" << (int) dir.getChildFile ("Data").getChildFile ("Patches").getChildFile ("Packs").isDirectory() << "\n";
- juce::File (args[args.indexOf ("--paths") + 1].unquoted()).replaceWithText (report);
- quit();
- return;
- }
- if (args.contains ("--fldb"))
- {
- // diagnostics: LYNX.exe --fldb report.txt [project.flp]: the FL Studio installation, its plugin database,
- // the suggested plugin folders and, for a project, how each of its plugins resolves (read-only)
- const auto i = args.indexOf ("--fldb");
- const auto fl = lynx::findFlStudio();
- lynx::PluginHost host (false);
- juce::String report;
- report << "install=" << fl.installDir.getFullPathName() << "\nuserdata=" << fl.userData.getFullPathName() << "\n";
- for (const auto& f : fl.vstFolders)
- report << "flvstfolder=" << f << "\n";
- report << "dbfiles=" << host.flPluginDatabaseFiles() << " entries=" << (int) host.flPluginDatabase().entries().size() << "\n";
- for (const auto& e : host.flPluginDatabase().entries())
- report << " entry: " << juce::String::fromUTF8 (e.name.c_str()) << " | " << juce::String::fromUTF8 (e.path.c_str()) << " | role=" << e.role << "\n";
- const auto suggested = host.suggestedFolders();
- for (int k = 0; k < suggested.getNumPaths(); ++k)
- report << "folder=" << suggested[k].getFullPathName() << "\n";
- if (const juce::File project (args[i + 2].unquoted()); project.existsAsFile())
- {
- juce::MemoryBlock data;
- project.loadFileAsData (data);
- try
- {
- for (const auto& use : lynx::flpForeignPlugins (flp::parseProject ({ static_cast<const std::uint8_t*> (data.getData()), data.getSize() })))
- {
- juce::String how;
- const auto d = host.findForeign (use.plugin, use.instrument, &how);
- const auto* entry = host.flPluginDatabase().match (use.plugin, use.instrument);
- report << "plugin: " << juce::String::fromUTF8 (use.plugin.name.c_str()) << " -> "
- << (d ? d->fileOrIdentifier + " (" + how + ")" : juce::String ("not known"))
- << (entry != nullptr ? " | fl db: " + juce::String::fromUTF8 (entry->path.c_str()) : juce::String()) << "\n";
- }
- const auto uses = lynx::flpForeignPlugins (flp::parseProject ({ static_cast<const std::uint8_t*> (data.getData()), data.getSize() }));
- const auto candidates = host.filesToScanFor (uses);
- report << "scan_candidates=" << candidates.joinIntoString (";") << "\n";
- if (args.contains ("--scan"))
- {
- // the targeted scan an open would run (child processes; the user's plugin list is not touched)
- report << "scanned_new=" << host.scanFiles (candidates, {}) << "\n";
- for (const auto& use : uses)
- {
- juce::String how;
- const auto d = host.findForeign (use.plugin, use.instrument, &how);
- report << "after_scan: " << juce::String::fromUTF8 (use.plugin.name.c_str()) << " -> "
- << (d ? d->fileOrIdentifier + " (" + how + ")" : juce::String ("not known")) << "\n";
- }
- }
- }
- catch (const flp::Error& e)
- {
- report << "error=" << e.what() << "\n";
- }
- }
- juce::File (args[i + 1].unquoted()).replaceWithText (report);
- quit();
- return;
- }
- if (args.contains ("--midisync-test"))
- {
- // LYNX --midisync-test report.txt ["output device"] ["input device"] (round 165f): MIDI clock timing
- const auto i = args.indexOf ("--midisync-test");
- const auto out = args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- const auto in = args.size() > i + 3 && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- juce::File (args[i + 1].unquoted()).replaceWithText (lynx::MidiSyncIo::selfTest (out, in));
- quit();
- return;
- }
- if (args.contains ("--linktest"))
- {
- // LYNX --linktest report.txt [seconds] [peer] (round 190gl): Ableton Link with simulated audio callbacks; with
- // "peer" a second Link peer in this process, else a peer on the network (Ableton's LinkHut) is expected
- const auto i = args.indexOf ("--linktest");
- const auto seconds = args.size() > i + 2 && ! args[i + 2].startsWith ("--") ? args[i + 2].getDoubleValue() : 20.0;
- const auto ownPeer = args.contains ("peer");
- juce::File (args[i + 1].unquoted()).replaceWithText (juce::String (lynx::AbletonLink::selfTest (seconds > 0.0 ? seconds : 20.0, ownPeer)));
- quit();
- return;
- }
- if (args.contains ("--devices") || args.contains ("--dispositivos")) // --dispositivos: legacy alias
- {
- // diagnostics: driver types and output devices JUCE offers (without opening any)
- juce::AudioDeviceManager manager;
- juce::String report;
- manager.getAvailableDeviceTypes();
- if (auto pipeWire = lynx::makePipeWireDeviceType()) // Linux: LYNX's own PipeWire client (round 161)
- manager.addAudioDeviceType (std::move (pipeWire));
- #if JUCE_LINUX
- report << lynx::describePipeWire() << "\n";
- #endif
- for (auto* type : manager.getAvailableDeviceTypes())
- {
- type->scanForDevices();
- report << "type=" << type->getTypeName() << "\n";
- for (const auto& name : type->getDeviceNames (false))
- report << " output=" << name << "\n";
- for (const auto& name : type->getDeviceNames (true))
- report << " input=" << name << "\n";
- }
- for (const auto& d : juce::MidiInput::getAvailableDevices())
- report << "midi-in=" << d.name << "\n";
- for (const auto& d : juce::MidiOutput::getAvailableDevices())
- report << "midi-out=" << d.name << "\n";
- const auto flag = args.contains ("--devices") ? args.indexOf ("--devices") : args.indexOf ("--dispositivos");
- juce::File (args[flag + 1].unquoted()).replaceWithText (report);
- quit();
- return;
- }
- if (args.contains ("--devicetest"))
- {
- // LYNX.exe --devicetest "type" "device" report.txt ["input device"] [--buffer N] [--roundtrip]: opens that output device (and, with the
- // 4th argument, an input: "*" = the same device / the driver's default input), receives 1 s of callbacks
- // writing silence, closes it and reports rate, block size, latency, callbacks and the input channels with
- // their peak level (driver check, no sound). --roundtrip: clicks out, found again on input 1 through a loopback
- // cable / PipeWire link: the round-trip latency (3 s)
- const auto i = args.indexOf ("--devicetest");
- const auto typeName = args[i + 1].unquoted(), deviceName = args[i + 2].unquoted();
- auto inputName = args.size() > i + 4 && ! args[i + 4].startsWith ("--") ? args[i + 4].unquoted() : juce::String();
- const auto wantInput = inputName.isNotEmpty();
- juce::String report;
- const juce::File reportFile (args[i + 3].unquoted());
- auto step = [&] (const juce::String& line) { report << line << "\n"; reportFile.replaceWithText (report); }; // progress survives a driver that ends the process
- step ("step=start");
- juce::AudioDeviceManager manager;
- manager.getAvailableDeviceTypes();
- if (auto pipeWire = lynx::makePipeWireDeviceType())
- manager.addAudioDeviceType (std::move (pipeWire));
- std::unique_ptr<juce::AudioIODevice> device;
- for (auto* type : manager.getAvailableDeviceTypes())
- if (type->getTypeName() == typeName)
- {
- type->scanForDevices();
- if (wantInput && type->hasSeparateInputsAndOutputs())
- {
- const auto inputs = type->getDeviceNames (true);
- if (inputName == "*" || ! inputs.contains (inputName))
- {
- const auto index = type->getDefaultDeviceIndex (true);
- inputName = juce::isPositiveAndBelow (index, inputs.size()) ? inputs[index] : juce::String();
- }
- for (const auto& n : inputs)
- step ("input_device=" + n);
- step ("input_chosen=" + inputName);
- }
- else if (wantInput)
- inputName = deviceName;
- step ("step=create");
- device.reset (type->createDevice (deviceName, type->hasSeparateInputsAndOutputs() ? inputName : juce::String()));
- step ("step=created");
- }
- struct Silence final : juce::AudioIODeviceCallback
- {
- std::atomic<int> calls { 0 }, inputs { 0 };
- std::array<std::atomic<float>, 64> peaks {};
- // --roundtrip (round 161): a click every quarter second on the outputs, found again on input 1 through a
- // loopback; the delays in samples
- bool roundtrip = false;
- int period = 12000;
- std::int64_t position = 0, lastClick = -1;
- std::vector<int> delays;
- void audioDeviceIOCallbackWithContext (const float* const* in, int numIn, float* const* out, int channels, int n,
- const juce::AudioIODeviceCallbackContext&) override
- {
- for (int c = 0; c < channels; ++c)
- if (out[c] != nullptr)
- juce::FloatVectorOperations::clear (out[c], n);
- if (roundtrip)
- {
- for (int i = 0; i < n; ++i)
- {
- if (numIn > 0 && in[0] != nullptr && lastClick >= 0 && std::abs (in[0][i]) > 0.5f)
- {
- if (delays.size() < delays.capacity())
- delays.push_back ((int) (position + i - lastClick));
- lastClick = -1;
- }
- if ((position + i) % period == 0 && position + i > 0)
- {
- for (int c = 0; c < channels; ++c)
- if (out[c] != nullptr)
- out[c][i] = 0.9f;
- lastClick = position + i;
- }
- }
- position += n;
- }
- inputs.store (numIn);
- for (int c = 0; c < juce::jmin (numIn, 64); ++c)
- if (in[c] != nullptr)
- {
- const auto range = juce::FloatVectorOperations::findMinAndMax (in[c], n);
- const auto peak = juce::jmax (std::abs (range.getStart()), std::abs (range.getEnd()));
- if (peak > peaks[(std::size_t) c].load())
- peaks[(std::size_t) c].store (peak);
- }
- ++calls;
- }
- void audioDeviceAboutToStart (juce::AudioIODevice*) override {}
- void audioDeviceStopped() override {}
- } silence;
- bool ok = false;
- if (device == nullptr)
- step ("error=device not found");
- else
- {
- step ("step=open");
- juce::BigInteger outputs;
- outputs.setRange (0, 2, true);
- const auto rates = device->getAvailableSampleRates();
- const auto rate = device->getCurrentSampleRate() > 0 ? device->getCurrentSampleRate()
- : rates.contains (48000.0) ? 48000.0 : rates.isEmpty() ? 44100.0 : rates[0];
- step ("rates=" + juce::String (rates.size()) + " chosen=" + juce::String (rate) + " default_block=" + juce::String (device->getDefaultBufferSize()));
- juce::BigInteger inputs;
- if (wantInput)
- {
- const auto names = device->getInputChannelNames();
- step ("input_channels=" + juce::String (names.size()));
- for (int c = 0; c < names.size(); ++c)
- step (" in" + juce::String (c + 1) + "=" + names[c]);
- inputs.setRange (0, juce::jmin (64, names.size()), true);
- }
- // --buffer N: ask for that block size (REA round 97 latency survey); default: the driver's default
- const auto wantedBlock = args.contains ("--buffer") ? args[args.indexOf ("--buffer") + 1].getIntValue() : 0;
- const auto error = device->open (inputs, outputs, rate, wantedBlock > 0 ? wantedBlock : device->getDefaultBufferSize());
- if (error.isNotEmpty())
- step ("error=" + error);
- else
- {
- step ("step=start_callbacks");
- silence.roundtrip = args.contains ("--roundtrip");
- silence.period = juce::jmax (1, (int) (rate / 4));
- silence.delays.reserve (64);
- device->start (&silence);
- juce::Thread::sleep (silence.roundtrip ? 3000 : 1000);
- device->stop();
- if (silence.roundtrip)
- {
- auto d = silence.delays;
- std::sort (d.begin(), d.end());
- report << "roundtrip_clicks=" << (int) d.size() << "\n";
- if (! d.empty())
- report << "roundtrip_samples=min " << d.front() << " median " << d[d.size() / 2] << " max " << d.back() << "\n"
- << "roundtrip_ms=" << juce::String (1000.0 * d[d.size() / 2] / device->getCurrentSampleRate(), 2) << "\n";
- }
- report << "rate=" << device->getCurrentSampleRate() << "\n"
- << "block=" << device->getCurrentBufferSizeSamples() << "\n"
- << "output_latency=" << device->getOutputLatencyInSamples() << "\n"
- << "callbacks=" << silence.calls.load() << "\n";
- if (wantInput)
- {
- report << "input_latency=" << device->getInputLatencyInSamples() << "\n"
- << "active_inputs=" << device->getActiveInputChannels().countNumberOfSetBits() << "\n"
- << "callback_inputs=" << silence.inputs.load() << "\n";
- for (int c = 0; c < juce::jmin (64, silence.inputs.load()); ++c)
- report << " peak_in" << (c + 1) << "=" << juce::Decibels::gainToDecibels (silence.peaks[(std::size_t) c].load(), -150.0f) << " dB\n";
- }
- ok = silence.calls.load() > 0 && (! wantInput || silence.inputs.load() > 0);
- device->close();
- }
- }
- step (juce::String ("result=") + (ok ? "OK" : "FAILED"));
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--pickertime"))
- {
- // LYNX.exe --pickertime report.txt (issue #209): the plugin lists' opening times with the profile's plugin
- // list (LYNX_PROFILE_MAIN samples the message thread meanwhile)
- const auto i = args.indexOf ("--pickertime");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- if (const auto profile = juce::SystemStats::getEnvironmentVariable ("LYNX_PROFILE_MAIN", {}); profile.isNotEmpty())
- lynx::crashguard::startMainProfiler (profile.toStdString());
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- lynx::AudioEngine offline (false);
- const auto engineMs = juce::Time::getMillisecondCounterHiRes() - t0;
- const auto report = "engine_ms=" + juce::String (engineMs) + "\n" + lynx::pluginPickerTimings (offline);
- juce::File (args[i + 1].unquoted()).replaceWithText (report);
- lynx::crashguard::stopMainProfiler();
- setApplicationReturnValue (0);
- quit();
- return;
- }
- if (args.contains ("--plusmenutime"))
- {
- // LYNX --plusmenutime report.txt [watched] (round 190mf): the Channel rack "+" menu's build time (as
- // showAddChannelMenu builds it, without showing it) with the profile's plugin list and Plugin database
- // folder: the first one, then each one after the old two-second throttle ran out; then one after the
- // folder was marked changed. "watched": as the app (a folder watcher), else as before round 190mf.
- const auto i = args.indexOf ("--plusmenutime");
- const auto watched = i + 2 < args.size() && args[i + 2] == "watched";
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::quickpick::installPluginDatabase (offline);
- std::unique_ptr<lynx::folderwatch::Watcher> watcher;
- if (watched)
- {
- const auto root = lynx::quickpick::pluginDatabaseFolder();
- watcher = std::make_unique<lynx::folderwatch::Watcher> (
- std::vector<std::string> { root.getChildFile ("Effects").getFullPathName().toStdString(), root.getChildFile ("Generators").getFullPathName().toStdString() },
- [] { juce::MessageManager::callAsync ([] { lynx::quickpick::markPluginDatabaseChanged(); }); });
- lynx::quickpick::setPluginDatabaseWatched (true);
- }
- juce::String report;
- report << "types=" << offline.getPluginHost().getKnownPlugins().getNumTypes() << " watched=" << (watched ? 1 : 0) << "\n";
- auto build = [&offline] (int& items) {
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- juce::PopupMenu menu;
- auto picks = lynx::quickpick::renamedGenerators (offline, [] (lynx::ChannelDef) {});
- lynx::quickpick::addPicks (menu, picks);
- lynx::quickpick::addGeneratorMenu (menu, offline, [] (lynx::ChannelDef) {}, [] {}, nullptr, nullptr);
- lynx::quickpick::addFolderViewItems (menu, offline);
- items = menu.getNumItems();
- return juce::Time::getMillisecondCounterHiRes() - t0;
- };
- auto line = [&report, &build] (const juce::String& what) {
- const auto readsBefore = lynx::quickpick::lastRefreshTimes().reads;
- int items = 0;
- const auto ms = build (items);
- const auto t = lynx::quickpick::lastRefreshTimes();
- const auto read = t.reads != readsBefore;
- report << what << " menu_ms=" << juce::String (ms, 2) << " items=" << items << " folder_read=" << (read ? 1 : 0);
- if (read)
- report << " list_ms=" << juce::String (t.listMs, 2) << " read_ms=" << juce::String (t.readMs, 2);
- report << "\n";
- };
- line ("first");
- for (int k = 1; k <= 5; ++k)
- {
- juce::Thread::sleep (2100);
- line ("again" + juce::String (k));
- }
- for (int k = 1; k <= 3; ++k)
- line ("quick" + juce::String (k));
- lynx::quickpick::markPluginDatabaseChanged();
- line ("marked");
- line ("after");
- lynx::quickpick::setPluginDatabaseWatched (false);
- watcher.reset();
- lynx::plugindb::finishInstalledWrites();
- juce::File (args[i + 1].unquoted()).replaceWithText (report);
- setApplicationReturnValue (0);
- quit();
- return;
- }
- if (args.contains ("--scantest"))
- {
- // LYNX.exe --scantest folder report.txt: scan (in child processes) without touching the user's list
- const auto i = args.indexOf ("--scantest");
- lynx::PluginHost host (false);
- const auto found = host.scan (juce::FileSearchPath (args[i + 1].unquoted()), {});
- juce::String report;
- report << "found=" << found << "\n";
- for (const auto& t : host.getKnownPlugins().getTypes())
- report << " " << (t.isInstrument ? "instrument: " : "effect: ") << t.name << "\n";
- for (const auto& f : host.getKnownPlugins().getBlacklistedFiles())
- report << " blacklisted: " << f << "\n";
- juce::File (args[i + 2].unquoted()).replaceWithText (report);
- setApplicationReturnValue (found > 0 ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--wrappermiditest"))
- {
- // LYNX.exe --wrappermiditest plugin.dll report.txt (round 181c), with LYNX_TEST_VST2_MIDILOG set: what a
- // hosted plugin receives after a wrapper MIDI option changes while it runs
- const auto i = args.indexOf ("--wrappermiditest");
- runWrapperMidiTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--wrappershot190oh"))
- {
- // LYNX --wrappershot190oh plugin <folder> [--open] (round 190oh, P3: FL's wrapper Settings › GUI): the
- // plugin (any format; an effect on insert 1) and its wrapper Settings tab drawn offscreen at 100 % and 150 %,
- // with FL's defaults and with "DPI aware" off + "Scale editor dimensions" on; --open also opens its editor
- // with each setting (a real window: Windows reports the editor windows' DPI awareness) -> report.txt
- const auto i = args.indexOf ("--wrappershot190oh");
- runWrapperShot190oh (args[i + 1].unquoted(), args[i + 2].unquoted(), args.contains ("--open"));
- return;
- }
- if (args.contains ("--hotfixui190qp"))
- {
- // LYNX --hotfixui190qp <prefix> [--plugin file]... (hotfix 0.1.31.1, round 190qp): the Clip-launch Arrangement's
- // track selection reaching the Device View, and channel / plugin windows opened and closed again and again
- // (src/HotfixUi190qp.inc); <prefix>-checks.txt, result=OK
- const auto i = args.indexOf ("--hotfixui190qp");
- juce::StringArray plugins;
- for (int k = 0; k + 1 < args.size(); ++k)
- if (args[k] == "--plugin")
- plugins.add (args[k + 1].unquoted());
- runHotfixUi190qp (args[i + 1].unquoted(), plugins);
- return;
- }
- if (args.contains ("--pertabshot259"))
- {
- // LYNX --pertabshot259 <prefix> [--plugin file]... [--shot-scale 1.5 --shot-suffix @150] (round 190pw, PR #259:
- // channel and plugin windows the size of the tab they show): src/PerTabShot259.inc
- const auto i = args.indexOf ("--pertabshot259");
- juce::StringArray plugins;
- for (int k = 0; k + 1 < args.size(); ++k)
- if (args[k] == "--plugin")
- plugins.add (args[k + 1].unquoted());
- runPerTabShot259 (args[i + 1].unquoted(), plugins);
- return;
- }
- if (args.contains ("--wrappershot"))
- {
- const auto i = args.indexOf ("--wrappershot");
- runWrapperShot (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--multiouttest"))
- {
- const auto i = args.indexOf ("--multiouttest");
- runMultiOutTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--vstitest"))
- {
- // LYNX --vstitest plugin folder [project.lynx] (round 190fw, issue #162): an instrument plugin (Image-Line's
- // "FL Studio VSTi") on a channel: notes in, audio out, its state through a saved project, its outputs and
- // the host tempo it follows. See runVstiTest.
- const auto i = args.indexOf ("--vstitest");
- const auto project = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- runVstiTest (args[i + 1].unquoted(), args[i + 2].unquoted(), project);
- return;
- }
- if (args.contains ("--vst2test"))
- {
- const auto i = args.indexOf ("--vst2test");
- runVst2Test (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--issuesshot190qr"))
- {
- // --issuesshot190qr <prefix> (round 190qr, issues #274-#281): src/IssuesShot190qr.inc
- setApplicationReturnValue (runIssuesShot190qr (args[args.indexOf ("--issuesshot190qr") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--issuesshot190ll"))
- {
- // --issuesshot190ll <prefix> (round 190ll, issues #200 / #203): src/IssuesShot190ll.inc
- setApplicationReturnValue (runIssuesShot190ll (args[args.indexOf ("--issuesshot190ll") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--hostplaytest190ll"))
- {
- // LYNX --hostplaytest190ll report.txt "<LYNX Test Synth.vst3>" [--buffer N] (round 190ll, issue #199): src/HostPlay190ll.inc
- const auto i = args.indexOf ("--hostplaytest190ll");
- const auto buffer = args.contains ("--buffer") ? args[args.indexOf ("--buffer") + 1].getIntValue() : 1024;
- runHostPlayTest190ll (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()), juce::jlimit (16, 4096, buffer));
- return;
- }
- if (args.contains ("--vst3noteidtest"))
- {
- const auto i = args.indexOf ("--vst3noteidtest");
- runVst3NoteIdTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--lv2scantest"))
- {
- runLv2ScanTest (args[args.indexOf ("--lv2scantest") + 1].unquoted());
- return;
- }
- if (args.contains ("--wrappertest"))
- {
- const auto i = args.indexOf ("--wrappertest");
- runWrapperTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--plugintest"))
- {
- const auto i = args.indexOf ("--plugintest");
- // optional 3rd argument: the plugin's name inside a shell (e.g. "CLA-2A Stereo" in a WaveShell)
- const auto only = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- runPluginTest (args[i + 1].unquoted(), args[i + 2].unquoted(), only);
- return;
- }
- if (args.contains ("--crashguardtest"))
- {
- // LYNX --crashguardtest "LYNX Test Crash.vst3|.clap" report.txt [process|memcpy] (round 190dt,
- // tools/testplugin/lynx_test_crash*.{c,cpp}): the plugin crashes in its 40th block on insert 1; LYNX must
- // catch it, mark the slot, keep playing the other inserts, save the project, reload the plugin; then the
- // saved project opens with the plugin crashing on its state; and LYNX's own faults are still crashes
- const auto i = args.indexOf ("--crashguardtest");
- runCrashGuardTest (args[i + 1].unquoted(), args[i + 2].unquoted(),
- i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String ("process"));
- return;
- }
- if (args.contains ("--claprestarttest"))
- {
- // LYNX.exe --claprestarttest "LYNX Test Restart.clap" report.txt (tools/testplugin/lynx_test_restart.c)
- const auto i = args.indexOf ("--claprestarttest");
- runClapRestartTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--multieditor255test"))
- {
- // LYNX --multieditor255test report.txt <plugin>[::Name] ... (round 190ou, issue #255): several plugin editors open
- // and in use while a keyboard plays; the audio must keep running (src/MultiEditor255Test.inc)
- const auto i = args.indexOf ("--multieditor255test");
- juce::StringArray plugins;
- for (int k = i + 2; k < args.size() && ! args[k].startsWith ("--"); ++k)
- plugins.add (args[k].unquoted());
- runMultiEditor255Test (args[i + 1].unquoted(), plugins);
- return;
- }
- if (args.contains ("--issue258test"))
- {
- // LYNX --issue258test report.txt (round 190pv, issue #258): a cloned channel's own automation clip drives its
- // sound, through the app's engine with render-ahead off and on (src/Issue258Test.inc; Transistor Bass needs
- // FL Studio, LYNX_FL_INSTALL on Linux)
- runIssue258Test (args[args.indexOf ("--issue258test") + 1].unquoted());
- return;
- }
- if (args.contains ("--autolive190qp"))
- {
- // LYNX --autolive190qp <project.flp|.lynx> report.txt [--per-kind N] [--all-modes] (round 190qp, issue #253): the
- // project's automated mixer volumes, send levels and effect parameters heard and shown through the app's engine
- // (src/Hotfix190qpTest.inc)
- const auto i = args.indexOf ("--autolive190qp");
- const auto perKind = args.contains ("--per-kind") ? args[args.indexOf ("--per-kind") + 1].getIntValue() : 2;
- runAutoLive190qpTest (args[i + 1].unquoted(), args[i + 2].unquoted(), perKind, args.contains ("--all-modes"));
- return;
- }
- if (args.contains ("--feel190qetest"))
- {
- // LYNX --feel190qetest report.txt [shot prefix [project]] (round 190qe, TOP-NEXT R1): edge scroll, view stack, zoom
- // glide and anchor, Restore selection, Keep labels on screen, off screen (src/Feel190qeTest.inc)
- const auto i = args.indexOf ("--feel190qetest");
- const auto arg = [&args] (int k) { return k < args.size() && ! args[k].startsWith ("--") ? args[k].unquoted() : juce::String(); };
- setApplicationReturnValue (runFeel190qeTest (arg (i + 1), arg (i + 2), arg (i + 3)) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--qa190rfchild"))
- {
- // LYNX --qa190rfchild exit|display <folder> (round 190rf; --qa190rbtest starts it): a process with the hang
- // watch's thread running that ends through exit() ("exit": exit code 3 expected; the static hang watch's
- // destructor called std::terminate before) or whose display connection breaks ("display", Linux: exit code 1
- // through crashguard::watchDisplayConnection, its session file names the lost display)
- const auto i = args.indexOf ("--qa190rfchild");
- const auto mode = args[i + 1];
- const juce::File folder (args[i + 2].unquoted());
- folder.createDirectory();
- lynx::crashguard::beginSession (folder.getChildFile ("session.txt").getFullPathName().toStdString(), "LYNX session\n");
- lynx::crashguard::startHangWatch (folder.getFullPathName().toStdString());
- if (mode == "exit")
- std::exit (3);
- #if JUCE_LINUX
- if (mode == "display")
- if (auto* xlib = dlopen ("libX11.so.6", RTLD_LAZY | RTLD_LOCAL))
- {
- using OpenDisplay = void* (*) (const char*);
- using ConnectionNumber = int (*) (void*);
- using Sync = int (*) (void*, int);
- const auto open = (OpenDisplay) dlsym (xlib, "XOpenDisplay");
- const auto number = (ConnectionNumber) dlsym (xlib, "XConnectionNumber");
- const auto sync = (Sync) dlsym (xlib, "XSync");
- if (auto* display = open != nullptr && number != nullptr && sync != nullptr ? open (nullptr) : nullptr)
- {
- lynx::crashguard::watchDisplayConnection (nullptr);
- ::shutdown (number (display), SHUT_RDWR); // (the server "went away")
- sync (display, 0);
- }
- }
- #endif
- std::_Exit (2); // (not reached when the display part ran)
- }
- if (args.contains ("--qa190rbtest"))
- {
- // LYNX --qa190rbtest report.txt (round 190rb, the 0.1.32 quality round's crash / memory fixes; also in
- // --selftest): src/Qa190rbCheck.inc
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String log;
- const auto result = qa190rbCheck (log);
- juce::File (args[args.indexOf ("--qa190rbtest") + 1].unquoted()).replaceWithText (log + "qa190rb=" + result + "\n");
- setApplicationReturnValue (result == "OK" ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--issues190qrtest"))
- {
- // LYNX --issues190qrtest report.txt (round 190qr, issues #274-#281; also in --selftest): src/Issues190qrCheck.inc
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String log;
- const auto result = issues190qrCheck (log);
- juce::File (args[args.indexOf ("--issues190qrtest") + 1].unquoted()).replaceWithText (log + "issues190qr=" + result + "\n");
- setApplicationReturnValue (result == "OK" ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--hwheel254test"))
- {
- // LYNX --hwheel254test report.txt (round 190ou, issue #254): the horizontal wheel in the Playlist (three layouts),
- // Piano roll, Mixer and Browser, off screen (src/HWheel254Test.inc)
- const auto i = args.indexOf ("--hwheel254test");
- setApplicationReturnValue (runHWheel254Test (args[i + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--determinismtest190po"))
- {
- // LYNX --determinismtest190po report.txt (round 190po, engine/Determinism190poTest.cpp): a render is the same
- // bit for bit on one thread and on several, and two exports have one hash (Windows: the x87 precision)
- const auto i = args.indexOf ("--determinismtest190po");
- juce::String lines;
- const auto result = lynx::determinism190po::check ([&lines] (const juce::String& line) { lines << line << "\n"; });
- juce::File (args[i + 1].unquoted()).replaceWithText (lines + "determinism190po=" + result + "\n");
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--renderagaintest"))
- {
- // LYNX --renderagaintest report.txt (round 190ou, engine/RenderAgainTest.cpp): offline renders made again
- const auto i = args.indexOf ("--renderagaintest");
- juce::String lines;
- const auto result = lynx::renderagain::check ([&lines] (const juce::String& line) { lines << line << "\n"; });
- juce::File (args[i + 1].unquoted()).replaceWithText (lines + "renderagain190ou=" + result + "\n");
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--jsfxtest") || args.contains ("--jsfxbench"))
- {
- // LYNX --jsfxtest <folder>: the JSFX format end to end (round 190pj, issue #241; also in --selftest), report in
- // <folder>/jsfx-selftest.txt. LYNX --jsfxbench <out.txt>: CPU per instance of every bundled script.
- const auto test = args.contains ("--jsfxtest");
- const auto i = args.indexOf (test ? "--jsfxtest" : "--jsfxbench");
- const juce::File out (args[i + 1].unquoted());
- juce::String result;
- if (test)
- {
- out.createDirectory();
- result = lynx::jsfx::selfTest (out);
- out.getChildFile ("report.txt").replaceWithText ("jsfx190pj=" + result + "\n");
- }
- else
- result = lynx::jsfx::bench (out);
- std::cout << result << std::endl;
- setApplicationReturnValue (result.startsWith ("OK") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--clapteardowntest"))
- {
- // LYNX.exe --clapteardowntest "LYNX Test Restart.clap" report.txt (round 190az, engine/ClapTeardownTest.cpp)
- const auto i = args.indexOf ("--clapteardowntest");
- lynx::runClapTeardownTest (args[i + 1].unquoted(), args[i + 2].unquoted(), [this] (int code) {
- setApplicationReturnValue (code);
- quit();
- });
- return;
- }
- if (args.contains ("--mpetest"))
- {
- // LYNX.exe --mpetest "LYNX Test MPE.clap" report.txt (tools/testplugin/lynx_test_mpe.c, issue #108)
- const auto i = args.indexOf ("--mpetest");
- runMpeTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--mpeplaytest190hy"))
- {
- // LYNX --mpeplaytest190hy plugin.(clap|vst3) report.txt (round 190hy, issue #108): a song note with a pitch
- // curve played by a hosted plugin with MPE on, through the whole song path (scheduler, renderer, the wrapper's
- // MPE / CLAP note expressions), rendered offline; the pitch heard is measured (report.txt, report.wav)
- const auto i = args.indexOf ("--mpeplaytest190hy");
- runMpePlayTest190hy (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--editortest"))
- {
- // LYNX.exe --editortest plugin.vst3 report.txt ["name"]: opens the plugin's own editor in a window for a few
- // seconds, then closes it (a plugin whose UI crashes the host ends the process before the report says OK)
- const auto i = args.indexOf ("--editortest");
- const auto only = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- runEditorTest (args[i + 1].unquoted(), args[i + 2].unquoted(), only);
- return;
- }
- if (args.contains ("--editorcrashtest"))
- {
- // LYNX.exe --editorcrashtest "LYNX Test Crash.clap" report.txt (issue #32, round 174a; Windows): the test
- // plugin's editor faults in its own window procedure (LYNX_TEST_CRASH=editor). LYNX must catch it, close
- // that editor, record the trace and keep running its message loop.
- const auto i = args.indexOf ("--editorcrashtest");
- runEditorCrashTest (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--reloadtest"))
- {
- // LYNX --reloadtest plugin report.txt [shots folder] [--wait-kill]: round 190ao (reload a crashed plugin).
- // Hosts the plugin in a separate process (a channel for an instrument, insert 1 for an effect) in an offline
- // engine, crashes its process (--wait-kill: writes <report>.pid and waits for the process to be killed
- // from outside), checks that nothing reloads by itself, reloads it on request and checks the new process,
- // the state captured last, the untouched song and undo history; twice. With a shots folder: PNGs of the
- // plugin window's crash notice and of the prompt.
- const auto i = args.indexOf ("--reloadtest");
- runReloadTest (args[i + 1].unquoted(), args[i + 2].unquoted(),
- i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String(), args.contains ("--wait-kill"));
- return;
- }
- if (args.contains ("--pluginoptionstest"))
- {
- // LYNX --pluginoptionstest plugin report.txt [shots folder]: round 190ao. Hosts the plugin inside LYNX (a
- // channel for an instrument, insert 1 for an effect) in an offline engine, opens its window and checks
- // LYNX's own plugin-window options: Pin on top (set, kept above another window, saved with the plugin,
- // back when the window opens again). With a shots folder: PNGs of each state. The window is on screen.
- const auto i = args.indexOf ("--pluginoptionstest");
- runPluginOptionsTest (args[i + 1].unquoted(), args[i + 2].unquoted(),
- i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String());
- return;
- }
- if (args.contains ("--plugwintest"))
- {
- // LYNX --plugwintest plugin report.txt ["name"] [seconds]: round 162d. Puts the plugin in a channel (an
- // instrument) or on insert 1 (an effect) of an offline engine, opens its plugin window (wrapper header,
- // presets), checks a preset round trip, keeps the window `seconds` on screen (default 15: time for xdotool /
- // screenshots), then removes the plugin from the song and reports whether its window closed by itself.
- const auto i = args.indexOf ("--plugwintest");
- const auto only = i + 3 < args.size() && ! args[i + 3].startsWith ("--") && ! args[i + 3].containsOnly ("0123456789") ? args[i + 3].unquoted() : juce::String();
- auto seconds = 15;
- for (int k = i + 3; k < juce::jmin (args.size(), i + 5); ++k)
- if (args[k].containsOnly ("0123456789"))
- seconds = args[k].getIntValue();
- runPlugWinTest (args[i + 1].unquoted(), args[i + 2].unquoted(), only, seconds);
- return;
- }
- if (args.contains ("--zorder191test"))
- {
- // LYNX --zorder191test report.txt [plugin.vst3]: issue #191 (round 190mx), ui/ZOrder191Test.h
- const auto i = args.indexOf ("--zorder191test");
- const auto plugin = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- lynx::runZOrder191Test (args[i + 1].unquoted(), plugin, &lookAndFeel, [this] (bool ok) {
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- });
- return;
- }
- if (args.contains ("--fittest"))
- {
- // LYNX.exe --fittest report.txt [percent]: round 163 — at that UI zoom (default 150) a window taller than
- // the screen and a big resizable window that grows with a zoom change keep their title bar and close
- // button on the screen. The windows show for about two seconds.
- const auto i = args.indexOf ("--fittest");
- runFitTest (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].getIntValue() : 150);
- return;
- }
- if (args.contains ("--windowtest"))
- {
- // LYNX.exe --windowtest report.txt: opens the Quick-add palette, the Audio editor, a plugin-like window and a name dialog
- // over the main window and checks that each one stays in front, owned by the main window, with the
- // keyboard focus (issue #4). The windows appear on screen for a few seconds.
- runWindowTest (args[args.indexOf ("--windowtest") + 1].unquoted());
- return;
- }
- if (args.contains ("--minimizeclicktest"))
- {
- // LYNX --minimizeclicktest report.txt (issue #188, round 190ir): a tool window over the main window is
- // minimised (through the window manager), the main window comes to the front, and a click where the tool
- // window was must reach the main window's component. Run it under a window manager (openbox on a private
- // Xvfb); exit code 0 = OK.
- runMinimizeClickTest (args[args.indexOf ("--minimizeclicktest") + 1].unquoted());
- return;
- }
- if (args.contains ("--focustest"))
- {
- // LYNX --focustest report.txt (issue #161): the main window with the Playlist and the Piano roll (native
- // child windows with docking on). For each: LYNX goes to the background (the main window loses the focus),
- // the user comes back with a click in the panel, then presses Space: playback must start. Also: a text
- // field's focus comes back with the window, and inside the active window the click's answer is unchanged.
- // Shows a window (takes the foreground on Windows: GUI lock); exit code 0 = OK.
- runFocusTest (args[args.indexOf ("--focustest") + 1].unquoted());
- return;
- }
- if (args.contains ("--simplekeytest"))
- {
- // LYNX --simplekeytest report.txt (round 190fc, 0.1.27 RC H2): the main window in the Simple layout; after a
- // demo opened from Welcome › Start from and after clicks in the dock, its tabs, the Lyrics button, a track
- // header and the grid, Space must start playback (a text field clicked into keeps its typing keys). Shows a
- // window (takes the foreground on Windows: GUI lock); exit code 0 = OK.
- runSimpleKeyTest (args[args.indexOf ("--simplekeytest") + 1].unquoted());
- return;
- }
- if (args.contains ("--pluginstyle")) // round 126: force one style for this run (glow, neon, hardware, vivid; auto = per plugin)
- {
- const auto i = args.indexOf ("--pluginstyle");
- if (i + 1 < args.size())
- {
- const auto name = args[i + 1].unquoted();
- lynx::skin::setForcedStyle (name.equalsIgnoreCase ("auto") ? -1 : (int) lynx::skin::styleFromName (name));
- }
- }
- if (args.contains ("--gfxprobe"))
- {
- // LYNX.exe --gfxprobe report.txt (round 170c, issue #11): renderer checks on this platform's native images —
- // text drawn with a gradient fill (a word with a space in it) and an empty path filled with a gradient must
- // stay inside their shapes. JUCE 8.0.4's CoreGraphics renderer (macOS) clipped to an empty glyph or path as
- // "no clip" and flooded the whole component (Facet EQ's blank pink window).
- const auto i = args.indexOf ("--gfxprobe");
- juce::File (args[i + 1].unquoted()).replaceWithText (lynx::skin::rendererProbeReport());
- quit();
- return;
- }
- if (args.contains ("--steppertest"))
- {
- // LYNX.exe --steppertest <report.txt>: round 170c (#14) — every value stepper of every generated effect editor
- // driven by synthetic input (arrows, click on the value, drag, wheel, trackpad); ends with result=OK / FAIL
- const auto i = args.indexOf ("--steppertest");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String report;
- int fails = 0, count = 0, skips = 0;
- {
- lynx::AudioEngine offline (false);
- auto kinds = lynx::plugui::flLayoutKinds();
- for (const auto own : lynx::plugui::ownLayoutKinds())
- kinds.push_back (own);
- // FL's Default preset when the installation has one (the state-backed controls need FL's state)
- const auto roots = lynx::findFlStudioRoots();
- const auto presets = juce::File (juce::String::fromUTF8 (roots.data.c_str())).getChildFile ("Patches/Plugin presets/Effects");
- for (const auto kind : kinds)
- {
- auto fx = lynx::makeEffectSlot (kind);
- for (const auto& plugin : lynx::flPluginsForEffect (kind))
- {
- juce::MemoryBlock data;
- const auto file = presets.getChildFile (juce::String::fromUTF8 (plugin.c_str())).getChildFile ("Default.fst");
- if (file.existsAsFile() && file.loadFileAsData (data))
- {
- const auto* bytes = static_cast<const std::uint8_t*> (data.getData());
- if (auto loaded = lynx::effectFromFlPreset (std::vector<std::uint8_t> (bytes, bytes + data.getSize()), 130.0, lynx::natives::flDataReader (lynx::flStudioAccess())); loaded && loaded->kind == kind)
- fx = *loaded;
- }
- break;
- }
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- const auto lines = lynx::stepperSelfTest (offline, 1, 0, (int) lynx::plugui::layoutFor (kind).pages.size());
- for (const auto& line : juce::StringArray::fromLines (lines))
- if (line.isNotEmpty())
- {
- ++count;
- fails += line.contains (": FAIL") ? 1 : 0;
- skips += line.contains (": SKIP") ? 1 : 0;
- }
- report << lines;
- juce::PopupMenu::dismissAllActiveMenus();
- offline.dispatchPendingMessages();
- }
- }
- report << "steppers=" << count << " failures=" << fails << " skipped=" << skips << "\nresult=" << (fails == 0 && count > 0 ? "OK" : "FAIL") << "\n";
- juce::File (args[i + 1].unquoted()).replaceWithText (report);
- quit();
- return;
- }
- if (args.contains ("--design190inshot"))
- {
- // LYNX --design190inshot prefix [project.flp]: round 190in off screen (no desktop window, no audio device) —
- // the channel window as it shows docked (FL's ▸, two-tone title, presets in the title bar, the 46 px strip
- // with icon tabs, LED, knobs, RANGE / TRACK badges) on each tab, the floating strip, and FL's ▸ menu
- const auto i = args.indexOf ("--design190inshot");
- runDesign190inShot (args[i + 1].unquoted(), i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--plugui"))
- {
- // LYNX.exe --plugui <folder>: the native effect editors at FL's size (one PNG per editor and page), each
- // loaded with the FL plugin's Default preset when the FL installation has one
- const auto i = args.indexOf ("--plugui");
- runPluginEditorSnapshots (args[i + 1].unquoted());
- return;
- }
- if (args.contains ("--parityshot"))
- {
- // LYNX.exe --parityshot <out.png> <effect name> [<params file>]: one built-in effect's editor with the given
- // parameters ("index value" lines, tools/fxrender --dump), its displays fed by the demo song — the LYNX side
- // of the third-party parity pictures (round tp172b)
- const auto i = args.indexOf ("--parityshot");
- runParityShot (args[i + 1].unquoted(), args[i + 2].unquoted(), i + 3 < args.size() ? args[i + 3].unquoted() : juce::String());
- if (parityShotFailed)
- setApplicationReturnValue (2);
- if (parityShow == nullptr)
- quit();
- return;
- }
- if (args.contains ("--design168rshot"))
- {
- // LYNX.exe --design168rshot <folder>: round 168r's editors (FL effects that had a generated page and LYNX's own
- // simple built-ins) at 100 % and 200 %, with their default settings and, when they have one, the first
- // preset of LYNX's own bank. "--design168rshot <folder> generated": the generated pages they had before
- const auto i = args.indexOf ("--design168rshot");
- if (i + 2 < args.size() && args[i + 2] == "generated")
- lynx::plugui::showGeneratedLayoutsOnly (true);
- runDesign168rShots (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--eq166fshot"))
- {
- // LYNX.exe --eq166fshot <folder>: round 166f's pictures (issue #16) — Parametric EQ 2's spectrum and heatmap
- // (flat, a +12 dB band, a -12 dB band, Top position) and Facet EQ's comparative EQ (listening to the target,
- // its spectrum over the source's), each fed by the demo song rendered offline
- const auto i = args.indexOf ("--eq166fshot");
- runEq166fShots (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--editorcpu"))
- {
- // LYNX.exe --editorcpu report.txt: opens built-in plugin editors one at a time in a small window (no audio
- // device: a silent, idle editor) and writes the process CPU each costs while idle and while its display
- // animates (demo signal) — round 122's check that an idle editor burns no CPU
- const auto i = args.indexOf ("--editorcpu");
- runEditorCpu (args[i + 1].unquoted());
- return;
- }
- if (args.contains ("--precomputeshot"))
- {
- // LYNX.exe --precomputeshot project.(flp|lynx) <prefix>: round 167h — <prefix>-precompute.png (channel 1's
- // Precomputed effects panel) and <prefix>-project.png (Options › Project with "Fast declick for cut groups")
- const auto i = args.indexOf ("--precomputeshot");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine shotEngine (false);
- const juce::File input (args[i + 1].unquoted());
- const auto prefix = args[i + 2].unquoted();
- juce::String error;
- bool ok = false;
- if (input.hasFileExtension ("flp"))
- ok = shotEngine.importFlpFile (input, error);
- else if (auto song = lynx::ProjectFile::load (input, error))
- shotEngine.setSong (std::move (*song)), ok = true;
- shotEngine.dispatchPendingMessages();
- auto shoot = [&] (std::unique_ptr<juce::Component> c, const juce::String& name) {
- if (c == nullptr)
- return false;
- if (c->getWidth() <= 0)
- c->setSize (520, 600);
- savePng (lynx::shot::snapshot (*c), prefix + name);
- return true;
- };
- ok = ok && shoot (lynx::makeChannelPrecomputePanel (shotEngine, 0), "-precompute.png");
- ok = ok && shoot (lynx::makeSettingsPanel (shotEngine, lynx::SettingsPage::project), "-project.png");
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--pluginthumbs"))
- {
- // LYNX.exe --pluginthumbs <folder> [key,key...]: the Plugin picker's pictures of LYNX's own plugins (round 171c,
- // ui/PluginThumbs.h), each editor drawn off-screen and kept as <folder>/<name>.png; the picker starts this in
- // the background when pictures are missing. One line per plugin on stdout.
- const auto i = args.indexOf ("--pluginthumbs");
- lynx::crashguard::quietCrashReports();
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray only;
- if (i + 2 < args.size() && ! args[i + 2].startsWith ("--"))
- only.addTokens (args[i + 2].unquoted(), ",", "");
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- // round 190bi: with --shot-scale / LYNX_SHOT_SCALE each plugin's whole editor at that scale, not the picker's
- // small thumbnail (never for the picker's own cache folder, whatever the environment says)
- const juce::File folder (args[i + 1].unquoted());
- const auto full = lynx::shot::given() && folder != lynx::pluginthumbs::nativeFolder() ? lynx::shot::scale() : 0.0f;
- const auto drawn = lynx::pluginthumbs::renderNative (folder, only, [] (const juce::String& line) {
- std::printf ("%s\n", line.toRawUTF8());
- std::fflush (stdout);
- }, full);
- std::printf ("drawn %d in %.0f ms\n", drawn, juce::Time::getMillisecondCounterHiRes() - t0);
- setApplicationReturnValue (0);
- quit();
- return;
- }
- if (args.contains ("--jsonroundtrip"))
- {
- // LYNX.exe --jsonroundtrip <folder>: round 183c's finding — a project saved, loaded and saved again: both texts
- // (a.json, b.json) and the first lines that differ (diff.txt) for the default song, with and without a Patcher
- const auto i = args.indexOf ("--jsonroundtrip");
- const juce::File out (args[i + 1].unquoted());
- out.createDirectory();
- juce::String report;
- auto check = [&] (const lynx::Song& song, const juce::String& name) {
- const auto a = lynx::ProjectFile::toJson (song);
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (a, error);
- const auto b = back ? lynx::ProjectFile::toJson (*back) : juce::String ("(not loaded: " + error + ")");
- out.getChildFile (name + "-a.json").replaceWithText (a);
- out.getChildFile (name + "-b.json").replaceWithText (b);
- juce::StringArray la, lb;
- la.addLines (a);
- lb.addLines (b);
- report << name << ": " << (a == b ? "stable" : "DIFFERS") << " (" << la.size() << " / " << lb.size() << " lines)\n";
- int shown = 0;
- for (int k = 0; k < juce::jmax (la.size(), lb.size()) && shown < 12; ++k)
- if (la[k] != lb[k])
- {
- report << " line " << (k + 1) << "\n a: " << la[k].trim().substring (0, 200) << "\n b: " << lb[k].trim().substring (0, 200) << "\n";
- ++shown;
- }
- };
- auto song = lynx::Song::makeDefault();
- check (song, "default");
- song.mixer.resize (3);
- song.mixer[1].effects = { lynx::makeEffectSlot (lynx::EffectKind::patcher) };
- check (song, "patcher");
- song.mixer[1].effects = { lynx::rack::makeRackSlot (lynx::RackDoc::Kind::audioEffect) };
- check (song, "rack");
- out.getChildFile ("diff.txt").replaceWithText (report);
- setApplicationReturnValue (0);
- quit();
- return;
- }
- // --prshot190jv <folder> (round 190jv: Piano roll › Scale highlighting › Automatic): src/PrShot190jv.inc
- if (args.contains ("--prshot190jv"))
- {
- setApplicationReturnValue (runPrShot190jv (juce::File (args[args.indexOf ("--prshot190jv") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --prchord190kd <folder> (round 190kd: FL's chord tool strip, scale shading, rack name alignment): src/PrChordShot190kd.inc
- if (args.contains ("--prchord190kd"))
- {
- setApplicationReturnValue (runPrChordShot190kd (juce::File (args[args.indexOf ("--prchord190kd") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --keys190nu <folder> (round chord2_190nu: key regions, the Scale degree chord, pinned Chord helper relationships)
- if (args.contains ("--keys190nu"))
- {
- setApplicationReturnValue (runKeysShot190nu (juce::File (args[args.indexOf ("--keys190nu") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --modal190mc <folder> (round 190mc: the Chord helper, Transistor Bass's program row): src/ModalShot190mc.inc
- if (args.contains ("--modal190mc"))
- {
- setApplicationReturnValue (runModalShot190mc (juce::File (args[args.indexOf ("--modal190mc") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --trimshot190jv <folder> (round 190jv: Mixer menu › Trim unused tracks): src/TrimShot190jv.inc
- if (args.contains ("--trimshot190jv"))
- {
- setApplicationReturnValue (runTrimShot190jv (juce::File (args[args.indexOf ("--trimshot190jv") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --undogesture190jv <report.txt> (round 190jv, queue item 73: one undo step per drag): src/UndoGesture190jv.inc
- if (args.contains ("--undogesture190jv"))
- {
- setApplicationReturnValue (runUndoGesture190jv (juce::File (args[args.indexOf ("--undogesture190jv") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --simplegb190keshot <folder> (round 190ke: tuner, fade-out, Controls tab, LYNX content): src/SimpleGbShot190ke.inc
- if (args.contains ("--simplegb190keshot"))
- {
- setApplicationReturnValue (runSimpleGbShot190ke (juce::File (args[args.indexOf ("--simplegb190keshot") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --browsershot190iz <folder> (round 190iz: FL's tabs, tags, Live's browser): src/BrowserShot190iz.inc
- // --qarest190lcshot <folder> [Live set] (rollup step 7: QA-8's View menu submenu, QA-2's take lanes in Simple):
- // src/QaRest190lcShot.inc
- if (args.contains ("--qarest190lcshot"))
- {
- const auto i = args.indexOf ("--qarest190lcshot");
- const auto set = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- setApplicationReturnValue (runQaRest190lcShot (juce::File (args[i + 1].unquoted()), set) ? 0 : 1);
- quit();
- return;
- }
- // --loopinfo190kxshot <folder> (round 190kx: loop key / tempo in the Simple rows, the Loop Browser, the clip menu)
- if (args.contains ("--loopinfo190kxshot"))
- {
- setApplicationReturnValue (runLoopInfoShot190kx (juce::File (args[args.indexOf ("--loopinfo190kxshot") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --loopshot190kf <folder> (round gaps190kf: the Loop Browser): src/LoopShot190kf.inc
- if (args.contains ("--loopshot190kf"))
- {
- setApplicationReturnValue (runLoopShot190kf (juce::File (args[args.indexOf ("--loopshot190kf") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--lynxmodelshot190ni"))
- {
- // LYNX --lynxmodelshot190ni prefix: round 190ni, LYNX Model's window per preset, its Browser entry, checks
- setApplicationReturnValue (runLynxModelShot190ni (args[args.indexOf ("--lynxmodelshot190ni") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--browsershot190iz"))
- {
- setApplicationReturnValue (runBrowserShot190iz (juce::File (args[args.indexOf ("--browsershot190iz") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--rackshot"))
- {
- // LYNX.exe --rackshot <folder>: round 183c's Rack view drawn off-screen (no window), for the LYNX | Live pairs:
- // rack-deviceview.png (an Audio Effect Rack laid out as in Live's reference shot), rack-mapmode.png (Map mode
- // with the mapping list), rack-instrument.png (an Instrument Rack with its key zones)
- const auto i = args.indexOf ("--rackshot");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto set = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- setApplicationReturnValue (runRackShots (juce::File (args[i + 1].unquoted()), set) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--artshot"))
- {
- // LYNX.exe --artshot <folder> [before|after] [name,name...]: every editor with art of its own (round 170j/170k: the
- // Themed style; or only the named ones, e.g. "sakura,facet-eq") drawn off-screen at 100 % and 200 % as
- // <folder>/<plugin>-<before|after>-<scale>.png. "before" draws each in the style it had before the Themed style
- const auto i = args.indexOf ("--artshot");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto mode = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String ("after");
- if (i + 3 < args.size() && ! args[i + 3].startsWith ("--")) // [name,name...]: only these arts
- artOnly().addTokens (args[i + 3].unquoted(), ",", "");
- setApplicationReturnValue (runArtShots (juce::File (args[i + 1].unquoted()), mode == "before") ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--artgui"))
- {
- // LYNX.exe --artgui <folder> [before|after|still] [name,name...]: the same editors in REAL windows on the desktop, one at a
- // time (always on top, no focus taken), each held while an outside script screenshots it (it writes
- // <folder>/<plugin>.ready with the window's bounds and waits up to 10 s for <folder>/<plugin>.done), then the
- // process CPU it costs over 6 s is written to <folder>/cpu-<mode>.txt. "still": Themed with the motion off
- const auto i = args.indexOf ("--artgui");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto mode = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String ("after");
- if (i + 3 < args.size() && ! args[i + 3].startsWith ("--")) // [name,name...]: only these arts
- artOnly().addTokens (args[i + 3].unquoted(), ",", "");
- runArtGui (juce::File (args[i + 1].unquoted()), mode);
- return;
- }
- if (args.contains ("--instrumentshot"))
- {
- // LYNX.exe --instrumentshot <folder> <engine,engine...|banks> [lynx|fl]: round 168n — the channel window of
- // each engine (its Plugin tab) at 100 %, 150 % and 200 %, as <folder>/<engine>-<source>-<scale>.png. Source
- // "lynx" starts from the engine's LYNX bank (what a PC without FL gets), "fl" from FL's Default preset.
- const auto i = args.indexOf ("--instrumentshot");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto source = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String ("lynx");
- setApplicationReturnValue (runInstrumentShots (juce::File (args[i + 1].unquoted()), args[i + 2].unquoted(), source) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--flextrashot"))
- {
- // LYNX.exe --flextrashot <folder>: pictures of the editors of round 165g (Big Clock, Tuner, HTML NoteBook, Mute 2, Scratcher, Transmitter) + round 167n Transporter
- const auto i = args.indexOf ("--flextrashot");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine shotEngine (false);
- const auto ok = lynx::runFlExtraShots (shotEngine, juce::File (args[i + 1].unquoted()));
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--visualtest"))
- {
- // LYNX.exe --visualtest <folder> [project.flp]: the visual plugins (round 164c) — the audio path's CPU, every
- // Wave Candy mode and Visualizer scene drawn from a test signal (PNG + the editor's CPU each), and the video
- // export of a project (default: FL's first ZGameEditor demo) with ffmpeg and as images. Writes report.txt.
- const auto i = args.indexOf ("--visualtest");
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? juce::File (args[i + 2].unquoted()) : juce::File();
- lynx::runVisualTest (juce::File (args[i + 1].unquoted()), project, [this] (bool ok) {
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- });
- return;
- }
- if (args.contains ("--menu-entry"))
- {
- // LYNX.AppImage --menu-entry on|off: puts the AppImage in the applications menu (and .lynx files on it) or
- // takes it out again, without opening a window; the same as the switch in Options › General (round 161)
- const auto i = args.indexOf ("--menu-entry");
- const auto on = args[i + 1].unquoted() != "off";
- const auto ok = lynx::runningAsAppImage() && lynx::setAppImageMenuEntry (on);
- std::fprintf (ok ? stdout : stderr, "%s\n", ok ? (on ? "LYNX SHARE added to the applications menu" : "LYNX SHARE removed from the applications menu")
- : "only the LYNX SHARE AppImage on Linux can do this");
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--leftovers190nrtest"))
- {
- // round 190nr: going back to an older version removes what newer versions added to the install folder
- // (the --apply-update helper's step after the installer). Prints "result=OK" or the failing check.
- const auto root = juce::File::createTempFile ("lynx-leftovers190nr");
- juce::StringArray fails;
- auto run = [&] (const juce::String& version, bool licensesGone, bool listGone) {
- root.deleteRecursively();
- root.getChildFile ("install/licenses").createDirectory();
- root.getChildFile ("install/licenses/onnxruntime-LICENSE.txt").replaceWithText ("x");
- root.getChildFile ("install/LYNX.exe").replaceWithText ("x");
- root.getChildFile ("install/installed-files.txt").replaceWithText ("LYNX.exe\r\nlicenses\r\n");
- root.getChildFile ("install/My notes.txt").replaceWithText ("x");
- root.getChildFile ("update/installing.txt").create();
- if (version.isNotEmpty())
- root.getChildFile ("update/installing.txt").replaceWithText ("from=0.1.31\nrollback=1\nversion=" + version + "\n");
- const auto removed = lynx::updater::removeNewerLeftovers (root.getChildFile ("install"), root.getChildFile ("update/installing.txt"));
- const auto in = root.getChildFile ("install");
- if (in.getChildFile ("licenses").exists() == licensesGone) fails.add (version + ": licenses");
- if (in.getChildFile ("installed-files.txt").exists() == listGone) fails.add (version + ": installed-files.txt");
- if (! in.getChildFile ("LYNX.exe").existsAsFile() || ! in.getChildFile ("My notes.txt").existsAsFile()) fails.add (version + ": removed too much");
- std::printf ("%s -> removed [%s]\n", version.toRawUTF8(), removed.joinIntoString (", ").toRawUTF8());
- };
- run ("0.1.29-alpha", true, true); // going back to 0.1.29: both newer entries go
- run ("0.1.28.1-alpha", true, true);
- run ("0.1.30-alpha", false, true); // 0.1.30 installs licenses itself
- run ("0.1.31-alpha", false, false); // same or newer: nothing goes
- run ("0.1.32", false, false);
- run ("", false, false); // unreadable note: nothing goes
- root.deleteRecursively();
- std::printf ("result=%s%s\n", fails.isEmpty() ? "OK" : "FAILED ", fails.joinIntoString ("; ").toRawUTF8());
- setApplicationReturnValue (fails.isEmpty() ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--send-test-report"))
- {
- // LYNX.exe --send-test-report out.txt [--dry]: builds a crash report marked "test" from the newest crash /
- // hang file and this computer's facts, writes its JSON to out.txt.json and (without --dry) sends it to
- // lynx-share.com (LYNX_CRASH_ENDPOINT overrides); out.txt gets "id=…" and "result=OK" or the error (round 159)
- const auto i = args.indexOf ("--send-test-report");
- const juce::File out (args[i + 1].unquoted());
- lynx::crashreporter::Session session;
- session.version = getApplicationVersion();
- for (const auto* pattern : { "crash *.txt", "hang *.txt" })
- {
- auto files = lynx::platform::settingsFile ("autosave").findChildFiles (juce::File::findFiles, false, pattern);
- lynx::filesort::byTime (files, lynx::filesort::By::modificationTime, true);
- if (! files.isEmpty())
- (juce::String (pattern).startsWith ("crash") ? session.crashFile : session.hangFile) = files[0];
- }
- session.steps = { "00:00:01 test report (LYNX.exe --send-test-report)", "00:00:02 opening project " + out.getFileName() };
- auto input = lynx::crashreporter::makeInput (session, session.crashFile.existsAsFile() ? "crash" : "manual", nullptr);
- input.test = true;
- const auto json = lynx::crashreporter::buildJson (input, false);
- out.withFileExtension (out.getFileExtension() + ".json").replaceWithText (json);
- const auto error = args.contains ("--dry") ? juce::String() : lynx::crashreporter::sendNow (json);
- out.replaceWithText ("id=" + juce::String::fromUTF8 (input.id.c_str()) + "\nendpoint=" + lynx::crashreporter::endpoint() + "\nbytes="
- + juce::String (json.getNumBytesAsUTF8()) + "\nresult=" + (error.isEmpty() ? juce::String ("OK") : error) + "\n");
- setApplicationReturnValue (error.isEmpty() ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--symbolize"))
- {
- // LYNX.exe --symbolize "crash … .txt" out.txt: names the LYNX.exe+offset frames of a user's crash / hang file
- // (needs this build's LYNX.pdb next to LYNX.exe — the release's "LYNX-symbols" CI artifact; round 157a)
- const auto i = args.indexOf ("--symbolize");
- const auto text = juce::File (args[i + 1].unquoted()).loadFileAsString();
- juce::File (args[i + 2].unquoted()).replaceWithText (juce::String::fromUTF8 (lynx::crashguard::symbolizeOwnFrames (text.toStdString()).c_str()));
- quit();
- return;
- }
- if (args.contains ("--opentest"))
- {
- // LYNX.exe --opentest report.txt [--visible]: every built-in effect and instrument window opened as the mixer /
- // Channel rack open them, with default, extreme, random and old-project states; a watchdog fails the test on
- // a hang (round 157a: opening the Parametric EQ froze LYNX). Windows stay off-screen without --visible.
- const auto i = args.indexOf ("--opentest");
- runOpenTest (args[i + 1].unquoted(), args.contains ("--visible"), [this] (bool ok) {
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- });
- return;
- }
- if (args.contains ("--fxfuzz"))
- {
- // LYNX.exe --fxfuzz report.txt [rounds] [--drags]: every built-in effect in its editor, parameters swept (and
- // dragged with the mouse), audio rendered at several rates; a crash ends the process (round 111)
- const auto i = args.indexOf ("--fxfuzz");
- const auto rounds = args.size() > i + 2 ? juce::jmax (1, args[i + 2].getIntValue()) : 6;
- // --drags: also mouse drags over the editors (their menus may flash on screen: not for the selftest)
- const auto ok = runEffectFuzz (rounds, args[i + 1].unquoted(), args.contains ("--drags"));
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--controllershot"))
- {
- // LYNX.exe --controllershot prefix: the built-in controllers' editors (round 133) as PNGs
- const auto i = args.indexOf ("--controllershot");
- runControllerShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--edisonshot"))
- {
- // LYNX.exe --edisonshot prefix [audio.wav]: the audio editor's Edison tool windows (round 165l) and the
- // editor before / after some of them, as PNGs (a synthetic drum loop without a file)
- const auto i = args.indexOf ("--edisonshot");
- runEdisonShot (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--arashot190kx"))
- {
- // LYNX --arashot190kx prefix (round 190kx): the Playlist's audio clip menu with its "Edit in ARA plugin" submenu
- // (a stand-in Melodyne entry in this engine's plugin list, as a scan lists the installed one), before and after the
- // clip's channel is edited in it
- const auto i = args.indexOf ("--arashot190kx");
- runAraShot190kx (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--polyshot190lj") && args.indexOf ("--polyshot190lj") + 2 < args.size())
- {
- // LYNX --polyshot190lj prefix audio.wav [bends.wav] (round 190lj): "Convert to MIDI (polyphonic)" — the audio
- // clip menu (Pattern and Simple layouts), the options dialog, Edison's Tools menu, and the result of a
- // conversion (Playlist, Piano roll; with bends on the second file), plus <prefix>-checks.txt (OK / FAIL)
- const auto i = args.indexOf ("--polyshot190lj");
- const auto ok = runPolyShot190lj (args[i + 1].unquoted(), args[i + 2].unquoted(), i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String());
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--newtoneshot190li"))
- {
- // LYNX --newtoneshot190li prefix audio.wav (round 190li): Newtone with the natural engine (a new slot), as
- // analysed and after Correct pitch 100 / 100 (centre and drift; the vibrato kept), and its Edit menu with the
- // round's items, for the Melodyne | LYNX pairs (with --shot-scale 1.5 for @150)
- const auto i = args.indexOf ("--newtoneshot190li");
- runNewtoneShot190li (args[i + 1].unquoted(), args[i + 2].unquoted());
- quit();
- return;
- }
- if (args.contains ("--polyeditshot190lk") && args.indexOf ("--polyeditshot190lk") + 2 < args.size())
- {
- // LYNX --polyeditshot190lk prefix audio.wav [key] (round 190lk): "Edit notes (polyphonic)" — the audio clip menu,
- // the editor as analysed and after one note (the one nearest `key`, default 64 = E4) moved down a semitone,
- // at 100 % and 150 %, plus <prefix>-checks.txt (OK / FAIL, timings) and <prefix>-notes.txt
- const auto i = args.indexOf ("--polyeditshot190lk");
- const auto ok = runPolyEditShot190lk (args[i + 1].unquoted(), args[i + 2].unquoted(),
- i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].getDoubleValue() : 64.0);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--polyeditshot190lo") && args.indexOf ("--polyeditshot190lo") + 2 < args.size())
- {
- // LYNX --polyeditshot190lo prefix audio.wav [key] (round 190lo): the polyphonic note editor's round-2 tools —
- // note assignment, rubber band and moving several notes, stretch handles, modulation / drift / drawn pitch,
- // a dragged note's preview, Edison's buffer mode and its undo, "Prepare edited clips when a project opens" —
- // at 100 % and 150 %, plus <prefix>-checks.txt and <prefix>-notes.txt
- const auto i = args.indexOf ("--polyeditshot190lo");
- const auto ok = runPolyEditShot190lo (args[i + 1].unquoted(), args[i + 2].unquoted(),
- i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].getDoubleValue() : 64.0);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--newtoneshot190kx"))
- {
- // LYNX --newtoneshot190kx prefix audio.wav (round 190kx): Newtone with FL's analysis and with "Separate close
- // notes", each as analysed and after Center 100 % (Melodyne's Correct Pitch), for the Melodyne | LYNX pairs
- const auto i = args.indexOf ("--newtoneshot190kx");
- runNewtoneShot190kx (args[i + 1].unquoted(), args[i + 2].unquoted());
- quit();
- return;
- }
- if (args.contains ("--newtoneshot"))
- {
- // LYNX --newtoneshot prefix audio.wav (round natives190kj): FL's Newtone window with the sample analysed, in a
- // few states (-plain, -selected, -advanced, -cut, -timesel, -moved) and the paint time of the FL look against
- // the round-165g layout (-paint.txt)
- const auto i = args.indexOf ("--newtoneshot");
- runNewtoneShot (args[i + 1].unquoted(), args[i + 2].unquoted());
- quit();
- return;
- }
- if (args.contains ("--edisonslottest"))
- {
- // LYNX.exe --edisonslottest folder [project.flp]: round 190cd — the audio editor as a mixer-slot plugin through
- // the engine and the project file (report.txt: one "name=ok|FAIL" per check), its window as slot-*.png, and
- // the Edison slots of an FL project (what was read of each)
- const auto i = args.indexOf ("--edisonslottest");
- const auto ok = runEdisonSlotTest (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String());
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--danceshot"))
- {
- // LYNX.exe --danceshot prefix: LYNX Dance (round 165e) — every move as a contact sheet, the channel's editor,
- // and a demo project with two dance channels (for --snapshot)
- const auto i = args.indexOf ("--danceshot");
- runDanceShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--videoshot") && args.indexOf ("--videoshot") + 2 < args.size())
- {
- // LYNX.exe --videoshot prefix video: the Video Player's editor (round 165g) at a few song positions, with
- // the user's ffmpeg, as PNGs + report.txt (frames decoded, the sound track)
- const auto i = args.indexOf ("--videoshot");
- runVideoShot (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--videotrackshot") && args.indexOf ("--videotrackshot") + 2 < args.size())
- {
- // LYNX.exe --videotrackshot prefix video [video2]: round 174d — the Playlist with video tracks (filmstrips,
- // timecode row) and the video window at a few song positions, as PNGs + report.txt (the decoder, the
- // frame shown for each wanted time: frame accuracy, frames dropped)
- const auto i = args.indexOf ("--videotrackshot");
- runVideoTrackShot (args[i + 1].unquoted(), args[i + 2].unquoted(), i + 3 < args.size() ? args[i + 3].unquoted() : juce::String());
- return;
- }
- if (args.contains ("--vfxshot"))
- {
- // LYNX.exe --vfxshot prefix: the VFX note effects' editors (round 164b), on channels and in a Patcher, as PNGs
- const auto i = args.indexOf ("--vfxshot");
- runVfxShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--patchershot"))
- {
- // LYNX.exe --patchershot prefix [project]: every Patcher's editor (round 141) as PNGs (a demo one without a project)
- const auto i = args.indexOf ("--patchershot");
- runPatcherShot (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--audioxshot"))
- {
- // LYNX.exe --audioxshot prefix (round 190aq): the pre-fader send, the "Low latency while recording" mark on a
- // bypassed slot and the Browser's "Preview in time", drawn off-screen
- runAudioXShot (args[args.indexOf ("--audioxshot") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--comp177shot"))
- {
- // LYNX.exe --comp177shot prefix project (round 177c): a project of loop takes in the maximised
- // Playlist as it opened; every group after "Comp these takes", with a swipe on the first; the track and record menus
- const auto i = args.indexOf ("--comp177shot");
- runComp177Shot (args[i + 1].unquoted(), args[i + 2].unquoted());
- quit();
- return;
- }
- if (args.contains ("--evpaneshot"))
- {
- // LYNX --evpaneshot prefix [project] (round 190fz): the Piano roll's event editor divider driven with the mouse
- // handlers (drag, right-click = alternate size and back, middle-click = default, a drag into the snap zone),
- // a picture of each state and prefix-report.txt with the heights and the remembered settings file
- const auto i = args.indexOf ("--evpaneshot");
- setApplicationReturnValue (runEvPaneShot (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--feat166shot"))
- {
- // LYNX.exe --feat166shot prefix [project]: round 166d (issue #14) — the Piano Roll with a scale, folded to
- // it, with one ghost channel, the ghost channels menu, and the Mixer filled to 500 inserts (its start and
- // its end, and the time a full repaint takes)
- const auto i = args.indexOf ("--feat166shot");
- runFeat166Shot (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--pickerdropshot"))
- {
- // LYNX --pickerdropshot prefix: round 190hm (issue #177) — Picker panel entries dropped on the Playlist as FL
- // places them (plain drop: one track per entry at the snapped time; Shift: one after another), off-screen,
- // with <prefix>-checks.txt (OK / FAIL per placement)
- setApplicationReturnValue (runPickerDropShot (args[args.indexOf ("--pickerdropshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--trackmodeshot"))
- {
- // LYNX --trackmodeshot prefix: rollup 190cv (UI gate of PR #151) — Playlist track header › Track mode › Audio
- // track, off-screen, in three states of FL's live check 190cu (q1-01 fresh, q1-02 one insert linked
- // elsewhere and one renamed, q1-07 the full state), plus a report that compares each list with FL's
- setApplicationReturnValue (runTrackModeShot (args[args.indexOf ("--trackmodeshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--curveshot"))
- {
- // LYNX.exe --curveshot prefix: round 190bw — an automation clip with one segment per FL curve mode in the
- // point editor and in the Playlist, and FL's point menu, off-screen
- runCurveShot (args[args.indexOf ("--curveshot") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--remoteshot"))
- {
- // LYNX.exe --remoteshot prefix: Online Sessions P5-A1 (round 190ai) — the host's "Share plugins with guests"
- // list and a guest's parameter editor of a plugin the host plays, off-screen with sample data
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::liveui::saveRemoteShots (args[args.indexOf ("--remoteshot") + 1].unquoted());
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- quit();
- return;
- }
- if (args.contains ("--settingsshot") && ! args.contains ("--rtstress")) // (--rtstress has its own --settingsshot file.png option, round 161)
- {
- // LYNX.exe --settingsshot prefix: round 190bx — every Settings page off-screen at the window's size, in a
- // small window (390 x 390) and, for the long pages, whole (see runSettingsShot)
- runSettingsShot (args[args.indexOf ("--settingsshot") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--perfshot"))
- {
- // LYNX.exe --perfshot prefix project: the Playlist in Performance mode with a few clips launched and waiting,
- // then the project patcherized (every insert's effects, the first channels) saved as prefix-patcherized.lynx
- // for --patchershot (round 165m)
- const auto i = args.indexOf ("--perfshot");
- runPerfShot (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--freezetest"))
- {
- // LYNX.exe --freezetest prefix [project]: round 190ay's Freeze end to end, off-screen (see runFreezeTest)
- const auto i = args.indexOf ("--freezetest");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- // a word after the project: "keep" = freeze, save prefix-frozen.lynx and stop (the audio stays);
- // "measure" = only load and render the project, for the memory and time of a process of its own
- const auto mode = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- setApplicationReturnValue (runFreezeTest (args[i + 1].unquoted(), project, mode) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--trackfreezetest"))
- {
- // LYNX --trackfreezetest prefix: round 190ff's Freeze Track, Flatten / Bounce Track in Place, Bounce to New
- // Track and Consolidate end to end in the Clip-launch workflow, off-screen (see runTrackFreezeTest)
- const auto i = args.indexOf ("--trackfreezetest");
- setApplicationReturnValue (runTrackFreezeTest (args[i + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190ihshot"))
- {
- // LYNX --details190ihshot prefix: round 190ih's live states off screen (no window, no audio device) — Gross
- // Beat's locator and slots from its real engine, the rack's activity light, Play / Pause, the Record blink,
- // the "Note on" hint, the save reminder, the Simple dock's input level, the Envelope Controller's key line
- const auto i = args.indexOf ("--details190ihshot");
- runDetails190ihShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--paintbench"))
- {
- // LYNX --paintbench project.(flp|lynx|als) report.txt (round 190ge): each main view drawn off screen, whole, many
- // times (the message thread's CPU per frame), with the playhead mid-song; no window, no audio device
- const auto i = args.indexOf ("--paintbench");
- runPaintBench (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()));
- quit();
- return;
- }
- if (args.contains ("--design190igshot"))
- {
- // LYNX --design190igshot prefix project.flp: round 190ig off-screen (design190ia slice 3) — the Pattern layout's
- // Playlist with FL's clip and header look: the song at FL's default zoom (26 px tracks, 15.6 px a bar, bar 21),
- // at FL's "zoom 17" (50 px tracks, 39.75 px a bar), and playing (the activity column), as FL's reference shots
- const auto i = args.indexOf ("--design190igshot");
- runDesign190igShot (args[i + 1].unquoted(), args[i + 2].unquoted());
- quit();
- return;
- }
- if (args.contains ("--cliplaunch190kcshot"))
- {
- // LYNX --cliplaunch190kcshot prefix set.als: round 190kc off screen (Live's return tracks, Sends rows, Pre / Post,
- // the crossfader, the map modes' crossfader positions and relative strip, Commit / Extract on audio); prefix-checks.txt
- const auto i = args.indexOf ("--cliplaunch190kcshot");
- const auto set = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- runClipLaunch190kcShot (args[i + 1].unquoted(), set);
- quit();
- return;
- }
- if (args.contains ("--livelook190jnshot"))
- {
- // LYNX --livelook190jnshot prefix [set.als]: round 190jn off screen (design190ia slices 13, 17, 18, 19, 25: the
- // Clip-launch layout in Live's look, and the classic look); prefix-checks.txt
- const auto i = args.indexOf ("--livelook190jnshot");
- const auto set = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- runLiveLook190jnShot (args[i + 1].unquoted(), set);
- quit();
- return;
- }
- if (args.contains ("--fllook190joshot"))
- {
- // LYNX --fllook190joshot prefix project.flp: round 190jo off screen (design190ia slices 12, 21, 23): the Pattern
- // toolbar's tiles in every state, time / tempo / hint / menu bar, at 1920 / 1600 / 1366 / 1280; the Piano roll
- // (FL's rows, notes, keys, grid, ghosts); the audio editor in Edison's layout with FL's "DL Breaker.wav";
- // prefix-checks.txt (note label contrast)
- const auto i = args.indexOf ("--fllook190joshot");
- runFllook190joShot (args[i + 1].unquoted(), i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--capfix190jjshot"))
- {
- // LYNX --capfix190jjshot prefix project.flp [set.als]: round 190jj off screen (capture190ji's changes: Simple
- // capsule states, master meter, pads press, held keys, drop lane ghosts; Live's control bar; FL's C-11 drop ghost
- // and the picker's playing mark); prefix-checks.txt
- const auto i = args.indexOf ("--capfix190jjshot");
- const auto set = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- runCapfix190jjShot (args[i + 1].unquoted(), args[i + 2].unquoted(), set);
- quit();
- return;
- }
- if (args.contains ("--demo190plcheck"))
- {
- // LYNX --demo190plcheck prefix: round 190pl, the --demo operations of tutorial batch 2 (src/Demo190plCheck.inc)
- const auto i = args.indexOf ("--demo190plcheck");
- setApplicationReturnValue (runDemoCheck190pl (args[i + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--demo190pgcheck"))
- {
- // LYNX --demo190pgcheck prefix project.lynx: round 190pg, the --demo operations of the tutorial videos (src/Demo190pgCheck.inc)
- const auto i = args.indexOf ("--demo190pgcheck");
- setApplicationReturnValue (runDemoCheck190pg (args[i + 1].unquoted(), juce::File (i + 2 < args.size() ? args[i + 2].unquoted() : juce::String())) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--onboard190npshot"))
- {
- // LYNX --onboard190npshot prefix: round 190np off screen (src/OnboardShot190np.inc): the welcome card, the choices,
- // the Next-3 card, the empty-state hints, the tips and the Help menu, 100 % and @150, with <prefix>-checks.txt
- const auto i = args.indexOf ("--onboard190npshot");
- setApplicationReturnValue (runOnboardShot190np (args[i + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190oashot"))
- {
- // LYNX --details190oashot prefix project.flp: round 190oa off screen (src/DetailsShot190oa.inc)
- const auto i = args.indexOf ("--details190oashot");
- setApplicationReturnValue (runDetailsShot190oa (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190myshot"))
- {
- // LYNX --details190myshot prefix project.flp: round 190my off screen (src/DetailsShot190my.inc)
- const auto i = args.indexOf ("--details190myshot");
- setApplicationReturnValue (runDetailsShot190my (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190mvshot"))
- {
- // LYNX --details190mvshot prefix project.flp: round 190mv off screen (src/DetailsShot190mv.inc)
- const auto i = args.indexOf ("--details190mvshot");
- setApplicationReturnValue (runDetailsShot190mv (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190mrshot"))
- {
- // LYNX --details190mrshot prefix project.flp: round 190mr off screen (src/DetailsShot190mr.inc)
- const auto i = args.indexOf ("--details190mrshot");
- setApplicationReturnValue (runDetailsShot190mr (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--rack190ncshot") && args.indexOf ("--rack190ncshot") + 1 < args.size())
- {
- // LYNX --rack190ncshot prefix: round 190nc off screen (src/RackShot190nc.inc): Live's rack with its devices
- // inline and the Macro Map overlay (DL-95), the Session mixer's Solo / Cue (DL-110)
- setApplicationReturnValue (runRackShot190nc (args[args.indexOf ("--rack190ncshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190mpshot"))
- {
- // LYNX --details190mpshot prefix project.flp: round 190mp off screen (src/DetailsShot190mp.inc)
- const auto i = args.indexOf ("--details190mpshot");
- setApplicationReturnValue (runDetailsShot190mp (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190mkshot"))
- {
- // LYNX --details190mkshot prefix project.flp: round 190mk off screen (src/DetailsShot190mk.inc)
- const auto i = args.indexOf ("--details190mkshot");
- setApplicationReturnValue (runDetailsShot190mk (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190mfshot"))
- {
- // LYNX --details190mfshot prefix project.flp: round 190mf off screen (src/DetailsShot190mf.inc)
- const auto i = args.indexOf ("--details190mfshot");
- setApplicationReturnValue (runDetailsShot190mf (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190lxshot"))
- {
- // LYNX --details190lxshot prefix project.flp [set.als]: round 190lx off screen (src/DetailsShot190lx.inc)
- const auto i = args.indexOf ("--details190lxshot");
- const auto set = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- setApplicationReturnValue (runDetailsShot190lx (args[i + 1].unquoted(), args[i + 2].unquoted(), set) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190lrshot"))
- {
- // LYNX --details190lrshot prefix project.flp [set.als]: round 190lr off screen (src/DetailsShot190lr.inc)
- const auto i = args.indexOf ("--details190lrshot");
- const auto set = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- setApplicationReturnValue (runDetailsShot190lr (args[i + 1].unquoted(), args[i + 2].unquoted(), set) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190ldshot"))
- {
- // LYNX --details190ldshot prefix project.flp [set.als]: round 190ld off screen (src/DetailsShot190ld.inc)
- const auto i = args.indexOf ("--details190ldshot");
- const auto set = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- setApplicationReturnValue (runDetailsShot190ld (args[i + 1].unquoted(), args[i + 2].unquoted(), set) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190knshot"))
- {
- // LYNX --details190knshot prefix project.flp [set.als]: round 190kn off screen (src/DetailsShot190kn.inc)
- const auto i = args.indexOf ("--details190knshot");
- const auto set = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- setApplicationReturnValue (runDetailsShot190kn (args[i + 1].unquoted(), args[i + 2].unquoted(), set) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--details190imshot"))
- {
- // LYNX --details190imshot prefix project.flp [set.als]: round 190im off-screen (details190if R1, R5, R6, R11, R12,
- // R13, R15) — the automation hints, the Playlist playing (picker marks, glow, overview, activity levels), a drop
- // preview, Follow's pause, the Sampler's handles, and with the Live set the grid's one-shot / follow / queued
- // scene / deactivated clip / hints and the Clip View's launched position; prefix-checks.txt
- const auto i = args.indexOf ("--details190imshot");
- const auto set = i + 3 < args.size() && ! args[i + 3].startsWith ("--") ? args[i + 3].unquoted() : juce::String();
- runDetails190imShot (args[i + 1].unquoted(), args[i + 2].unquoted(), set);
- quit();
- return;
- }
- if (args.contains ("--toolbarshot190qg"))
- {
- // LYNX --toolbarshot190qg prefix [project]: round 190qg off screen — the toolbar walk (every preset, icon size,
- // Interface size and window width: each item on the toolbar or in its overflow), every preset's toolbar at
- // 80-175 % on 1280 / 1920 px screens, the overflow menus; exit 0 = the walk passed (src/ToolbarShot190qg.inc)
- const auto i = args.indexOf ("--toolbarshot190qg");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- setApplicationReturnValue (runToolbarShot190qg (args[i + 1].unquoted(), project) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--toolbarshot190iv"))
- {
- // LYNX --toolbarshot190iv prefix [project.als]: round 190iv off screen — the toolbar of each layout style (Pattern,
- // Simple, Clip-launch) at 1920 / 1366 / 1280, the Simple transport capsule idle / hover / pressed / playing /
- // recording, the "Last saved" status in its four states, Live's control bar with every button idle / hover /
- // pressed / lit, the "⋯" menus, and a report of the parts' bounds
- const auto i = args.indexOf ("--toolbarshot190iv");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- runToolbarShot190iv (args[i + 1].unquoted(), project);
- quit();
- return;
- }
- if (args.contains ("--gridshot"))
- {
- // LYNX.exe --gridshot prefix [project]: the Clip-launch workflow's layout off-screen, with a grid of sample
- // clips, some playing and waiting, at the size of LYNX_SNAPSHOT_SIZE (round 181a); with a project (.lynx,
- // .flp, .als), that project's grid instead (round 181c: a Live set's Session view as LYNX imports it)
- const auto i = args.indexOf ("--gridshot");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- runGridShot (args[i + 1].unquoted(), project);
- quit();
- return;
- }
- if (args.contains ("--tour190dvshot"))
- {
- // LYNX.exe --tour190dvshot prefix: round 190dv off-screen — the Simple workflow's Welcome screen, every step of
- // the first-song tour done with its "Do it for me" (a loop dropped for the loop step), the end card, Back /
- // Next / close, the Help menu, the chooser's tour button, Start from with the three demo songs, a demo
- // opened in Simple — and a text report of the checks (incl. resources/demos/*.lynx = the generated songs)
- const auto i = args.indexOf ("--tour190dvshot");
- runTour190dvShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--donateshot"))
- {
- // LYNX --donateshot prefix: round 190fq off-screen (no window) — Help › Support LYNX SHARE... in the three
- // layouts, the Support window, the About window's Support button, the start-up support note in the main
- // window, and the note's rules end to end on its saved state (run it with LYNX_PROFILE_DIR: it writes
- // support-note.txt there, and puts the old one back at the end); report prefix-report.txt, exit 0 = OK
- const auto i = args.indexOf ("--donateshot");
- setApplicationReturnValue (runDonateShot (args[i + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--simpleclosetest"))
- {
- // LYNX --simpleclosetest <report.txt>: round 190fc off-screen (no window) — the main window in the Simple
- // layout with Welcome, the tour, Start from, a demo, the dock's tabs, Finish and Lyrics open, then closed as at
- // shutdown (the 0.1.27 RC crashed on every such close); exit code 0 = OK
- const auto i = args.indexOf ("--simpleclosetest");
- setApplicationReturnValue (runSimpleCloseTest (args[i + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--patterns190ea"))
- {
- // LYNX --patterns190ea <report.txt>: round 190ea off-screen (no window) — a song with no pattern at all
- // reaching the engine in every layout (the Simple dock's Editor tab, the Piano roll panel of the Pattern
- // layout, the Clip-launch layout), the last pattern deleted, all patterns cleared by an edit, undo / redo,
- // a live session's remote song and an out-of-range current pattern; each must leave one pattern and not crash
- const auto i = args.indexOf ("--patterns190ea");
- setApplicationReturnValue (runPatterns190ea (args[i + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--reabl190foshot"))
- {
- // LYNX --reabl190foshot prefix: round 190fo off-screen — the Simple Sampler track's 16 pads in the dock, its
- // menus and kits, the typing keys, the .lynx round trip, a folder of stems and MIDI files — and a report
- const auto i = args.indexOf ("--reabl190foshot");
- runReabl190foShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--simple190dsshot"))
- {
- // LYNX.exe --simple190dsshot prefix: round 190ds off-screen, at 1x and 2x — loops dropped in the Simple
- // workflow following the project key (the dock's switch, the clip menu), the docked Piano roll in the Editor
- // tab, the keyboard's modes Keys / Scale keys / Chord pad with the scale selector — and a text report
- const auto i = args.indexOf ("--simple190dsshot");
- runSimple190dsShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--simple190dgshot"))
- {
- // LYNX.exe --simple190dgshot prefix: round 190dg's additions to the Simple dock off-screen, at 1x and 2x —
- // the Effects tab with all eight one-knob cards and each card alone, a chain preset with Blend, the
- // favourites in the Preset menu, the sound picker (a search, My plugins with a made-up plugin list) — and a
- // text report of the checks
- const auto i = args.indexOf ("--simple190dgshot");
- runSimple190dgShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--simplefxshot"))
- {
- // LYNX.exe --simplefxshot prefix: round 190bu's track dock of the Simple workflow off-screen, at 1x and 2x —
- // the Instrument tab (LYNX sounds, My SoundFonts), the Effects tab (empty, a preset, its menus), and a text
- // report: the dock's edits, a user preset saved and loaded, the same slots in the Pattern workflow's Mixer
- const auto i = args.indexOf ("--simplefxshot");
- runSimpleFxShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--simple190jcshot"))
- {
- // LYNX.exe --simple190jcshot prefix: round 190jc's Simple layout look (design190ia slices 5, 14, 15, 22, 24 and
- // Large controls) off-screen, at 1x and 2x, with a text report
- const auto i = args.indexOf ("--simple190jcshot");
- runSimple190jcShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--simpleshot"))
- {
- // LYNX.exe --simpleshot prefix: round 184a's Simple workflow off-screen — View › Layout style with each style
- // chosen, Settings › General (Pattern, then Simple selected) with its style list, the window in Pattern, then
- // Simple, then Pattern again, and how many Simple workflow objects existed before and after (0 before)
- const auto i = args.indexOf ("--simpleshot");
- runSimpleShot (args[i + 1].unquoted());
- quit();
- return;
- }
- // --versionsshot <prefix> (round 190ap): the Versions panel, File's new items, a project opened without its
- // third-party plugins (window, list, File menu) and the Export window's additions, offscreen
- if (args.contains ("--versionsshot"))
- {
- runVersionsShot (args[args.indexOf ("--versionsshot") + 1].unquoted());
- quit();
- return;
- }
- // --linkshot <prefix> (round 190bt): FL's Remote control settings / Global link settings windows, the control
- // menu with "Link to controller...", the formula presets and controller menus and the Multilink items,
- // offscreen; prefix-checks.txt holds the round's checks of the engine, the project file and the settings
- if (args.contains ("--linkshot"))
- {
- setApplicationReturnValue (runLinkShot (args[args.indexOf ("--linkshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --flctlshot <prefix> (round 190df): FL's multilink menu (on / off), the plugin menu's A/B and "Link all
- // parameters...", the sampler's File row with its Sample history, and the Envelope / instrument page of a sampler
- // running FL's voice with its envelope presets, offscreen; prefix-checks.txt holds the checks
- if (args.contains ("--flctlshot"))
- {
- setApplicationReturnValue (runFlCtlShot (args[args.indexOf ("--flctlshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --samplerpageshot <prefix> (round 190dh): FL's Sampler page offscreen (shots and checks in prefix-checks.txt)
- if (args.contains ("--samplerpageshot"))
- {
- setApplicationReturnValue (runSamplerPageShot (args[args.indexOf ("--samplerpageshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --flplshot <prefix> (round 190dx): the audio clip menu (Preview, Automate › Panning / Volume), the Playlist's "+"
- // and its menu, Track mode › Instrument track, the Channel rack's "Assign to new instrument track", Tools › One-click
- // audio recording and Mixer › Disk recording › Latency compensation, offscreen; prefix-checks.txt holds the checks
- // --hdrshot190ft <prefix> (round 190ft, issues #163 / #164): FL's track-header selection and resize rules driven
- // with synthetic mouse events on the Playlist headers and the mixer strips, offscreen; prefix-checks.txt
- if (args.contains ("--hdrshot190ft"))
- {
- setApplicationReturnValue (runHdrShot190ft (args[args.indexOf ("--hdrshot190ft") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --dawprojcheck190jf <prefix> <project> (round 190jf, slice B22): export to DAWproject and open it again
- if (args.contains ("--dawprojcheck190jf") && args.indexOf ("--dawprojcheck190jf") + 2 < args.size())
- {
- const auto at = args.indexOf ("--dawprojcheck190jf");
- setApplicationReturnValue (runDawProjectCheck190jf (args[at + 1].unquoted(), juce::File (args[at + 2].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --foldersshot190jf <prefix> <thief.flp> (round 190jf, slice B17): the Playlist's folders; prefix-checks.txt
- if (args.contains ("--foldersshot190jf") && args.indexOf ("--foldersshot190jf") + 2 < args.size())
- {
- const auto at = args.indexOf ("--foldersshot190jf");
- setApplicationReturnValue (runFoldersShot190jf (args[at + 1].unquoted(), juce::File (args[at + 2].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --userfixshot190ib <prefix> (round 190ib): issue #182's type-to-jump in a real popup menu (the Playlist's Edit menu
- // of the issue's screenshot, typed into), #183's Piano roll item, #181's Ctrl+, through the main window's keys;
- // prefix-checks.txt
- if (args.contains ("--userfixshot190ib"))
- {
- setApplicationReturnValue (runUserFixShot190ib (args[args.indexOf ("--userfixshot190ib") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190ht <prefix> (round 190ht): issue #127's other tools on Pattern Blocks (Mute, Select + group move,
- // Slice, Zoom) and issue #154's insert effects list on linked headers, driven with synthetic mouse events,
- // offscreen; prefix-checks.txt and pictures
- if (args.contains ("--issuesshot190ht"))
- {
- setApplicationReturnValue (runIssuesShot190ht (args[args.indexOf ("--issuesshot190ht") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --chordlane190pfshot <prefix> (round 190pf, research190oe P13 / P12): src/ChordLaneShot190pf.inc
- if (args.contains ("--chordlane190pfshot"))
- {
- setApplicationReturnValue (runChordLaneShot190pf (args[args.indexOf ("--chordlane190pfshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --sections190olshot <prefix> (round 190ol, research190oe P1 / P6): src/SectionsShot190ol.inc
- if (args.contains ("--sections190olshot"))
- {
- setApplicationReturnValue (runSectionsShot190ol (args[args.indexOf ("--sections190olshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --playlistshot190jq <prefix> (round 190jq, issues #164 and #191): src/PlaylistShot190jq.inc
- if (args.contains ("--playlistshot190jq"))
- {
- setApplicationReturnValue (runPlaylistShot190jq (args[args.indexOf ("--playlistshot190jq") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --focus218shot190ng <prefix> (round 190ng, issue #218): src/Focus218Shot190ng.inc
- if (args.contains ("--focus218shot190ng"))
- {
- setApplicationReturnValue (runFocus218Shot190ng (args[args.indexOf ("--focus218shot190ng") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --mixerqolshot190qh <prefix> [project.flp] (round 190qh, research190qa R5 Mixer QoL): src/MixerQolShot190qh.inc
- if (args.contains ("--mixerqolshot190qh"))
- {
- const auto i = args.indexOf ("--mixerqolshot190qh");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- setApplicationReturnValue (runMixerQolShot190qh (args[i + 1].unquoted(), project) ? 0 : 1);
- quit();
- return;
- }
- // --slots260shot <prefix> (round 190qf, PR #260: FL 2026.2's mixer slots): src/Slots260Shot190qf.inc
- if (args.contains ("--slots260shot"))
- {
- setApplicationReturnValue (runSlots260Shot (args[args.indexOf ("--slots260shot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --mixer221shot190ng <prefix> (round 190ng, issue #221): src/Mixer221Shot190ng.inc
- if (args.contains ("--mixer221shot190ng"))
- {
- setApplicationReturnValue (runMixer221Shot190ng (args[args.indexOf ("--mixer221shot190ng") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --research190onshot <prefix> (round 190on: research190oe P2, P8, P10): src/Research190onShot.inc
- if (args.contains ("--research190onshot"))
- {
- setApplicationReturnValue (runResearchShot190on (args[args.indexOf ("--research190onshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190nq <prefix> (round 190nq, issues #193, #225-#230): src/IssuesShot190nq.inc
- if (args.contains ("--issuesshot190nq"))
- {
- setApplicationReturnValue (runIssuesShot190nq (args[args.indexOf ("--issuesshot190nq") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --design190ojshot <prefix> [project] (round 190oj, design review): src/Design190ojShot.inc
- if (args.contains ("--design190ojshot"))
- {
- const auto i = args.indexOf ("--design190ojshot");
- setApplicationReturnValue (runDesign190ojShot (args[i + 1].unquoted(), i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- // --rackauto190owshot <prefix> [project.flp] [probe.flp] (round 190ow, PAT-7 rest / DE-123): src/RackAuto190owShot.inc
- if (args.contains ("--rackauto190owshot"))
- {
- const auto i = args.indexOf ("--rackauto190owshot");
- const auto arg = [&args] (int k) { return k < args.size() && ! args[k].startsWith ("--") ? args[k].unquoted() : juce::String(); };
- setApplicationReturnValue (runRackAuto190owShot (args[i + 1].unquoted(), arg (i + 2), arg (i + 3)) ? 0 : 1);
- quit();
- return;
- }
- // --extras190qkshot <prefix> (round 190qk: the LYNX extras on by default, FL-exact / Recommended): src/Extras190qkShot.inc
- if (args.contains ("--extras190qkshot"))
- {
- setApplicationReturnValue (runExtras190qkShot (args[args.indexOf ("--extras190qkshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --design190ooshot <prefix> [project] (round 190oo, design review 2): src/Design190ooShot.inc
- if (args.contains ("--design190ooshot"))
- {
- const auto i = args.indexOf ("--design190ooshot");
- setApplicationReturnValue (runDesign190ooShot (args[i + 1].unquoted(), i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- // --rollup031s3shot <prefix> (rollup 0.1.31 step 3, round 190ny): src/Rollup031S3Shot.inc
- if (args.contains ("--rollup031s3shot"))
- {
- setApplicationReturnValue (runRollup031S3Shot (args[args.indexOf ("--rollup031s3shot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --tabs2test190nz <a|b> <folder> (round 190nz, issue #232 stage 2: copy and paste between two LYNX windows):
- // src/Tabs2Test190nz.inc
- if (args.contains ("--tabs2test190nz"))
- {
- const auto i = args.indexOf ("--tabs2test190nz");
- setApplicationReturnValue (runTabs2Test190nz (args[i + 1].unquoted(), juce::File (args[i + 2].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --headergearshot248 <prefix> (rollup 0.1.31 step 7, PRs #248 / #256): src/HeaderGearShot248.inc
- if (args.contains ("--headergearshot248"))
- {
- setApplicationReturnValue (runHeaderGearShot (args[args.indexOf ("--headergearshot248") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --hotfix190qpwfshot <prefix> (round 190qp, 0.1.31.1 hotfix): src/Hotfix190qpWf.inc, its checks and pictures
- if (args.contains ("--hotfix190qpwfshot"))
- {
- const auto prefix = args[args.indexOf ("--hotfix190qpwfshot") + 1].unquoted();
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto r = hotfix190qpWfCheck (prefix);
- juce::File (prefix + "-checks.txt").replaceWithText ("hotfix190qp_wf=" + r + "\n");
- setApplicationReturnValue (r == "OK" ? 0 : 1);
- quit();
- return;
- }
- // --pickerpaint190qi <report> (round 190qi): the plugin lists' and the Browser's paint cost, src/PickerPaintBench190qi.inc
- if (args.contains ("--pickerpaint190qi"))
- {
- runPickerPaint190qi (juce::File (args[args.indexOf ("--pickerpaint190qi") + 1].unquoted()));
- setApplicationReturnValue (0);
- quit();
- return;
- }
- // --picker190qishot <folder> (round 190qi, picker and Browser quality of life): src/Picker190qiShot.inc
- if (args.contains ("--picker190qishot"))
- {
- setApplicationReturnValue (runPicker190qiShot (juce::File (args[args.indexOf ("--picker190qishot") + 1].unquoted())) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190qo <prefix> (round 190qo, issues #239, #215, #251, #270): src/IssuesShot190qo.inc
- if (args.contains ("--issuesshot190qo"))
- {
- setApplicationReturnValue (runIssuesShot190qo (args[args.indexOf ("--issuesshot190qo") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190qb <prefix> (round 190qb, follow-ups of issues #206 and #215): src/IssuesShot190qb.inc
- if (args.contains ("--issuesshot190qb"))
- {
- setApplicationReturnValue (runIssuesShot190qb (args[args.indexOf ("--issuesshot190qb") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190oq <prefix> (round 190oq, issues #243-#252): src/IssuesShot190oq.inc
- if (args.contains ("--issuesshot190oq"))
- {
- setApplicationReturnValue (runIssuesShot190oq (args[args.indexOf ("--issuesshot190oq") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190od <prefix> (round 190od, issues #236-#242): src/IssuesShot190od.inc
- if (args.contains ("--issuesshot190od"))
- {
- setApplicationReturnValue (runIssuesShot190od (args[args.indexOf ("--issuesshot190od") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190ns <prefix> (round 190ns, issues #231-#235): src/IssuesShot190ns.inc
- if (args.contains ("--issuesshot190ns"))
- {
- setApplicationReturnValue (runIssuesShot190ns (args[args.indexOf ("--issuesshot190ns") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issuesshot190ng <prefix> (round 190ng, issues #215, #217, #219, #220, #222): src/IssuesShot190ng.inc
- if (args.contains ("--issuesshot190ng"))
- {
- setApplicationReturnValue (runIssuesShot190ng (args[args.indexOf ("--issuesshot190ng") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --tracker190nwshot <prefix> [module] (round 190nw, 0.1.31: the built-in tracker): src/TrackerShot190nw.inc
- if (args.contains ("--tracker190nwshot"))
- {
- const auto i = args.indexOf ("--tracker190nwshot");
- setApplicationReturnValue (runTrackerShot190nw (args[i + 1].unquoted(), i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String()) ? 0 : 1);
- quit();
- return;
- }
- // --automodes190pashot <prefix> (round 190pa, 0.1.32: automation write modes, range edits on chosen tracks): src/AutoModesShot190pa.inc
- if (args.contains ("--automodes190pashot"))
- {
- setApplicationReturnValue (runAutoModesShot190pa (args[args.indexOf ("--automodes190pashot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --trackstates190opshot <prefix> (round 190op, 0.1.31: Hide / Deactivate tracks, Capture automation): src/TrackStatesShot190op.inc
- // --tracks190peshot <prefix> (round 190pe, 0.1.32: Track versions, Import tracks from another project): src/Tracks190peShot.inc
- if (args.contains ("--tracks190peshot"))
- {
- setApplicationReturnValue (runTracks190peShot (args[args.indexOf ("--tracks190peshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--trackstates190opshot"))
- {
- setApplicationReturnValue (runTrackStatesShot190op (args[args.indexOf ("--trackstates190opshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --trackclips190neshot <prefix> (round 190ne, 0.1.31: track clips): src/TrackClipsShot190ne.inc
- if (args.contains ("--trackclips190neshot"))
- {
- setApplicationReturnValue (runTrackClipsShot190ne (args[args.indexOf ("--trackclips190neshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issueshot190mq <prefix> (round 190mq, issues #211, #212, #213): src/IssuesShot190mq.inc
- if (args.contains ("--issueshot190mq"))
- {
- setApplicationReturnValue (runIssuesShot190mq (args[args.indexOf ("--issueshot190mq") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issueshot190lw <prefix> (round 190lw, issues #205, #206, #207): src/IssuesShot190lw.inc
- if (args.contains ("--issueshot190lw"))
- {
- setApplicationReturnValue (runIssuesShot190lw (args[args.indexOf ("--issueshot190lw") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --issueshot190jz <prefix> (round 190jz, issues #192, #194, #195): src/IssuesShot190jz.inc
- if (args.contains ("--issueshot190jz"))
- {
- setApplicationReturnValue (runIssuesShot190jz (args[args.indexOf ("--issueshot190jz") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --workflowshot190iu <prefix> (round 190iu, issues #186 and #191): src/WorkflowShot190iu.inc
- if (args.contains ("--workflowshot190iu"))
- {
- setApplicationReturnValue (runWorkflowShot190iu (args[args.indexOf ("--workflowshot190iu") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --trackautoshot190gz <prefix> (round 190gz, issue #170): LYNX's "Link Playlist tracks to mixer tracks" — the
- // switch, the linked headers' M / S / volume / pan driven with synthetic mouse events, row sizes, undo and the
- // .lynx round trip, offscreen; prefix-checks.txt
- if (args.contains ("--trackautoshot190gz"))
- {
- setApplicationReturnValue (runTrackAutoShot190gz (args[args.indexOf ("--trackautoshot190gz") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--flplshot"))
- {
- setApplicationReturnValue (runFlPlShot (args[args.indexOf ("--flplshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --genpresetshot <prefix> (round 190fs): the channel window's preset box with the user's own presets (Save
- // preset..., Your presets, Delete preset, Show the presets folder) for Fruity DX10, 3x Osc and LYNX's synth, the
- // name box, a load (one undo step) and the Browser's new channel, offscreen; prefix-checks.txt holds the checks
- if (args.contains ("--genpresetshot"))
- {
- setApplicationReturnValue (runGenPresetShot (args[args.indexOf ("--genpresetshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --flfixshot <prefix> (round 190ey): what the live FL session 190ew found different (the Sampler page, the
- // Multilink menu, the Playlist, issue #152's question), offscreen; prefix-checks.txt holds the checks
- if (args.contains ("--flfixshot"))
- {
- setApplicationReturnValue (runFlFixShot (args[args.indexOf ("--flfixshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- // --flclipshot <prefix> (round 190dz): FL's audio clip menu layout (two columns, FL's sections, LYNX's own items at
- // the end) and the channel's Misc › Levels adjustment, offscreen; prefix-checks.txt holds the checks
- if (args.contains ("--flclipshot"))
- {
- setApplicationReturnValue (runFlClipShot (args[args.indexOf ("--flclipshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--warpshot"))
- {
- // LYNX.exe --warpshot prefix: round 190cg's pictures (warp commands in the audio editor, the Clip page's
- // Audio panel, the arrangement with the loop switched off, a folded track, signature changes), off-screen
- const auto i = args.indexOf ("--warpshot");
- runWarpShot (args[i + 1].unquoted());
- quit();
- return;
- }
- // --bandlab190jrshot <prefix> (round 190jr): a .blx imported as Simple tracks, the region loop handle, the Simple
- // automation view and its menu, the Extract stems form; <prefix>-report.txt with ok / FAIL lines
- if (args.contains ("--bandlab190jrshot"))
- {
- runBandlab190jrShot (args[args.indexOf ("--bandlab190jrshot") + 1].unquoted());
- quit();
- return;
- }
- // --bandlabshot <prefix> (round 190ch): Lyrics / Notes, Reference match, Start from and Clean voice, offscreen
- if (args.contains ("--bandlabshot"))
- {
- runBandlabShot (args[args.indexOf ("--bandlabshot") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--mpeshot190hy"))
- {
- // LYNX --mpeshot190hy prefix: round 190hy (issue #108, MPE stage 2) off-screen: the Piano roll's MPE lanes (pitch
- // bend, slide, pressure) over notes with curves in Pattern workflow, then the Clip-launch layout's Clip page with
- // its Notes and MPE tabs. Writes prefix-checks.txt.
- runMpeShot190hy (args[args.indexOf ("--mpeshot190hy") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--detailshot"))
- {
- // LYNX.exe --detailshot prefix: the Clip-launch workflow's detail view off-screen (round 183a): a track's chain
- // (instrument, effects, one off, one folded), its clip page, and Pattern workflow before / after, at
- // LYNX_SNAPSHOT_SIZE. Writes prefix-counts.txt with what the chain shows.
- const auto i = args.indexOf ("--detailshot");
- runDetailShot (args[i + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--meldshot190ko"))
- {
- // LYNX.exe --meldshot190ko prefix meld.adv spectraltime.adv spectralresonator.adv: round 190ko off-screen, in the
- // Clip-launch layout: a track whose instrument is what a Live Meld preset imports onto (Braid) and whose insert
- // holds what Spectral Time and Spectral Resonator presets import onto (Timeprism, Harmonia), on the Device View.
- // Writes prefix-devices.png and prefix-checks.txt.
- const auto i = args.indexOf ("--meldshot190ko");
- runMeldShot190ko (args[i + 1].unquoted(), args[i + 2].unquoted(), args[i + 3].unquoted(), args[i + 4].unquoted());
- quit();
- return;
- }
- if (args.contains ("--livedevshot190kk"))
- {
- // LYNX.exe --livedevshot190kk prefix: round 190kk off-screen, in the Clip-launch layout: a track whose insert holds
- // what Live's Erosion, Vinyl Distortion and Corpus (Core Library presets) import onto — Corrode, Platter,
- // Soundboard — on the Device View as ordinary effect cards. Writes prefix-devices.png and prefix-checks.txt.
- runLiveDevShot190kk (args[args.indexOf ("--livedevshot190kk") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--liverackshot190hr"))
- {
- // LYNX.exe --liverackshot190hr prefix: round 190hr off-screen, in the Ableton-style layout: the Device View's
- // instrument menu with Group / Ungroup, an instrument grouped into an Instrument Rack and back, a rack's Save
- // Preset button and drop area (a device dropped in, an instrument refused), Live's own .adg presets opened
- // with their chains, and a saved .adg read back. Writes prefix-checks.txt.
- runLiveRackShot190hr (args[args.indexOf ("--liverackshot190hr") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--helixshot190mi"))
- {
- // LYNX --helixshot190mi prefix [bank preset name]: round 190mi off-screen, the Pattern layout's Helix channel
- // window with Helix+'s strip, from a factory preset (default "Growl FM"): the device + strip, LFO 1 (drawn),
- // the Matrix page (macros, Helix+'s rows); --shot-scale 1.5 --shot-suffix @150 for the 150 % pictures.
- const auto i = args.indexOf ("--helixshot190mi");
- runHelixShot190mi (args[i + 1].unquoted(), i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String ("Growl FM"));
- quit();
- return;
- }
- if (args.contains ("--helixshot190oc"))
- {
- // LYNX --helixshot190oc prefix: round 190oc off-screen: the Pattern layout's Helix channel window with round 4's
- // row (Grain Swarm, Spectral Ensemble; Frozen Choir and Triple Stack for the side by side with 190mt), the strip's
- // row alone; paint costs in prefix-checks.txt
- runHelixShot190oc (args[args.indexOf ("--helixshot190oc") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--helixshot190mt"))
- {
- // LYNX --helixshot190mt prefix: round 190mt off-screen: the Pattern layout's Helix channel window with round 3's
- // row (Grain Cloud, Frozen Choir, Spectral Glass; Triple Stack for the side by side with 190ml), the Matrix page with
- // the new rows, and the Clip-launch Device View card's Helix+ panel; paint costs in prefix-checks.txt.
- runHelixShot190mt (args[args.indexOf ("--helixshot190mt") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--helixshot190ml"))
- {
- // LYNX --helixshot190ml prefix: round 190ml off-screen: the Pattern layout's Helix channel window with Helix+ 2's
- // rows (Triple Stack, Vowel Sync), the Matrix page's Macros tab, the table editor (Draw, Harmonics) and the
- // Clip-launch Device View card without / with its Helix+ panel; paint costs in prefix-checks.txt.
- runHelixShot190ml (args[args.indexOf ("--helixshot190ml") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--helixshot190ja"))
- {
- // LYNX --helixshot190ja prefix [Wavetable preset .adv]: round 190ja off-screen, the Clip-launch layout's Device
- // View with a Helix track (the preset's values imported as a Live set would bring them, else Helix's defaults):
- // the device and its pages (Matrix, MIDI, MPE, Env 2, LFO 1, Osc 2), then the Pattern layout's channel window.
- const auto i = args.indexOf ("--helixshot190ja");
- runHelixShot190ja (args[i + 1].unquoted(), i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--liveshot190ce"))
- {
- // LYNX.exe --liveshot190ce prefix: round 190ce off-screen, in the Ableton-style layout: the Device View's cards
- // with their hot-swap and save buttons, a device's menu, hot-swap on (the Browser's bar, the lit button), a
- // swap and its undo, a duplicate, and the Browser's collections (STARRED tab, the Collections menu, a search
- // by a collection's name). Writes prefix-checks.txt.
- runLiveShot190ce (args[args.indexOf ("--liveshot190ce") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--missingsearchshot190eo"))
- {
- // LYNX --missingsearchshot190eo prefix folder...: round 190eo (integration of issue #159's fix) off-screen: the
- // Missing files window's Samples page while a real search of the folders runs (matches streamed in, Stop
- // shown, Apply usable). Writes prefix-searching.png and prefix-checks.txt; the search is let go at the end.
- const auto i = args.indexOf ("--missingsearchshot190eo");
- const auto prefix = args[i + 1].unquoted();
- juce::StringArray folders;
- for (int k = i + 2; k < args.size(); ++k)
- folders.add (args[k].unquoted());
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- std::shared_ptr<juce::Component> panel = lynx::makeMissingFilesPanelSearching (lynx::missingFilesSnapshotInfo(), folders);
- juce::Timer::callAfterDelay (700, [this, panel, prefix] {
- juce::String status;
- bool stopShown = false, applyEnabled = false;
- const auto searching = lynx::missingFilesSearchState (*panel, status, stopShown, applyEnabled);
- auto image = lynx::shot::paint (*panel, lynx::theme::panel);
- const auto file = juce::File (prefix + "-searching.png");
- file.deleteFile();
- if (auto out = file.createOutputStream())
- juce::PNGImageFormat().writeImageToStream (image, *out);
- juce::String checks;
- auto check = [&checks] (const char* name, bool ok, const juce::String& detail) {
- checks << name << "=" << (ok ? "OK" : "FAIL") << " " << detail << "\n";
- };
- check ("still_searching_at_the_shot", searching, {});
- check ("status_shows_the_walk", status.contains (lynx::tr ("Searching {0}... {1} files looked at").upToFirstOccurrenceOf ("{0}", false, false)), status);
- check ("stop_shown", stopShown, {});
- check ("apply_usable_during_the_search", applyEnabled, {});
- lynx::stopMissingFilesSearch (*panel);
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- quit();
- });
- return;
- }
- // --grooveshot190fm <prefix> (round 190fm): a Playlist pattern clip's menu with its Groove items (the chooser, Commit,
- // Extract) and the "Classic swing" folder, and a Groove Pool holding classic swing grooves, offscreen;
- // prefix-checks.txt holds the checks (also the .lynx round trip of a Playlist clip's groove)
- if (args.contains ("--grooveshot190fm"))
- {
- setApplicationReturnValue (runGrooveShot190fm (args[args.indexOf ("--grooveshot190fm") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--mtshot190fm"))
- {
- // LYNX --mtshot190fm prefix: round 190fm off-screen: the MIDI Tools panel's Generate tab with each generator
- // (prefix-generate-rhythm.png … -euclidean.png), the five side by side as Live's picture shows them
- // (prefix-generate-panels.png; Live's: ableton190o/shots/live-04-generate-panels.png), then each generator
- // written into a one-bar pattern and undone again: prefix-checks.txt.
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- runMtShot190fm (args[args.indexOf ("--mtshot190fm") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--drumshot190ec"))
- {
- // LYNX.exe --drumshot190ec prefix: round 190ec off-screen: a demo Drum Rack's pad view (default and scrolled), its
- // chain list with I-O, sends and return chains, a new empty Drum Rack and the Piano roll's pad names. Writes
- // prefix-checks.txt (hit tests: C1 bottom-left, overview scroll, a pad dragged onto another swaps them).
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::drumshot::run (args[args.indexOf ("--drumshot190ec") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--linkshot190gl"))
- {
- // LYNX --linkshot190gl prefix (round 190gl): Ableton Link off-screen with a second Link peer in this process —
- // the toolbar in FL's Pattern layout (hidden by default, then shown, off and on) and in the Clip-launch layout
- // ("1 Link", the position display's progress bar, Play waiting), Settings › Ableton Link, the toggle's
- // drop-down and the Options menu. Writes prefix-checks.txt.
- runLinkShot190gl (args[args.indexOf ("--linkshot190gl") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--communityshot190hp"))
- {
- // LYNX --communityshot190hp prefix (round 190hp): global MIDI mappings, Mix snapshots and Split at silence
- // off-screen; writes prefix-checks.txt
- runCommunityShot190hp (args[args.indexOf ("--communityshot190hp") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--mapshot190ef"))
- {
- // LYNX.exe --mapshot190ef prefix: round 190ef's map modes off-screen, in the Clip-launch workflow: MIDI Map Mode
- // (the overlay over the grid, the Session mixer, the Device View and the transport; the Mapping Browser with
- // Min / Max), Key Map Mode, the row menu, the title bar's Draw / Key / MIDI switches, Ctrl+M / Ctrl+K and the
- // Pattern layout keeping Ctrl+M. Writes prefix-checks.txt.
- runMapShot190ef (args[args.indexOf ("--mapshot190ef") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--sceneshot190ef"))
- {
- // LYNX.exe --sceneshot190ef prefix: round 190ef's scene work off-screen, in the Clip-launch workflow: the scene
- // column with its tempo / time signature fields, the scene menu, a scene field's menu, the column title's menu
- // (Rename, colours), a duplicated scene and a captured scene. Writes prefix-checks.txt.
- runSceneShot190ef (args[args.indexOf ("--sceneshot190ef") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--drawshot190ef"))
- {
- // LYNX.exe --drawshot190ef prefix: round 190ef off-screen, in the Clip-launch workflow: Draw Mode in an
- // automation lane, steps at the grid width and an Alt (no grid) freehand stroke drawn through the Playlist's
- // own mouse handlers, and the Options menu with "Draw Mode". Writes prefix-checks.txt.
- runDrawShot190ef (args[args.indexOf ("--drawshot190ef") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--clipenvshot190gi"))
- {
- // LYNX.exe --clipenvshot190gi prefix: round 190gi off-screen: audio clip envelopes on the Playlist (volume and
- // pan lanes, edited through the Playlist's own mouse handlers), the clip menu's LYNX extras (Clip envelope ›,
- // Auto-warp, Quantize audio, run from the menu), warp flags added on the flag strip and moved with Alt + drag,
- // and the Clip-launch Clip View's Envelopes tab (Clip › Gain, Mixer › Track Panning). Writes prefix-checks.txt.
- runClipEnvShot190gi (args[args.indexOf ("--clipenvshot190gi") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--gapsshot190kf"))
- {
- // LYNX.exe --gapsshot190kf prefix [file.wav]: round gaps190kf off-screen: the Clip View's warp time line (Live's
- // loop brace and Start / End markers under the beat-time ruler, the seconds ruler of an unwarped clip) on the
- // probe of gaps190kf/live/cv-clipview.als (voice.wav, warp markers at 30 % / 55 %, Loop 1.3 … 3.3, Start 1.4).
- const auto i = args.indexOf ("--gapsshot190kf");
- runGapsShot190kf (args[i + 1].unquoted(), i + 2 < args.size() ? args[i + 2].unquoted() : juce::String());
- quit();
- return;
- }
- if (args.contains ("--livefactsshot190gx"))
- {
- // LYNX.exe --livefactsshot190gx prefix: round 190gx off-screen: the Clip page's Audio panel in Live's 190gu
- // layout (Beats: Preserve label + chooser, the loop-mode icon chooser beside the Transient Envelope box;
- // Tones / Texture: Grain Size [+ Flux]; Complex [Pro]), the Envelopes tab with a Clip Gain staircase on Live's
- // axis, choosers at the bottom left, and an unwarped clip without the Envelopes tab. Writes prefix-checks.txt.
- runLiveFactsShot190gx (args[args.indexOf ("--livefactsshot190gx") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--dvshot190hr"))
- {
- // LYNX.exe --dvshot190hr prefix: round 190hr off-screen, the Clip-launch Clip View: a MIDI clip whose Start
- // marker sits inside its loop, with its own scale and a follow action (Launch panel controls), the docked
- // editor's grid value and menu, Ctrl+1 / Ctrl+3 / Ctrl+U on it, the Quantize Settings panel, and an audio clip
- // transposed past ±12. Writes prefix-checks.txt.
- runDvShot190hr (args[args.indexOf ("--dvshot190hr") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--warpshot190fm"))
- {
- // LYNX.exe --warpshot190fm prefix: round 190fm off-screen: the Clip page's Audio panel of a grid audio clip in
- // Beats (Preserve, Transient Loop Mode, Envelope), Tones and Texture (Grain Size), Complex (none), and the clip
- // made unique by a mode change while another clip shares its channel (O16). Writes prefix-checks.txt.
- runWarpShot190fm (args[args.indexOf ("--warpshot190fm") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--liveshot190dr"))
- {
- // LYNX.exe --liveshot190dr prefix: round 190dr off-screen, in the Clip-launch workflow: the Session mixer
- // under the clip grid (default sections, Track Options, Volume only, hidden, its View menu), the Clip page's
- // Sample panel of an audio clip (Warp on / off, the Set buttons while it plays, the sample's title) and a
- // device dragged from one track's Device View to another track. Writes prefix-checks.txt.
- runLiveShot190dr (args[args.indexOf ("--liveshot190dr") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--modshot190ox"))
- {
- // LYNX.exe --modshot190ox prefix [--shot-scale 1.5 --shot-suffix @150] (round 190ox, modulators stage 2): the
- // Modulators window, rings on knobs, the Modulate with menu; checks in prefix-checks.txt
- runModShot190ox (args[args.indexOf ("--modshot190ox") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--gapshot190og"))
- {
- // LYNX.exe --gapshot190og prefix [--shot-scale 1.5 --shot-suffix @150] (round gap190og, coverage rows still open on
- // 0.1.31): in the Clip-launch layout, the Edit menu's Live block on the Device View (deviceview-0012), the Clip
- // panel's Duplicate (Loop) button (detail-019), the clip menu's Crop Clip and Ctrl+Shift+J (detail-020), the
- // Velocity lane's Randomize footer (detail-047), Key Map Mode on the transport switches (mapping-0028);
- // checks in prefix-checks.txt
- runGapShot190og (args[args.indexOf ("--gapshot190og") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--undoshot190mz"))
- {
- // LYNX.exe --undoshot190mz prefix [--shot-scale 1.5 --shot-suffix @150] (round 190mz, issue #214): the main
- // window's undo keys with three edits, in both "Alternate undo mode" settings, and the Edit menu after each
- // step in the Pattern, Clip-launch and Simple layouts (prefix-menu-*.png); checks in prefix-checks.txt
- runUndoShot190mz (args[args.indexOf ("--undoshot190mz") + 1].unquoted());
- quit();
- return;
- }
- if (args.contains ("--design190igs4shot"))
- {
- // LYNX.exe --design190igs4shot prefix [set.als]: round 190ig slice 4 off-screen, in the Clip-launch layout with the
- // set imported there (Live's colours, CL-6): the Session grid in Live's look idle, then the launch states —
- // playing, a launch waiting (both blink phases), a stop waiting, recording, the status pie at 25 / 50 / 75 % —
- // and the same with Animations off, then round 181a's look (the option); prefix-checks.txt
- const auto i = args.indexOf ("--design190igs4shot");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- runDesign190igS4Shot (args[i + 1].unquoted(), project);
- quit();
- return;
- }
- if (args.contains ("--typeaheadtest"))
- {
- // LYNX.exe --typeaheadtest out.txt: issue #64 — a real popup menu (headings, a submenu) driven by key presses
- // through its window's peer, as the OS delivers them; writes what got the highlight and what was picked
- const auto i = args.indexOf ("--typeaheadtest");
- runTypeAheadTest (juce::File (args[i + 1].unquoted()));
- return;
- }
- if (args.contains ("--choosertest"))
- {
- // LYNX --choosertest out.txt file: issue #72 — opens LYNX's file chooser as the UI does (makeFileChooser +
- // launchChooser) and reports which dialog came up and what reached the callback. A built-in dialog is shot
- // (out.txt.png), `file` typed into it and confirmed; a native one (zenity / kdialog) is left to answer.
- const auto i = args.indexOf ("--choosertest");
- runChooserTest (juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()));
- return;
- }
- if (args.contains ("--stabilityshot"))
- {
- // LYNX --stabilityshot <folder> (round 190gg): offscreen PNGs of the crash prompt, the plugin window's crash
- // notice, the Plugin manager's "Separate process" column and the monitor's dropout line (no window opens)
- const auto i = args.indexOf ("--stabilityshot");
- runStabilityShot (args[i + 1].unquoted());
- return;
- }
- if (args.contains ("--repeats190pmshot"))
- {
- // LYNX --repeats190pmshot <folder> (round 190pm, research190oe P19 / P23): Note Repeats and Conditions, Touch mode
- setApplicationReturnValue (runRepeatsShot190pm (args[args.indexOf ("--repeats190pmshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--discord190qushot"))
- {
- // LYNX --discord190qushot <folder> [lanes.flp] (round 190qu, Discord 11-24): keys, Clip View, lanes, Simple, Track-only
- const auto i = args.indexOf ("--discord190qushot");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- setApplicationReturnValue (runDiscordShot190qu (args[i + 1].unquoted(), project) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--simpleduck190otshot"))
- {
- // LYNX --simpleduck190otshot <folder> (round 190ot, research190oe P5): "Duck under..." and the Echo send at 100 / 150 %
- setApplicationReturnValue (runSimpleDuckShot190ot (args[args.indexOf ("--simpleduck190otshot") + 1].unquoted()) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--smarttipshot190ok"))
- {
- // LYNX --smarttipshot190ok <folder> [project.flp] (round 190ok, D1): the smart-disable tip at 100 / 150 %
- const auto i = args.indexOf ("--smarttipshot190ok");
- const auto project = i + 2 < args.size() && ! args[i + 2].startsWith ("--") ? args[i + 2].unquoted() : juce::String();
- setApplicationReturnValue (runSmartTipShot190ok (args[i + 1].unquoted(), project) ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--monitorshot190of"))
- {
- // LYNX --monitorshot190of <folder> (round 190of): the Plugin performance monitor with its sample numbers
- // (Longest, Spikes) at 100 % and 150 %, off screen
- const juce::File dir (args[args.indexOf ("--monitorshot190of") + 1].unquoted());
- dir.createDirectory();
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- offline.dispatchPendingMessages();
- for (const auto scale : { 1.0f, 1.5f })
- {
- auto panel = lynx::makePluginMonitorPanel (offline);
- juce::Component frame;
- frame.setSize (panel->getWidth(), panel->getHeight());
- frame.setOpaque (true);
- frame.addAndMakeVisible (*panel);
- savePng (frame.createComponentSnapshot (frame.getLocalBounds(), true, scale),
- dir.getChildFile (scale > 1.0f ? "plugin-monitor@150.png" : "plugin-monitor.png").getFullPathName());
- }
- }
- setApplicationReturnValue (0);
- quit();
- return;
- }
- if (args.contains ("--jsfxshots"))
- {
- // LYNX --jsfxshots <folder> [--shot-scale 1.5 --shot-suffix @150] (round 190pj): the JSFX slider panels of
- // bundled scripts, the Browser's JSFX category and Settings › File with the JSFX folders, off screen
- const auto i = args.indexOf ("--jsfxshots");
- runJsfxShots (args[i + 1].unquoted());
- return;
- }
- if (args.contains ("--snapshot"))
- {
- const auto i = args.indexOf ("--snapshot");
- runSnapshot (args[i + 1].unquoted(), args[i + 2].unquoted());
- return;
- }
- if (args.contains ("--stemsplit"))
- {
- // LYNX.exe --stemsplit input.wav folder ["stems=111100 model=2 ..."]: the stem separation of the clip menu,
- // without the window (round 190jr: the options as the settings file writes them; none = every stem, Standard)
- const auto i = args.indexOf ("--stemsplit");
- lynx::AudioEngine loader (false);
- const auto options = i + 3 < args.size() && args[i + 3].unquoted().containsChar ('=') ? lynx::stemsplit::optionsFromText (args[i + 3].unquoted().toStdString())
- : lynx::stemsplit::Options {};
- const auto started = juce::Time::getMillisecondCounterHiRes();
- const auto error = lynx::extractStemsToFolder (loader, juce::File (args[i + 1].unquoted()), juce::File (args[i + 2].unquoted()), options);
- std::fprintf (stderr, "stemsplit: %.0f ms\n", juce::Time::getMillisecondCounterHiRes() - started);
- juce::File (args[i + 2].unquoted()).getSiblingFile ("stemsplit.txt").replaceWithText (error.isEmpty() ? "result=OK\n" : "result=FAIL " + error + "\n");
- setApplicationReturnValue (error.isEmpty() ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--audio2midi"))
- {
- // LYNX.exe --audio2midi input.wav melody|harmony|drums notes.csv: the clip menu's Convert to MIDI, without the
- // window (round a2m189b's measurements)
- // Round 190lj: mode "poly" = the "Convert to MIDI (polyphonic)" dialog's path, settings after the CSV as
- // key=value (poly=0|1 note=0..1 split=0..1 minms=N low=K high=K bends=0|1); audio2midi.txt also gets the
- // seconds spent resampling, in the model and making the notes.
- const auto i = args.indexOf ("--audio2midi");
- const auto mode = args[i + 2] == "drums" ? lynx::a2m::Mode::drums : args[i + 2] == "harmony" ? lynx::a2m::Mode::harmony : lynx::a2m::Mode::melody;
- lynx::AudioEngine loader (false);
- const juce::File csv (args[i + 3].unquoted());
- juce::String error, timing;
- if (args[i + 2] == "poly")
- {
- lynx::a2m::ConvertOptions options;
- for (int k = i + 4; k < args.size() && args[k].containsChar ('='); ++k)
- {
- const auto key = args[k].upToFirstOccurrenceOf ("=", false, false);
- const auto value = args[k].fromFirstOccurrenceOf ("=", false, false);
- if (key == "poly") options.polyphonic = value.getIntValue() != 0;
- else if (key == "note") options.noteSensitivity = value.getFloatValue();
- else if (key == "split") options.splitSensitivity = value.getFloatValue();
- else if (key == "minms") options.minNoteMs = value.getDoubleValue();
- else if (key == "low") options.minKey = value.getIntValue();
- else if (key == "high") options.maxKey = value.getIntValue();
- else if (key == "bends") options.pitchBends = value.getIntValue() != 0;
- }
- error = lynx::convertFileToMidiCsv (loader, juce::File (args[i + 1].unquoted()), options, csv, &timing);
- }
- else
- error = lynx::convertFileToMidiCsv (loader, juce::File (args[i + 1].unquoted()), mode, csv);
- csv.getSiblingFile ("audio2midi.txt").replaceWithText (error.isEmpty() ? "result=OK\n" + (timing.isEmpty() ? juce::String() : "seconds=" + timing + "\n")
- : "result=FAIL " + error + "\n");
- setApplicationReturnValue (error.isEmpty() ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--stems") || args.contains ("--stemexport"))
- {
- // LYNX.exe --stems project.(flp|als|lynx) base.wav [--separate]: one WAV per insert that has sound (like
- // "Export stems"), in one render of the song (round 190gj; --separate: one render per insert, as before).
- // LYNX.exe --stemexport project base.ext options.txt [--separate]: what the Export window writes with these
- // options (exportopts::toText lines: stems, sections, the full mix, formats...), the same code.
- // Both write <base>.txt: the files with their peaks, the renders, the wall and CPU time.
- const auto full = args.contains ("--stemexport");
- const auto i = args.indexOf (full ? "--stemexport" : "--stems");
- const auto separate = args.contains ("--separate");
- juce::String error, report;
- int written = 0;
- {
- lynx::AudioEngine loader (false);
- const juce::File input (args[i + 1].unquoted()), base (args[i + 2].unquoted());
- // an .flp or a Live set (.als) opens through the import, as File › Open does (round 182b)
- auto ok = input.hasFileExtension ("flp;als") ? loader.importFlpFile (input, error) : false;
- if (! input.hasFileExtension ("flp;als"))
- if (auto song = lynx::ProjectFile::load (input, error))
- {
- loader.setSong (std::move (*song));
- ok = true;
- }
- const auto& song = loader.getSong();
- lynx::StemPlan plan;
- if (full && ok)
- plan = lynx::planStemExport (song, lynx::exportopts::fromText (juce::File (args[i + 3].unquoted()).loadFileAsString().toStdString()), base);
- else if (ok)
- {
- // every insert a channel goes to, as "<base> - <insert>.wav", 24-bit, 6 s of tail at most
- lynx::ExportSettings settings;
- plan.sets.push_back ({ song, settings.toOptions() });
- for (int t = 1; t < (int) song.mixer.size(); ++t)
- if (std::any_of (song.channels.begin(), song.channels.end(), [t] (const lynx::ChannelDef& c) { return c.mixerTrack == t; }))
- plan.items.push_back ({ juce::String (t), base.getSiblingFile (base.getFileNameWithoutExtension() + " - " + juce::String (t) + ".wav"), 0, t,
- lynx::makeBounceSong (song, t), settings.toOptions() });
- }
- const auto wallStart = juce::Time::getMillisecondCounterHiRes();
- const auto cpuStart = std::clock();
- lynx::StemRunStats stats;
- std::vector<juce::String> lines (plan.items.size());
- auto previous = wallStart; // (one render per file: the time since the file before is its render's)
- written = lynx::runStemExport (
- plan, [] (std::function<void()> f) { f(); }, {}, {}, {},
- [&] (std::size_t k, bool done, float peak) {
- const auto now = juce::Time::getMillisecondCounterHiRes();
- if (done)
- lines[k] = plan.items[k].file.getFileName() + " peak=" + juce::String (peak) + " ms=" + juce::String (now - previous, 0) + "\n";
- previous = now;
- },
- separate, full, &stats);
- const auto wallMs = juce::Time::getMillisecondCounterHiRes() - wallStart;
- const auto cpuMs = 1000.0 * (double) (std::clock() - cpuStart) / (double) CLOCKS_PER_SEC;
- for (const auto& line : lines)
- report << line;
- report << "renders=" << (stats.passes + stats.alone) << " shared=" << stats.passes << " inshared=" << stats.inPass
- << " alone=" << stats.alone << "\n";
- for (const auto& why : stats.why)
- report << "alone: " << why << "\n";
- report << "wall_ms=" << juce::String (wallMs, 0) << " cpu_ms=" << juce::String (cpuMs, 0) << " make_ms=" << juce::String (stats.makeMs, 0)
- << " render_ms=" << juce::String (stats.renderMs, 0) << "\n";
- }
- report << "stems=" << written << "\n";
- juce::File (args[i + 2].unquoted() + ".txt").replaceWithText (report);
- setApplicationReturnValue (written > 0 ? 0 : 1);
- quit();
- return;
- }
- // --export-als <in.lynx|.flp|.als> <folder> [--live11] [--reference] [--scan]: "<folder>/<name> Project/<name>.als" (round 175a)
- if (args.contains ("--export-als"))
- {
- const auto i = args.indexOf ("--export-als");
- runAlsExport (args[i + 1].unquoted(), args[i + 2].unquoted(), args.contains ("--live11"), args.contains ("--reference"));
- return;
- }
- // --export-flm <in.lynx|.flp|.als|.flm|...> <out.flm> (round 190og, FLM coverage app-0003): File › "Save a copy as FL
- // Studio Mobile project" without the window; the samples go beside it, the losses and the result to "<out>.txt".
- // --flmexportshot <prefix> <project> [--shot-scale 1.5 --shot-suffix @150]: the window with that project's losses
- if (args.contains ("--export-flm") || args.contains ("--flmexportshot"))
- {
- const auto shot = args.contains ("--flmexportshot");
- const auto i = args.indexOf (shot ? "--flmexportshot" : "--export-flm");
- const juce::File input (args[i + (shot ? 2 : 1)].unquoted());
- juce::String error, report;
- auto ok = false;
- {
- lynx::AudioEngine loader (false);
- if (input.hasFileExtension ("flp;als;flm;songtmpl;band;blx;mod;xm;s3m;it;dawproject"))
- ok = loader.importFlpFile (input, error);
- else if (auto song = lynx::ProjectFile::load (input, error))
- {
- loader.setSong (std::move (*song));
- ok = true;
- }
- if (ok && shot)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::FlmExportOptions o;
- o.title = input.getFileNameWithoutExtension().toStdString();
- const auto dry = lynx::exportFlm (loader.getSong(), o);
- auto list = std::make_shared<juce::TextEditor>();
- std::unique_ptr<juce::AlertWindow> w (lynx::buildFlmExportWindow (dry, list));
- saveSnapshot (*w, args[i + 1].unquoted() + "-flmexport.png");
- report << lynx::flmExportLossText (dry) << "\n";
- }
- else if (ok)
- {
- loader.capturePluginStates();
- lynx::FlmExportResult result;
- const juce::File out (args[i + 2].unquoted());
- ok = lynx::writeFlmCopy (loader.getSong(), out, result, error);
- report << "bytes=" << (int) result.bytes.size() << "\nsamples=" << (int) result.samples.size() << "\n";
- for (const auto& l : result.lost)
- report << (l.sound ? "sound: " : "other: ") << juce::String::fromUTF8 (l.text.c_str()).replace ("{0}", juce::String::fromUTF8 (l.detail.c_str())) << "\n";
- }
- }
- report << "result=" << (ok ? "OK" : "ERROR " + error) << "\n";
- juce::File (args[i + (shot ? 1 : 2)].unquoted() + (shot ? "-flmexport.txt" : ".txt")).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- // --gamepadshot <prefix> (round 184a, S16): the game controller's hints overlay and the MIDI settings page with
- // the option on, offscreen, plus the poller fed fake pad states ("<prefix>-gamepad.txt")
- if (args.contains ("--gamepadshot"))
- {
- runGamepadShot (args[args.indexOf ("--gamepadshot") + 1].unquoted());
- return;
- }
- // --midioutshot <prefix> [--shot-scale 1.5] (round 190jl): Settings › MIDI with the output devices' Port boxes
- // (the snapshot's sample devices: the volca on port 1 of its own, the drum machine with master sync), offscreen
- if (args.contains ("--midioutshot"))
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- {
- lynx::AudioEngine engine (false);
- auto page = lynx::makeMidiPage (engine, {}, false);
- page->setSize (1000, 1300);
- savePng (lynx::shot::snapshot (*page), args[args.indexOf ("--midioutshot") + 1].unquoted() + "-settings-midi.png");
- }
- setApplicationReturnValue (0);
- quit();
- return;
- }
- // --export-bundle <in.lynx|.flp|.als> <folder> [--zip] [--no-mixdown] [--shot <prefix>] (round 184a, S9): File ›
- // Export › "For other apps..." without the window; the report goes to "<folder>/export-bundle.txt"
- if (args.contains ("--export-bundle"))
- {
- const auto i = args.indexOf ("--export-bundle");
- runBundleExport (args[i + 1].unquoted(), args[i + 2].unquoted(), args.contains ("--zip"), ! args.contains ("--no-mixdown"),
- args.contains ("--shot") ? args[args.indexOf ("--shot") + 1].unquoted() : juce::String());
- return;
- }
- if (args.contains ("--export-flp"))
- {
- const auto i = args.indexOf ("--export-flp");
- runFlExport (args[i + 1].unquoted(), args[i + 2].unquoted(), args.contains ("--substitute"));
- return;
- }
- if (args.contains ("--export"))
- {
- const auto i = args.indexOf ("--export");
- const auto insert = args.contains ("--insert") ? args[args.indexOf ("--insert") + 1].getIntValue() : 0;
- runExport (args[i + 1].unquoted(), args[i + 2].unquoted(), args.contains ("--pattern"), insert);
- return;
- }
- if (args.contains ("--tempomarkershot"))
- {
- // LYNX --tempomarkershot <prefix> <project.lynx> (round 190hq): the Playlist of the project with its tempo
- // markers on the ruler (-playlist.png) and the "Save a copy for an older LYNX" window for each release
- // (-savecopy-<release>.png); no window, nothing saved
- const auto i = args.indexOf ("--tempomarkershot");
- const auto prefix = args[i + 1].unquoted();
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine shotEngine (false);
- juce::String error;
- auto ok = false;
- if (auto song = lynx::ProjectFile::load (juce::File (args[i + 2].unquoted()), error))
- shotEngine.setSong (std::move (*song)), ok = true;
- if (ok)
- {
- {
- lynx::PlaylistComponent playlist (shotEngine);
- playlist.setBounds (0, 0, 1400, 420);
- playlist.setVisible (true);
- playlist.setViewForSnapshot (70.0, 0, 0);
- shotEngine.dispatchPendingMessages();
- saveSnapshot (playlist, prefix + "-playlist.png");
- }
- auto list = std::make_shared<juce::TextEditor>();
- std::unique_ptr<juce::AlertWindow> w (lynx::MainComponent::buildSaveCopyWindow (lynx::ProjectFile::toJson (shotEngine.getSong()), list));
- const auto releases = lynx::olderlynx::releases();
- for (int k = 0; k < releases.size(); ++k)
- {
- w->getComboBoxComponent ("release")->setSelectedItemIndex (k, juce::sendNotificationSync);
- saveSnapshot (*w, prefix + "-savecopy-" + releases[k] + ".png");
- }
- }
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--savecopyfor"))
- {
- // LYNX --savecopyfor <in.lynx> <release> <out.lynx> (round 190hq, B20): File › "Save a copy for an older
- // LYNX..." without the window; what the copy loses goes to <out.lynx>.txt (English), then result=OK
- const auto i = args.indexOf ("--savecopyfor");
- const juce::File input (args[i + 1].unquoted()), output (args[i + 3].unquoted());
- const auto release = args[i + 2].unquoted();
- juce::String report, error;
- auto ok = false;
- if (const auto song = lynx::ProjectFile::load (input, error))
- {
- const auto copy = lynx::olderlynx::forRelease (*song, release);
- for (const auto& l : copy.lost)
- report << (l.sound ? "sound: " : "view: ") << juce::String::fromUTF8 (l.text).replace ("{0}", l.detail) << "\n";
- ok = copy.ok && output.replaceWithText (copy.json, false, false, nullptr);
- if (! copy.ok)
- error = copy.error;
- }
- report << "result=" << (ok ? juce::String ("OK") : "ERROR " + error) << "\n";
- juce::File (output.getFullPathName() + ".txt").replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- if (args.contains ("--render"))
- {
- const auto i = args.indexOf ("--render");
- runRender (args[i + 1].unquoted(), args[i + 2].unquoted(), args[i + 3].getDoubleValue());
- return;
- }
- // session breadcrumb: a fail-fast (no crash handler runs) still leaves the last steps behind (round 111)
- uncleanLastStep = collectUncleanSessions();
- sessionsFolder().createDirectory();
- lynx::crashguard::beginSession (
- sessionsFolder().getChildFile ("session-" + juce::String (lynx::crashguard::processId()) + ".txt").getFullPathName().toStdString(),
- ("LYNX session\nversion=" + getApplicationVersion() + "\npid=" + juce::String (lynx::crashguard::processId())
- + "\nstart=" + juce::String ((juce::int64) lynx::crashguard::processStartTime())
- + "\nstarted=" + juce::Time::getCurrentTime().toISO8601 (true) + "\n").toStdString());
- startHangWatch();
- // LYNX_PROFILE_MAIN=<file> (round 174f): the message thread sampled every millisecond, 5-second windows
- if (const auto profile = juce::SystemStats::getEnvironmentVariable ("LYNX_PROFILE_MAIN", {}); profile.isNotEmpty())
- lynx::crashguard::startMainProfiler (profile.toStdString());
- startupTrace.mark ("initialise (normal start)");
- // (round 190hd, Windows) how long before the trace's 0 the process was made: the loader (the exe, its DLLs,
- // relocations) and the static initialisers that ran before this file's
- if (const auto created = lynx::crashguard::processStartTime(); created != 0)
- {
- const auto t0 = (std::uint64_t) std::chrono::duration_cast<std::chrono::microseconds> (startupTrace.t0System.time_since_epoch()).count() * 10u
- + 116444736000000000ull; // (FILETIME: 100 ns since 1601)
- if (t0 > created)
- startupTrace.mark ((" (the process was made " + juce::String ((double) (t0 - created) / 10000.0, 1)
- + " ms before this trace's 0: the loader, the DLLs, the first static initialisers)").toRawUTF8());
- }
- prepareGraphicsDevice();
- if (startupTrace.on)
- lynx::startupMark = startupMarkHook;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::themeui::loadSaved(); // the user's theme (Options › Theme, round 162d)
- startupOptions = lynx::StartupOptions::load();
- if (lynx::demo::active()) // (round 190np: --demo records from the first frame: no splash card, no start-up sound)
- startupOptions.splash = startupOptions.sound = false;
- lynx::registerFileTypes();
- startupTrace.mark ("options + file types");
- // Double-clicking a .lynx/.flp opens LYNX with the file as an argument; a path typed in a terminal may be relative
- // (D#92, round 180a: it was ignored, leaving the blank project with no message). A missing file gets "Could not open".
- if (args.size() > 0 && lynx::safety::isFileArgument (args[0].unquoted().toStdString()))
- fileToOpen = juce::File::getCurrentWorkingDirectory().getChildFile (args[0].unquoted());
- // LYNX --no-plugins project.lynx (round 190ap): File › "Open without third-party plugins..." from the command
- // line, for a project a plugin keeps from opening — no hosted plugin is created, each keeps its settings
- if (const auto i = args.indexOf ("--no-plugins"); i >= 0)
- {
- if (i + 1 < args.size() && lynx::safety::isFileArgument (args[i + 1].unquoted().toStdString()))
- fileToOpen = juce::File::getCurrentWorkingDirectory().getChildFile (args[i + 1].unquoted());
- startWithoutPlugins = fileToOpen.hasFileExtension ("lynx");
- }
- // LYNX_TEST_MODE=1 LYNX --open-event-test <ms> <file>: the file arrives the way macOS's Finder delivers it (a Linux
- // or Windows run can exercise that path): 0 ms = at once, before the window exists
- if (lynx::platform::testMode() && args[0] == "--open-event-test" && args.size() > 2)
- {
- const auto file = args[2].unquoted().quoted();
- if (args[1].getIntValue() == 0)
- anotherInstanceStarted (file);
- else
- juce::Timer::callAfterDelay (args[1].getIntValue(), [this, file] { anotherInstanceStarted (file); });
- }
- // LYNX --opentime project.(flp|lynx)|- report.txt [idle seconds] (round 165i): the normal start-up (splash, audio
- // device, window) opens the project, waits until it is loaded and LYNX has gone quiet, measures the idle CPU and
- // memory, writes the times and quits normally (a benchmark that killed LYNX left "closed unexpectedly" behind)
- if (args.contains ("--opentime"))
- {
- const auto i = args.indexOf ("--opentime");
- const auto project = args[i + 1].unquoted();
- fileToOpen = project != "-" && juce::File::isAbsolutePath (project) ? juce::File (project) : juce::File();
- openTimeReport = juce::File (args[i + 2].unquoted());
- if (args.size() > i + 3 && ! args[i + 3].startsWith ("--"))
- openTimeIdleSeconds = juce::jlimit (1, 120, args[i + 3].getIntValue());
- }
- // round 190go: the ASIO device of the last session is made and opened from now on, while the splash and the
- // window come up (see below)
- lynx::AudioEngine::prewarmAudioDevice();
- // round 190go: the built-in start-up sound is made while the splash and the window come up (pure maths)
- if (startupOptions.sound && lynx::themeui::current().startupSound.empty())
- startupSampleJob = std::async (std::launch::async, [] { return lynx::makeStartupSample(); });
- // Round 190go (start-up faster than FL Studio): the main window is built first, with the engine ready but no
- // audio device open; the device opens after it. An ASIO device of the last session was made and opened ahead,
- // on a worker, while the window was built (AudioEngine::prewarmAudioDevice; the driver itself only ever runs on
- // JUCE's ASIO thread, as COM wants). Play pressed before the device is open starts with it.
- if (! startupOptions.splash)
- {
- startEngine();
- createMainWindow();
- mainWindow->reveal();
- startupTrace.mark ("window revealed");
- // the device (and the start-up sound) once the window's first frame is on screen
- mainWindow->whenPainted ([this] {
- openAudioDevice();
- openMidiDevices();
- startAfterWindow (lynx::demo::active()); // (round 190np: --demo has no splash; its first run still gets the welcome card)
- });
- return;
- }
- // the splash first; the main window is built behind its card (still: the logo has not started to drop; building
- // it during the drop would stop the animation, both run on the message thread), then the audio device opens
- // (the start-up sound needs it), and the drop starts with its sound. The window shows the moment the logo has
- // landed (round 190go, A4: before, the window was built only after the drop: the drop, then ~0.6 s of build).
- // Round 190hd (Windows): the card draws on a thread of its own, so the main window is built DURING the drop
- // (startOnItsOwnThread below).
- splash = lynx::makeStartupSplash();
- startupTrace.mark ("splash made");
- splash->showOnDesktop();
- startupTrace.mark ("splash on the desktop");
- if (splash->drawsOnItsOwnThread())
- {
- startWithThreadedSplash();
- return;
- }
- // the rest once the card's first frame is on the screen (round 190go: before, a fixed 40 ms), at the latest
- // after 40 ms
- const auto goOn = [this, started = std::make_shared<bool> (false)] {
- if (std::exchange (*started, true) || splash == nullptr) // (once; or quit meanwhile)
- return;
- startEngine();
- if (splash == nullptr) // quit meanwhile
- return;
- createMainWindow();
- if (splash == nullptr || mainWindow == nullptr)
- return;
- if (startupOptions.sound)
- openAudioDevice (false); // (else after the splash: nothing waits for it)
- // one turn of the message loop before the drop: what fell due while the window was built (JUCE's timers,
- // the window's own async work) runs now, on the still card, not in the drop's first frames
- juce::MessageManager::callAsync ([this] { startDrop(); });
- };
- splash->onFirstFrame = goOn;
- juce::Timer::callAfterDelay (40, goOn);
- }
- // Round 190hd (start-up faster than FL Studio, Windows): the card draws on a thread of its own (ui/Splash.cpp), so
- // nothing the message thread does stops the drop. The card shows at once (no Direct2D device is made for it); the
- // engine starts and the audio device opens behind the still card (an ASIO device of the last session was made and
- // opened ahead on its own thread meanwhile), the drop starts with its sound, and the main window is built while
- // the logo drops and shown as soon as it is built, behind the card (the drop and its sound go on above it); the card
- // fades the moment the logo has landed. The card stays for the drop only (the JUCE card's
- // 2.1 s from the process start was there to keep a fast start from flashing; the drop alone is 1.05 s).
- void startWithThreadedSplash()
- {
- splash->onFirstFrame = [this] {
- if (splash != nullptr && startupTrace.on)
- startupTrace.mark ((" splash: first frame on the screen at "
- + juce::String (std::chrono::duration<double, std::milli> (splash->getFirstFrameTime() - startupTrace.t0).count(), 1) + " ms (its own thread)")
- .toRawUTF8());
- };
- juce::MessageManager::callAsync ([this] {
- if (splash == nullptr) // (quit meanwhile)
- return;
- startEngine();
- if (splash == nullptr)
- return;
- if (startupOptions.sound)
- openAudioDevice (false); // (else after the splash: nothing waits for it)
- startDrop();
- // the main window while the logo drops (one more message, so the drop's start is not held by it)
- juce::MessageManager::callAsync ([this] {
- if (splash == nullptr || mainWindow != nullptr || engine == nullptr)
- return;
- createMainWindow();
- // shown as soon as it is built, behind the card: the logo goes on dropping above it and the card fades at
- // the landing as before (LYNX_REVEAL_AT_LANDING=1: the window shows at the landing, as in round 190go)
- if (mainWindow != nullptr && splash != nullptr
- && juce::SystemStats::getEnvironmentVariable ("LYNX_REVEAL_AT_LANDING", {}) != "1")
- {
- mainWindow->reveal();
- windowRevealed = true;
- startupTrace.mark ("window revealed (behind the card, while the logo drops)");
- splash->raise();
- }
- });
- });
- }
- // the logo's drop and the start-up sound together; the window shows the moment the logo has landed
- void startDrop()
- {
- const auto ownThread = splash != nullptr && splash->drawsOnItsOwnThread(); // (the window is built during the drop)
- if (splash == nullptr || (mainWindow == nullptr && ! ownThread) || engine == nullptr)
- return;
- if (startupOptions.sound)
- playStartupSound();
- splash->setStatus (lynx::tr ("Loading the workspace..."));
- splash->startClock();
- // the minimum counts from the process start (the window and the audio device took part of it already); a card
- // on its own thread stays for the drop (round 190hd)
- splashDuration = ownThread ? landingSeconds : lynx::SplashScreen::remainingDuration (startupTrace.seconds());
- splash->setBarDuration (splashDuration);
- splash->whenLanded (splashDuration, [this] {
- if (splash == nullptr || mainWindow == nullptr)
- return;
- if (startupTrace.on)
- startupTrace.mark (("splash: the drop in " + juce::String (splash->getDropFrames()) + " frames, longest gap "
- + juce::String (splash->getLongestDropGapMs(), 1) + " ms"
- + (splash->getLongestDropGapAt() >= 0.0 ? " (at " + juce::String (splash->getLongestDropGapAt(), 3) + " s of its clock; the frame before: "
- + splash->getLongestDropGapDetail() + ")"
- : juce::String()))
- .toRawUTF8());
- if (! std::exchange (windowRevealed, true))
- {
- mainWindow->reveal();
- startupTrace.mark ("window revealed (after the splash)");
- }
- splash->raise();
- const auto deviceOpen = ! engine->isAudioDeviceOpenPending();
- splash->finish ([this, deviceOpen] {
- splash = nullptr;
- // without the start-up sound the device opens now, once the card has faded (the window is up)
- if (! deviceOpen)
- openAudioDevice();
- openMidiDevices();
- if (! deviceOpen)
- startAfterWindow (true);
- });
- if (deviceOpen)
- mainWindow->whenPainted ([this] { startAfterWindow (true); });
- });
- }
- // what follows the window's first frame (the audio device is open): the notice of an unclean end, the start-up
- // project, the probes and the update check; on a first run (with the splash) the setup wizard
- void startAfterWindow (bool offerSetupWizard)
- {
- if (std::exchange (startedAfterWindow, true) || mainWindow == nullptr)
- return;
- // (round 190go) each step after the window is a timed line of the start-up trace
- showUncleanNotice();
- startupTrace.mark ("after the window: unclean-session notice");
- openStartupFile();
- startupTrace.mark ("startup file opened");
- startOpenTimeProbe();
- if (! lynx::demo::active()) // (round 190np: --demo records videos: no update prompt, no support note)
- {
- startUpdateCheck();
- startSupportNote(); // (round 190fq)
- }
- startupTrace.mark ("after the window: probes, update check scheduled");
- juce::MessageManager::callAsync ([] { startupTrace.mark ("first message loop turn"); });
- markSettled(); // (round 190gd)
- // first run: language, audio, plugin folders (FL Studio's included) and a background scan
- if (! offerSetupWizard)
- return;
- // round 190np: a fresh profile gets the welcome card ("Where are you coming from?"); a profile that had LYNX's
- // settings and never finished the old wizard keeps the old wizard; an answered one gets nothing (core/Onboarding.h)
- const auto action = lynx::onboarding::startAction (lynx::setupWizardDone(), lynx::onboardui::profileExistedAtStart(),
- mainWindow->getContent().onboardingStateForCheck().pending);
- using StartAction = lynx::onboarding::StartAction;
- if (action != StartAction::none && lynx::platform::testMode())
- lynx::platform::testModeLog (action == StartAction::welcomeCard ? "setup wizard: welcome card" : "setup wizard");
- else if (action == StartAction::welcomeCard)
- {
- mainWindow->getContent().showWelcomeCard (true);
- startupTrace.mark ("after the window: welcome card shown");
- }
- else if (action == StartAction::setupWizard)
- {
- mainWindow->showSetupWizard();
- startupTrace.mark ("after the window: setup wizard shown");
- }
- // issue #252 (round 190oq; on by default as FL's Welcome window, rollup 0.1.31 step 6): the start page over the start-up project, never over the
- // first run's card, never when a file was given to open
- if (lynx::startpage::showAtStart (lynx::startpage::enabled(), fileToOpen != juce::File(), action != StartAction::none,
- openTimeReport != juce::File() || lynx::platform::testMode()))
- {
- mainWindow->getContent().showStartPage();
- startupTrace.mark ("after the window: start page shown");
- }
- }
- // round 190fq: the start-up support note (ui/SupportLynx.h) counts this start and, from the 10th on, may show its
- // card once at a quiet moment. Only here, on the normal start path (the command-line modes returned earlier); test
- // mode and CI machines neither count nor show it.
- void startSupportNote()
- {
- if (mainWindow == nullptr)
- return;
- const auto env = [] (const char* name) { return juce::SystemStats::getEnvironmentVariable (name, {}).toStdString(); };
- const auto quiet = lynx::supportnote::quietEnvironment (lynx::platform::testMode(), env ("CI"), env ("GITHUB_ACTIONS"), env ("LYNX_NO_SUPPORT_NOTE"));
- if (quiet && lynx::platform::testMode())
- lynx::platform::testModeLog ("support note: not counted (test mode)");
- mainWindow->getContent().startSupportNote (quiet);
- }
- // the start-up trace's last lines: what the first seconds after the window add (lazy work, caches, the first paints)
- static void markSettled()
- {
- if (! startupTrace.on)
- return;
- juce::Timer::callAfterDelay (5000, [] { startupTrace.mark ("5 s after the window"); startupTrace.write(); });
- juce::Timer::callAfterDelay (15000, [] { startupTrace.mark ("15 s after the window"); startupTrace.write(); });
- }
- // Round 190hd (Windows): the Direct3D 11 + Direct2D device (~0.35 s: the graphics driver loads) is made once, on a
- // worker, while the splash card, the engine and the audio device come up, and kept until LYNX closes: a 1 x 1
- // Direct2D image holds JUCE's shared DirectX object (its devices), so the main window finds them made and nothing
- // makes them again (before, every holder going away -- the splash's logo, a temporary one -- could mean a new device
- // at its next use). Other systems: nothing to do.
- void prepareGraphicsDevice()
- {
- #if JUCE_WINDOWS
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_GPU_PREWARM", {}) == "0")
- return;
- graphicsDeviceJob = std::async (std::launch::async, [] {
- const auto from = std::chrono::steady_clock::now();
- juce::Image holder (juce::Image::ARGB, 1, 1, false); // (NativeImageType: Direct2D, the shared device)
- return std::make_pair (holder, std::chrono::duration<double, std::milli> (std::chrono::steady_clock::now() - from).count());
- });
- #endif
- }
- void markGraphicsDevice()
- {
- if (! graphicsDeviceJob.valid() || ! startupTrace.on || std::exchange (graphicsDeviceMarked, true))
- return;
- const auto ready = graphicsDeviceJob.wait_for (std::chrono::seconds (0)) == std::future_status::ready;
- startupTrace.mark (ready ? (" graphics device made on a worker in " + juce::String (graphicsDeviceJob.get().second, 1) + " ms").toRawUTF8()
- : " graphics device: still being made on its worker");
- }
- void startEngine()
- {
- startupTrace.mark ("before the audio engine");
- lynx::BrowserComponent::allowIndexerProcess = true; // (round 190hd: the normal window only)
- // (round 190go) ready to play, no device open yet: see openAudioDevice
- engine = std::make_unique<lynx::AudioEngine> (true, -1, true, true);
- lynx::videoview::install (*engine); // (Fruity Video Player channels: their sound tracks)
- startupTrace.mark ("audio engine (no device yet)");
- crashEngine = engine.get();
- lynx::crashreporter::watchAudioDevice (engine->getDeviceManager()); // (the session file names the device: crash reports)
- // a project given on the command line: its slow plugin modules (a Waves shell) start now, on their own
- // thread, while the splash and the main window come up (round 121)
- if (fileToOpen.hasFileExtension ("flp"))
- if (juce::MemoryBlock data; fileToOpen.loadFileAsData (data))
- try
- {
- engine->getPluginHost().startModulesFor (lynx::flpForeignPlugins (flp::parseProject ({ static_cast<const std::uint8_t*> (data.getData()), data.getSize() })));
- startupTrace.mark ("plugin modules started ahead");
- }
- catch (const flp::Error&)
- {
- }
- }
- // The audio device of the last session, then (withSound) the start-up sound on it (once; message thread)
- void openAudioDevice (bool withSound = true)
- {
- if (engine == nullptr || ! engine->isAudioDeviceOpenPending())
- return;
- engine->openAudioDevice();
- if (const auto prewarmed = lynx::asioPrewarmReport(); prewarmed.isNotEmpty() && startupTrace.on)
- startupTrace.mark ((" " + prewarmed).toRawUTF8());
- startupTrace.mark ("audio device opened");
- addDriverFileDeviceType();
- if (withSound)
- playStartupSound();
- }
- // issue #280 (round 190qr): the LYNX extra "Play a sound when an export finishes" (core/ExportDone.h)
- void bindExportDoneSound()
- {
- lynx::exportdone::playSound = [this] {
- if (engine != nullptr)
- {
- auto sound = lynx::startup::makeDoneSound (48000.0);
- auto sample = std::make_shared<lynx::SampleData>();
- sample->left = std::move (sound.left);
- sample->right = std::move (sound.right);
- sample->sampleRate = sound.sampleRate;
- engine->previewSample (sample);
- }
- };
- }
- void playStartupSound()
- {
- if (startupOptions.sound && ! std::exchange (startupSoundPlayed, true) && engine != nullptr)
- {
- // Options › Theme › Startup sound (issue #12): the user's file, else (or when it can't be read) LYNX's own
- std::shared_ptr<const lynx::SampleData> sound;
- if (const auto& own = lynx::themeui::current().startupSound; ! own.empty() && juce::File (juce::String::fromUTF8 (own.c_str())).existsAsFile())
- sound = engine->getSampleLibrary().load (juce::String::fromUTF8 (own.c_str()));
- if (sound == nullptr && startupSampleJob.valid())
- sound = startupSampleJob.get();
- engine->previewSample (sound != nullptr ? sound : lynx::makeStartupSample());
- }
- startupTrace.mark ("startup sound");
- }
- void openMidiDevices()
- {
- if (engine != nullptr)
- engine->openMidiDevices(); // (its own line in the start-up trace: "engine: MIDI inputs")
- }
- void createMainWindow()
- {
- bindExportDoneSound(); // (round 190qr, #280)
- mainWindow = std::make_unique<MainWindow> ("LYNX SHARE", *engine); // the brand; getApplicationName() stays "LYNX" (an id: instance lock, X11 WM_CLASS, ALSA client)
- lynx::setMainWindowForOwnership (mainWindow.get());
- lynx::crashguard::watchDisplayConnection (onDisplayLost); // (round 190rf, Linux: the display is open now)
- lynx::applyRenderingChoice (*mainWindow); // (GPU rendering off: GDI; round 157a)
- lynx::startRenderingWatch();
- startupTrace.mark ("main window built");
- lynx::remoteui::install ([this] (bool enabled) {
- remoteControl = nullptr;
- if (enabled)
- remoteControl = lynx::RemoteControl::create (*engine, true, [this] {
- const auto title = mainWindow != nullptr ? mainWindow->getName() : juce::String ("Untitled");
- const auto separator = title.indexOf (" - ");
- return separator >= 0 ? title.substring (separator + 3) : title;
- }, [this] {
- const auto file = mainWindow != nullptr ? mainWindow->getContent().getCurrentProjectFile() : juce::File();
- return file == juce::File() ? juce::String() : file.getFullPathName();
- });
- lynx::remoteui::setRuntimeStatus (remoteControl != nullptr && remoteControl->active());
- });
- if (lynx::demo::active()) // round 190np: --demo's view operations (ui.find, ui.click, ui.layout...) on the API
- lynx::RemoteControl::setExtension (lynx::demo::operations(), [this] (const juce::String& op, const juce::var& args) -> juce::var {
- if (mainWindow == nullptr)
- throw std::runtime_error ("No main window");
- return mainWindow->getContent().handleDemoOp (op, args);
- });
- markGraphicsDevice();
- }
- // the previous run ended without closing (see collectUncleanSessions): say so once, with its last step — and, as
- // Settings › General › "Crash reports" says (round 159), ask whether to send a report, send it unasked, or not
- void showUncleanNotice()
- {
- if (lynx::platform::testMode()) // LYNX_TEST_MODE: no prompt, no report sent (written to test-mode.log)
- {
- if (uncleanLastStep.isNotEmpty())
- lynx::platform::testModeLog ("\"closed unexpectedly\" notice (last step: " + uncleanLastStep + ")");
- return;
- }
- if (uncleanLastStep.isEmpty())
- {
- lynx::crashreporter::retryPending(); // (reports an earlier run could not send: once more)
- return;
- }
- auto message = lynx::tr ("The last session ended without closing normally. Last step: {0}. Backup copies of your project are in "
- "LYNX SHARE's autosave folder; details in crash-history.log.",
- { uncleanLastStep });
- uncleanLastStep.clear();
- const auto cause = uncleanCause();
- // round 157a: a plugin's editor was opening — it crashed (often in the graphics driver, inside the plugin's own
- // OpenGL window): offer to keep that plugin in its own process, where a crash takes only the plugin down
- juce::String separatePlugin;
- if (cause.editorPlugin.isNotEmpty() && ! lynx::pluginSandboxEnabled() && ! lynx::pluginAlwaysSeparate (cause.editorPlugin))
- separatePlugin = cause.editorPlugin;
- // LYNX's own drawing crashed in the graphics driver (Direct2D / Direct3D): draw with the CPU from now on
- else if (cause.gpuDriver && lynx::gpuRenderingEnabled())
- {
- lynx::setGpuRenderingEnabled (false);
- message << "\n\n"
- << lynx::tr ("The crash was in the graphics driver ({0}). LYNX SHARE now draws its windows without the GPU; you can turn GPU "
- "rendering back on in Options > General settings (after a driver update, for example).",
- { cause.driverModule });
- }
- // round 165e: the Visualizer's GPU view was drawing when the session ended (a driver crash, a hang, the machine
- // going down): the Visualizer draws with the 2D renderer from now on (its GPU button turns it back on)
- for (int i = uncleanSteps.size(); --i >= 0;)
- {
- if (uncleanSteps[i].contains (lynx::visualgl::stopNote))
- break;
- if (uncleanSteps[i].contains (lynx::visualgl::startNote))
- {
- if (lynx::visualgl::enabled())
- {
- lynx::visualgl::setEnabled (false);
- message << "\n\n"
- << lynx::tr ("The Visualizer was drawing with the GPU (OpenGL) when it happened. It now draws without the GPU; its GPU "
- "button turns it back on.");
- }
- break;
- }
- }
- const auto session = lynx::crashreporter::parseSession (uncleanSessionText);
- auto* devices = engine != nullptr ? &engine->getDeviceManager() : nullptr;
- const auto action = lynx::crashreport::actionFor (lynx::crashreporter::consent());
- lynx::crashreporter::retryPending();
- if (action == lynx::crashreport::Action::askUser)
- {
- if (separatePlugin.isNotEmpty())
- message << "\n\n"
- << lynx::tr ("It happened while the window of {0} was opening{1}.",
- { separatePlugin, cause.gpuDriver ? lynx::tr (" (in the graphics driver, {0})", { cause.driverModule }) : juce::String() });
- lynx::crashreporter::showStartupDialog (session, message, separatePlugin, [separatePlugin] { lynx::setPluginAlwaysSeparate (separatePlugin, true); },
- devices);
- return;
- }
- if (action == lynx::crashreport::Action::sendSilently)
- {
- const auto input = lynx::crashreporter::makeInput (session, session.kind(), devices);
- lynx::crashreporter::send (lynx::crashreporter::buildJson (input, false), juce::String::fromUTF8 (input.id.c_str()));
- message << "\n\n" << lynx::tr ("A crash report is being sent to help fix it (Options > General settings > Crash reports).");
- }
- if (separatePlugin.isNotEmpty())
- {
- juce::AlertWindow::showOkCancelBox (
- juce::MessageBoxIconType::WarningIcon, lynx::tr ("LYNX SHARE closed unexpectedly"),
- message + "\n\n"
- + lynx::tr ("It happened while the window of {0} was opening{1}. Run {0} in a separate process from now on? If it "
- "crashes again, only the plugin stops and LYNX SHARE keeps running (Plugin wrapper menu: \"Always run in a "
- "separate process\").",
- { separatePlugin, cause.gpuDriver ? lynx::tr (" (in the graphics driver, {0})", { cause.driverModule }) : juce::String() }),
- lynx::tr ("Run separately"), lynx::tr ("No"), nullptr,
- juce::ModalCallbackFunction::create ([separatePlugin] (int result) {
- if (result != 0)
- lynx::setPluginAlwaysSeparate (separatePlugin, true);
- }));
- return;
- }
- juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::WarningIcon, lynx::tr ("LYNX SHARE closed unexpectedly"), message);
- }
- // --opentime: after the start-up file was handed to the window
- void startOpenTimeProbe()
- {
- if (openTimeReport == juce::File())
- return;
- struct Probe final : juce::Timer
- {
- LynxApplication& app;
- juce::File report, project;
- int idleSeconds;
- int phase = 0; // 0 loading, 1 settling, 2 idle measurement
- double revealedS = 0.0, loadedS = -1.0, settledS = -1.0, cpuAtLoaded = 0.0;
- double lastCpu = 0.0, lastT = 0.0, quietSince = -1.0, idleCpu0 = 0.0, idleT0 = 0.0;
- Probe (LynxApplication& a, juce::File r, juce::File p, int idle)
- : app (a), report (std::move (r)), project (std::move (p)), idleSeconds (idle)
- {
- revealedS = startupTrace.seconds();
- startTimer (250);
- }
- bool loaded() const
- {
- if (project == juce::File())
- return true;
- return app.mainWindow != nullptr
- && app.mainWindow->getName().containsIgnoreCase (project.getFileNameWithoutExtension());
- }
- void finish (const juce::String& result)
- {
- stopTimer();
- const auto now = startupTrace.seconds();
- const auto cpu = lynx::processCpuSeconds();
- juce::String text;
- text << "project=" << (project == juce::File() ? juce::String ("-") : project.getFullPathName()) << "\n"
- << "window_s=" << juce::String (revealedS, 3) << "\n"
- << "loaded_s=" << juce::String (loadedS, 3) << "\n"
- << "settled_s=" << juce::String (settledS, 3) << "\n"
- << "cpu_at_loaded_s=" << juce::String (cpuAtLoaded, 3) << "\n"
- << "idle_s=" << juce::String (now - idleT0, 2) << "\n"
- << "idle_cpu_pct=" << juce::String (phase == 2 && now > idleT0 ? 100.0 * (cpu - idleCpu0) / (now - idleT0) : -1.0, 1) << "\n"
- << "working_set_mb=" << juce::String ((double) lynx::toolbar::PerformanceMeter::processMemoryBytes() / 1048576.0, 0) << "\n"
- << "cpu_total_s=" << juce::String (cpu, 3) << "\n"
- << "result=" << result << "\n";
- report.replaceWithText (text);
- app.setApplicationReturnValue (result == "OK" ? 0 : 1);
- app.quit();
- }
- void timerCallback() override
- {
- const auto now = startupTrace.seconds();
- const auto cpu = lynx::processCpuSeconds();
- if (phase == 0)
- {
- if (loaded())
- {
- loadedS = now;
- cpuAtLoaded = cpu;
- phase = 1;
- lastCpu = cpu;
- lastT = now;
- }
- else if (now - revealedS > 240.0)
- finish ("TIMEOUT loading");
- return;
- }
- if (phase == 1)
- {
- // quiet = under 10 % of one core for 1.5 s (the harness's rule), at most 30 s after loading
- const auto use = now > lastT ? 100.0 * (cpu - lastCpu) / (now - lastT) : 0.0;
- lastCpu = cpu;
- lastT = now;
- if (use < 10.0)
- {
- if (quietSince < 0.0)
- quietSince = now - 0.25;
- if (now - quietSince >= 1.5)
- settledS = quietSince;
- }
- else
- quietSince = -1.0;
- if (settledS >= 0.0 || now - loadedS > 30.0)
- {
- phase = 2;
- idleCpu0 = cpu;
- idleT0 = now;
- }
- return;
- }
- if (now - idleT0 >= (double) idleSeconds)
- finish ("OK");
- }
- };
- perf = std::make_unique<Probe> (*this, openTimeReport, fileToOpen, openTimeIdleSeconds);
- }
- // round 166b: the update check of a normal start (never in --opentime and the other command-line modes), a few
- // seconds after the window is up so it never competes with the start-up; and the result of an update just installed
- void startUpdateCheck()
- {
- if (openTimeReport != juce::File())
- return;
- lynx::updater::afterStart();
- juce::Timer::callAfterDelay (3000, [] { lynx::updater::startAutomaticCheck(); });
- }
- void openStartupFile()
- {
- startupFileHandled = true;
- if (fileToOpen != juce::File() && mainWindow != nullptr)
- {
- if (std::exchange (startWithoutPlugins, false)) // --no-plugins (round 190ap)
- mainWindow->getContent().openNextWithoutPlugins (true);
- mainWindow->openFile (fileToOpen);
- mainWindow->getContent().openNextWithoutPlugins (false); // (a file that did not open leaves nothing behind)
- }
- else if (mainWindow != nullptr && openTimeReport == juce::File())
- mainWindow->getContent().openStartupProject(); // issue #123 (FL's Startup project)
- }
- void shutdown() override
- {
- parityShow.reset(); // (LYNX_PARITYSHOT_SHOW's window, before the engine it shows)
- if (relaunched || updateHelper)
- return; // the copy that ran owns the session (its crash notes stay for the next start)
- lynx::crashguard::note ("closing");
- lynx::shutdownPluginSandboxWorker();
- splash = nullptr;
- lynx::shutdownStemExtraction(); // (a separation in flight stops before its window and the engine go)
- lynx::shutdownAudioToMidi(); // (the same for a conversion to MIDI)
- if (mainWindow != nullptr && mainWindow->isVisible())
- mainWindow->saveState();
- lynx::remoteui::shutdown();
- lynx::closeModalWindows(); // (round 190rf: a call-out box or dialog still open goes before the UI and the engine)
- remoteControl = nullptr; // cancels queued control work before its engine and UI go
- mainWindow = nullptr; // the UI goes before the engine
- graphicsDeviceJob = {}; // (round 190hd: the graphics device's holder, after every window)
- lynx::updater::shutdown(); // (a check or download in flight stops)
- crashEngine = nullptr;
- engine = nullptr;
- // separate-process plugins end on threads of their own (issue #159): a moment for them, never the 10 s a dead
- // child's pipe can take
- lynx::finishSandboxTeardowns (2000);
- // CLAP plugins whose instance another thread deleted while this one was busy: deactivated and destroyed now
- lynx::ClapPluginFormat::finishPendingTeardowns();
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- heartbeat.stopTimer();
- lynx::crashreporter::shutdown(); // (an upload in flight gets a moment, never long)
- lynx::crashguard::stopHangWatch();
- lynx::crashguard::stopMainProfiler();
- lynx::crashguard::endSession(); // a clean exit: no breadcrumb left behind
- // everything is saved and closed: a process that loaded third-party plugins ends here, before the DLLs' own
- // teardown runs (some crash in it at exit, round 111)
- if (sandboxChild || lynx::PluginHost::pluginsWereLoaded())
- lynx::crashguard::exitNow (getApplicationReturnValue());
- }
- void systemRequestedQuit() override
- {
- if (mainWindow != nullptr)
- mainWindow->confirmDiscard ([] { juce::JUCEApplication::quit(); });
- else
- quit();
- }
- private:
- // round 157a: a frozen UI (Windows' "not responding") writes the message thread's stack to autosave\hang <time>.txt
- // and a session step, so a freeze can be told apart from a crash and located. The timer is the heartbeat.
- struct Heartbeat final : juce::Timer
- {
- void timerCallback() override { lynx::crashguard::heartbeat(); }
- } heartbeat;
- void startHangWatch()
- {
- const auto folder = lynx::platform::settingsFile ("autosave");
- folder.createDirectory();
- // keep the newest hang files only
- auto old = folder.findChildFiles (juce::File::findFiles, false, "hang *.txt");
- lynx::filesort::byTime (old, lynx::filesort::By::modificationTime, true);
- for (int i = 20; i < old.size(); ++i)
- old.getReference (i).deleteFile();
- lynx::crashguard::startHangWatch (folder.getFullPathName().replaceCharacter ('\\', '/').toStdString());
- heartbeat.startTimerHz (5);
- }
- bool sandboxChild = false;
- bool relaunched = false; // relaunchFromAsciiPath ran LYNX from its short path: this process only waited
- bool updateHelper = false; // --apply-update (round 166b)
- juce::String uncleanLastStep; // last step of a previous run that ended without closing
- // LYNX_PROFILE_DIR=<folder> LYNX --lv2scantest report.txt (Linux, issue #85): the LV2 scan's promise, with real child
- // processes. A new PluginHost per step, as every start of LYNX has. The LV2 folders of the machine are read too.
- void runLv2ScanTest (const juce::String& reportPath)
- {
- juce::String report;
- auto ok = lynx::platform::profileOverride() != juce::File();
- #if JUCE_LINUX
- const auto folder = lynx::platform::profileOverride().getChildFile ("lv2-test");
- const juce::FileSearchPath paths (folder.getFullPathName());
- const auto check = [&] (const juce::String& name, bool passed) {
- report << name << "=" << (passed ? "ok" : "FAILED") << "\n";
- ok = ok && passed;
- };
- const auto install = [&] (const juce::String& name) {
- const auto bundle = folder.getChildFile (name + ".lv2");
- bundle.createDirectory();
- bundle.getChildFile ("manifest.ttl").replaceWithText ("@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
- "<urn:lynx-test:" + name + "> a lv2:Plugin ; lv2:binary <" + name + ".so> ; rdfs:seeAlso <plugin.ttl> .\n");
- bundle.getChildFile ("plugin.ttl").replaceWithText ("@prefix doap: <http://usefulinc.com/ns/doap#> .\n<urn:lynx-test:" + name + "> doap:name \"" + name + "\" .\n");
- };
- auto date = juce::Time::getCurrentTime();
- const auto touch = [&] { // the next date, whatever the file system's date resolution
- date += juce::RelativeTime::seconds (2.0);
- folder.getChildFile ("a.lv2/plugin.ttl").setLastModificationTime (date);
- };
- const auto listed = [] (lynx::PluginHost& host, const juce::String& name) {
- for (const auto& d : host.getKnownPlugins().getTypes())
- if (d.fileOrIdentifier == "urn:lynx-test:" + name)
- return true;
- return false;
- };
- const auto step = [&] (const juce::String& name, int children, const std::function<void (lynx::PluginHost&)>& prepare = {}) {
- lynx::PluginHost host (true);
- if (prepare)
- prepare (host);
- host.scan (paths, {});
- check (name, host.scanChildrenStarted() == children && listed (host, "a"));
- };
- install ("a");
- step ("first_scan_one_child", 1);
- step ("nothing_changed_no_child", 0);
- touch();
- step ("ttl_updated", 1);
- install ("b");
- step ("bundle_installed", 1);
- step ("forget_file", 1, [] (lynx::PluginHost& host) { host.forgetFile ("urn:lynx-test:a"); });
- step ("forget_all", 1, [] (lynx::PluginHost& host) { host.forgetAll(); });
- lynx::platform::settingsFile ("plugins.xml").deleteFile();
- step ("list_lost", 1);
- step ("nothing_changed_again", 0);
- // cancelled while the child works: stopped at once, and nothing is taken for done
- touch();
- setenv ("LYNX_TEST_CRASH", "lv2-batch-hang", 1);
- {
- lynx::PluginHost host (true);
- const auto started = juce::Time::getMillisecondCounter();
- host.scan (paths, [] (float, const juce::String&) { return false; });
- check ("cancel_stops_the_child", host.scanChildrenStarted() == 1 && juce::Time::getMillisecondCounter() - started < 20000);
- }
- unsetenv ("LYNX_TEST_CRASH");
- step ("described_after_cancel", 1);
- // the child dies: plugin by plugin takes over (stopped after two of them: a machine may have hundreds)
- touch();
- setenv ("LYNX_TEST_CRASH", "lv2-batch", 1);
- {
- lynx::PluginHost host (true);
- host.scan (paths, [&host] (float, const juce::String&) { return host.scanChildrenStarted() < 3; });
- check ("crash_falls_back_plugin_by_plugin", host.scanChildrenStarted() == 3);
- auto blamed = false;
- for (const auto& file : host.getKnownPlugins().getBlacklistedFiles())
- blamed = blamed || file.startsWith ("lv2-folders:");
- check ("crash_blacklists_nothing", ! blamed);
- }
- unsetenv ("LYNX_TEST_CRASH");
- step ("described_after_crash", 1);
- // round 190fw: past the first limit, a child that still works is waited for (FL Studio's own VST plugin boots
- // the FL engine), one that sits still is killed as before, and a busy one only up to the cap. Limits are
- // shortened for the test: 2 s first limit, 2 s without work, 8 s cap (real: 30 s, 30 s, 5 min).
- setenv ("LYNX_TEST_SCAN_MS", "2000,2000,8000", 1);
- const auto timed = [&] (const char* fault, const std::function<bool (lynx::PluginHost&)>& progress) {
- touch();
- setenv ("LYNX_TEST_CRASH", fault, 1);
- lynx::PluginHost host (true);
- const auto started = juce::Time::getMillisecondCounter();
- host.scan (paths, [&] (float, const juce::String&) { return ! progress || progress (host); });
- unsetenv ("LYNX_TEST_CRASH");
- const auto took = (int) (juce::Time::getMillisecondCounter() - started);
- report << " " << fault << ": " << took << " ms, children " << host.scanChildrenStarted() << "\n";
- return std::make_pair (took, host.scanChildrenStarted());
- };
- // (after a failed batch, one plugin-by-plugin child and no more: it describes quickly)
- const auto stopAfterBatch = [] (lynx::PluginHost& host) { return host.scanChildrenStarted() < 2; };
- {
- const auto [took, children] = timed ("lv2-batch-busy:5000", {});
- check ("busy_child_is_waited_for", children == 1 && took >= 4500);
- }
- {
- const auto [took, children] = timed ("lv2-batch-hang", stopAfterBatch);
- check ("idle_child_ends_near_the_first_limit", children == 2 && took >= 1900 && took < 9000);
- }
- {
- const auto [took, children] = timed ("lv2-batch-busy:60000", stopAfterBatch);
- check ("busy_child_ends_at_the_cap", children == 2 && took >= 7500 && took < 20000);
- }
- unsetenv ("LYNX_TEST_SCAN_MS");
- step ("described_after_slow_children", 1);
- #endif
- juce::File (reportPath).replaceWithText (report + "result=" + (ok ? "OK" : "FAILED") + "\n");
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --selftest report.txt: renders 2 s without a sound card and writes the result.
- // Exit code 0 = audio came out, 1 = silence.
- // --selftest (round 190ci): two more copies of LYNX end by a fault on purpose (--faulttest), one on a normal stack
- // (the top-level filter) and one on a stack Windows cannot walk (the first-chance hook); each must leave
- // "crash <time>.txt" with the access violation in the folder it is given.
- // Round 190dt (Linux / macOS): a plain fault, and LYNX's own fault inside a guarded plugin call (in its code, and in
- // the C library called from its code), must each leave the crash file with the signal: the plugin guard passes
- // LYNX's own faults on to the crash handler instead of swallowing them ("swallowed.txt" = it did).
- // Round 190gj (P9): the inserts' stems from one render are the files each stem's own render writes, byte for byte
- // (a short song with a bus, a send return, delay compensation, a channel on the Master, an automated insert and a
- // side-chained insert), streamed (24-bit WAV with the full mix) and buffered (normalised float).
- static juce::String stemsSinglePassSelfTest()
- {
- auto s = lynx::Song::makeDefault();
- s.mixer = lynx::Song::defaultMixer (7);
- for (std::size_t c = 0; c < s.channels.size(); ++c)
- s.channels[c].mixerTrack = (int) c + 1;
- auto onMaster = s.channels[2];
- onMaster.mixerTrack = 0;
- onMaster.pan = -0.4f;
- s.channels.push_back (onMaster);
- for (int step : { 1, 5, 9, 13 })
- s.patterns[0].toggleStep ((int) s.channels.size() - 1, step);
- for (int step : { 4, 12 })
- s.patterns[0].toggleStep (3, step); // the snare
- for (int k = 0; k < 4; ++k) // the synth under the kick (its compressor listens to it)
- s.patterns[0].notes.push_back ({ (std::int64_t) k * lynx::ppq, lynx::ppq - 60, 4, 57 + 3 * k, 0.9f });
- s.patterns[0].sortNotes();
- s.mixer[0].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::limiter));
- s.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::compressor));
- s.mixer[2].toMaster = false;
- s.mixer[2].sends = { lynx::MixerSend { 6, 1.0f } };
- s.mixer[3].sends = { lynx::MixerSend { 7, 0.5f } };
- s.mixer[3].latencyMs = 3.0f;
- s.mixer[4].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::delay));
- s.mixer[4].latencyMs = 5.0f;
- s.mixer[4].sends = { lynx::MixerSend { 6, 0.7f } };
- s.mixer[4].masterLevel = 0.8f;
- auto keyed = lynx::makeEffectSlot (lynx::EffectKind::compressor);
- keyed.params[0] = 0.5f; // (−30 dB: the kick's hits pull the synth down)
- keyed.sidechain = 1;
- s.mixer[5].effects.push_back (keyed);
- s.mixer[6].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::distortion));
- s.mixer[7].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::reverb));
- lynx::Automation a;
- a.target = { lynx::AutomationTargetKind::mixerPan, 3 };
- a.points = { { 0, 0.2f, 0.0f }, { 8 * lynx::ppq, 0.9f, 0.0f } };
- s.automations.push_back (a);
- s.playlist.clear();
- for (int bar = 0; bar < 2; ++bar)
- s.playlist.push_back ({ 0, 0, bar * 4 * lynx::ppq, 4 * lynx::ppq, 0 });
- lynx::Clip automationClip;
- automationClip.kind = lynx::ClipKind::automation;
- automationClip.automation = 0;
- automationClip.length = 8 * lynx::ppq;
- automationClip.track = 1;
- s.playlist.push_back (automationClip);
- s.mode = lynx::PlayMode::song;
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-stems190gj-" + juce::String (juce::Time::currentTimeMillis()));
- juce::String problems;
- auto run = [&] (lynx::exportopts::Options o, const juce::String& name) {
- o.stems = lynx::exportopts::Stems::mixerTracks;
- o.maxTailSeconds = 3.0;
- const auto alone = dir.getChildFile ("alone"), shared = dir.getChildFile ("shared");
- alone.createDirectory();
- shared.createDirectory();
- const auto ext = juce::String (lynx::exportopts::extension (o.format));
- const auto planAlone = lynx::planStemExport (s, o, alone.getChildFile (name + ext));
- const auto planShared = lynx::planStemExport (s, o, shared.getChildFile (name + ext));
- auto now = [] (std::function<void()> f) { f(); };
- lynx::StemRunStats stats;
- const auto a = lynx::runStemExport (planAlone, now, {}, {}, {}, {}, true);
- const auto b = lynx::runStemExport (planShared, now, {}, {}, {}, {}, false, true, &stats);
- if (a != (int) planAlone.items.size() || b != a)
- problems << name << ": " << a << " / " << b << " files; ";
- // (every insert from the one render, insert 5 with its side-chain too: it stays ducked as in the mix)
- if (stats.passes != 1 || stats.inPass < 6)
- problems << name << ": renders " << stats.passes << " shared, " << stats.inPass << " in it, " << stats.alone << " alone; ";
- for (std::size_t k = 0; k < planShared.items.size() && k < planAlone.items.size(); ++k)
- {
- juce::MemoryBlock x, y;
- planAlone.items[k].file.loadFileAsData (x);
- planShared.items[k].file.loadFileAsData (y);
- if (x.getSize() == 0 || x != y)
- problems << name << ": " << planShared.items[k].file.getFileName() << " differs; ";
- }
- };
- lynx::exportopts::Options streamed;
- streamed.wavBits = 24;
- streamed.stemsIncludeMaster = true;
- run (streamed, "streamed");
- lynx::exportopts::Options buffered;
- buffered.wavBits = 32;
- buffered.normalize = true;
- run (buffered, "buffered");
- dir.deleteRecursively();
- return problems.isEmpty() ? juce::String ("OK") : "ERROR " + problems;
- }
- static juce::String faultReportSelfTest()
- {
- #if (JUCE_WINDOWS && (defined (_M_X64) || defined (__x86_64__))) \
- || ((JUCE_LINUX || JUCE_MAC) && (defined (__x86_64__) || defined (__aarch64__)))
- const auto exe = juce::File::getSpecialLocation (juce::File::currentExecutableFile);
- const auto root = juce::File::getSpecialLocation (juce::File::tempDirectory)
- .getChildFile ("lynx-faulttest-" + juce::String::toHexString (juce::Random::getSystemRandom().nextInt64()));
- juce::StringArray problems;
- // (rollup step 12: + hang = the crash handler's watchdog ends a handler that never returns, within its time limit
- // (3 s here); heap = the C library's heap-corruption abort leaves the allocation-free crash file and no recovered
- // project, at once (before the watchdog: the old handler waited for ever on the allocator's lock); Linux / macOS)
- #if JUCE_WINDOWS
- const char* const kinds[] = { "plain", "unwalkable", "hang" };
- #else
- const char* const kinds[] = { "plain", "guarded", "guarded-libc", "thread", "thread-libc", "hang", "heap" };
- #endif
- for (const auto* kind : kinds)
- {
- const auto folder = root.getChildFile (kind);
- folder.createDirectory();
- const auto watchdogTest = juce::String (kind) == "hang" || juce::String (kind) == "heap";
- #if JUCE_WINDOWS
- _putenv_s ("LYNX_CRASH_WATCHDOG_S", watchdogTest ? "3" : "");
- #else
- if (watchdogTest)
- setenv ("LYNX_CRASH_WATCHDOG_S", "3", 1);
- else
- unsetenv ("LYNX_CRASH_WATCHDOG_S");
- #endif
- juce::ChildProcess child;
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- const auto started = child.start (juce::StringArray { exe.getFullPathName(), "--faulttest", kind, folder.getFullPathName() }, 0);
- const auto ended = started && child.waitForProcessToFinish (60000);
- const auto seconds = (juce::Time::getMillisecondCounterHiRes() - t0) / 1000.0;
- if (! ended)
- {
- child.kill();
- problems.add (juce::String (kind) + ": " + (started ? "did not end" : "did not start"));
- continue;
- }
- juce::String text;
- for (const auto& file : folder.findChildFiles (juce::File::findFiles, false, "crash *.txt"))
- text = file.loadFileAsString();
- if (watchdogTest)
- {
- const auto recovered = folder.findChildFiles (juce::File::findFiles, false, "recovered *").size();
- if (juce::String (kind) == "hang" && (seconds < 2.5 || seconds > 30.0 || text.isEmpty()))
- problems.add ("hang: ended after " + juce::String (seconds, 1) + " s (the watchdog: 3 s)" + (text.isEmpty() ? ", no crash file" : ""));
- if (juce::String (kind) == "heap" && (seconds > 20.0 || ! text.contains ("heap-corruption abort") || recovered != 0))
- problems.add ("heap: " + juce::String (seconds, 1) + " s, " + (text.isEmpty() ? juce::String ("no crash file") : text.upToFirstOccurrenceOf ("\n", false, false))
- + ", " + juce::String (recovered) + " recovered project(s)");
- continue;
- }
- #if JUCE_WINDOWS
- const auto found = text.contains ("0xc0000005");
- #else
- const auto found = text.contains ("segmentation fault") || text.contains ("bus error");
- #endif
- if (folder.getChildFile ("swallowed.txt").existsAsFile())
- problems.add (juce::String (kind) + ": LYNX's own fault was caught as a plugin's ("
- + folder.getChildFile ("swallowed.txt").loadFileAsString() + ")");
- else if (! found)
- problems.add (juce::String (kind) + ": " + (text.isEmpty() ? "no crash file" : "a crash file without the fault")
- + " (exit code 0x" + juce::String::toHexString ((juce::int64) child.getExitCode()) + ")");
- }
- root.deleteRecursively();
- #if JUCE_WINDOWS
- _putenv_s ("LYNX_CRASH_WATCHDOG_S", "");
- #else
- unsetenv ("LYNX_CRASH_WATCHDOG_S");
- #endif
- return problems.isEmpty() ? juce::String ("OK") : "ERROR " + problems.joinIntoString ("; ");
- #else
- return "SKIPPED (Windows x64, Linux / macOS x86-64 / ARM64 only)";
- #endif
- }
- void runSelfTest (const juce::String& reportPath, const juce::String& demoProjectPath)
- {
- lynx::AudioEngine offline (false);
- const auto peak = offline.renderOffline (2.0, 48000.0);
- const auto audioOk = peak > 0.01f && peak < 10.0f;
- // round 190qk (core/ExtrasDefaults.h, the owner's policy 11-23): first, before any item switches an option — every
- // LYNX extra starts at the default the list names (the visual four on, FL's own two on, the rest off); a 0.1.31
- // ui-options.txt keeps what the user changed and takes the new defaults for the rest; a file with the user-set
- // list keeps a choice that differs from the default; the page's two buttons' values
- juce::String extras190qkResult = "OK";
- {
- lynx::SettingsHooks hooks;
- hooks.getGeneral = [] { return lynx::GeneralOptions {}; };
- for (const auto& item : lynx::extras::items)
- {
- const auto now = item.id == "general.stretchedClipsLoop" ? lynx::stretchedClipsLoop()
- : lynx::lynxExtraOn (offline, hooks, item.id);
- if (now != lynx::extras::defaultOn (item.id))
- extras190qkResult = "ERROR default of " + juce::String (std::string (item.id));
- }
- const auto kept = lynx::extras::userSet();
- std::vector<std::string> old { "wheelZones=1", "shadeFadedAudio=0", "hoverValues=0", "escClosesWindows=0", "liveScaleControl=1" };
- lynx::extras::followDefaults (old);
- const std::vector<std::string> expected { "wheelZones=1", "shadeFadedAudio=0", "hoverValues=0", "escClosesWindows=0", "liveScaleControl=1" };
- if (old != expected || lynx::extras::userSet() != std::set<std::string> { "controlBar.liveScale", "general.escCloses", "playlist.wheelZones" })
- extras190qkResult = "ERROR 0.1.31 file";
- std::vector<std::string> mine { "trackInserts=0", "prChordHighlight=0", "extrasUserSet=playlist.trackInserts" };
- lynx::extras::followDefaults (mine);
- if (mine[0] != "trackInserts=0" || mine[1] != "prChordHighlight=1")
- extras190qkResult = "ERROR user-set list";
- if (lynx::extras::noteUserChoices ("\nshadeFadedAudio=0\ntrackInserts=0\nwheelZones=1") != "\nextrasUserSet=playlist.trackInserts,playlist.wheelZones")
- extras190qkResult = "ERROR noting the choices";
- if (! lynx::extras::flExactOn ("general.escCloses") || lynx::extras::flExactOn ("playlist.shadeFadedAudio") || lynx::extras::flExactOn ("general.stretchedClipsLoop"))
- extras190qkResult = "ERROR FL-exact values";
- lynx::extras::userSet() = kept;
- }
- // project format round trip, with accents in the name
- auto original = lynx::Song::makeDefault();
- original.channels[0].name = "Bumbo ação";
- original.playlist.push_back ({ 0, 2, 3840, 1920, 960 });
- original.mode = lynx::PlayMode::song;
- original.mixer[3].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::delay));
- original.mixer[3].effects[0].params[1] = 0.25f;
- lynx::Automation automation;
- automation.name = "Pan";
- automation.target = { lynx::AutomationTargetKind::effectParam, 3, 0, 1 };
- automation.points = { { 0, 0.25f, 0.5f }, { 3840, 1.0f, 0.0f } };
- original.automations.push_back (automation);
- lynx::Clip automationClip;
- automationClip.kind = lynx::ClipKind::automation;
- automationClip.automation = 0;
- automationClip.track = 4;
- automationClip.length = 3840;
- original.playlist.push_back (automationClip);
- original.loopStart = 960;
- original.loopEnd = 7680;
- original.playlistTracks.resize (3);
- original.playlistTracks[2].colour = 0xFF2A6FDB; // a track colour (round 90)
- { // the clip grid (round 181a)
- lynx::launcher::setClip (original, 1, 2, { 0, 0, 0, 1920, 0 });
- auto& slot = *lynx::launcher::settingsAt (*original.clipGrid, 1, 2);
- slot.name = "Clip ação";
- slot.mode = lynx::LaunchMode::toggle;
- slot.quant = lynx::LaunchQuant::eighthTriplet;
- slot.legato = true;
- slot.loop = false;
- original.clipGrid->scenes[0].name = "Intro";
- original.clipGrid->globalQuant = lynx::LaunchQuant::bars2;
- }
- std::uint32_t savedGroove = 0;
- { // round 190bv: the groove pool, a groove on the slot's clip, and that clip copied and the copy moved
- lynx::Groove g;
- g.name = "Balanço";
- g.base = lynx::GrooveBase::eighth;
- g.quantize = 0.25f;
- g.timing = 0.8f;
- g.random = 0.1f;
- g.velocity = -0.5f;
- g.length = 1920;
- g.points = { { 0, 1.0f }, { 560, 0.5f } };
- savedGroove = lynx::groove::add (original.grooves, g);
- original.grooves.amount = 1.2f;
- lynx::groove::setClipGroove (original, 1, 2, savedGroove);
- lynx::session::moveClip (original, 1, 2, 0, 1, true);
- lynx::session::moveClip (original, 0, 1, 2, 0, false);
- original.playlist[0].groove = savedGroove; // round 190fm: a Playlist pattern clip's groove
- }
- original.playlistTracks[2].grouped = true; // track groups and rack filter groups (round 104)
- original.playlistTracks[1].collapsed = true;
- original.channelGroups = { "Drums", "Keys" };
- original.channels[1].group = 1;
- original.channels[1].cutOthersOnly = original.channels[1].cutAtNoteEnd = true; // FL Studio Mobile's cut rule (round 190fe)
- juce::String error;
- if (demoProjectPath.isNotEmpty()) // sample project for checking the UI with --snapshot
- lynx::ProjectFile::save (original, juce::File (demoProjectPath), error);
- const auto reloaded = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (original), error);
- // round 190bw: FL's curve modes of automation points come back from a project, tension whole; a bent point
- // without a mode (a project saved before the modes: [tick, value, tension]) keeps LYNX's older law
- const auto curveModesOk = [&original] {
- auto song = original;
- auto& a = song.automations[0];
- a.points = { { 0, 0.25f, 0.5f, (std::uint8_t) lynx::flcurve::stairs },
- { 960, 1.0f, -0.123456f, (std::uint8_t) lynx::flcurve::smooth },
- { 1920, 0.5f, 0.0f, (std::uint8_t) lynx::flcurve::hold },
- { 2400, 0.75f, 0.7f, lynx::AutomationPoint::legacyCurve },
- { 2880, 0.3f, 0.0f, 0 },
- { 3840, 0.6f, 0.0f, 0 } };
- a.lfo.on = true;
- a.lfo.amp = { { 0, 1.0f, -0.25f, (std::uint8_t) lynx::flcurve::pulse }, { 960, 0.5f, 0.0f, 0 } };
- juce::String e;
- const auto text = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (text, e);
- return back && back->automations.size() == 1 && back->automations[0].points == a.points && back->automations[0].lfo.amp == a.lfo.amp
- && back->automations[0].valueAt (700.0) == a.valueAt (700.0) && back->automations[0].valueAt (2600.0) == a.valueAt (2600.0);
- }();
- const auto projectOk = curveModesOk && reloaded && reloaded->channels.size() == original.channels.size()
- && reloaded->channels[0].name == original.channels[0].name
- && reloaded->patterns[0].notes.size() == original.patterns[0].notes.size()
- && reloaded->patterns[0].notes[3].start == original.patterns[0].notes[3].start
- && reloaded->mode == lynx::PlayMode::song && reloaded->playlist.size() == 2
- && reloaded->clipGrid.has_value() && reloaded->clipGrid->globalQuant == lynx::LaunchQuant::bars2
- && reloaded->clipGrid->scenes.size() == 3 && reloaded->clipGrid->scenes[0].name == "Intro"
- && lynx::launcher::clipAt (*reloaded->clipGrid, 1, 2) != nullptr
- && [&reloaded] {
- auto grid = *reloaded->clipGrid;
- const auto* slot = lynx::launcher::settingsAt (grid, 1, 2);
- return slot != nullptr && slot->name == "Clip ação" && slot->mode == lynx::LaunchMode::toggle
- && slot->quant == lynx::LaunchQuant::eighthTriplet && slot->legato && ! slot->loop;
- }()
- && [&reloaded, &original, savedGroove] { // round 190bv
- auto grid = *reloaded->clipGrid;
- const auto* kept = lynx::launcher::settingsAt (grid, 1, 2);
- const auto* moved = lynx::launcher::settingsAt (grid, 2, 0);
- const auto* clip = lynx::launcher::clipAt (grid, 2, 0);
- return reloaded->grooves == original.grooves && reloaded->grooves.grooves.size() == 1
- && reloaded->grooves.amount == 1.2f && reloaded->grooves.grooves[0].name == "Balanço"
- && reloaded->grooves.grooves[0].points.size() == 2 && savedGroove != 0
- && kept != nullptr && kept->groove == savedGroove
- && lynx::launcher::clipAt (grid, 0, 1) == nullptr
- && clip != nullptr && clip->pattern == 0 && clip->length == 1920
- && moved != nullptr && moved->groove == savedGroove && moved->name == "Clip ação"
- && moved->mode == lynx::LaunchMode::toggle && moved->legato && ! moved->loop
- && reloaded->playlist[0].groove == savedGroove && reloaded->playlist[1].groove == 0; // (190fm)
- }()
- && reloaded->playlist[1].kind == lynx::ClipKind::automation && reloaded->playlist[1].automation == 0
- && reloaded->automations.size() == 1 && reloaded->automations[0].target == automation.target
- && reloaded->automations[0].points.size() == 2 && reloaded->automations[0].points[0].tension == 0.5f
- && reloaded->automations[0].points[1].tick == 3840
- && reloaded->loopStart == 960 && reloaded->loopEnd == 7680
- && reloaded->playlistTracks.size() == 3 && reloaded->playlistTracks[2].colour == 0xFF2A6FDB
- && reloaded->playlistTracks[1].colour == 0
- && reloaded->playlistTracks[2].grouped && reloaded->playlistTracks[1].collapsed && ! reloaded->playlistTracks[1].grouped
- && reloaded->channelGroups == original.channelGroups && reloaded->channels[1].group == 1 && reloaded->channels[0].group == -1
- && reloaded->channels[1].cutOthersOnly && reloaded->channels[1].cutAtNoteEnd && ! reloaded->channels[0].cutOthersOnly
- && ! reloaded->channels[0].cutAtNoteEnd
- && reloaded->playlist[0].offset == 960 && reloaded->playlist[0].track == 2
- && reloaded->mixer[3].effects.size() == 1
- && reloaded->mixer[3].effects[0].kind == lynx::EffectKind::delay
- && reloaded->mixer[3].effects[0].params[1] == 0.25f;
- // round trip of the newer features: synth/sampler with modulation, EQs, utility, markers
- auto rich = lynx::Song::makeDefault();
- auto& synth = rich.channels[4].synth;
- synth.osc[1] = { lynx::Waveform::square, -1, 7.0f, 0.4f, 5, -0.25f };
- synth.filterType = 2;
- synth.mono = true;
- synth.portaBeats = 0.125f;
- synth.am = true;
- synth.filterEnv = { 3.0f, 0.01f, 0.02f, 0.3f, 0.25f, 0.4f };
- synth.lfo[lynx::lfoPitch] = { 0.5f, 0.25f, true, 1, 0.1f, 0.2f };
- auto& sampler = rich.channels[0].sampler;
- sampler.cutoff = 1200.0f;
- sampler.resonance = 0.3f;
- sampler.filterType = 1;
- sampler.pitchEnv = { -12.0f, 0.0f, 0.0f, 0.05f, 0.0f, 0.1f };
- sampler.lfo[lynx::lfoVolume] = { 0.5f, 0.5f, false, 2, 0.0f, 0.0f };
- rich.mixer[2].eq.gainDb = { 3.0f, -2.5f, 1.0f };
- rich.mixer[2].eq.hz[1] = 2200.0f;
- auto peqSlot = lynx::makeEffectSlot (lynx::EffectKind::parametricEq);
- peqSlot.params[(std::size_t) lynx::peq::param (2, 2)] = lynx::peq::gainValue (6.0);
- peqSlot.params[(std::size_t) (lynx::peq::slopeParam + 0)] = lynx::peq::slopeValue (3);
- rich.mixer[2].effects.push_back (peqSlot);
- auto utilitySlot = lynx::makeEffectSlot (lynx::EffectKind::utility);
- utilitySlot.params[1] = 0.2f;
- rich.mixer[2].effects.push_back (utilitySlot);
- auto vocodexSlot = lynx::makeEffectSlot (lynx::EffectKind::vocodex); // FL's raw state travels as base64
- for (int i = 0; i < 300; ++i)
- vocodexSlot.state.push_back ((std::uint8_t) (i * 37));
- vocodexSlot.sidechain = 1;
- vocodexSlot.sidechain2 = 2;
- rich.mixer[3].effects.push_back (vocodexSlot);
- rich.addMarker ({ 3840, "Refrão", 0, 4 });
- rich.addMarker ({ 7680, {}, 7, 8 });
- const auto richBack = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (rich), error);
- auto paramsClose = [] (const lynx::EffectParams& a, const lynx::EffectParams& b) {
- for (std::size_t i = 0; i < a.size(); ++i)
- if (std::abs (a[i] - b[i]) > 1.0e-3f)
- return false;
- return true;
- };
- // round 190bu: a one-knob effect, the chain's Blend and its preset name travel in the project; a project without
- // them reads as before (no goal, Blend 100 %) and writes none of the new keys
- bool fx190buOk = false;
- {
- auto song = lynx::Song::makeDefault();
- const auto plainJson = lynx::ProjectFile::toJson (song);
- const auto* preset = lynx::chains::find ("Whisper Air");
- if (preset != nullptr && song.mixer.size() > 2)
- {
- lynx::chains::apply (song, 1, *preset);
- song.mixer[2].effects.push_back (lynx::goals::make (lynx::goals::room, 0.62f));
- song.mixer[2].effects.push_back (lynx::goals::make (lynx::goals::bass, 0.3f));
- song.mixer[2].chainBlend = 0.4f;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, error);
- const auto plainBack = lynx::ProjectFile::fromJson (plainJson, error);
- auto same = back && back->mixer.size() == song.mixer.size();
- for (std::size_t t = 1; same && t <= 2; ++t)
- {
- const auto& a = song.mixer[t];
- const auto& b = back->mixer[t];
- same = a.effects.size() == b.effects.size() && std::abs (a.chainBlend - b.chainBlend) < 1.0e-6f && a.chainPreset == b.chainPreset;
- for (std::size_t i = 0; same && i < a.effects.size(); ++i)
- same = a.effects[i].kind == b.effects[i].kind && a.effects[i].goal == b.effects[i].goal
- && std::abs (a.effects[i].goalAmount - b.effects[i].goalAmount) < 1.0e-6f && a.effects[i].row == b.effects[i].row
- && lynx::goals::active (b.effects[i]) == lynx::goals::active (a.effects[i]);
- }
- fx190buOk = same && lynx::chains::unchanged (*back, 1) && back->mixer[2].chainPreset.empty()
- && ! plainJson.contains ("\"goal\"") && ! plainJson.contains ("chainBlend") && ! plainJson.contains ("chainPreset")
- && json.contains ("\"goalAmount\"") && plainBack && plainBack->mixer[1].chainBlend == 1.0f
- && lynx::ProjectFile::toJson (*back) == json;
- // a user's chain preset file: the slots, Blend and name come back; the strip's level is not part of it
- song.mixer[2].volume = 0.31f;
- const auto file = lynx::ProjectFile::mixerTrackStateToJson (lynx::chains::stateOf (song.mixer[2], "Mine"));
- const auto state = lynx::ProjectFile::mixerTrackStateFromJson (file, error);
- fx190buOk = fx190buOk && state && state->effects.size() == 2 && state->effects[0].goal == lynx::goals::room
- && lynx::goals::active (state->effects[1]) && std::abs (state->chainBlend - 0.4f) < 1.0e-6f && state->chainPreset == "Mine"
- && state->volume == lynx::MixerTrack().volume;
- }
- }
- const auto richOk = fx190buOk && richBack && richBack->channels[4].synth == synth && richBack->channels[0].sampler == sampler
- && richBack->mixer[2].eq == rich.mixer[2].eq && richBack->mixer[2].effects.size() == 2
- && richBack->mixer[2].effects[0].kind == lynx::EffectKind::parametricEq
- && paramsClose (richBack->mixer[2].effects[0].params, peqSlot.params)
- && richBack->mixer[2].effects[1].kind == lynx::EffectKind::utility
- && paramsClose (richBack->mixer[2].effects[1].params, utilitySlot.params)
- && richBack->mixer[3].effects.size() == 1 && richBack->mixer[3].effects[0].kind == lynx::EffectKind::vocodex
- && richBack->mixer[3].effects[0].state == vocodexSlot.state && richBack->mixer[3].effects[0].sidechain2 == 2
- && richBack->markers() == rich.markers();
- // issue #96's per-plugin option: saved only when on; old projects (no field) read as off
- bool hostKeysOk = false;
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef plugin;
- plugin.instrument = lynx::InstrumentKind::plugin;
- plugin.plugin.id = "x";
- song.channels.push_back (plugin);
- const auto channel = song.channels.size() - 1;
- const auto off = lynx::ProjectFile::toJson (song);
- song.channels[channel].plugin.allowHostKeys = true;
- song.channels[channel].plugin.hostKeysFirst = true;
- song.channels[channel].plugin.pinned = true; // (round 190ao: Pin on top)
- song.channels[channel].plugin.velocityMode = lynx::prefs::pluginVelocityFixed; // (round 190ao: the plugin's own velocity)
- song.channels[channel].plugin.fixedVelocity = 64;
- const auto on = lynx::ProjectFile::toJson (song);
- const auto offBack = lynx::ProjectFile::fromJson (off, error);
- const auto onBack = lynx::ProjectFile::fromJson (on, error);
- hostKeysOk = ! off.contains ("allowHostKeys") && on.contains ("allowHostKeys") && offBack && onBack
- && ! offBack->channels[channel].plugin.allowHostKeys && onBack->channels[channel].plugin.allowHostKeys
- && ! off.contains ("hostKeysFirst") && ! offBack->channels[channel].plugin.hostKeysFirst && onBack->channels[channel].plugin.hostKeysFirst
- && ! off.contains ("pinnedOnTop") && ! offBack->channels[channel].plugin.pinned && onBack->channels[channel].plugin.pinned
- && ! off.contains ("velocityMode") && ! off.contains ("fixedVelocity") && offBack->channels[channel].plugin.velocityMode == 0
- && offBack->channels[channel].plugin.fixedVelocity == lynx::prefs::defaultFixedVelocity
- && onBack->channels[channel].plugin.velocityMode == lynx::prefs::pluginVelocityFixed && onBack->channels[channel].plugin.fixedVelocity == 64;
- }
- // round 190ad: a new project has FL's plugin levels and keeps them through a save; a project saved before
- // (no "pluginLevels") reads as LYNX's own law, and stays so when it opens
- bool pluginLevelsOk = false;
- {
- const auto fresh = lynx::makeNewProject();
- const auto saved = lynx::ProjectFile::toJson (fresh);
- const auto back = lynx::ProjectFile::fromJson (saved, error);
- auto old = lynx::Song::makeDefault(); // (what every earlier version made)
- const auto oldSaved = lynx::ProjectFile::toJson (old);
- const auto oldBack = lynx::ProjectFile::fromJson (oldSaved, error);
- const auto stripped = lynx::ProjectFile::fromJson (saved.replace ("\"pluginLevels\"", "\"pluginLevelsGone\""), error);
- pluginLevelsOk = fresh.flPluginLevels && saved.contains ("\"pluginLevels\"") && back && back->flPluginLevels
- && ! old.flPluginLevels && ! oldSaved.contains ("pluginLevels") && oldBack && ! oldBack->flPluginLevels
- && stripped && ! stripped->flPluginLevels;
- }
- // hardware output targets (REA round 156): saved only when set; old projects (no field) keep the defaults
- bool hwOutOk = false;
- {
- auto song = lynx::Song::makeDefault();
- const auto plain = lynx::ProjectFile::toJson (song);
- song.mixer[0].outputChannel = lynx::outputNone;
- song.mixer[1].outputChannel = 2;
- song.mixer[1].outputMode = lynx::OutputMode::monoRight;
- song.mixer[2].outputChannel = 6;
- song.mixer[3].outputChannel = 4;
- song.mixer[3].outputMode = lynx::OutputMode::monoSum;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- const auto plainBack = lynx::ProjectFile::fromJson (plain, error);
- hwOutOk = back && back->mixer[0].outputChannel == lynx::outputNone && back->mixer[1].outputChannel == 2
- && back->mixer[1].outputMode == lynx::OutputMode::monoRight && back->mixer[2].outputChannel == 6
- && back->mixer[2].outputMode == lynx::OutputMode::stereo && back->mixer[3].outputMode == lynx::OutputMode::monoSum
- && back->mixer[4].outputChannel == lynx::outputDefault && ! plain.contains ("\"output\"") && plainBack
- && plainBack->mixer[0].outputChannel == lynx::outputDefault && plainBack->mixer[1].outputChannel == lynx::outputDefault;
- }
- // round 168j: FL's icons (channel / mixer track / playlist track), PDC Automatic / Compensate automations, Time
- // settings, scale highlighting and data folder — saved only when set, old projects load with FL's defaults
- bool flp168jOk = false;
- {
- auto song = lynx::Song::makeDefault();
- const auto plain = lynx::ProjectFile::toJson (song);
- song.channels[0].icon = 75;
- song.mixer[2].icon = 71;
- song.playlistTracks.resize (3);
- song.playlistTracks[2].icon = 30;
- song.autoPdc = false;
- song.compensateAutomations = false;
- song.timeSignatureMode = true;
- song.scaleHighlight = { 10, 5 };
- song.dataFolder = "D:\\Projects\\data";
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- const auto plainBack = lynx::ProjectFile::fromJson (plain, error);
- flp168jOk = back && back->channels[0].icon == 75 && back->mixer[2].icon == 71 && back->playlistTracks.size() >= 3
- && back->playlistTracks[2].icon == 30 && ! back->autoPdc && ! back->compensateAutomations && back->timeSignatureMode
- && back->scaleHighlight == song.scaleHighlight && back->dataFolder == song.dataFolder && plainBack && plainBack->autoPdc
- && plainBack->compensateAutomations && ! plainBack->timeSignatureMode && plainBack->scaleHighlight == lynx::Song::ScaleHighlight {}
- && plainBack->dataFolder.empty() && plainBack->channels[0].icon == 0 && ! plain.contains ("\"icon\"")
- && ! plain.contains ("autoPdc") && ! plain.contains ("scaleHighlight");
- }
- // round 180d: clip fades take FL's S curve; a project saved before that keeps its straight fades, also after another
- // save, and a clip made in it takes the S curve. FL's fade tensions and stretch mode and PITCH survive a save.
- // issue #122: playlist tracks linked to inserts (audio) and channels (instrument) survive save, load and save
- // again byte for byte (they were read before the mixer and fell back to Unassigned)
- bool trackModes122Ok = false;
- {
- auto song = lynx::Song::makeDefault();
- song.playlistTracks.resize (6);
- song.playlistTracks[1].mode = lynx::PlaylistTrackMode::audio;
- song.playlistTracks[1].mixerTrack = 3;
- song.playlistTracks[4].mode = lynx::PlaylistTrackMode::audio;
- song.playlistTracks[4].mixerTrack = (int) song.mixer.size() - 1;
- song.playlistTracks[5].mode = lynx::PlaylistTrackMode::instrument;
- song.playlistTracks[5].channel = 1;
- song.playlistTracks[5].mixerTrack = 2;
- const auto json = lynx::ProjectFile::toJson (song, false);
- const auto loaded = lynx::ProjectFile::fromJson (json, error);
- const auto again = loaded ? lynx::ProjectFile::toJson (*loaded, false) : juce::String();
- trackModes122Ok = loaded && json.contains ("playlistTrackModes") && again == json && loaded->playlistTracks.size() >= 6
- && loaded->playlistTracks[1].mode == lynx::PlaylistTrackMode::audio && loaded->playlistTracks[1].mixerTrack == 3
- && loaded->playlistTracks[4].mode == lynx::PlaylistTrackMode::audio
- && loaded->playlistTracks[4].mixerTrack == (int) song.mixer.size() - 1
- && loaded->playlistTracks[5].mode == lynx::PlaylistTrackMode::instrument && loaded->playlistTracks[5].channel == 1;
- }
- bool clipFades180dOk = false;
- {
- auto song = lynx::Song::makeDefault();
- lynx::Clip faded;
- faded.kind = lynx::ClipKind::audio;
- faded.channel = 0;
- faded.length = lynx::ppq * 8;
- faded.fadeIn = lynx::ppq;
- faded.fadeOutTension = -812.933f;
- faded.fadeOut = lynx::ppq * 2;
- lynx::Clip plainClip = faded;
- plainClip.fadeIn = plainClip.fadeOut = 0;
- plainClip.fadeOutTension = 0.0f;
- plainClip.start = lynx::ppq * 16;
- song.playlist = { faded, plainClip };
- song.channels[0].sampler.flStretchMode = 5;
- song.channels[0].sampler.flStretchPitch = 247;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto current = lynx::ProjectFile::fromJson (json, error);
- const auto oldJson = json.replace ("\"clipFadesPerClip\"", "\"clipFadesOther\"");
- auto old = lynx::ProjectFile::fromJson (oldJson, error);
- auto resaved = old;
- if (resaved)
- {
- auto added = faded;
- added.start = lynx::ppq * 32;
- added.linearFades = 0;
- resaved->playlist.push_back (added);
- resaved = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (*resaved), error);
- }
- clipFades180dOk = current && old && resaved && json.contains ("clipFadesPerClip") && ! oldJson.contains ("clipFadesPerClip")
- && current->playlist.size() == 2 && ! current->playlist[0].linearFades
- && current->playlist[0].fadeOutTension == -812.933f && ! current->playlist[1].linearFades
- && current->channels[0].sampler.flStretchMode == 5 && current->channels[0].sampler.flStretchPitch == 247
- && old->playlist.size() == 2 && old->playlist[0].linearFades && ! old->playlist[1].linearFades
- && resaved->playlist.size() == 3 && resaved->playlist[0].linearFades && ! resaved->playlist[1].linearFades
- && ! resaved->playlist[2].linearFades && resaved->playlist[0].fadeOutTension == -812.933f;
- }
- // FL's legacy Pattern Blocks (round 170f): the option and every arrangement's blocks are saved; a project without
- // them has neither in its file and loads with the option off
- bool blocksOk = false;
- {
- auto song = lynx::Song::makeDefault();
- const auto plain = lynx::ProjectFile::toJson (song);
- song.patternBlocksOn = true;
- lynx::patternblocks::place (song, 0, 0);
- lynx::patternblocks::place (song, 0, 4 * 4 * lynx::ppq);
- lynx::patternblocks::setMuted (song, 1, true); // (round 190ht, issue #127: a muted block keeps its mute)
- song.addArrangement ("Second");
- lynx::patternblocks::place (song, 0, 2 * 4 * lynx::ppq);
- song.selectArrangement (0);
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- const auto plainBack = lynx::ProjectFile::fromJson (plain, error);
- blocksOk = back && back->patternBlocksOn && back->blocks == song.blocks && song.blocks.size() == 2 && back->blocks[1].muted
- && back->arrangements.size() == 2 && back->arrangements[1].blocks == song.arrangements[1].blocks
- && song.arrangements[1].blocks.size() == 1 && back->songLength() == song.songLength() && plainBack
- && ! plainBack->patternBlocksOn && plainBack->blocks.empty() && ! plain.contains ("blocks")
- && ! plain.contains ("patternBlocks");
- }
- // FL's pattern clip takeover (issue #158): saved when on; a project saved before it (no key) loads with it off and
- // keeps playing every overlapping clip of a pattern in full; new projects have it on
- bool takeoverOk = false;
- {
- auto song = lynx::Song::makeDefault();
- const auto plain = lynx::ProjectFile::toJson (song);
- song.patternClipTakeover = true;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, error);
- const auto plainBack = lynx::ProjectFile::fromJson (plain, error);
- takeoverOk = back && back->patternClipTakeover && json.contains ("patternClipTakeover") && plainBack
- && ! plainBack->patternClipTakeover && ! plain.contains ("patternClipTakeover")
- && lynx::makeNewProject().patternClipTakeover;
- }
- // comping (round 177c): a comp's equal-power crossfades (Clip::fadeCurve) and the crossfade length are saved; a
- // project without them has neither in its file
- bool compOk = false;
- {
- auto song = lynx::Song::makeDefault();
- const auto plain = lynx::ProjectFile::toJson (song);
- lynx::ChannelDef take;
- take.instrument = lynx::InstrumentKind::audioClip;
- take.samplePath = "take.wav";
- song.channels.push_back (take);
- lynx::Clip a;
- a.kind = lynx::ClipKind::audio;
- a.channel = (int) song.channels.size() - 1;
- a.length = lynx::ppq;
- a.fadeOut = 20;
- a.fadeCurve = 2;
- auto b = a;
- b.start = lynx::ppq - 20;
- b.fadeOut = 0;
- b.fadeIn = 20;
- b.fadeCurve = 1;
- // round 180d's FL fade fields (indices 17..20) and the comp curve (index 21) on one clip, all kept
- auto c = a;
- c.start = 4 * lynx::ppq;
- c.fadeIn = 30;
- c.fadeInTension = -0.75f;
- c.fadeOutTension = 0.5f;
- c.linearFades = 2;
- c.flFadeFlags = 0x1234u;
- c.fadeCurve = 3;
- song.playlist = { a, b, c };
- song.compCrossfadeMs = 12.5f;
- song.playlistTracks.resize (2);
- song.playlistTracks[0].compTrack = true;
- song.playlistTracks[1].grouped = true;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- const auto plainBack = lynx::ProjectFile::fromJson (plain, error);
- const auto* both = back && back->playlist.size() == 3 ? &back->playlist[2] : nullptr;
- compOk = back && back->playlist.size() == 3 && back->playlist[0].fadeCurve == 2 && back->playlist[1].fadeCurve == 1
- && both != nullptr && both->fadeCurve == 3 && both->fadeInTension == -0.75f && both->fadeOutTension == 0.5f
- && both->linearFades == 2 && both->flFadeFlags == 0x1234u && both->fadeIn == 30
- && back->playlist[1].fadeIn == 20 && back->compCrossfadeMs == 12.5f && back->playlistTracks[0].compTrack && ! back->playlistTracks[1].compTrack && plainBack
- && plainBack->compCrossfadeMs == lynx::Song::defaultCompCrossfadeMs && ! plain.contains ("compCrossfadeMs") && ! plain.contains ("playlistCompTracks");
- }
- // Misc › Mono / Porta / Slide on every generator (round 168l): kept in the file; a project saved before (an
- // imported engine's flags in its synth settings) gets them back, a Max polyphony of 1 is not Mono
- bool polyOk = false;
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef osc;
- osc.instrument = lynx::InstrumentKind::threeosc;
- osc.misc.mono = osc.misc.porta = true;
- osc.misc.portaBeats = 0.25f;
- song.channels.push_back (osc);
- auto old = osc;
- old.misc = {};
- old.synth.mono = old.synth.porta = true;
- old.synth.portaBeats = 0.5f;
- song.channels.push_back (old);
- old.maxPolyphony = 1;
- song.channels.push_back (old);
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- const auto n = song.channels.size();
- polyOk = back && back->channels.size() == n && back->channels[n - 3].misc.mono && back->channels[n - 3].misc.porta
- && std::abs (back->channels[n - 3].misc.portaBeats - 0.25f) < 1e-6f && back->channels[n - 2].misc.mono
- && back->channels[n - 2].misc.porta && std::abs (back->channels[n - 2].misc.portaBeats - 0.5f) < 1e-6f
- && ! back->channels[n - 1].misc.mono && back->channels[n - 1].maxPolyphony == 1
- && ! back->channels[4].misc.mono; // (the LYNX Synth keeps its own flags)
- }
- // FL's track latency (REA round 165f-mixer): manual ms, bypass mode and master compensation saved only when set
- bool latencyOk = false;
- {
- auto song = lynx::Song::makeDefault();
- const auto plain = lynx::ProjectFile::toJson (song);
- song.mixer[1].latencyMs = -20.0f;
- song.mixer[2].latencyMs = 12.5f;
- song.mixer[2].latencyBypass = lynx::LatencyBypass::always;
- song.mixer[3].latencyBypass = lynx::LatencyBypass::whenRecordingOrStopped;
- song.mixer[3].compensateMasterLatency = false;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- latencyOk = back && back->mixer[1].latencyMs == -20.0f && back->mixer[2].latencyMs == 12.5f
- && back->mixer[2].latencyBypass == lynx::LatencyBypass::always
- && back->mixer[3].latencyBypass == lynx::LatencyBypass::whenRecordingOrStopped && ! back->mixer[3].compensateMasterLatency
- && back->mixer[4].latencyMs == 0.0f && back->mixer[4].compensateMasterLatency
- && ! plain.contains ("latencyMs") && ! plain.contains ("latencyBypass") && ! plain.contains ("compensateMaster");
- }
- // LYNX's pre-fader sends (round 190aq): saved only when one is used, in a list of its own ("preSends") that a
- // version from before ignores (its sends then play post-fader, as FL's)
- bool preSendOk = false;
- {
- auto song = lynx::Song::makeDefault();
- song.setRoute (1, 3, true, 0.5f);
- song.setRoute (1, 4, true);
- song.setRoute (2, 3, true);
- const auto plain = lynx::ProjectFile::toJson (song);
- song.setSendPre (1, 3, true);
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, error);
- preSendOk = back && back->sendPre (1, 3) && ! back->sendPre (1, 4) && ! back->sendPre (2, 3)
- && std::abs (back->routeLevel (1, 3) - 0.5f) < 1.0e-4f && back->mixer[1].sends == song.mixer[1].sends
- && ! plain.contains ("preSends") && json.contains ("preSends")
- && json.replace ("\"preSends\"", "\"preSendsOld\"") != json;
- // the same file without the list (what an older version reads): the sends are there, post-fader
- if (const auto old = lynx::ProjectFile::fromJson (json.replace ("\"preSends\"", "\"unknownToOldVersions\""), error))
- preSendOk = preSendOk && old->routes (1, 3) && ! old->sendPre (1, 3) && old->mixer[1].sends.size() == 2;
- else
- preSendOk = false;
- }
- // LYNX's "Low latency while recording" (round 190aq): a latency-adding effect on a monitored insert's path is
- // bypassed in the engine only — PDC drops, the slot is marked, the song and the saved project stay as they are —
- // and it is back when the option goes off
- bool lowLatencyOk = false;
- {
- lynx::AudioEngine live (false);
- live.editSong ([] (lynx::Song& s) {
- s.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::limiter)); // 1.5 ms look-ahead
- s.mixer[1].inputChannel = 0;
- s.mixer[1].monitor = lynx::InputMonitor::on;
- });
- const auto before = live.getLatencySamples();
- const auto saved = lynx::ProjectFile::toJson (live.getSong());
- const auto idle = live.lowLatencyBypassedCount() == 0; // the option is off: nothing is bypassed
- auto o = live.getRecordOptions();
- o.lowLatencyRecording = true;
- live.setRecordOptions (o);
- const auto during = live.getLatencySamples();
- const auto marked = live.isSlotLowLatencyBypassed (1, 0) && live.lowLatencyBypassedLatency (1, 0) > 0 && live.lowLatencyBypassedCount() >= 1;
- const auto untouched = live.getSong().mixer[1].effects[0].enabled && lynx::ProjectFile::toJson (live.getSong()) == saved;
- // monitoring leaves "On" (nothing armed): the effect returns
- live.editSong ([] (lynx::Song& s) { s.mixer[1].monitor = lynx::InputMonitor::whenArmed; });
- const auto released = live.getLatencySamples() == before && ! live.isSlotLowLatencyBypassed (1, 0);
- live.editSong ([] (lynx::Song& s) { s.mixer[1].monitor = lynx::InputMonitor::on; });
- const auto again = live.getLatencySamples() == during && live.isSlotLowLatencyBypassed (1, 0);
- o.lowLatencyRecording = false;
- live.setRecordOptions (o);
- lowLatencyOk = before > 0 && idle && during < before && marked && untouched && released && again
- && live.getLatencySamples() == before && live.lowLatencyBypassedCount() == 0;
- }
- // The Browser's "Preview in time" (round 190aq): a loop whose name gives its tempo is stretched to the project's
- // and starts on the beat; a one-shot plays as it always did; off, nothing changes
- bool previewInTimeOk = false;
- double previewPrepareMs = 0.0;
- {
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-selftest-preview");
- dir.deleteRecursively();
- dir.createDirectory();
- auto writeWav = [&dir] (const juce::String& name, int frames, bool loop) {
- const auto wav = dir.getChildFile (name);
- juce::WavAudioFormat format;
- juce::AudioBuffer<float> audio (1, frames);
- for (int i = 0; i < frames; ++i) // a click on every beat of 120 BPM over a tone, or a decaying hit
- audio.setSample (0, i, loop ? (i % 24000 < 400 ? 0.8f : 0.0f) + 0.1f * std::sin (0.02f * (float) i)
- : 0.6f * std::exp (-(float) i / 2000.0f) * std::sin (0.05f * (float) i));
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- return wav;
- };
- const auto loop = writeWav ("selftest loop 120 bpm.wav", 96000, true); // 4 beats at 120 BPM
- const auto hit = writeWav ("selftest hit.wav", 14400, false); // 0.3 s
- lynx::AudioEngine player (false);
- const auto projectBpm = player.getTransport().bpm.load();
- // off (FL's preview): nothing is prepared, the file plays as it is
- player.previewFile (loop);
- const auto offOk = ! player.getPreviewTiming().pending && ! player.getPreviewTiming().inTime;
- player.setPreviewInTime (true);
- player.previewFile (hit); // a one-shot: as it always played, at once
- const auto hitOk = ! player.getPreviewTiming().pending && ! player.getPreviewTiming().inTime;
- player.previewFile (loop);
- const auto queued = player.getPreviewTiming().pending || std::abs (projectBpm - 120.0) < 0.2;
- player.finishPreviewJobs();
- const auto timing = player.getPreviewTiming();
- previewPrepareMs = player.getLastPreviewPrepareMs();
- const auto wanted = lynx::previewtempo::stretchRatio (120.0, projectBpm);
- const auto stretchedOk = timing.inTime && ! timing.pending && timing.source == lynx::previewtempo::Source::name
- && std::abs (timing.fileBpm - 120.0) < 1.0e-9 && std::abs (timing.ratio - wanted) < 1.0e-12
- && std::abs ((double) timing.frames - 96000.0 * wanted) < 96000.0 * 0.01;
- // the second click on the same file has its stretch ready
- player.previewFile (loop);
- const auto cachedOk = ! player.getPreviewTiming().pending && player.getPreviewTiming().inTime && player.getPreviewTiming().frames == timing.frames;
- player.previewFile ({});
- const auto stoppedOk = ! player.getPreviewTiming().inTime && player.getPreviewInTimeProgress() < 0.0;
- // the start: on the next heard beat while the transport plays (sample exact), at once when it is stopped
- auto firstSample = [] (bool playing, double startTick, int latency) {
- lynx::Transport transport;
- transport.sampleRate.store (48000.0);
- transport.bpm.store (120.0); // 0.04 ticks per sample
- transport.playing.store (playing);
- transport.positionTicks.store (startTick);
- lynx::PreviewPlayer p;
- p.prepareToPlay (48000.0, 512);
- p.setTransport (&transport);
- p.setSyncLatency (latency);
- auto dc = std::make_shared<lynx::SampleData>();
- dc->sampleRate = 48000.0;
- dc->left.assign (48000, 0.5f);
- p.playBrowser (dc, 1.0f, true);
- juce::AudioBuffer<float> block (2, 512);
- juce::MidiBuffer midi;
- for (int done = 0; done < 48000; done += 512)
- {
- p.processBlock (block, midi);
- for (int i = 0; i < 512; ++i)
- if (block.getSample (0, i) != 0.0f)
- return done + i;
- if (playing)
- transport.positionTicks.store (transport.positionTicks.load() + 512 * transport.ticksPerSample());
- }
- return -1;
- };
- const auto beatOk = firstSample (true, 480.0, 0) == 12000 // half a beat to go: 480 ticks / 0.04
- && firstSample (true, 480.0, 100) == 12100 // the song is heard 100 samples late (PDC)
- && firstSample (true, 960.0, 0) == 0 // on a beat: now
- && firstSample (false, 480.0, 0) == 0; // stopped: a free start
- previewInTimeOk = loop.existsAsFile() && hit.existsAsFile() && offOk && hitOk && queued && stretchedOk && cachedOk && stoppedOk && beatOk;
- dir.deleteRecursively();
- }
- // LYNX substitutes (round 98): a missing plugin's slot plays a built-in equivalent and the project keeps the
- // original reference byte for byte (.flp record and LYNX plugin state)
- bool substituteOk = false;
- {
- auto song = lynx::Song::makeDefault();
- lynx::ForeignPlugin vv; // an .flp VST3 record (ValhallaVintageVerb's class ID), opaque state
- vv.format = lynx::ForeignPlugin::Format::vst3;
- const std::uint8_t cid[] = { 0x76, 0x54, 0x53, 0x56, 0x65, 0x65, 0x76, 0x33, 0x61, 0x6c, 0x68, 0x61, 0x6c, 0x6c, 0x61, 0x76 };
- std::copy (std::begin (cid), std::end (cid), vv.classId.begin());
- vv.hasClassId = true;
- vv.name = "ValhallaVintageVerb";
- vv.path = "C:\\x\\ValhallaVintageVerb.vst3";
- for (int i = 0; i < 777; ++i)
- vv.state.push_back ((std::uint8_t) (i * 13 + 1));
- lynx::EffectSlot fromFlp;
- fromFlp.kind = lynx::EffectKind::plugin;
- fromFlp.plugin.foreign = vv;
- lynx::EffectSlot fromLynx; // a LYNX reference whose plugin isn't installed here
- fromLynx.kind = lynx::EffectKind::plugin;
- fromLynx.plugin.id = "VST3-FabFilter Pro-Q 3-1a2b3c4d-5e6f7a8b";
- fromLynx.plugin.name = "FabFilter Pro-Q 3";
- fromLynx.plugin.state = "AAECAwQFBgcICQ==";
- const auto flpRef = fromFlp.plugin, lynxRef = fromLynx.plugin;
- song.mixer[1].effects = { fromFlp, fromLynx };
- const auto substitutesOn = lynx::pluginSubstitutesEnabled();
- const auto changed = offline.getPluginHost().applySubstitutes (song);
- auto& fx = song.mixer[1].effects;
- // only the LYNX reference is substituted here (an .flp record is the import's job); do the .flp one directly
- const auto flpSubstituted = lynx::substituteEffectSlot (fx[0], lynx::pluginIdentity (vv));
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- substituteOk = flpSubstituted && fx[0].kind == lynx::EffectKind::epochVerb
- && (! substitutesOn || (changed == 1 && fx[1].kind == lynx::EffectKind::facetEq && fx[1].substituteFor == lynxRef))
- && back && back->mixer[1].effects.size() == 2 && back->mixer[1].effects[0].kind == lynx::EffectKind::epochVerb
- && back->mixer[1].effects[0].substituteFor == flpRef && back->mixer[1].effects[0].substituteFor.foreign.state == vv.state
- && back->mixer[1].effects[1].kind == fx[1].kind && back->mixer[1].effects[1].substituteFor == fx[1].substituteFor;
- }
- // undo/redo
- offline.editSong ([] (lynx::Song& s) { s.bpm = 99.0; });
- offline.editSong ([] (lynx::Song& s) { s.bpm = 101.0; });
- offline.undo();
- const auto afterUndo = offline.getSong().bpm;
- offline.redo();
- const auto undoOk = afterUndo == 99.0 && offline.getSong().bpm == 101.0 && offline.canUndo() && ! offline.canRedo()
- && offline.isModified();
- // Remote-owned steps still behave as ordinary native history when no RemoteControl instance is enabled.
- // Only API undo/redo refuse device drift; remote reads, staging and publication never hold the audio-device callback lock.
- const auto remoteHistoryResult = []() -> juce::String {
- int checks = 0;
- const auto require = [&] (bool condition, const char* message) {
- ++checks;
- if (! condition) throw std::runtime_error (message);
- };
- try
- {
- for (const auto session : { false, true })
- {
- lynx::AudioEngine history (false);
- lynx::Song initial;
- initial.channels.resize (1);
- initial.channels[0].instrument = lynx::InstrumentKind::synth;
- initial.mixer = lynx::Song::defaultMixer (1);
- initial.bpm = 120.0;
- history.setSong (std::move (initial));
- history.setSessionHistory (session);
- const auto editTempo = [&] (double bpm) {
- require (history.editSongRemoteTransaction ([&] (lynx::Song& s) { s.bpm = bpm; }), "remote tempo edit was not committed");
- };
- const auto refused = [&] (const std::function<void()>& operation) {
- const auto position = history.getHistoryPosition();
- const auto before = lynx::ProjectFile::toJsonExact (history.getSong());
- bool changed = false;
- try { operation(); }
- catch (const lynx::RemoteError& e) { changed = e.code == "changed" && ! e.uncertain; }
- require (changed, "API history did not refuse untracked device changes");
- require (history.getHistoryPosition() == position && lynx::ProjectFile::toJsonExact (history.getSong()) == before,
- "refused API history changed the project or history position");
- };
- const auto withoutDeviceLock = [&] (const std::function<void()>& operation) {
- juce::WaitableEvent locked, release;
- bool timedOut = false;
- std::thread callback ([&] {
- const juce::ScopedLock lock (history.getDeviceManager().getAudioCallbackLock());
- locked.signal();
- timedOut = ! release.wait (3000);
- });
- const auto acquired = locked.wait (3000);
- std::exception_ptr failure;
- try { if (acquired) operation(); }
- catch (...) { failure = std::current_exception(); }
- release.signal();
- callback.join();
- // Check before rethrowing: an expected rejection must not conceal waiting for this lock.
- require (acquired && ! timedOut, "remote read, edit or history publication waited for the audio-device callback lock");
- if (failure) std::rethrow_exception (failure);
- };
- const auto baseline = lynx::ProjectFile::toJsonExact (history.getSong());
- const auto baselineStamp = history.getSongStamp();
- const auto baselinePosition = history.getHistoryPosition();
- const auto unchanged = [&] {
- return history.getSongStamp() == baselineStamp && history.getHistoryPosition() == baselinePosition
- && lynx::ProjectFile::toJsonExact (history.getSong()) == baseline;
- };
- withoutDeviceLock ([&] {
- require (lynx::ProjectFile::toJsonExact (history.snapshotForRemoteControl()) == baseline,
- "remote snapshot changed the project");
- require (history.remoteDeviceStateHash().isNotEmpty(), "remote snapshot did not hash device state");
- });
- require (unchanged(), "remote reads changed the project, revision or history");
- bool staged = false;
- withoutDeviceLock ([&] {
- require (! history.editSongRemoteTransaction ([&] (lynx::Song&) { staged = true; }),
- "remote no-op committed a history step");
- });
- require (staged && unchanged(), "remote no-op did not stage cleanly without changing history");
- bool rejected = false;
- try {
- withoutDeviceLock ([&] {
- history.editSongRemoteTransaction ([] (lynx::Song& next) {
- next.bpm = 999.0;
- throw lynx::RemoteError ("invalid", "selftest stage rejection");
- });
- });
- }
- catch (const lynx::RemoteError& e) { rejected = e.code == "invalid" && ! e.uncertain; }
- require (rejected && unchanged(), "rejected staging changed the project, revision or history");
- for (const auto cancelAfterStage : { false, true })
- {
- int calls = 0;
- staged = false;
- bool cancelledEdit = false;
- try {
- withoutDeviceLock ([&] {
- history.editSongRemoteTransaction ([&] (lynx::Song& next) { staged = true; next.bpm = 999.0; },
- [&] { return ++calls >= (cancelAfterStage ? 2 : 1); });
- });
- }
- catch (const lynx::RemoteError& e) { cancelledEdit = e.code == "failed" && ! e.uncertain; }
- require (cancelledEdit && staged == cancelAfterStage && unchanged(),
- "cancelled edit changed the project, revision or history");
- }
- withoutDeviceLock ([&] { editTempo (130.0); });
- require (history.getSong().bpm == 130.0 && history.getHistoryPosition() == baselinePosition + 1
- && history.getSongStamp() > baselineStamp, "remote commit did not publish one history step");
- history.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.23f; }, false);
- refused ([&] { history.undoRemoteControl(); });
- withoutDeviceLock ([&] { history.undo(); });
- require (history.getHistoryPosition() == 0 && history.getSong().bpm == 120.0 && history.getRemoteHistoryError().isEmpty(),
- "native undo refused device drift while remote control was disabled");
- history.editSong ([] (lynx::Song& s) { s.channels[0].name = "Untracked change"; }, false);
- refused ([&] { history.redoRemoteControl(); });
- withoutDeviceLock ([&] { history.redo(); });
- require (history.getHistoryPosition() == 1 && history.getSong().bpm == 130.0 && history.getRemoteHistoryError().isEmpty(),
- "native redo refused device drift while remote control was disabled");
- withoutDeviceLock ([&] { editTempo (140.0); });
- history.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.42f; }, false);
- withoutDeviceLock ([&] { history.jumpToHistory (0); });
- require (history.getHistoryPosition() == 0 && history.getSong().bpm == 120.0, "native history jump stopped at a remote step");
- withoutDeviceLock ([&] { history.jumpToHistory (2); });
- require (history.getHistoryPosition() == 2 && history.getSong().bpm == 140.0, "native redo jump stopped at a remote step");
- withoutDeviceLock ([&] { history.undoRemoteControl(); });
- require (history.getHistoryPosition() == 1 && history.getSong().bpm == 130.0, "API undo failed with an unchanged device fence");
- withoutDeviceLock ([&] { history.redoRemoteControl(); });
- require (history.getHistoryPosition() == 2 && history.getSong().bpm == 140.0, "API redo failed with an unchanged device fence");
- int cancelledChecks = 0;
- bool cancelled = false;
- try { history.undoRemoteControl ([&] { return ++cancelledChecks >= 2; }); }
- catch (const lynx::RemoteError& e) { cancelled = e.code == "failed" && ! e.uncertain; }
- require (cancelled && history.getHistoryPosition() == 2 && history.getSong().bpm == 140.0,
- "cancelled API history moved a step");
- withoutDeviceLock ([&] { history.undo(); });
- require (history.getHistoryPosition() == 1 && history.getSong().bpm == 130.0 && history.getRemoteHistoryError().isEmpty(),
- "API cancellation leaked into native history");
- }
- return "OK (" + juce::String (checks) + " checks)";
- }
- catch (const std::exception& e) { return "ERROR " + juce::String::fromUTF8 (e.what()); }
- }();
- // Hosted state access and processing share a per-instance lock, including fixed blocks and deferred resets.
- const auto hostedStateLockResult = []() -> juce::String {
- struct Probe final : juce::AudioPluginInstance
- {
- struct Parameter final : juce::HostedAudioProcessorParameter
- {
- explicit Parameter (Probe& p) : owner (p) {}
- float getValue() const override { owner.access (owner.parameterReads); return value.load(); }
- void setValue (float v) override { owner.access (owner.parameterWrites); value.store (v); }
- float getDefaultValue() const override { return 0.0f; }
- juce::String getName (int) const override { return "Value"; }
- juce::String getLabel() const override { return {}; }
- juce::String getParameterID() const override { return "value"; }
- float getValueForText (const juce::String& text) const override { return text.getFloatValue(); }
- Probe& owner;
- std::atomic<float> value { 0.0f };
- };
- Probe() : AudioPluginInstance (BusesProperties().withInput ("Input", juce::AudioChannelSet::stereo(), true)
- .withOutput ("Output", juce::AudioChannelSet::stereo(), true))
- {
- addHostedParameter (std::make_unique<Parameter> (*this));
- }
- const juce::String getName() const override { return "State lock probe"; }
- void fillInPluginDescription (juce::PluginDescription& d) const override { d.name = getName(); }
- void prepareToPlay (double, int) override {}
- void releaseResources() override {}
- void processBlock (juce::AudioBuffer<float>& audio, juce::MidiBuffer&) override { access (blocks); audio.clear(); }
- void reset() override { access (resets, std::this_thread::get_id() == ui); } // (on the UI thread: the export reset)
- double getTailLengthSeconds() const override { return 0.0; }
- bool acceptsMidi() const override { return true; }
- bool producesMidi() const override { return false; }
- bool hasEditor() const override { return false; }
- juce::AudioProcessorEditor* createEditor() override { return nullptr; }
- int getNumPrograms() override { return 1; }
- int getCurrentProgram() override { return 0; }
- void setCurrentProgram (int) override {}
- const juce::String getProgramName (int) override { return {}; }
- void changeProgramName (int, const juce::String&) override {}
- void getStateInformation (juce::MemoryBlock& state) override { access (captures); state.replaceAll ("state", 5); }
- void setStateInformation (const void*, int) override { access (restores, true); }
- // Round 190ha: only a restore and the export reset are exclusive with the audio side. A capture and the
- // UI's parameter changes run beside processing, as on JUCE's own hosts (UI-thread calls never overlap
- // each other here: they run in turn).
- void access (std::atomic<int>& calls, bool exclusive = false)
- {
- ++calls;
- if (exclusive)
- {
- ++exclusiveActive;
- if (active.fetch_add (1) != 0) overlap = true;
- }
- else
- {
- ++active;
- if (exclusiveActive.load() != 0) overlap = true;
- }
- juce::Thread::sleep (1); // widen the concurrent vendor-call window without using real plugins
- --active;
- if (exclusive) --exclusiveActive;
- }
- const std::thread::id ui = std::this_thread::get_id();
- std::atomic<int> active { 0 }, exclusiveActive { 0 }, blocks { 0 }, resets { 0 }, captures { 0 }, restores { 0 };
- std::atomic<int> parameterReads { 0 }, parameterWrites { 0 };
- std::atomic<bool> overlap { false };
- };
- int checks = 0;
- const auto require = [&] (bool condition, const char* message) {
- ++checks;
- if (! condition) throw std::runtime_error (message);
- };
- const auto exercise = [&] (auto& adapter, Probe& probe, const auto& render, const auto& reset) {
- const auto saved = adapter.captureState();
- require (saved.has_value(), "mock hosted state could not be captured");
- juce::WaitableEvent start (true);
- std::thread audio ([&] {
- start.wait();
- for (int i = 0; i < 32; ++i)
- {
- adapter.setParameter (0, i % 2 == 0 ? 0.25f : 0.75f);
- (void) adapter.parameterValue (0);
- reset();
- render();
- }
- });
- const juce::ScopeGuard joinAudio { [&] { if (audio.joinable()) audio.join(); } };
- start.signal();
- bool stateOk = true;
- for (int i = 0; i < 32; ++i)
- {
- stateOk = adapter.captureState().has_value() && stateOk;
- stateOk = adapter.restoreState (*saved) && stateOk;
- adapter.setParameterFromUi (0, i % 2 == 0 ? 0.1f : 0.9f);
- if (i % 8 == 0) adapter.resetForExport();
- }
- audio.join();
- // Contended audio callbacks may all have bypassed while state was held.
- // Exercise a successful callback after release before checking coverage.
- adapter.setParameter (0, 0.5f);
- (void) adapter.parameterValue (0);
- reset();
- render();
- require (stateOk && probe.blocks > 0 && probe.resets > 0 && probe.captures > 0 && probe.restores > 0,
- "mock did not exercise processing, resets and hosted state access");
- require (probe.parameterReads > 0 && probe.parameterWrites > 0,
- "mock did not exercise concurrent hosted parameter access");
- require (! probe.overlap, "hosted processing/reset/parameters overlapped a state restore or the export reset");
- require (! adapter.hasCrashed(), "mock hosted adapter crashed");
- };
- try
- {
- for (const auto fixed : { 0, 64 })
- {
- std::array<float, 128> left {}, right {};
- auto instrument = std::make_unique<Probe>();
- auto* instrumentProbe = instrument.get();
- lynx::PluginInstrument voice (std::move (instrument), 128, fixed);
- exercise (voice, *instrumentProbe, [&] { voice.render (left.data(), right.data(), 128, 1.0f, 1.0f); }, [&] { voice.panic(); });
- auto effect = std::make_unique<Probe>();
- auto* effectProbe = effect.get();
- lynx::PluginEffect fx (std::move (effect), 128, fixed);
- exercise (fx, *effectProbe, [&] { fx.process (left.data(), right.data(), 128, {}, 120.0); }, [&] { fx.transportReset(); });
- }
- return "OK (" + juce::String (checks) + " checks)";
- }
- catch (const std::exception& e) { return "ERROR " + juce::String::fromUTF8 (e.what()); }
- }();
- const auto hostedStateContentionResult = lynx::pluginStateContentionSelfTest();
- const auto modulators190oxResult = lynx::modulators190oxSelfTest(); // round 190ox: modulators stage 2
- const auto generatorSmartResult = lynx::generatorSmartDisableSelfTest(); // (round 190ok, D2)
- // recording from the PC keyboard: a one-beat note lands in the pattern, in a single undo step
- // (Blend on: this checks that the take joins the pattern's notes; a new install starts with Blend off)
- const auto notesBefore = offline.getSong().patterns[0].notes.size();
- {
- auto o = offline.getRecordOptions();
- o.mode = lynx::RecordMode::overdub;
- offline.setRecordOptions (o);
- }
- offline.setRecording (true);
- offline.play();
- offline.getTransport().positionTicks.store (960.0);
- offline.sendLiveNote (2, 72, 0.9f, true, true);
- offline.getTransport().positionTicks.store (1920.0);
- offline.sendLiveNote (2, 72, 0.0f, false, true);
- offline.setRecording (false);
- offline.stop();
- const auto& recorded = offline.getSong().patterns[0].notes;
- const auto recordOk = recorded.size() == notesBefore + 1
- && std::any_of (recorded.begin(), recorded.end(), [] (const lynx::Note& n) {
- return n.key == 72 && n.channel == 2 && n.length == 960 && n.start >= 960 && n.start < 3840;
- });
- offline.undo();
- const auto recordUndoOk = offline.getSong().patterns[0].notes.size() == notesBefore;
- // FL's Tools › Cancel recording (round 187a): the pass's notes go, an edit made before it stays, recording turns
- // off and playback goes on; nothing to redo
- bool cancelRecordOk = false;
- {
- offline.editSong ([] (lynx::Song& s) { s.bpm = 123.0; });
- const auto notesThen = offline.getSong().patterns[0].notes.size();
- offline.setRecording (true);
- offline.play();
- offline.getTransport().positionTicks.store (960.0);
- offline.sendLiveNote (2, 74, 0.9f, true, true);
- offline.getTransport().positionTicks.store (1920.0);
- offline.sendLiveNote (2, 74, 0.0f, false, true);
- offline.sendLiveNote (2, 76, 0.9f, true, true); // (still held when the pass is cancelled)
- const auto cancelled = offline.cancelRecording();
- cancelRecordOk = cancelled && ! offline.isRecording() && offline.getTransport().playing.load()
- && offline.getSong().patterns[0].notes.size() == notesThen && offline.getSong().bpm == 123.0 && ! offline.canRedo()
- && ! offline.cancelRecording(); // (not recording: nothing to cancel)
- offline.sendLiveNote (2, 76, 0.0f, false, false);
- offline.stop();
- }
- // MIDI: exporting the pattern and importing it back gives the same notes
- bool midiOk = false;
- {
- auto source = lynx::Song::makeDefault();
- source.patterns[0].notes.push_back ({ 1000, 480, 4, 67, 0.5f });
- source.patterns[0].sortNotes();
- const auto midiFile = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-selftest.mid");
- juce::String midiError;
- const auto saved = lynx::MidiFileIo::savePattern (source, 0, midiFile, midiError);
- const auto song = saved ? lynx::MidiFileIo::loadSong (midiFile, midiError) : std::nullopt;
- midiFile.deleteFile();
- if (song && song->patterns.size() == 1 && song->patterns[0].notes.size() == source.patterns[0].notes.size()
- && std::abs (song->bpm - source.bpm) < 0.01)
- {
- midiOk = true;
- const auto& a = source.patterns[0].notes;
- const auto& b = song->patterns[0].notes;
- for (std::size_t i = 0; i < a.size(); ++i)
- midiOk = midiOk && a[i].start == b[i].start && a[i].key == b[i].key && a[i].length == b[i].length;
- }
- }
- // project package (REA round 118): a project with a sample exported as .zip, extracted and opened again,
- // finds its sample inside the extracted folder
- bool packageOk = false;
- {
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-selftest-package");
- dir.deleteRecursively();
- dir.getChildFile ("src").createDirectory();
- const auto wav = dir.getChildFile ("src/hit.wav");
- {
- juce::WavAudioFormat format;
- juce::AudioBuffer<float> hit (1, 480);
- for (int i = 0; i < 480; ++i)
- hit.setSample (0, i, 0.5f * std::sin (0.1f * (float) i));
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (hit, 0, 480);
- }
- }
- auto source = lynx::Song::makeDefault();
- lynx::ChannelDef c;
- c.name = "Hit";
- c.instrument = lynx::InstrumentKind::sampler;
- c.samplePath = wav.getFullPathName().toStdString();
- source.channels.push_back (c);
- lynx::ProjectPackage::Result packed;
- juce::String packageError;
- const auto zip = dir.getChildFile ("Beat.zip");
- if (wav.existsAsFile() && lynx::ProjectPackage::exportZip (source, "Beat", zip, packed, packageError) && packed.files == 1)
- {
- const auto project = lynx::ProjectPackage::extractZip (zip, dir.getChildFile ("out"), packageError);
- const auto song = project.existsAsFile() ? lynx::ProjectFile::load (project, packageError) : std::nullopt;
- if (song && ! song->channels.empty())
- {
- const juce::File back (juce::String::fromUTF8 (song->channels.back().samplePath.c_str()));
- packageOk = back.existsAsFile() && back.isAChildOf (project.getParentDirectory()) && back.getSize() == wav.getSize();
- }
- }
- dir.deleteRecursively();
- }
- // D#92, round 180a: a non-ASCII folder and a dotted name save and load back; an unwritable place says so, and a
- // relative path resolves as the start-up argument does
- bool projectSaveOk = false;
- {
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-selftest-save180a");
- dir.deleteRecursively();
- const auto folder = dir.getChildFile (juce::String::fromUTF8 ("M\xc3\xbasica nova"));
- folder.createDirectory();
- const auto named = lynx::ProjectFile::withProjectExtension (folder.getChildFile (juce::String::fromUTF8 ("Can\xc3\xa7\xc3\xa3o.v2")));
- auto song = lynx::Song::makeDefault();
- lynx::Note note;
- note.length = 240;
- note.key = 64;
- song.patterns[0].notes.push_back (note);
- juce::String error, blockedError;
- const auto again = lynx::ProjectFile::save (song, named, error) ? lynx::ProjectFile::load (named, error) : std::nullopt;
- const auto blocker = dir.getChildFile ("a file");
- blocker.replaceWithText ("x");
- const auto cwd = juce::File::getCurrentWorkingDirectory();
- folder.setAsCurrentWorkingDirectory();
- const auto relative = juce::File::getCurrentWorkingDirectory().getChildFile (named.getFileName());
- cwd.setAsCurrentWorkingDirectory();
- projectSaveOk = named.getFileName().endsWith (".v2.lynx") && again && again->patterns[0].notes.size() == song.patterns[0].notes.size()
- && relative == named && ! lynx::ProjectFile::save (song, blocker.getChildFile ("x.lynx"), blockedError)
- && blockedError.isNotEmpty() && lynx::ProjectFile::withProjectExtension (named) == named;
- dir.deleteRecursively();
- }
- // Online Sessions (round 168a): a project sent as a .lynxpack (one sample used twice is stored once, the uids
- // survive), a stand-in rendered through an ExportJob, the guest's part sent back and merged by the host
- juce::String sessionResult = "ERROR";
- {
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-selftest-session");
- dir.deleteRecursively();
- dir.getChildFile ("src").createDirectory();
- const auto wav = dir.getChildFile ("src/hit.wav");
- {
- juce::WavAudioFormat format;
- juce::AudioBuffer<float> hit (1, 4800);
- for (int i = 0; i < 4800; ++i)
- hit.setSample (0, i, 0.5f * std::sin (0.05f * (float) i) * (1.0f - (float) i / 4800.0f));
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (hit, 0, 4800);
- }
- }
- auto host = lynx::Song::makeDefault();
- host.mode = lynx::PlayMode::song;
- const auto copyOfWav = dir.getChildFile ("src/hit copy.wav"); // the same bytes under another name: stored once
- wav.copyFileTo (copyOfWav);
- for (const auto& [name, file] : { std::pair<const char*, juce::File> { "Hit", wav }, { "Hit 2", copyOfWav } })
- {
- lynx::ChannelDef c;
- c.name = name;
- c.instrument = lynx::InstrumentKind::sampler;
- c.samplePath = file.getFullPathName().toStdString();
- host.channels.push_back (c);
- }
- const auto hitChannel = (int) host.channels.size() - 2;
- lynx::Note hitNote;
- hitNote.channel = hitChannel;
- hitNote.length = 480;
- host.patterns[0].notes.push_back (hitNote);
- host.playlist.push_back ({ 0, 0, 0, host.patterns[0].effectiveLength (host.meter()), 0 });
- lynx::uids::normalize (host);
- const auto* guest = lynx::parts::invite (host, "Host", "Ana", 0xFF3D9BE9, false);
- juce::String e;
- std::vector<lynx::sessionpack::Rendered> rendered;
- // (a sampler stands in for a plugin channel here: render() renders whatever it is given)
- const std::vector<lynx::sessionpack::RenderItem> items { { false, hitChannel, false, "Hit", "Test" } };
- const auto renderedOk = guest != nullptr && lynx::sessionpack::render (host, items, 44100.0, dir.getChildFile ("stems"), "Host", rendered, {}, e)
- && rendered.size() == 1 && rendered[0].standIns.size() == 2
- && juce::File (juce::String::fromUTF8 (rendered[0].standIns[0].path.c_str())).getSize() > 1000;
- if (renderedOk)
- lynx::sessionpack::apply (host, rendered);
- lynx::sessionpack::Manifest m;
- m.projectName = "Selftest";
- m.from = *host.session.find (lynx::session::hostTag);
- m.to = *host.session.find (2);
- lynx::sessionpack::WriteResult written;
- const auto pack = dir.getChildFile (juce::String ("Selftest") + lynx::sessionpack::extension);
- const auto packOk = renderedOk && lynx::sessionpack::write (lynx::parts::guestCopy (host, 2), m, offline.getPluginHost(), pack, written, e)
- && written.media == 3 && written.duplicates == 1; // the sample once (used twice), the stand-in pair
- auto opened = packOk ? lynx::sessionpack::open (pack, dir.getChildFile ("received"), e) : std::nullopt;
- bool openOk = false, mergeOk = false;
- if (opened && opened->corrupt.isEmpty())
- {
- const auto& g = opened->song;
- const juce::File sample (juce::String::fromUTF8 (g.channels[(std::size_t) hitChannel].samplePath.c_str()));
- openOk = g.session.me == 2 && g.projectId == host.projectId && g.channels[(std::size_t) hitChannel].uid == host.channels[(std::size_t) hitChannel].uid
- && sample.existsAsFile() && sample.isAChildOf (opened->folder) && g.channels[(std::size_t) hitChannel].standIns.size() == 2
- && juce::File (juce::String::fromUTF8 (g.channels[(std::size_t) hitChannel].standIns[1].path.c_str())).existsAsFile();
- // the guest adds a channel and a pattern of his own, sends his part back
- auto copy = g;
- lynx::ChannelDef mine;
- mine.name = "Ana's hit";
- mine.instrument = lynx::InstrumentKind::sampler;
- mine.samplePath = sample.getFullPathName().toStdString();
- copy.channels.push_back (mine);
- lynx::Pattern p;
- p.name = "Ana";
- lynx::Note note;
- note.channel = (int) copy.channels.size() - 1;
- note.length = 240;
- note.key = 64;
- p.notes.push_back (note);
- copy.patterns.push_back (p);
- lynx::uids::normalize (copy);
- // its uids survive a save and a load
- const auto saved = dir.getChildFile ("guest.lynx");
- auto reloaded = lynx::ProjectFile::save (copy, saved, e) ? lynx::ProjectFile::load (saved, e) : std::nullopt;
- lynx::sessionpack::Manifest back;
- back.part = true;
- back.from = *copy.session.self();
- const auto partFile = dir.getChildFile (juce::String ("Ana part") + lynx::sessionpack::extension);
- lynx::sessionpack::WriteResult partWritten;
- auto part = reloaded && reloaded->channels.back().uid == copy.channels.back().uid && lynx::uids::tagOf (reloaded->channels.back().uid) == 2
- ? lynx::sessionpack::write (lynx::parts::extract (*reloaded, 2), back, offline.getPluginHost(), partFile, partWritten, e)
- : false;
- auto partOpened = part ? lynx::sessionpack::open (partFile, dir.getChildFile ("parts"), e) : std::nullopt;
- if (partOpened && partOpened->manifest.part && lynx::sessionpack::adoptMedia (partOpened->song, dir.getChildFile ("Session media/Ana"), e))
- {
- const auto report = lynx::parts::merge (host, partOpened->song, 2);
- const auto& added = host.channels.back();
- mergeOk = report.ok && report.channels >= 1 && added.name == "Ana's hit" && lynx::uids::tagOf (added.uid) == 2
- && juce::File (juce::String::fromUTF8 (added.samplePath.c_str())).isAChildOf (dir.getChildFile ("Session media/Ana"))
- && host.channels[(std::size_t) hitChannel].name == "Hit";
- }
- }
- // a crafted package whose project points at a file elsewhere on this computer: opening it must not
- // reach that file, or merging would copy it into the project and the next package would send it on
- if (mergeOk)
- {
- const auto secret = dir.getChildFile ("secret.wav");
- wav.copyFileTo (secret);
- auto evil = lynx::Song::makeDefault();
- lynx::ChannelDef c;
- c.instrument = lynx::InstrumentKind::sampler;
- c.samplePath = secret.getFullPathName().toStdString();
- evil.channels.push_back (c);
- lynx::ChannelDef keys; // (FL Keys' zones are read by the engine but are not in the media list)
- keys.instrument = lynx::InstrumentKind::flkeys;
- keys.zones.push_back ({});
- keys.zones.back().path = c.samplePath;
- evil.channels.push_back (keys);
- lynx::ChannelDef patch; // (a Patcher's nodes are not in the media list either)
- patch.instrument = lynx::InstrumentKind::patcher;
- patch.patcher.nodes.resize (2);
- patch.patcher.nodes[0].generator = true;
- patch.patcher.nodes[0].channel = c;
- patch.patcher.nodes[1].effect.samplePath = c.samplePath;
- evil.channels.push_back (patch);
- evil.mixer[1].recordTo = dir.getChildFile ("overwritten.wav").getFullPathName().toStdString();
- const auto evilProject = dir.getChildFile ("evil.lynx");
- lynx::sessionpack::Manifest em;
- em.part = true;
- juce::ZipFile::Builder b;
- const auto json = lynx::sessionpack::manifestToJson (em);
- b.addEntry (new juce::MemoryInputStream (json.toRawUTF8(), json.getNumBytesAsUTF8(), true), 0, "manifest.json", {});
- const auto evilPack = dir.getChildFile (juce::String ("Evil") + lynx::sessionpack::extension);
- bool zipped = false;
- if (lynx::ProjectFile::save (evil, evilProject, e))
- {
- b.addFile (evilProject, 0, "project.lynx");
- juce::FileOutputStream out (evilPack);
- zipped = out.openedOk() && b.writeToStream (out, nullptr);
- }
- auto evilOpened = zipped ? lynx::sessionpack::open (evilPack, dir.getChildFile ("evil"), e) : std::nullopt;
- const auto media = dir.getChildFile ("Session media/Evil");
- mergeOk = evilOpened && lynx::sessionpack::adoptMedia (evilOpened->song, media, e)
- && std::none_of (evilOpened->song.channels.begin(), evilOpened->song.channels.end(), [&] (const lynx::ChannelDef& ch) {
- return juce::File (juce::String::fromUTF8 (ch.samplePath.c_str())) == secret
- || std::any_of (ch.zones.begin(), ch.zones.end(), [&] (const lynx::SampleZone& z) { return juce::File (juce::String::fromUTF8 (z.path.c_str())) == secret; });
- })
- && evilOpened->song.channels.back().patcher.nodes.size() == 2
- && juce::File (juce::String::fromUTF8 (evilOpened->song.channels.back().patcher.nodes[0].channel.samplePath.c_str())) != secret
- && juce::File (juce::String::fromUTF8 (evilOpened->song.channels.back().patcher.nodes[1].effect.samplePath.c_str())) != secret
- && evilOpened->song.mixer[1].recordTo.empty()
- && media.findChildFiles (juce::File::findFiles, true).isEmpty();
- if (! mergeOk && e.isEmpty())
- e = "a received package reached a file outside it";
- }
- // ... nor through its own folder: "..", Windows' dotted names (". ." climbs like ".." there), and a manifest
- // media entry outside the package (it must not even be read: "/dev/zero" would never end)
- if (mergeOk)
- {
- const auto secret = dir.getChildFile ("secret.wav");
- const auto folder = dir.getChildFile ("evil2").getChildFile ("Evil2"); // (where open() will unpack it)
- const auto climb = folder.getFullPathName() + "/media/../../../secret.wav";
- const auto dotted = folder.getFullPathName() + "/. ./.. ./secret.wav";
- auto evil = lynx::Song::makeDefault();
- for (const auto& path : { climb, dotted })
- {
- lynx::ChannelDef c;
- c.instrument = lynx::InstrumentKind::sampler;
- c.samplePath = path.toStdString();
- evil.channels.push_back (c);
- }
- juce::MemoryBlock secretBytes;
- secret.loadFileAsData (secretBytes);
- lynx::sessionpack::Manifest em;
- em.part = true;
- em.media.push_back ({ "sha256-" + juce::String (lynx::sha256Hex ((const std::uint8_t*) secretBytes.getData(), secretBytes.getSize())),
- "secret.wav", (juce::int64) secretBytes.getSize(), "../../secret.wav" });
- const auto evilProject = dir.getChildFile ("evil2.lynx");
- juce::ZipFile::Builder b;
- const auto json = lynx::sessionpack::manifestToJson (em);
- b.addEntry (new juce::MemoryInputStream (json.toRawUTF8(), json.getNumBytesAsUTF8(), true), 0, "manifest.json", {});
- const auto evilPack = dir.getChildFile (juce::String ("Evil2") + lynx::sessionpack::extension);
- bool zipped = false;
- if (lynx::ProjectFile::save (evil, evilProject, e))
- {
- b.addFile (evilProject, 0, "project.lynx");
- juce::FileOutputStream out (evilPack);
- zipped = out.openedOk() && b.writeToStream (out, nullptr);
- }
- auto evilOpened = zipped ? lynx::sessionpack::open (evilPack, dir.getChildFile ("evil2"), e) : std::nullopt;
- const auto media = dir.getChildFile ("Session media/Evil2");
- mergeOk = evilOpened && evilOpened->folder == folder && evilOpened->corrupt.contains ("secret.wav")
- && lynx::sessionpack::adoptMedia (evilOpened->song, media, e) && evilOpened->song.channels.size() >= 2
- && std::none_of (evilOpened->song.channels.begin(), evilOpened->song.channels.end(), [&] (const lynx::ChannelDef& ch) {
- const auto p = juce::String::fromUTF8 (ch.samplePath.c_str());
- return p == climb || p == dotted || (juce::File::isAbsolutePath (p) && juce::File (p) == secret);
- })
- && media.findChildFiles (juce::File::findFiles, true).isEmpty();
- if (! mergeOk && e.isEmpty())
- e = "a received package climbed out of its folder";
- }
- if (! packOk && e.isEmpty())
- e = "media " + juce::String (written.media) + ", duplicates " + juce::String (written.duplicates) + ", missing "
- + written.missing.joinIntoString (";");
- sessionResult = mergeOk ? juce::String ("OK")
- : "ERROR (" + juce::String (renderedOk ? packOk ? openOk ? "merge" : "open" : "pack" : "render") + (e.isEmpty() ? "" : ": " + e) + ")";
- dir.deleteRecursively();
- }
- // WavPack: a .wv from the FL packs (if installed) opens through the sample loader
- juce::String wavpack = "NO_FL";
- {
- const auto roots = lynx::findFlStudioRoots();
- const auto packs = juce::File (juce::String::fromUTF8 (roots.data.c_str())).getChildFile ("Patches/Packs");
- const auto found = packs.isDirectory() ? packs.findChildFiles (juce::File::findFiles, true, "*.wv") : juce::Array<juce::File> {};
- if (! found.isEmpty())
- {
- lynx::SampleLibrary library;
- const auto sample = library.load (found.getFirst().getFullPathName());
- float peakWv = 0.0f;
- if (sample != nullptr)
- for (std::size_t i = 0; i < sample->frames(); ++i)
- peakWv = std::max (peakWv, std::abs (sample->leftData()[i]));
- wavpack = sample != nullptr && sample->frames() > 0 && peakWv > 1e-4f ? "OK" : "ERROR";
- }
- }
- // every built-in effect's editor and engine with extreme settings (round 111): a crash or NaN output fails here
- const auto effectsOk = runEffectFuzz (4, {}); // (no mouse drags: nothing may open on screen)
- // FL's Patcher (round 141): a mixer slot and a generator channel with their graphs survive save / load, and the
- // generator one plays through the rack
- bool patcherOk = false;
- {
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (4);
- auto slot = lynx::makeEffectSlot (lynx::EffectKind::patcher);
- lynx::PatchNode reverb, gain;
- reverb.effect = lynx::makeEffectSlot (lynx::EffectKind::utility); // (exact defaults: params are saved to 4 decimals)
- reverb.label = "Room";
- reverb.x = 120.5f;
- reverb.y = 40.0f;
- gain.effect = lynx::makeEffectSlot (lynx::EffectKind::utility);
- gain.effect.enabled = false;
- slot.patcher.nodes = { reverb, gain };
- lynx::PatchWire a, b, c, control;
- a.to = 0;
- b.from = 0, b.to = 1, b.gain = 0.5f;
- c.from = 1;
- control.kind = lynx::PatchWire::Kind::control, control.from = 0, control.to = 1, control.toPort = 0, control.curve = { 0.0f, 0.25f, 1.0f };
- slot.patcher.wires = { a, b, c, control };
- slot.patcher.outputTracks = { 3 };
- song.mixer[1].effects = { slot };
- lynx::ChannelDef ch;
- ch.name = "Patched";
- ch.instrument = lynx::InstrumentKind::patcher;
- lynx::PatchNode synth;
- synth.generator = true;
- synth.channel.instrument = lynx::InstrumentKind::synth;
- synth.channel.name = "Synth";
- ch.patcher.nodes = { synth };
- lynx::PatchWire notes, out;
- notes.kind = lynx::PatchWire::Kind::midi, notes.to = 0;
- out.from = 0;
- ch.patcher.wires = { notes, out };
- // round 162: the I/O nodes' MIDI pins and a MIDI Out node between them
- lynx::PatchNode midiOutNode;
- midiOutNode.generator = true;
- midiOutNode.channel.instrument = lynx::InstrumentKind::midiOut;
- lynx::midictl::writeMidiOut (midiOutNode.channel.pluginState, { 4, 0, 0, -1, -1 });
- ch.patcher.nodes.push_back (midiOutNode);
- lynx::PatchWire portIn, portOut;
- portIn.kind = portOut.kind = lynx::PatchWire::Kind::midi;
- portIn.fromPort = lynx::patchMidiPortPin (7), portIn.to = 1;
- portOut.from = 1, portOut.to = lynx::patchToHost, portOut.toPort = 9;
- ch.patcher.wires.push_back (portIn);
- ch.patcher.wires.push_back (portOut);
- ch.patcher.fromMidiPorts = { 2, 7 };
- ch.patcher.toMidiPorts = { 9, 11 };
- ch.patcher.fromNotesHidden = true;
- song.channels.push_back (ch);
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- patcherOk = back && back->mixer.size() >= 2 && back->mixer[1].effects.size() == 1
- && back->mixer[1].effects[0].kind == lynx::EffectKind::patcher && back->mixer[1].effects[0].patcher == slot.patcher
- && back->channels.back().instrument == lynx::InstrumentKind::patcher && back->channels.back().patcher.nodes.size() == 2
- && back->channels.back().patcher.fromMidiPorts == ch.patcher.fromMidiPorts
- && back->channels.back().patcher.toMidiPorts == ch.patcher.toMidiPorts && back->channels.back().patcher.fromNotesHidden
- && back->channels.back().patcher.nodes[1].channel.pluginState == midiOutNode.channel.pluginState
- && back->channels.back().patcher.nodes[0].generator
- && back->channels.back().patcher.nodes[0].channel.instrument == lynx::InstrumentKind::synth
- && back->channels.back().patcher.wires == ch.patcher.wires;
- }
- // Round 183c, Racks: (1) a plain Patcher's stored JSON loads and saves back byte for byte and never holds a
- // "rack" key (FL's Patcher is untouched); (2) an Audio Effect Rack slot and an Instrument Rack channel survive save /
- // load with their chains, zones, macros, mappings, variations and compiled cables
- juce::String rackResult = "OK";
- {
- lynx::MixerTrack plain;
- plain.name = "Plain Patcher";
- auto fx = lynx::makeEffectSlot (lynx::EffectKind::patcher);
- lynx::PatchNode a, b;
- a.effect = lynx::makeEffectSlot (lynx::EffectKind::utility);
- a.label = "A";
- a.x = 120.5f;
- b.effect = lynx::makeEffectSlot (lynx::EffectKind::utility);
- b.effect.enabled = false;
- fx.patcher.nodes = { a, b };
- lynx::PatchWire w1, w2, w3, wc;
- w1.to = 0;
- w2.from = 0, w2.to = 1, w2.gain = 0.5f;
- w3.from = 1;
- wc.kind = lynx::PatchWire::Kind::control, wc.from = 0, wc.to = 1, wc.toPort = 0, wc.curve = { 0.0f, 0.25f, 1.0f };
- fx.patcher.wires = { w1, w2, w3, wc };
- lynx::SurfaceControl knob;
- knob.name = "Drive";
- knob.value = 0.25f;
- fx.patcher.surface = { knob };
- lynx::PatchParam pp;
- pp.node = 0, pp.param = 1, pp.name = "Balance";
- fx.patcher.published = { pp };
- plain.effects = { fx };
- const auto first = juce::JSON::toString (lynx::ProjectFile::mixerTrackToVar (plain), true);
- const auto again = juce::JSON::toString (lynx::ProjectFile::mixerTrackToVar (lynx::ProjectFile::mixerTrackFromVar (juce::JSON::parse (first))), true);
- if (first != again || first.contains ("\"rack\"") || first.contains ("rackMixer"))
- rackResult = "ERROR plain Patcher changed";
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (3);
- auto rackSlot = lynx::rack::makeRackSlot (lynx::RackDoc::Kind::audioEffect);
- auto& doc = rackSlot.patcher;
- lynx::PatchNode u;
- u.effect = lynx::makeEffectSlot (lynx::EffectKind::utility);
- const auto n0 = lynx::rack::addDevice (doc, 0, u);
- lynx::rack::addChain (doc, "Wet");
- lynx::rack::addDevice (doc, 1, u);
- doc.rack[0].chains[1].select = { 10, 90, 30, 70 };
- lynx::rack::setChainPan (doc, 1, -0.5f);
- lynx::RackMapping m;
- m.node = n0, m.param = 0, m.min = 0.2f, m.max = 0.9f;
- lynx::rack::map (doc, 0, m);
- lynx::RackMapping v;
- v.target = lynx::RackMapping::Target::chainVolume, v.chain = 1, v.min = 0.0f, v.max = lynx::rack::unityVolume;
- lynx::rack::map (doc, 1, v);
- lynx::rack::setMacro (doc, 0, 64.0f);
- lynx::rack::storeVariation (doc);
- lynx::rack::setMacro (doc, 0, 100.0f);
- lynx::rack::storeVariation (doc);
- doc.rack[0].morphOn = true, doc.rack[0].morphA = 0, doc.rack[0].morphB = 1;
- lynx::rack::setMorph (doc, 0.5f);
- lynx::rack::compile (doc);
- song.mixer[1].effects = { rackSlot };
- lynx::ChannelDef inst;
- inst.name = "Instrument Rack";
- inst.instrument = lynx::InstrumentKind::patcher;
- inst.patcher = lynx::rack::makeRack (lynx::RackDoc::Kind::instrument);
- lynx::PatchNode synth;
- synth.generator = true;
- synth.channel.instrument = lynx::InstrumentKind::synth;
- synth.channel.name = "Synth";
- lynx::rack::addDevice (inst.patcher, 0, synth);
- inst.patcher.rack[0].chains[0].velocity = { 1, 127, 64, 127 };
- lynx::rack::compile (inst.patcher);
- song.channels.push_back (inst);
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, error);
- // (the devices' parameters are stored to 4 decimals: the documents are compared as stored, the rack exactly)
- const auto loaded = back && back->mixer.size() >= 2 && back->mixer[1].effects.size() == 1;
- const auto& got = loaded ? back->mixer[1].effects[0].patcher : doc;
- if (! loaded)
- rackResult = "ERROR rack slot not loaded";
- else if (got.rack != doc.rack)
- rackResult = "ERROR rack model";
- else if (got.wires != doc.wires)
- rackResult = "ERROR rack cables";
- else if (got.nodes.size() != doc.nodes.size())
- rackResult = "ERROR rack devices";
- else if (back->channels.back().patcher.rack != inst.patcher.rack || back->channels.back().patcher.wires != inst.patcher.wires
- || back->channels.back().patcher.zones != inst.patcher.zones || back->channels.back().patcher.nodes.size() != inst.patcher.nodes.size())
- rackResult = "ERROR instrument rack";
- // the slot's insert as stored, once more: the same text (the stored form is stable)
- else if (const auto once = juce::JSON::toString (lynx::ProjectFile::mixerTrackToVar (back->mixer[1]), true);
- once != juce::JSON::toString (lynx::ProjectFile::mixerTrackToVar (lynx::ProjectFile::mixerTrackFromVar (juce::JSON::parse (once))), true))
- rackResult = "ERROR rack stored form not stable";
- }
- // Round 190ec, Drum Rack: pads (Receive / Play / Choke / Audio To / sends), return chains and the views survive save /
- // load with their compiled zones and cables
- if (rackResult == "OK")
- {
- lynx::Song song;
- song.mixer.resize (2);
- lynx::ChannelDef ch;
- ch.name = "Drums";
- ch.instrument = lynx::InstrumentKind::patcher;
- ch.patcher = lynx::rack::makeDrumRack();
- lynx::PatchNode synth;
- synth.generator = true;
- synth.channel.instrument = lynx::InstrumentKind::synth;
- const auto kick = lynx::rack::addPad (ch.patcher, 36, "Kick", synth);
- const auto hat = lynx::rack::addPad (ch.patcher, 42, "Hat", synth);
- lynx::rack::addPad (ch.patcher, -1, "Every note");
- lynx::rack::addReturn (ch.patcher, "A Verb");
- lynx::rack::setPlay (ch.patcher, kick, 64);
- lynx::rack::setChoke (ch.patcher, hat, 2);
- lynx::rack::setSend (ch.patcher, hat, 0, 0.25f, false);
- lynx::rack::setAudioTo (ch.patcher, kick, 0);
- lynx::rack::rackOf (ch.patcher)->showIO = true;
- lynx::rack::rackOf (ch.patcher)->padScroll = 17;
- song.channels.push_back (ch);
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- const auto& got = back && ! back->channels.empty() ? back->channels.back().patcher : lynx::PatcherDoc {};
- if (! back || ! lynx::rack::isDrumRack (got))
- rackResult = "ERROR drum rack not loaded";
- else if (got.rack != ch.patcher.rack)
- rackResult = "ERROR drum rack model";
- else if (got.zones != ch.patcher.zones || got.wires != ch.patcher.wires)
- rackResult = "ERROR drum rack cables";
- }
- // FL engines in a native project (round 142, issue #5): every engine this PC can make survives save / load and
- // the instruments play through the rack
- juce::String nativesResult = "OK";
- int nativesMade = 0, nativesSilent = 0;
- {
- auto song = lynx::Song::makeDefault();
- song.channels.clear();
- song.patterns[0].notes.clear();
- song.mixer.resize (3);
- const auto& fl = lynx::flStudioAccess();
- for (const auto& e : lynx::natives::instrumentEngines())
- if (lynx::natives::available (e, fl))
- if (auto c = lynx::natives::makeChannel (e.kind, fl))
- {
- c->mixerTrack = 1;
- song.channels.push_back (*c);
- }
- for (const auto& e : lynx::natives::effectEngines())
- if (auto fx = lynx::natives::makeSlot (e.kind, fl))
- song.mixer[2].effects.push_back (*fx);
- nativesMade = (int) (song.channels.size() + song.mixer[2].effects.size());
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- auto same = back && back->channels.size() == song.channels.size() && back->mixer.size() >= 3
- && back->mixer[2].effects.size() == song.mixer[2].effects.size();
- for (std::size_t i = 0; same && i < song.channels.size(); ++i)
- {
- const auto& a = song.channels[i];
- const auto& b = back->channels[i];
- same = a.instrument == b.instrument && a.pluginState == b.pluginState && a.samplePath == b.samplePath && a.zones.size() == b.zones.size()
- && a.modelParams.size() == b.modelParams.size();
- if (! same)
- nativesResult = "ERROR channel " + juce::String::fromUTF8 (a.name.c_str());
- }
- for (std::size_t i = 0; same && i < song.mixer[2].effects.size(); ++i)
- {
- const auto& a = song.mixer[2].effects[i];
- const auto& b = back->mixer[2].effects[i];
- same = a.kind == b.kind && a.state == b.state;
- for (std::size_t p = 0; same && p < a.params.size(); ++p)
- same = std::abs (a.params[p] - b.params[p]) < 1.0e-3f;
- if (! same)
- nativesResult = juce::String ("ERROR effect ") + lynx::effectInfo (a.kind).name;
- }
- if (! back)
- nativesResult = "ERROR " + error;
- // each instrument plays a note alone. The Granulizer and Wave Traveller play the channel's sample, and a new
- // one has none (a PC without FL Studio, macOS / Linux: FL's presets are not there either), so they get a
- // generated one: a second of a 220 Hz tone (round 167m, PR #19: Wave Traveller was "SILENT 1" on macOS)
- const auto toneWav = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-selftest-natives.wav");
- {
- juce::WavAudioFormat format;
- juce::AudioBuffer<float> tone (1, 48000);
- for (int i = 0; i < 48000; ++i)
- tone.setSample (0, i, 0.5f * std::sin (juce::MathConstants<float>::twoPi * 220.0f * (float) i / 48000.0f));
- toneWav.deleteFile();
- std::unique_ptr<juce::OutputStream> out (toneWav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (tone, 0, 48000);
- }
- }
- juce::StringArray silentNames;
- for (std::size_t i = 0; same && i < song.channels.size(); ++i)
- {
- auto one = song;
- one.channels = { song.channels[i] };
- one.channels[0].mixerTrack = 1;
- const auto kind = song.channels[i].instrument;
- // A new Fruity Slicer has no sample and no slices, and FL's is silent then too (round 180c), so it is
- // not one of the engines that must sound here (Linux / macOS CI: "SILENT 1 [Fruity Slicer]", 0.1.25)
- if (kind == lynx::InstrumentKind::fruityslicer && one.channels[0].samplePath.empty())
- continue;
- if (kind == lynx::InstrumentKind::slicex && one.channels[0].samplePath.empty()) // (the same: no sample on its decks yet)
- continue;
- if (kind == lynx::InstrumentKind::directwave && one.channels[0].zones.empty()) // (FL's new DirectWave: no zones yet, round 190hz)
- continue;
- if ((kind == lynx::InstrumentKind::granulizer || kind == lynx::InstrumentKind::wavetraveller) && one.channels[0].samplePath.empty())
- one.channels[0].samplePath = toneWav.getFullPathName().toStdString();
- one.mixer[2].effects.clear();
- // Drumaxx plays pad 1's key: FL's default kit has a pad at 48, LYNX's own bank kits (a PC without FL,
- // macOS / Linux; round 168p) start at 36 (round 169d: "SILENT 1 [Drumaxx]" on the Linux / macOS CI)
- auto key = 60;
- if (kind == lynx::InstrumentKind::drumaxx)
- {
- const auto padKey = lynx::drumaxxParam (one.channels[0].pluginState, 4);
- key = std::isfinite (padKey) && padKey >= 0.0f && padKey <= 127.0f ? (int) padKey : 48;
- }
- // FPC plays its pads' keys; a kit without a sample (FL's "Empty" kit: no FL Studio on this PC) is silent
- // in FL too (round 190q)
- if (kind == lynx::InstrumentKind::fpc)
- {
- const auto pads = lynx::fpcChannelPads (one.channels[0]);
- if (pads.empty())
- continue;
- key = pads.front().key;
- }
- one.patterns[0].notes = { { 0, 1920, 0, key, 0.8f } };
- lynx::AudioEngine player (false);
- player.setSong (std::move (one));
- player.dispatchPendingMessages();
- if (! (player.renderOffline (1.0, 48000.0) > 1.0e-4f))
- {
- ++nativesSilent;
- silentNames.add (juce::String::fromUTF8 (song.channels[i].name.c_str()));
- }
- }
- toneWav.deleteFile();
- if (nativesSilent > 0 && nativesResult == "OK")
- nativesResult = "SILENT " + juce::String (nativesSilent) + " [" + silentNames.joinIntoString (", ") + "]";
- }
- const auto nativesOk = nativesResult == "OK";
- // The metronome as FL 2026 plays it (round 165z-a2): FL's five sounds from its install, the downbeat at
- // 0.9404 × the Tick two semitones up, into the Master ("---") by default; insert 2 as its track plays it through
- // insert 2 (muted: silent); never in an export
- juce::String metronomeResult = "OK";
- int metronomeFlSounds = 0;
- float metronomeMaster = 0.0f;
- {
- const auto& flData = lynx::flStudioAccess().roots.data;
- const auto sounds = lynx::Metronome::loadSounds (flData.empty() ? juce::File() : lynx::platform::localFile (flData));
- for (const auto& s : sounds)
- metronomeFlSounds += s.fromFl ? 1 : 0;
- auto renderClick = [] (int track, bool muteInsert, bool include) {
- auto song = lynx::Song::makeDefault();
- song.channels.clear();
- song.playlist.clear();
- for (auto& p : song.patterns)
- p.notes.clear();
- song.mixer[0].effects.clear(); // (the default Master limiter)
- song.mixer[2].muted = muteInsert;
- lynx::AudioEngine player (false);
- player.setSong (std::move (song));
- player.dispatchPendingMessages();
- auto& t = player.getTransport();
- t.metronome = true;
- t.metronomeSound = 1; // Tick
- t.metronomeTrack = track;
- lynx::AudioEngine::RenderOptions o;
- o.seconds = 0.25;
- o.sampleRate = 44100.0;
- o.pluginWarmUp = false;
- o.includeMetronome = include;
- return player.renderOffline (o);
- };
- metronomeMaster = renderClick (0, false, true);
- const auto insert = renderClick (2, false, true);
- const auto muted = renderClick (2, true, true);
- const auto exported = renderClick (0, false, false);
- // FL's Tick peaks at 1.0: its downbeat at most 0.9404 (the interpolation may land between peaks)
- const auto expectHigh = metronomeFlSounds == lynx::metronome::soundCount ? lynx::metronome::downbeatGain + 1.0e-3f : 1.0f;
- if (! (metronomeMaster > 0.5f && metronomeMaster < expectHigh))
- metronomeResult = "ERROR master " + juce::String (metronomeMaster, 4);
- else if (std::abs (insert - metronomeMaster) > 2.0e-3f)
- metronomeResult = "ERROR insert " + juce::String (insert, 4);
- else if (muted > 1.0e-4f)
- metronomeResult = "ERROR muted insert " + juce::String (muted, 4);
- else if (exported > 1.0e-4f)
- metronomeResult = "ERROR in export " + juce::String (exported, 4);
- }
- const auto metronomeOk = metronomeResult == "OK";
- // Settings › Audio "Driver settings…" with a fake driver panel (issue #13's crash, the panel's buffer kept)
- const auto driverPanel = lynx::AudioEngine::driverPanelSelfTest();
- // issue #134 (round 190c): the output device, its rate and its buffer changed under a playing project, on
- // stand-in devices (a short run; --devicechangetest plays every instrument and effect)
- const auto deviceChange = lynx::AudioEngine::deviceChangeSelfTest (10, false);
- // round 190gh: export parity (B7) and MIDI device hot-plug (B8)
- const auto exportParity = lynx::AudioEngine::exportParitySelfTest();
- // round 190jb: exports with the live plugin instances (Surge XT when it is installed here; otherwise only noted)
- juce::StringArray livePlugins;
- #if JUCE_WINDOWS
- livePlugins.add ("C:\\Program Files\\Common Files\\VST3\\Surge Synth Team\\Surge XT.vst3");
- #elif JUCE_MAC
- livePlugins.add ("/Library/Audio/Plug-Ins/VST3/Surge XT.vst3");
- #else
- livePlugins.add (juce::File::getSpecialLocation (juce::File::userHomeDirectory).getChildFile (".vst3/Surge XT.vst3").getFullPathName());
- #endif
- const auto exportLive = lynx::AudioEngine::exportLiveSelfTest ({}, livePlugins);
- const auto midiHotplug = lynx::AudioEngine::midiHotplugSelfTest();
- const auto midiOutPorts = lynx::AudioEngine::midiOutPortSelfTest(); // round 190jl
- // Online Sessions P2 (round 169b): live sessions without a network (the JSON round trip of every entity, replicas
- // through it, the invite code's keys)
- const auto liveResult = lynx::livetest::selfTest (&rich);
- // issue #67: every built-in effect's parameters, named and hidden (the Parametric EQ's FL law, processing, band
- // mask...), at odd values, through a project save and reload: the same floats back
- juce::String effectParamsResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (1);
- for (int k = 0; k <= (int) lynx::lastEffectKind; ++k)
- {
- const auto kind = (lynx::EffectKind) k;
- if (kind == lynx::EffectKind::plugin || kind == lynx::EffectKind::parallel)
- continue;
- auto fx = lynx::makeEffectSlot (kind);
- for (std::size_t i = 0; i < fx.params.size(); ++i)
- {
- auto v = (float) ((double) ((i * 7919 + (std::size_t) k * 104729) % 65521) / 65521.0);
- fx.params[i] = v == fx.params[i] ? 1.0f - v : v;
- }
- if (kind == lynx::EffectKind::fruitySend) // ("Send to" is written over the insert span)
- fx.params[3] = 0.0f;
- song.mixer.emplace_back();
- song.mixer.back().name = "Insert " + std::to_string (song.mixer.size() - 1);
- song.mixer.back().effects.push_back (fx);
- }
- // round 171b's Patcher round trip (coordinator): the Frequency Splitter, Fruity Delay 3 and Peak Controller
- // nodes came back different (their FL defaults, e.g. the LFO speed 32750 / 65336, lost to 4 decimals)
- {
- auto patch = lynx::makeEffectSlot (lynx::EffectKind::patcher);
- for (const auto kind : { lynx::EffectKind::frequencySplitter, lynx::EffectKind::fruityDelay3, lynx::EffectKind::peakController,
- lynx::EffectKind::reverb, lynx::EffectKind::hardwareInsert })
- {
- lynx::PatchNode node;
- node.effect = lynx::natives::newEffect (kind, lynx::flStudioAccess()).value_or (lynx::makeEffectSlot (kind));
- if (kind == lynx::EffectKind::peakController)
- node.effect.params[7] = 32750.0f / 65336.0f;
- node.x = 200.0f, node.y = 60.0f * (float) patch.patcher.nodes.size();
- patch.patcher.nodes.push_back (node);
- }
- song.mixer.emplace_back();
- song.mixer.back().name = "Patcher";
- song.mixer.back().effects.push_back (patch);
- }
- juce::String why;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (back && back->mixer.size() == song.mixer.size())
- {
- const auto& a = song.mixer.back().effects[0].patcher.nodes;
- const auto& b = back->mixer.back().effects[0].patcher.nodes;
- for (std::size_t n = 0; n < a.size(); ++n)
- if (n >= b.size() || ! (a[n].effect == b[n].effect))
- effectParamsResult = juce::String ("ERROR Patcher node ") + lynx::effectInfo (a[n].effect.kind).name;
- }
- if (! back || back->mixer.size() != song.mixer.size())
- effectParamsResult = "ERROR load " + why;
- else
- for (std::size_t t = 1; t + 1 < song.mixer.size() && effectParamsResult == "OK"; ++t)
- if (back->mixer[t].effects.size() != 1 || back->mixer[t].effects[0].params != song.mixer[t].effects[0].params)
- {
- effectParamsResult = juce::String ("ERROR ") + lynx::effectInfo (song.mixer[t].effects[0].kind).name;
- break;
- }
- }
- // round 170j: the Themed plugin style (its resolution with and without art; every art draws)
- const auto artResult = lynx::skin::artSelfTest();
- // round 177b: a plugin's sidechain bus gets the slot's sidechain (one-click sidechain)
- const auto sidechainResult = lynx::pluginSidechainSelfTest();
- // round 190pj (issue #241): JSFX scripts in slots, their state, PDC, MIDI, file policy, the copy for older releases
- // (rollup 0.1.31 step 7: the message thread's floating-point environment before and after it, reported and put back:
- // the Linux arm64 self-test's float round trips, renders and paint tiles after this item differed from x86's: EEL2's
- // code left FPCR at round-toward-minus-infinity; ysfx_lynx_fp_guard in third_party/ysfx/sources/ysfx.cpp now puts the
- // caller's environment back, and this check counts in result=)
- std::fenv_t fpBeforeJsfx {};
- std::fegetenv (&fpBeforeJsfx);
- const auto fpModeNow = [] {
- #if defined (__aarch64__) && ! defined (_MSC_VER)
- juce::uint64 fpcr = 0; // (an instruction, not GCC's __builtin_aarch64_get_fpcr: Apple clang has no such builtin)
- asm volatile ("mrs %0, fpcr" : "=r" (fpcr));
- return fpcr;
- #else
- return (juce::uint64) std::fegetround();
- #endif
- };
- const auto fpModeBeforeJsfx = fpModeNow();
- const auto jsfxResult = lynx::jsfx::selfTest ({});
- const auto fpModeAfterJsfx = fpModeNow();
- std::fesetenv (&fpBeforeJsfx);
- const auto jsfxFpResult = fpModeAfterJsfx == fpModeBeforeJsfx ? juce::String ("OK")
- : "CHANGED 0x" + juce::String::toHexString ((juce::int64) fpModeBeforeJsfx) + " -> 0x"
- + juce::String::toHexString ((juce::int64) fpModeAfterJsfx) + " (put back)";
- // round 190qi: the slot menu's Recent section, a plugin hidden from the lists, one row per plugin's formats, a MIDI
- // file's preview schedule (src/Picker190qiShot.inc)
- const auto picker190qiResult = picker190qiSelfTest (juce::File::getSpecialLocation (juce::File::tempDirectory));
- // round 190ap: the Versions panel's list of files, and its labels on disk beside them
- const auto versionsResult = lynx::versionsSelfTest();
- // round 190ap: a project opened with its plugins off creates none of them and saves their settings unchanged
- const auto pluginsOffResult = lynx::pluginsOffSelfTest();
- const auto missingFilesResult = lynx::missingFilesSelfTest(); // issue #165
- // round 190cj: a dancer's own native window stays where the stage put it (it drifted off the screen: JUCE
- // moved a transparent child window by the main window's client offset on every repaint)
- juce::String danceWindowDetail;
- const auto danceWindowResult = lynx::danceWindowSelfTest (&danceWindowDetail);
- // issue #161: a click in a panel (a native child window that takes no focus on a click) of an inactive main
- // window activates it (back from another app, Space played nothing until the Browser was clicked)
- const auto clickActivationResult = lynx::nativechild::clickActivationSelfTest();
- // round 190jy (queue item 44): the holes the native panels get under a docked editor drawn by the main window
- const auto editorHolesResult = lynx::nativechild::editorHolesSelfTest();
- // round 177b: automation lanes come back from a project (track, automation, height, folded)
- juce::String lanesResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- const auto lane = lynx::autolanes::addLane (song, 3, { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 }, "Vol", 0.4f);
- song.playlistTracks[3].lanes[0].height = 72;
- song.playlistTracks[3].lanesFolded = true;
- // (the same round's clip LFO and modulators ride along)
- auto& lfo = song.automations[(std::size_t) lane].lfo;
- lfo.on = true;
- lfo.level = -40;
- lfo.speed = 30000;
- lfo.flags = 1 | 4;
- lfo.phase = 123456789u;
- lfo.amp = { { 0, 0.5f, 0.0f }, { 960, 1.0f, 0.0f } };
- lynx::Modulator mod;
- mod.name = "LFO 1";
- mod.shape = lynx::ModShape::square;
- mod.sync = false;
- mod.hz = 2.5;
- mod.routes = { { { lynx::AutomationTargetKind::mixerPan, 1, 0, 0 }, -0.5f } };
- song.modulators.push_back (mod);
- juce::String why;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (! back || back->playlistTracks.size() < 4 || ! (back->playlistTracks[3].lanes == song.playlistTracks[3].lanes)
- || ! back->playlistTracks[3].lanesFolded || back->automations.size() != song.automations.size()
- || ! (back->automations[(std::size_t) lane].points == song.automations[(std::size_t) lane].points)
- || ! (back->automations[(std::size_t) lane].lfo == lfo) || ! (back->modulators == song.modulators))
- lanesResult = "ERROR " + why;
- }
- // round 190cg: the loop switch, folded tracks and the tempo lane's range come back from a project; a project
- // without them loads as before (loop on, nothing folded, the whole range)
- juce::String arrange190cgResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- juce::String why;
- const auto plain = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- song.loopStart = 960;
- song.loopEnd = 4800;
- song.loopOff = true;
- song.tempoViewLow = 80.0;
- song.tempoViewHigh = 160.0;
- song.playlistTracks.resize (std::max<std::size_t> (song.playlistTracks.size(), 6));
- song.playlistTracks[2].folded = song.playlistTracks[5].folded = true;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (! plain || plain->loopOff || plain->tempoViewLow != 0.0 || plain->tempoViewHigh != 0.0
- || std::any_of (plain->playlistTracks.begin(), plain->playlistTracks.end(), [] (const lynx::PlaylistTrack& t) { return t.folded; }))
- arrange190cgResult = "ERROR defaults " + why;
- else if (! back || ! back->loopOff || back->loopStart != 960 || back->loopEnd != 4800 || back->loopPlays() || back->tempoViewLow != 80.0
- || back->tempoViewHigh != 160.0 || back->playlistTracks.size() < 6 || ! back->playlistTracks[2].folded
- || ! back->playlistTracks[5].folded || back->playlistTracks[3].folded)
- arrange190cgResult = "ERROR round trip " + why;
- }
- // round 190gz (issue #170): "Link Playlist tracks to mixer tracks" comes back from a project with its links; a
- // project without it loads with it off (FL's tracks)
- juce::String trackauto190gzResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- juce::String why;
- const auto plain = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::pattern;
- clip.pattern = 0; // (the default pattern: Kick, Clap and Hat; a second one plays Kick alone)
- song.playlist.push_back (clip);
- auto& kick = song.patterns.emplace_back();
- kick.name = "Kick";
- kick.toggleStep (0, 0);
- clip.pattern = (int) song.patterns.size() - 1;
- clip.track = 1;
- song.playlist.push_back (clip);
- lynx::autolink::setOn (song, true);
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (! plain || plain->linkTracksToMixer)
- trackauto190gzResult = "ERROR defaults " + why;
- // (round 190ib: Track 1 holds Kick, Clap and Hat, so they all go through insert 1 and Track 1 is its audio
- // track; Track 2 only repeats Kick and stays unassigned)
- // (a .lynx keeps the tracks up to the last one that differs from a plain track: Track 2 may not be written)
- else if (! back || ! back->linkTracksToMixer || back->playlistTracks.empty() || back->playlistTracks[0].mode != lynx::PlaylistTrackMode::audio
- || back->playlistTracks[0].mixerTrack != 1
- || (back->playlistTracks.size() > 1 && back->playlistTracks[1].mode != lynx::PlaylistTrackMode::unassigned)
- || back->channels[1].mixerTrack != 1 || back->channels[2].mixerTrack != 1)
- {
- trackauto190gzResult = "ERROR round trip " + why;
- if (back && ! back->playlistTracks.empty() && back->channels.size() >= 3)
- trackauto190gzResult << " tracks " << (int) back->playlistTracks.size() << " mode " << (int) back->playlistTracks[0].mode << " insert "
- << back->playlistTracks[0].mixerTrack << " routes " << back->channels[0].mixerTrack << " "
- << back->channels[1].mixerTrack << " " << back->channels[2].mixerTrack;
- }
- }
- // round 190fm: the MIDI Tools generators' settings come back from a project; a project without them loads with
- // Live's defaults (and saves none)
- juce::String midigen190fmResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- juce::String why;
- const auto plainJson = lynx::ProjectFile::toJson (song);
- const auto plain = lynx::ProjectFile::fromJson (plainJson, why);
- song.midiGenerate.tool = lynx::midigen::Settings::stacks;
- song.midiGenerate.rhythmOptions.pattern = 3;
- song.midiGenerate.seedOptions.voices = 2;
- song.midiGenerate.shapeOptions.levels[4] = 0.25f;
- song.midiGenerate.shapeOptions.preset = lynx::midigen::ShapeOptions::custom;
- song.midiGenerate.stacksOptions.sequence.push_back ({ 4, 3, 67, 1, 1, 0.5f, 2.0f });
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (! plain || ! plain->midiGenerate.isDefault() || plainJson.contains ("midiGenerate"))
- midigen190fmResult = "ERROR defaults " + why;
- else if (! back || ! (back->midiGenerate == song.midiGenerate))
- midigen190fmResult = "ERROR round trip " + why;
- }
- // round 190gi: audio clip envelopes come back from a project (an entry two clips share stays shared, an unused one
- // is not written, the lane shown, FL's curve modes); a project without them writes neither "clipEnvelopes" nor a
- // clip field 25 (older projects save byte-identical)
- juce::String clipenv190giResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef channel;
- channel.instrument = lynx::InstrumentKind::audioClip;
- channel.samplePath = "clipenv190gi.wav";
- song.channels.push_back (channel);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = (int) song.channels.size() - 1;
- clip.length = lynx::ppq * 4;
- song.playlist.push_back (clip);
- juce::String why;
- const auto plainJson = lynx::ProjectFile::toJson (song);
- lynx::ClipEnvelope e;
- e.volume = { { 0, 1.0f, 0.0f, 0 }, { lynx::ppq * 4, 0.25f, 0.3f, 1 } };
- e.pan = { { 0, 0.5f, 0.0f, 0 }, { lynx::ppq * 2, 0.0f, 0.0f, 0 } };
- e.shown = lynx::clipenv::panLane;
- song.clipEnvelopes.emplace_back(); // (no clip uses it: not written)
- song.clipEnvelopes.push_back (e);
- song.playlist.back().envelope = 1;
- auto twin = song.playlist.back();
- twin.start = lynx::ppq * 8;
- song.playlist.push_back (twin);
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (plainJson.contains ("clipEnvelopes") || ! json.contains ("clipEnvelopes"))
- clipenv190giResult = "ERROR written " + why;
- else if (! back || back->clipEnvelopes.size() != 1 || ! (back->clipEnvelopes[0] == e))
- clipenv190giResult = "ERROR table " + why;
- else
- {
- int withEnvelope = 0;
- for (const auto& c : back->playlist)
- withEnvelope += c.kind == lynx::ClipKind::audio && c.envelope == 0 ? 1 : 0;
- if (withEnvelope != 2)
- clipenv190giResult = "ERROR clips " + why;
- }
- }
- // round 190gx: Beats' law in the .lynx — a new project's channels are Measured; a project saved before the law
- // (no "beatsLaw190gx" mark, or a nine-number warpModes list) loads Classic; a Classic channel stays Classic
- juce::String beatslaw190gxResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef channel;
- channel.instrument = lynx::InstrumentKind::audioClip;
- channel.samplePath = "beatslaw190gx.wav";
- channel.sampler.keepPitch = true;
- channel.sampler.stretchMethod = lynx::StretchMethod::beats;
- song.channels.push_back (channel);
- const auto index = song.channels.size() - 1;
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto lawOf = [&] (const juce::String& text) {
- const auto back = lynx::ProjectFile::fromJson (text, why);
- return back && back->channels.size() > index ? (int) back->channels[index].sampler.warpModes.beatsLaw : -1;
- };
- auto oldVar = juce::JSON::parse (json); // (the mark removed: a project saved before 190gx)
- if (auto* o = oldVar.getDynamicObject())
- o->removeProperty ("beatsLaw190gx");
- const auto old = juce::JSON::toString (oldVar);
- auto classic = song;
- classic.channels[index].sampler.warpModes.beatsLaw = lynx::WarpModeSettings::beatsLawClassic;
- auto nine = song;
- nine.channels[index].sampler.warpModes.beatsLoop = 0; // (a 190fm project with a changed setting: nine numbers)
- // (the list with its tenth number, the law, removed: what a 190fm build wrote)
- auto nineVar = juce::JSON::parse (lynx::ProjectFile::toJson (nine));
- bool trimmed = false;
- if (auto* channels = nineVar.getProperty ("channels", {}).getArray(); channels != nullptr && (int) index < channels->size())
- if (auto* modes = (*channels)[(int) index].getProperty ("samplerSettings", {}).getProperty ("warpModes", {}).getArray(); modes != nullptr && modes->size() == 11)
- {
- modes->removeLast (2); // (round 190ik's eleventh number too)
- trimmed = true;
- }
- const auto nineJson = juce::JSON::toString (nineVar);
- if (! json.contains ("beatsLaw190gx") || old.contains ("beatsLaw190gx"))
- beatslaw190gxResult = "ERROR mark";
- else if (lawOf (json) != lynx::WarpModeSettings::beatsLawPitchAware) // (round 190ik: the new default)
- beatslaw190gxResult = "ERROR new " + why;
- else if (lawOf (old) != lynx::WarpModeSettings::beatsLawClassic)
- beatslaw190gxResult = "ERROR old " + why;
- else if (lawOf (lynx::ProjectFile::toJson (classic)) != lynx::WarpModeSettings::beatsLawClassic)
- beatslaw190gxResult = "ERROR classic kept " + why;
- else if (! trimmed || lawOf (nineJson) != lynx::WarpModeSettings::beatsLawClassic)
- beatslaw190gxResult = "ERROR nine-number list";
- }
- // round 190ik: the pitch-aware Beats law and the Texture / Complex Pro engines in the .lynx — a new project's channels
- // use them; a project saved before 190ik (no "warpLaw190ik" mark, or a ten-number warpModes list) keeps Beats Measured
- // and the Classic engines; a channel kept on an older law stays on it when saved again
- juce::String warplaw190ikResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef channel;
- channel.instrument = lynx::InstrumentKind::audioClip;
- channel.samplePath = "warplaw190ik.wav";
- channel.sampler.keepPitch = true;
- channel.sampler.stretchMethod = lynx::StretchMethod::texture;
- song.channels.push_back (channel);
- const auto index = song.channels.size() - 1;
- juce::String why;
- const auto lawsOf = [&] (const juce::String& text) {
- const auto back = lynx::ProjectFile::fromJson (text, why);
- if (! back || back->channels.size() <= index)
- return std::pair<int, int> { -1, -1 };
- const auto& w = back->channels[index].sampler.warpModes;
- return std::pair<int, int> { (int) w.beatsLaw, (int) w.warpLaw };
- };
- const auto json = lynx::ProjectFile::toJson (song);
- auto oldVar = juce::JSON::parse (json); // (the mark removed: a project saved by 0.1.28 / 0.1.29)
- if (auto* o = oldVar.getDynamicObject())
- o->removeProperty ("warpLaw190ik");
- const auto old = juce::JSON::toString (oldVar);
- auto kept = song; // a channel left on the older laws
- kept.channels[index].sampler.warpModes.beatsLaw = lynx::WarpModeSettings::beatsLawMeasured;
- kept.channels[index].sampler.warpModes.warpLaw = lynx::WarpModeSettings::warpLawClassic;
- auto ten = song; // a changed setting saved by 0.1.28: a ten-number list
- ten.channels[index].sampler.warpModes.textureFlux = 60.0f;
- auto tenVar = juce::JSON::parse (lynx::ProjectFile::toJson (ten));
- bool trimmed = false;
- if (auto* channels = tenVar.getProperty ("channels", {}).getArray(); channels != nullptr && (int) index < channels->size())
- if (auto* modes = (*channels)[(int) index].getProperty ("samplerSettings", {}).getProperty ("warpModes", {}).getArray(); modes != nullptr && modes->size() == 11)
- {
- modes->removeLast();
- modes->set (9, 1); // (0.1.28 wrote Measured)
- trimmed = true;
- }
- const auto tenJson = juce::JSON::toString (tenVar);
- const std::pair<int, int> newest { lynx::WarpModeSettings::beatsLawPitchAware, lynx::WarpModeSettings::warpLawMeasured };
- const std::pair<int, int> older { lynx::WarpModeSettings::beatsLawMeasured, lynx::WarpModeSettings::warpLawClassic };
- if (! json.contains ("warpLaw190ik") || old.contains ("warpLaw190ik"))
- warplaw190ikResult = "ERROR mark";
- else if (lawsOf (json) != newest)
- warplaw190ikResult = "ERROR new " + why;
- else if (lawsOf (old) != older)
- warplaw190ikResult = "ERROR old " + why;
- else if (lawsOf (lynx::ProjectFile::toJson (kept)) != older)
- warplaw190ikResult = "ERROR older laws kept " + why;
- else if (! trimmed || lawsOf (tenJson) != std::pair<int, int> { lynx::WarpModeSettings::beatsLawMeasured, lynx::WarpModeSettings::warpLawClassic })
- warplaw190ikResult = "ERROR ten-number list";
- }
- // round 190he (issue #152): a channel window's Scaling is saved with the channel; the default (125 %) writes
- // nothing, so older projects and untouched channels read as before
- juce::String editorScale190heResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- song.channels[0].editorScale = 100;
- song.channels[1].editorScale = 0;
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- auto outOfRange = juce::JSON::parse (json);
- if (auto* chans = outOfRange.getProperty ("channels", {}).getArray(); chans != nullptr && ! chans->isEmpty())
- if (auto* o = (*chans)[0].getDynamicObject())
- o->setProperty ("editorScale", 9000);
- const auto clamped = lynx::ProjectFile::fromJson (juce::JSON::toString (outOfRange), why);
- if (! back || back->channels[0].editorScale != 100 || back->channels[1].editorScale != 0)
- editorScale190heResult = "ERROR round trip " + why;
- else if (json.indexOf ("editorScale") != json.lastIndexOf ("editorScale"))
- editorScale190heResult = "ERROR written for a default channel";
- else if (! clamped || clamped->channels[0].editorScale != lynx::editorscale::maxPercent)
- editorScale190heResult = "ERROR not clamped";
- }
- // round 190he (coordinator's gate): a project saved before 190he (no "sfModBase190he") keeps the old 0.5 centre of
- // a Modulation route on a Soundfont knob; a new song, saved and opened again, centres on the knob
- juce::String sfModBase190heResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- auto oldVar = juce::JSON::parse (json);
- if (auto* o = oldVar.getDynamicObject())
- o->removeProperty ("sfModBase190he");
- const auto back = lynx::ProjectFile::fromJson (json, why);
- const auto old = lynx::ProjectFile::fromJson (juce::JSON::toString (oldVar), why);
- auto resaved = old ? lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (*old), why) : std::optional<lynx::Song> {};
- if (! json.contains ("sfModBase190he") || ! back || ! back->soundfontModBaseReal)
- sfModBase190heResult = "ERROR new song " + why;
- else if (! old || old->soundfontModBaseReal)
- sfModBase190heResult = "ERROR old project " + why;
- else if (! resaved || resaved->soundfontModBaseReal)
- sfModBase190heResult = "ERROR old project saved again";
- }
- // round 190hq: tempo markers (B11) and the fader / route PDC switch (B13) in the .lynx, and the copy for an older
- // LYNX (B20): an effect 0.1.27 does not know keeps its slot (as a switched-off Utility) and loses its automation,
- // the later slots and their automation stay; the copy for 0.1.28 turns the markers into a plain tempo clip
- juce::String community190hqResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- song.mode = lynx::PlayMode::song;
- lynx::tempomarkers::add (song, 4 * lynx::ppq, 90.0);
- lynx::tempomarkers::add (song, 8 * lynx::ppq, 140.0, true);
- song.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::anvilBus));
- song.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::delay));
- for (const auto slot : { 0, 1 })
- {
- lynx::Automation a;
- a.name = slot == 0 ? "Anvil" : "Delay";
- a.target = { lynx::AutomationTargetKind::effectParam, 1, slot, 1 };
- a.points = { { 0, 0.2f }, { 1920, 0.8f } };
- song.automations.push_back (a);
- }
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- auto unmarked = juce::JSON::parse (json);
- if (auto* o = unmarked.getDynamicObject())
- o->removeProperty ("mixerLevelPdc190hq");
- const auto old = lynx::ProjectFile::fromJson (juce::JSON::toString (unmarked), why);
- const auto marks = back ? lynx::tempomarkers::list (*back) : std::vector<lynx::tempomarkers::Mark> {};
- const auto for127 = lynx::olderlynx::forRelease (song, "0.1.27");
- const auto for128 = lynx::olderlynx::forRelease (song, "0.1.28");
- const auto copy127 = for127.ok ? lynx::ProjectFile::fromJson (for127.json, why) : std::optional<lynx::Song> {};
- const auto copy128 = for128.ok ? lynx::ProjectFile::fromJson (for128.json, why) : std::optional<lynx::Song> {};
- const auto anvilLost = std::any_of (for127.lost.begin(), for127.lost.end(), [] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).startsWith ("Anvil Bus");
- });
- auto targetOf = [] (const std::optional<lynx::Song>& s, const char* name) {
- if (s)
- for (const auto& a : s->automations)
- if (a.name == name)
- return a.target;
- return lynx::AutomationTarget {};
- };
- if (! back || ! back->compensateMixerLevels || ! old || old->compensateMixerLevels)
- community190hqResult = "ERROR mixer level PDC mark " + why;
- else if (marks.size() != 2 || marks[0].tick != 4 * lynx::ppq || std::abs (marks[1].bpm - 140.0) > 0.01 || ! marks[1].glide || marks[0].glide
- || std::abs (back->tempoAt (5.0 * lynx::ppq) - 102.5) > 0.5) // (90 at bar 2, ramping into the gliding 140 at bar 3)
- community190hqResult = "ERROR tempo markers round trip";
- else if (! copy127 || for127.json.contains ("anvilBus") || copy127->mixer[1].effects.size() != 2
- || copy127->mixer[1].effects[0].kind != lynx::EffectKind::utility || copy127->mixer[1].effects[0].enabled
- || copy127->mixer[1].effects[1].kind != lynx::EffectKind::delay || ! anvilLost)
- community190hqResult = "ERROR copy for 0.1.27: slots " + why;
- else if (targetOf (copy127, "Anvil").kind != lynx::AutomationTargetKind::none
- || ! (targetOf (copy127, "Delay") == lynx::AutomationTarget { lynx::AutomationTargetKind::effectParam, 1, 1, 1 }))
- community190hqResult = "ERROR copy for 0.1.27: automation";
- else if (! juce::JSON::parse (for127.json)["savedBy"].toString().equalsIgnoreCase ("0.1.27") || for127.json.contains ("tempoMarkers")
- || for127.json.contains ("mixerLevelPdc190hq") || for127.json.contains ("beatsLaw190gx"))
- community190hqResult = "ERROR copy for 0.1.27: fields";
- else if (! copy128 || for128.json.contains ("tempoMarkers") || ! for128.json.contains ("anvilBus") || lynx::tempomarkers::automationIndex (*copy128) >= 0
- || std::abs (copy128->tempoAt (5.0 * lynx::ppq) - 102.5) > 0.5 || std::abs (copy128->tempoAt (12.0 * lynx::ppq) - 140.0) > 0.01)
- community190hqResult = "ERROR copy for 0.1.28";
- else if (lynx::olderlynx::forRelease (song, "0.1.9").ok)
- community190hqResult = "ERROR unknown release accepted";
- }
- // rollup 0.1.30 (round 190il): the copy for 0.1.28 knows what the other 0.1.30 rounds save: a Tetra channel becomes
- // an empty Sampler, MPE note curves, muted Pattern Blocks, clips transposed past ±12, clip slots' Start markers and
- // scales, Voice Shift's revision 1, Ridge's Pink EQ, Hush's Allround timing (round 190iy), automation colours and mix snapshots are reported and taken
- // out; a DirectWave state's 36-byte sample format record is completed (0.1.28 skipped it, and the loop with it)
- juce::String rollup030Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef tetra;
- tetra.name = "FM";
- tetra.instrument = lynx::InstrumentKind::tetra;
- tetra.modelParams = { 0.5f, 0.25f };
- song.channels.push_back (tetra);
- lynx::ChannelDef wave;
- wave.name = "Piano";
- wave.instrument = lynx::InstrumentKind::directwave;
- {
- auto doc = lynx::dw::freshDoc();
- lynx::dw::Node zone;
- zone.id = 3;
- zone.container = true;
- lynx::dw::Node format;
- format.id = 0x1F7;
- format.body.assign (36, 0);
- format.body[20] = 2; // loop mode
- format.body[24] = 44; // loop A
- format.body[28] = 200; // loop B
- zone.kids.push_back (format);
- for (auto& n : doc.top)
- if (n.id == 1 && n.container)
- {
- n.kids.push_back (zone);
- break;
- }
- wave.pluginState = lynx::dw::writeDoc (doc);
- }
- song.channels.push_back (wave);
- lynx::Note curved;
- curved.key = 60;
- curved.length = lynx::ppq;
- lynx::NoteCurves curves;
- curves.lane (lynx::NoteCurveLane::pitch) = { { 0.0f, 0.0f }, { 96.0f, 200.0f } };
- curved.curves = curves;
- song.patterns[0].notes.push_back (curved);
- song.patternBlocksOn = true;
- lynx::patternblocks::place (song, 0, 0);
- lynx::patternblocks::place (song, 0, 4 * lynx::ppq);
- lynx::patternblocks::setMuted (song, 1, true);
- lynx::Clip up;
- up.track = 1;
- up.length = 4 * lynx::ppq;
- up.pitch = 24.0f;
- song.playlist.push_back (up);
- lynx::Clip slotClip;
- slotClip.length = 4 * lynx::ppq;
- if (const auto id = lynx::launcher::setClip (song, 0, 0, slotClip); id >= 0)
- {
- song.clipGrid->slots[(std::size_t) id].startMarker = lynx::ppq;
- song.clipGrid->slots[(std::size_t) id].ownScale = true;
- }
- song.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::voiceShift)); // (a new one: revision 1)
- auto ridgeSlot = lynx::makeEffectSlot (lynx::EffectKind::ridgeStrip);
- ridgeSlot.params[(std::size_t) lynx::mixsuite::ridge::k4Pink] = 1.0f;
- song.mixer[2].effects.push_back (ridgeSlot);
- auto hushSlot = lynx::makeEffectSlot (lynx::EffectKind::hushDeEsser); // (a new one: the measured timing, round 190iq)
- hushSlot.params[(std::size_t) lynx::mixsuite::hush::allround] = 1.0f;
- song.mixer[3].effects.push_back (hushSlot);
- lynx::Automation coloured;
- coloured.name = "Cutoff";
- coloured.colour = 0xFFC03030u;
- coloured.points = { { 0, 0.2f }, { 1920, 0.8f } };
- song.automations.push_back (coloured);
- lynx::mixsnap::take (song);
- // rollup step 3 (round 190jk): Helix (190ja), the effects' hidden revisions (190is / 190it), a warped Texture
- // channel with its offline transposition and tempo automation (190ik), a deactivated clip slot (190im)
- lynx::ChannelDef helix;
- helix.name = "WT";
- helix.instrument = lynx::InstrumentKind::helix;
- helix.modelParams = { 0.5f };
- song.channels.push_back (helix);
- lynx::ChannelDef loop;
- loop.name = "Loop";
- loop.instrument = lynx::InstrumentKind::sampler;
- loop.sampler.stretchBeats = 8.0f;
- loop.sampler.keepPitch = true;
- loop.sampler.stretchMethod = lynx::StretchMethod::texture;
- loop.sampler.stretchPitch = 5.0f;
- song.channels.push_back (loop);
- lynx::Automation tempoClip;
- tempoClip.name = "Tempo";
- tempoClip.target.kind = lynx::AutomationTargetKind::tempo;
- tempoClip.points = { { 0, 0.4f }, { 1920, 0.6f } };
- song.automations.push_back (tempoClip);
- if (song.clipGrid)
- for (auto& slot : song.clipGrid->slots)
- slot.active = false;
- auto echoSlot = lynx::makeEffectSlot (lynx::EffectKind::echoform); // (new: voicings revision 1)
- echoSlot.params[(std::size_t) lynx::echosuite::echoform::voicing] = 1.0f;
- song.mixer[4].effects.push_back (echoSlot);
- auto haloSlot = lynx::makeEffectSlot (lynx::EffectKind::halo); // (new: revision 1 of the Measured law)
- haloSlot.params[(std::size_t) lynx::verbs::halo::engineLaw] = 1.0f;
- song.mixer[5].effects.push_back (haloSlot);
- song.mixer[6].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::latticeMod));
- auto luxeSlot = lynx::makeEffectSlot (lynx::EffectKind::luxeVerb);
- luxeSlot.params[(std::size_t) lynx::luxeVerbSpaceDucking] = 0.5f;
- song.mixer[7].effects.push_back (luxeSlot);
- // rollup step 4 (round 190jt): Facet's automatic threshold (190jh), a MIDI Out channel (190jl), a hosted VST3's
- // automated parameter (190jg), a nested Playlist folder (190jf), the Limiter's CURVE view (190jd)
- auto facetSlot = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
- facetSlot.params[(std::size_t) lynx::facet::autoThresholdParam0 + 2] = 1.0f;
- song.mixer[8].effects.push_back (facetSlot);
- auto limiterSlot = lynx::makeEffectSlot (lynx::EffectKind::fruityLimiter);
- limiterSlot.displayView = 1;
- song.mixer[9].effects.push_back (limiterSlot);
- lynx::ChannelDef midiOut;
- midiOut.name = "Hardware";
- midiOut.instrument = lynx::InstrumentKind::midiOut;
- song.channels.push_back (midiOut);
- lynx::ChannelDef hosted;
- hosted.name = "Hosted";
- hosted.instrument = lynx::InstrumentKind::plugin;
- hosted.plugin.id = "VST3-Test Synth-1a2b3c4d-5e6f7a8b";
- hosted.plugin.name = "Test Synth";
- song.channels.push_back (hosted);
- lynx::Automation pluginKnob;
- pluginKnob.name = "Test Synth - Cutoff";
- pluginKnob.target.kind = lynx::AutomationTargetKind::channelParam;
- pluginKnob.target.index = (int) song.channels.size() - 1;
- pluginKnob.target.param = 3;
- pluginKnob.points = { { 0, 0.1f }, { 1920, 0.9f } };
- song.automations.push_back (pluginKnob);
- if (song.playlistTracks.size() < 4)
- song.playlistTracks.resize (4);
- song.playlistTracks[1].grouped = true;
- song.playlistTracks[2].grouped = true;
- song.playlistTracks[2].nest = 1;
- // rollup step 5 (round 190kh): Hush's Single Vocal revision (190js), a slide note on an FL native generator (190jv)
- song.mixer[10].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::hushDeEsser)); // (new: Single Vocal, revision 1)
- lynx::ChannelDef slider;
- slider.name = "Slides";
- slider.instrument = lynx::InstrumentKind::sampler;
- song.channels.push_back (slider);
- if (song.patterns.empty())
- song.patterns.emplace_back();
- {
- lynx::Note slide;
- slide.start = 0;
- slide.length = lynx::ppq;
- slide.channel = (int) song.channels.size() - 1;
- slide.key = 64;
- slide.slide = true;
- song.patterns[0].notes.push_back (slide);
- }
- // rollup step 6 (round 190km): Live's Crossfade Assign and a return track (190kc), the Simple Controls tab's own
- // mapping (190ke), a Newtone slot whose state is version 3 (natives190kj: + the key and the notes' velocity)
- song.mixer[11].crossfade = lynx::CrossfadeAssign::a;
- song.crossfader = -0.5f;
- song.mixer[12].liveReturn = true;
- song.mixer[12].returnPre = true;
- song.mixer[13].smartControls = "custom";
- {
- auto newtoneSlot = lynx::makeEffectSlot (lynx::EffectKind::newtone);
- lynx::newtonefx::Track nt;
- nt.frames = 48000;
- nt.key = 9;
- lynx::newtonefx::Note n;
- n.origEnd = n.curEnd = 24000;
- n.origPitch = 69.0;
- n.velocity = 0.8;
- n.validEnd = 20000;
- nt.pitches = { n };
- nt.notes = 1;
- newtoneSlot.state = lynx::newtonefx::writeNative (nt);
- song.mixer[14].effects.push_back (newtoneSlot);
- }
- // rollup step 7 (round 190lc): a Peak Controller on a LYNX shape (190kl), Crest's console law (190kt), a locked
- // insert beside a solo (190kn), an imported take lane (qafix190kq), a plugin that records no notes from its
- // window (190ks)
- {
- auto peakSlot = lynx::makeEffectSlot (lynx::EffectKind::peakController);
- peakSlot.params[(std::size_t) lynx::peakshapes::extraShapeParam] = (float) lynx::peakshapes::expFall / lynx::peakshapes::idScale;
- song.mixer[15].effects.push_back (peakSlot);
- auto crestSlot = lynx::makeEffectSlot (lynx::EffectKind::crestCompressor);
- crestSlot.params[(std::size_t) lynx::dyn::crest::busLaw] = 1.0f;
- song.mixer[16].effects.push_back (crestSlot);
- // rollup step 8: a new Crest (round 190kw's revision 1), a Crest on round 190ky's FET law, a Ridge Strip with
- // round 190lb's 4K G filters, an Echoform on round 190kw's Timeless 3 line law in a locked slot (round
- // 190ld), and a Playlist track's solo lock (round 190ld)
- song.mixer[16].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::crestCompressor));
- auto fetSlot = lynx::makeEffectSlot (lynx::EffectKind::crestCompressor);
- fetSlot.params[(std::size_t) lynx::dyn::crest::revision] = 0.0f;
- fetSlot.params[(std::size_t) lynx::dyn::crest::fetLaw] = lynx::dyn::crest::fetLawValue (0);
- song.mixer[16].effects.push_back (fetSlot);
- auto k4gSlot = lynx::makeEffectSlot (lynx::EffectKind::ridgeStrip);
- k4gSlot.params[(std::size_t) lynx::mixsuite::ridge::k4gLaw] = 1.0f;
- song.mixer[16].effects.push_back (k4gSlot);
- auto lineSlot = lynx::makeEffectSlot (lynx::EffectKind::echoform);
- lineSlot.params[(std::size_t) lynx::echosuite::echoform::lineLaw] = 1.0f;
- lineSlot.lockState = true;
- song.mixer[16].effects.push_back (lineSlot);
- // (round 190mo: track 4 is the fifth; the song had four tracks here, so this wrote one byte past the
- // vector's end: the heap corruption of the Linux self-test, "corrupted size vs. prev_size" later on)
- if (song.playlistTracks.size() < 5)
- song.playlistTracks.resize (5);
- song.playlistTracks[4].soloLock = true;
- song.mixer[1].lockState = true; // (the default mixer has inserts 1…16)
- song.mixer[2].solo = true;
- song.playlistTracks[3].takeLane = true;
- for (auto& c : song.channels)
- if (c.name == "Hosted")
- c.plugin.recordOwnNotes = false;
- }
- // rollup step 9 (round 190lu): a new Ember (round 190kw / 190lg's Saturn laws), a Prism on round 190lg's Pro-MB
- // law, round 190lf's L2 law on the Limiter, cell law on Glow Leveler, direct sound on Reeverb 2, zero law on Quell
- // and H-Delay loop law on Echoform, round 190ln's all-pass dispersion on Facet, and a note on an audio clip
- // channel (round 190lq: FL's law in a marked project)
- {
- auto& m16 = song.mixer[16].effects;
- m16.push_back (lynx::makeEffectSlot (lynx::EffectKind::ember)); // [5]
- auto prism = lynx::makeEffectSlot (lynx::EffectKind::prismMultiband);
- prism.params[(std::size_t) lynx::dyn::prism::revision] = 1.0f;
- m16.push_back (prism); // [6]
- auto l2 = lynx::makeEffectSlot (lynx::EffectKind::limiter);
- l2.params[(std::size_t) lynx::limiterlaw::lawParam] = lynx::limiterlaw::l2LawValue;
- m16.push_back (l2); // [7]
- auto glow = lynx::makeEffectSlot (lynx::EffectKind::glowLeveler);
- glow.params[(std::size_t) lynx::mixsuite::glow::cellLaw] = 1.0f;
- m16.push_back (glow); // [8]
- auto verb = lynx::makeEffectSlot (lynx::EffectKind::reeverb2);
- verb.params[(std::size_t) lynx::reeverb2DirectLaw] = 1.0f;
- m16.push_back (verb); // [9]
- auto quell = lynx::makeEffectSlot (lynx::EffectKind::quellDenoiser);
- quell.params[(std::size_t) lynx::voicetools::quell::zeroLaw] = 1.0f;
- m16.push_back (quell); // [10]
- auto disperser = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
- disperser.params[(std::size_t) lynx::facet::dispersionCountParam] = 0.25f;
- m16.push_back (disperser); // [11]
- auto hybrid = lynx::makeEffectSlot (lynx::EffectKind::echoform);
- hybrid.params[(std::size_t) lynx::echosuite::echoform::hybridLaw] = 1.0f;
- m16.push_back (hybrid); // [12]
- lynx::ChannelDef clipChannel;
- clipChannel.name = "Clip";
- clipChannel.instrument = lynx::InstrumentKind::audioClip;
- song.channels.push_back (clipChannel);
- lynx::Note hit;
- hit.length = lynx::ppq / 4;
- hit.channel = (int) song.channels.size() - 1;
- hit.key = 67;
- song.patterns[0].notes.push_back (hit);
- }
- // rollup step 10 (round 190me): a new Apex Limiter and Sentry Gate (round 190lp's revision 1), a LuxeVerb on its
- // Space engine (revision 1, round 190kw / 190lz), an Echoform on round 190ly's ValhallaDelay law, a new Spiral Echo
- // on the Measured law (round 190ly's rate law) and a scene follow action (round 190lr)
- {
- auto& m16 = song.mixer[16].effects; // (after step 9's [5] … [12]: the song has inserts 0 … 16)
- m16.push_back (lynx::makeEffectSlot (lynx::EffectKind::apexLimiter)); // [13]
- m16.push_back (lynx::makeEffectSlot (lynx::EffectKind::sentryGate)); // [14]
- auto luxe = lynx::makeEffectSlot (lynx::EffectKind::luxeVerb);
- luxe.params[(std::size_t) lynx::luxeVerbSpaceFirst] = 1.0f;
- m16.push_back (luxe); // [15]
- auto valhalla = lynx::makeEffectSlot (lynx::EffectKind::echoform);
- valhalla.params[(std::size_t) lynx::echosuite::echoform::valhallaLaw] = 1.0f;
- m16.push_back (valhalla); // [16]
- auto spiral = lynx::makeEffectSlot (lynx::EffectKind::spiralEcho);
- spiral.params[(std::size_t) lynx::echosuite::spiral::law] = 1.0f;
- m16.push_back (spiral); // [17]
- if (! song.clipGrid)
- song.clipGrid.emplace();
- if (song.clipGrid->scenes.empty())
- song.clipGrid->scenes.emplace_back();
- song.clipGrid->scenes[0].follow.enabled = true;
- }
- // rollup step 11 (round 190mn): a new Horizon (round 190mb / 190mj's revision and FutureVerb law), a Nebula on the
- // Supermassive tone, an Orbit on the SpaceModulator laws (190mb / 190mj), round 190mg's Waves laws (Prism C4,
- // Compressor Renaissance, Quell NS1, Gemini splice, LYNX Tune Waves Tune, Facet PuigTec) and a note repeat (190ma)
- {
- auto& m16 = song.mixer[16].effects; // (after step 10's [13] … [17])
- m16.push_back (lynx::makeEffectSlot (lynx::EffectKind::horizon)); // [18]
- auto nebula = lynx::makeEffectSlot (lynx::EffectKind::nebula);
- nebula.params[(std::size_t) lynx::verbs::nebula::toneLaw] = 1.0f;
- m16.push_back (nebula); // [19]
- auto orbit = lynx::makeEffectSlot (lynx::EffectKind::orbit);
- orbit.params[(std::size_t) lynx::echosuite::orbit::smLaw] = 1.0f;
- orbit.params[(std::size_t) lynx::echosuite::orbit::voiceLaw] = 1.0f;
- m16.push_back (orbit); // [20]
- auto c4 = lynx::makeEffectSlot (lynx::EffectKind::prismMultiband);
- c4.params[(std::size_t) lynx::dyn::prism::c4Law] = lynx::dyn::prism::c4LawValue (false);
- m16.push_back (c4); // [21]
- auto ren = lynx::makeEffectSlot (lynx::EffectKind::compressor);
- ren.params[(std::size_t) lynx::compressorRenLaw] = 1.0f;
- m16.push_back (ren); // [22]
- auto ns1 = lynx::makeEffectSlot (lynx::EffectKind::quellDenoiser);
- ns1.params[(std::size_t) lynx::voicetools::quell::ns1Law] = 1.0f;
- m16.push_back (ns1); // [23]
- auto splice = lynx::makeEffectSlot (lynx::EffectKind::geminiDoubler);
- splice.params[(std::size_t) lynx::voicetools::gemini::spliceLaw] = 1.0f;
- m16.push_back (splice); // [24]
- auto tune = lynx::makeEffectSlot (lynx::EffectKind::lynxTune);
- tune.params[(std::size_t) lynx::lynxtune::wavesLaw] = 1.0f;
- m16.push_back (tune); // [25]
- auto puig = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
- puig.params[(std::size_t) lynx::facet::puigLawParam] = lynx::facet::puigLawValue (2);
- m16.push_back (puig); // [26]
- lynx::Note repeated;
- repeated.length = lynx::ppq;
- repeated.channel = 0;
- repeated.key = 60;
- repeated.repeat = 9;
- song.patterns[0].notes.push_back (repeated);
- }
- // rollup step 12 (round 190mu): round 190mm's Waves laws (Facet's Waves design law, Compressor's Vox / API-2500 /
- // RChannel EQ, Prism's C6 floating bands, Hush's Renaissance law, Low Lifter's bass law, Aether's Vitamin law,
- // Ridge's omni law), round 190mk's Multiband display SPEED and a zipped channel
- {
- auto& m16 = song.mixer[16].effects; // (after step 11's [18] … [26])
- auto req = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
- req.params[(std::size_t) lynx::facet::wavesLawParam] = 1.0f;
- req.params[(std::size_t) lynx::facet::wavesBandParam0] = lynx::facet::waveCodeValue (lynx::facet::WaveCode::reqBell);
- m16.push_back (req); // [27]
- auto vox = lynx::makeEffectSlot (lynx::EffectKind::compressor);
- vox.params[8] = 1.0f;
- vox.params[(std::size_t) lynx::compressorVoxLaw] = 1.0f;
- m16.push_back (vox); // [28]
- auto api = lynx::makeEffectSlot (lynx::EffectKind::compressor);
- api.params[(std::size_t) lynx::compressorApiLaw] = 1.0f;
- m16.push_back (api); // [29]
- auto rchannel = lynx::makeEffectSlot (lynx::EffectKind::compressor);
- rchannel.params[(std::size_t) lynx::compressorRenLaw] = 1.0f;
- rchannel.params[(std::size_t) lynx::compressorChannelLaw] = 1.0f;
- m16.push_back (rchannel); // [30]
- auto c6 = lynx::makeEffectSlot (lynx::EffectKind::prismMultiband);
- c6.params[(std::size_t) lynx::dyn::prism::c4Law] = lynx::dyn::prism::c4LawValue (false);
- c6.params[(std::size_t) lynx::dyn::prism::c6Param (1, lynx::dyn::prism::c6On)] = 1.0f;
- m16.push_back (c6); // [31]
- auto rdeesser = lynx::makeEffectSlot (lynx::EffectKind::hushDeEsser);
- rdeesser.params[(std::size_t) lynx::mixsuite::hush::essLaw] = 1.0f;
- m16.push_back (rdeesser); // [32]
- auto maxx = lynx::makeEffectSlot (lynx::EffectKind::flLowLifter);
- maxx.params[(std::size_t) lynx::lowlifter::bassLaw] = 1.0f;
- m16.push_back (maxx); // [33]
- auto vitamin = lynx::makeEffectSlot (lynx::EffectKind::aether);
- vitamin.params[(std::size_t) lynx::mixsuite::aether::vitLaw] = 1.0f;
- m16.push_back (vitamin); // [34]
- auto scheps = lynx::makeEffectSlot (lynx::EffectKind::ridgeStrip);
- scheps.params[(std::size_t) lynx::mixsuite::ridge::omniLaw] = 1.0f;
- m16.push_back (scheps); // [35]
- auto multiband = lynx::makeEffectSlot (lynx::EffectKind::fruityMultiband);
- multiband.displayView = 100;
- m16.push_back (multiband); // [36]
- song.channels[0].zipped = true;
- }
- // rollup step 13 (round 190na): round 190mt's Waves laws (Facet's API-560 law, Compressor's RVox type and gate,
- // Ridge's G-Channel EQ law) and round 190mv's FL Current mixer track (round 190mr's window layout: below)
- int currentAt = -1;
- {
- auto& m16 = song.mixer[16].effects; // (after step 12's [27] … [36])
- auto api560 = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
- api560.params[(std::size_t) lynx::facet::api560LawParam] = 1.0f;
- api560.params[(std::size_t) lynx::facet::api560GainParam0 + 3] = lynx::facet::api560GainValue (6.0);
- m16.push_back (api560); // [37]
- auto rch = lynx::makeEffectSlot (lynx::EffectKind::compressor);
- rch.params[(std::size_t) lynx::compressorRenLaw] = 1.0f;
- rch.params[(std::size_t) lynx::compressorRVoxType] = 1.0f;
- rch.params[(std::size_t) lynx::compressorRchGate] = 1.0f;
- m16.push_back (rch); // [38]
- auto sslG = lynx::makeEffectSlot (lynx::EffectKind::ridgeStrip);
- sslG.params[(std::size_t) lynx::mixsuite::ridge::gEqLaw] = 1.0f;
- sslG.params[(std::size_t) lynx::mixsuite::ridge::gHfKHz] = 0.5f;
- m16.push_back (sslG); // [39]
- currentAt = lynx::mixerops::addCurrentTrack (song);
- if (currentAt >= 0)
- song.mixer[(std::size_t) currentAt].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::facetEq));
- }
- // rollup step 14 (round 190nf): round 190nb's Kilohearts law on Effector, round 190mx's launched pattern clip that
- // plays its pattern's events (the grid's slot clip above plays pattern 1)
- {
- auto khs = lynx::makeEffectSlot (lynx::EffectKind::effector);
- khs.params[(std::size_t) lynx::khsdsp::lawParam] = lynx::khsdsp::lawValue (lynx::khsdsp::Law::resonator);
- khs.params[(std::size_t) lynx::khsdsp::valueParam] = 0.5f;
- song.mixer[16].effects.push_back (khs); // [40]
- lynx::PatternEvents knob;
- knob.target.kind = lynx::AutomationTargetKind::channelVolume;
- knob.target.index = 0;
- knob.events = { { 0, 0.2f }, { lynx::ppq, 0.8f } };
- song.patterns[0].events.push_back (knob);
- }
- // round 190qf (PR #260): a copy for 0.1.30 / 0.1.28 keeps 10 effect slots per insert (those releases hold 10) and
- // leaves the rest out. The effects [10] … [40] this test lays on insert 16 move to inserts of their own, 10 each
- // (added at the end), so every law above still reaches the copy; m16[k] below finds effect k where it went.
- std::vector<int> spread16;
- for (std::size_t from = 10; from < song.mixer[16].effects.size(); from += 10)
- {
- auto& added = song.mixer.emplace_back();
- added.name = "Insert " + std::to_string (song.mixer.size() - 1);
- const auto end = std::min (from + 10, song.mixer[16].effects.size());
- added.effects.assign (song.mixer[16].effects.begin() + (std::ptrdiff_t) from, song.mixer[16].effects.begin() + (std::ptrdiff_t) end);
- for (auto& fx : added.effects)
- fx.row = -1;
- spread16.push_back ((int) song.mixer.size() - 1);
- }
- if (song.mixer[16].effects.size() > 10)
- song.mixer[16].effects.resize (10);
- struct Spread16
- {
- const juce::var& root;
- const std::vector<int>& inserts;
- juce::var operator[] (int k) const
- {
- if (k < 10)
- return root["mixer"][16]["effects"][k];
- const auto chunk = (std::size_t) (k / 10 - 1);
- return chunk < inserts.size() ? root["mixer"][inserts[chunk]]["effects"][k % 10] : juce::var();
- }
- };
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.28");
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- const auto said = [©] (const char* start) {
- return std::any_of (copy.lost.begin(), copy.lost.end(), [start] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (start); });
- };
- const auto parsed = juce::JSON::parse (copy.json);
- const auto* channels = parsed["channels"].getArray();
- bool fmEmpty = false, notesCut = true, waveDone = false, wtEmpty = false, loopKnob = false;
- if (channels != nullptr)
- for (const auto& c : *channels)
- {
- if (c["name"].toString() == "FM")
- fmEmpty = c["instrument"].toString() == "sampler" && ! c.hasProperty ("modelParams");
- if (c["name"].toString() == "WT")
- wtEmpty = c["instrument"].toString() == "sampler" && ! c.hasProperty ("modelParams");
- if (c["name"].toString() == "Loop")
- loopKnob = std::abs ((double) c["samplerSettings"]["pitch"] - 5.0) < 1.0e-6 && ! c["samplerSettings"].hasProperty ("stretchPitch")
- && (! c["samplerSettings"]["warpModes"].isArray() || c["samplerSettings"]["warpModes"].size() <= 10);
- if (c["name"].toString() == "Piano")
- {
- juce::MemoryOutputStream bytes;
- if (juce::Base64::convertFromBase64 (bytes, c["pluginState"].toString()))
- {
- const auto* b = static_cast<const std::uint8_t*> (bytes.getData());
- if (const auto st = lynx::dw::parseState (std::vector<std::uint8_t> (b, b + bytes.getDataSize())))
- for (const auto& prog : st->programs)
- for (const auto& z : prog.zones)
- waveDone = waveDone || (z.loopMode == 2 && z.loopA == 44 && z.loopB == 200 && z.bits == 32);
- if (const auto doc = lynx::dw::readDoc (std::vector<std::uint8_t> (b, b + bytes.getDataSize())))
- for (const auto& n : doc->top)
- for (const auto& z : n.kids)
- for (const auto& r : z.kids)
- if (r.id == 0x1F7)
- waveDone = waveDone && r.body.size() == 40;
- }
- }
- }
- if (const auto* patterns = parsed["patterns"].getArray())
- for (const auto& pt : *patterns)
- if (const auto* notes = pt["notes"].getArray())
- for (const auto& n : *notes)
- notesCut = notesCut && n.size() <= 19;
- if (! copy.ok || ! back)
- rollup030Result = "ERROR copy " + why;
- else if (! fmEmpty || ! said ("Tetra is not in this release"))
- rollup030Result = "ERROR Tetra channel";
- else if (! waveDone)
- rollup030Result = "ERROR DirectWave short record";
- else if (! notesCut || ! said ("{0} note(s) lose their MPE curves"))
- rollup030Result = "ERROR note curves";
- else if (back->blocks.size() != 1 || back->blocks[0].start != 0 || ! said ("{0} muted Pattern Block(s)"))
- rollup030Result = "ERROR muted blocks";
- else if (std::none_of (back->playlist.begin(), back->playlist.end(), [] (const lynx::Clip& c) { return c.pitch == 12.0f; })
- || ! said ("{0} clip(s) transposed"))
- rollup030Result = "ERROR clip pitch";
- else if (copy.json.contains ("startMarker") || copy.json.contains ("clipScale") || ! said ("{0} clip slot(s) launch") || ! said ("Clip scales"))
- rollup030Result = "ERROR clip slots";
- else if (! said ("Voice Shift's Measured law") || ! said ("Ridge Strip's 4K Pink EQ") || ! said ("Hush De-esser's Allround mode")
- || parsed["mixer"][1]["effects"][0]["params"].size() > lynx::voiceshift::revision
- || parsed["mixer"][3]["effects"][0]["params"].size() > lynx::mixsuite::hush::timing)
- rollup030Result = "ERROR effects";
- else if (copy.json.contains ("mixSnapshots") || ! said ("Mix snapshots") || ! said ("Automation clip colours")
- || std::any_of (back->automations.begin(), back->automations.end(), [] (const lynx::Automation& a) { return a.colour != 0; }))
- rollup030Result = "ERROR view items";
- else if (! wtEmpty || ! said ("Helix is not in this release"))
- rollup030Result = "ERROR Helix channel";
- else if (! said ("Echoform's echo voicings") || ! said ("Epoch Verb, Atrium, Foil Plate and Halo") || ! said ("Lattice Mod plays")
- || ! said ("LuxeVerb's Space ducking")
- || parsed["mixer"][4]["effects"][0]["params"].size() > lynx::echosuite::echoform::revision
- || parsed["mixer"][5]["effects"][0]["params"].size() > lynx::verbs::halo::revision
- || parsed["mixer"][6]["effects"][0]["params"].size() > lynx::echosuite::lattice::revision
- || parsed["mixer"][7]["effects"][0]["params"].size() > lynx::luxeVerbSpaceDucking)
- rollup030Result = "ERROR step-3 effects";
- else if (! loopKnob || ! said ("Texture and Complex Pro play") || ! said ("Complex Pro and Texture transpositions") || ! said ("Warped samples do not follow"))
- rollup030Result = juce::String ("ERROR warp engines ") + (loopKnob ? "" : "knob ") + (said ("Texture and Complex Pro play") ? "" : "engines ")
- + (said ("Complex Pro and Texture transpositions") ? "" : "transpose ") + (said ("Warped samples do not follow") ? "" : "tempo");
- else if (copy.json.contains ("\"inactive\"") || ! said ("{0} deactivated clip slot(s)"))
- rollup030Result = "ERROR deactivated slots";
- else if (! said ("Facet EQ's automatic dynamic thresholds") || parsed["mixer"][8]["effects"][0]["params"].size() > lynx::facet::autoThresholdParam0)
- rollup030Result = "ERROR Facet automatic threshold";
- else if (! said ("MIDI Out channels and plugins' MIDI output") || ! said ("Automation of hosted CLAP and VST3 plugins"))
- rollup030Result = juce::String ("ERROR engine notes ") + (said ("MIDI Out channels") ? "" : "midi-out ") + (said ("Automation of hosted") ? "" : "timed");
- else if (copy.json.contains ("playlistTrackNest") || copy.json.contains ("displayView") || ! said ("{0} track(s) in nested Playlist folders")
- || ! said ("Fruity Limiter's CURVE view"))
- rollup030Result = "ERROR step-4 view items";
- else if (! said ("Hush De-esser's Single Vocal mode") || ! said ("Slide notes on FL's native generators"))
- rollup030Result = juce::String ("ERROR step-5 engine notes ") + (said ("Hush De-esser's Single Vocal") ? "" : "hush ") + (said ("Slide notes") ? "" : "slides");
- else if (! said ("The crossfader (Live's Crossfade Assign)") || ! said ("Live return tracks show") || ! said ("The Simple Controls tab's")
- || copy.json.contains ("\"crossfade") || copy.json.contains ("liveReturn") || copy.json.contains ("returnPre")
- || copy.json.contains ("smartControls") || copy.json.contains ("engineRev"))
- rollup030Result = "ERROR step-6 mixer items";
- else if (const auto nts = [&parsed] {
- juce::MemoryOutputStream bytes;
- std::vector<std::uint8_t> st;
- if (juce::Base64::convertFromBase64 (bytes, parsed["mixer"][14]["effects"][0]["state"].toString()))
- st.assign (static_cast<const std::uint8_t*> (bytes.getData()), static_cast<const std::uint8_t*> (bytes.getData()) + bytes.getDataSize());
- return st;
- }();
- ! said ("Newtone's detected key") || lynx::newtonefx::nativeVersionOf (nts) != 2 || ! lynx::newtonefx::parseNative (nts)
- || lynx::newtonefx::parseNative (nts)->pitches.size() != 1 || lynx::newtonefx::parseNative (nts)->pitches[0].curEnd != 24000)
- rollup030Result = "ERROR step-6 Newtone state";
- else if (! said ("The Peak Controller's LYNX LFO shapes") || ! said ("Crest Compressor's console law") || ! said ("Mixer lock states")
- || ! said ("{0} imported take lane(s)")
- || parsed["mixer"][15]["effects"][0]["params"].size() > lynx::peakshapes::extraShapeParam
- || parsed["mixer"][16]["effects"][0]["params"].size() > lynx::dyn::crest::busLaw
- || copy.json.contains ("lockState") || copy.json.contains ("playlistTakeLanes") || copy.json.contains ("recordOwnNotes"))
- rollup030Result = "ERROR step-7 items";
- else if (const Spread16 m16 { parsed, spread16 };
- ! said ("Crest Compressor's styles play their earlier laws") || ! said ("Crest Compressor's FET law")
- || ! said ("Ridge Strip's measured SSL 4K G / 4K E filters") || ! said ("Echoform's Timeless 3 line law")
- || ! said ("Lock states of effect slots and Playlist tracks") || copy.json.contains ("playlistTrackSoloLocks")
- || m16[1]["params"].size() > lynx::dyn::crest::busLaw || m16[2]["params"].size() > lynx::dyn::crest::busLaw
- || m16[3]["params"].size() > lynx::mixsuite::ridge::k4Pink || m16[4]["params"].size() > lynx::echosuite::echoform::revision)
- rollup030Result = "ERROR step-8 items";
- else if (const Spread16 m16 { parsed, spread16 };
- ! said ("Ember's Saturn styles") || ! said ("Prism Multiband's Pro-MB band law") || ! said ("The Limiter's L2 law")
- || ! said ("Glow Leveler's cell law") || ! said ("Reeverb 2's measured direct sound") || ! said ("Quell's zero law")
- || ! said ("Facet EQ's all-pass dispersion") || ! said ("Echoform's H-Delay loop law")
- || ! said ("Notes on audio clip channels play cut") || copy.json.contains ("clipNotes190lq") || copy.json.contains ("clipNoteLegacy")
- || m16[5]["params"].size() > lynx::mixsuite::ember::revision || m16[6]["params"].size() > lynx::dyn::prism::revision
- || m16[7]["params"].size() > lynx::limiterlaw::lawParam || m16[8]["params"].size() > lynx::mixsuite::glow::cellLaw
- || m16[9]["params"].size() > lynx::reeverb2DirectLaw || m16[10]["params"].size() > lynx::voicetools::quell::zeroLaw
- || m16[11]["params"].size() > lynx::facet::autoThresholdParam0 || m16[12]["params"].size() > lynx::echosuite::echoform::revision)
- rollup030Result = "ERROR step-9 items";
- else if (const Spread16 m16 { parsed, spread16 };
- ! said ("Apex Limiter's styles") || ! said ("Sentry Gate plays its earlier") || ! said ("LuxeVerb's Space engine plays")
- || ! said ("Echoform's ValhallaDelay loop law") || ! said ("Spiral Echo's Measured loop") || ! said ("{0} scene follow action")
- || m16[13]["params"].size() > lynx::apex::pRevision || m16[14]["params"].size() > (int) lynx::dyn::sentry::revision
- || m16[15]["params"].size() > lynx::luxeVerbSpaceDucking || m16[16]["params"].size() > lynx::echosuite::echoform::revision
- || m16[17]["params"].size() > (int) lynx::echosuite::spiral::rateLaw || parsed["clipGrid"]["scenes"][0].hasProperty ("follow"))
- rollup030Result = "ERROR step-10 items";
- else if (const Spread16 m16 { parsed, spread16 };
- ! said ("Horizon plays its earlier") || ! said ("Nebula's classic modes") || ! said ("Orbit plays its own voices")
- || ! said ("Prism Multiband's C4 law") || ! said ("Compressor's Renaissance law") || ! said ("Quell's NS1 law")
- || ! said ("Gemini Doubler's splice law") || ! said ("LYNX Tune's Waves Tune") || ! said ("Facet EQ's PuigTec law")
- || ! said ("{0} note(s) play once instead of repeating")
- || m16[18]["params"].size() > lynx::verbs::horizon::revision || m16[19]["params"].size() > lynx::verbs::nebula::toneLaw
- || m16[20]["params"].size() > (int) lynx::echosuite::orbit::smLaw || m16[21]["params"].size() > (int) lynx::dyn::prism::revision
- || m16[22]["params"].size() > lynx::compressorRenLaw || m16[23]["params"].size() > (int) lynx::voicetools::quell::zeroLaw
- || m16[24]["params"].size() > (int) lynx::voicetools::gemini::spliceLaw || m16[25]["params"].size() > (int) lynx::lynxtune::wavesLaw
- || m16[26]["params"].size() > lynx::facet::autoThresholdParam0)
- rollup030Result = "ERROR step-11 items";
- else if (const Spread16 m16 { parsed, spread16 };
- ! said ("Facet EQ's Waves design law") || ! said ("Compressor's Vox law") || ! said ("Compressor's bus law")
- || ! said ("Compressor's channel EQ") || ! said ("Prism Multiband's floating bands") || ! said ("Hush De-esser's Renaissance law")
- || ! said ("Low Lifter's bass law") || ! said ("Aether's Vitamin law") || ! said ("Ridge Strip's omni law")
- || ! said ("Fruity Multiband Compressor's display SPEED") || ! said ("{0} zipped channel(s)")
- || m16[27]["params"].size() > lynx::facet::autoThresholdParam0 || m16[28]["params"].size() > lynx::compressorRenLaw
- || m16[29]["params"].size() > lynx::compressorRenLaw || m16[30]["params"].size() > lynx::compressorRenLaw
- || m16[31]["params"].size() > (int) lynx::dyn::prism::revision || m16[32]["params"].size() > (int) lynx::mixsuite::hush::timing
- || m16[33]["params"].size() > (int) lynx::lowlifter::bassLaw || m16[34]["params"].size() > (int) lynx::mixsuite::aether::vitLaw
- || m16[35]["params"].size() > (int) lynx::mixsuite::ridge::k4Pink || m16[36].hasProperty ("displayView")
- || copy.json.contains ("\"zipped\""))
- rollup030Result = "ERROR step-12 items";
- else if (const Spread16 m16 { parsed, spread16 };
- ! said ("Facet EQ's API-560 law") || ! said ("Compressor's RVox type") || ! said ("Compressor's gate")
- || ! said ("Ridge Strip's G-Channel EQ law") || ! said ("The Current mixer track shows as an ordinary insert")
- || m16[37]["params"].size() > lynx::facet::autoThresholdParam0 || m16[38]["params"].size() > lynx::compressorRenLaw
- || m16[39]["params"].size() > (int) lynx::mixsuite::ridge::k4Pink || currentAt < 0
- || parsed["mixer"][currentAt].hasProperty ("current") || parsed["mixer"][currentAt]["effects"].size() != 1)
- rollup030Result = "ERROR step-13 items";
- else if (const auto laid = lynx::olderlynx::forRelease (lynx::ProjectFile::withWindowLayout (lynx::ProjectFile::toJson (lynx::Song::makeDefault()),
- { 0, "rollup step 13" }), "0.1.28");
- ! laid.ok || laid.json.contains ("windowLayout")
- || std::none_of (laid.lost.begin(), laid.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith ("The window layout saved"); }))
- rollup030Result = "ERROR step-13 window layout";
- else if (const Spread16 m16 { parsed, spread16 };
- ! said ("Effector's Kilohearts laws") || ! said ("Launched pattern clips play without their pattern's events")
- || m16[40]["params"].size() > lynx::khsdsp::lawParam || parsed["patterns"][0]["events"].size() != 1)
- rollup030Result = juce::String ("ERROR step-14 items (") + (said ("Effector's Kilohearts laws") ? "" : "no Kilohearts line, ")
- + (said ("Launched pattern clips play without their pattern's events") ? "" : "no launched-clip line, ")
- + "Effector params " + juce::String (m16[40]["params"].size()) + ", events " + juce::String (parsed["patterns"][0]["events"].size()) + ")";
- else if (const auto plain = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.28");
- ! plain.ok || std::any_of (plain.lost.begin(), plain.lost.end(), [] (const lynx::olderlynx::Loss& l) {
- const auto t = juce::String (l.text);
- return t.startsWith ("Tetra") || t.contains ("MPE") || t.contains ("Pattern Block") || t.contains ("Voice Shift")
- || t.contains ("Ridge") || t.contains ("Hush") || t.startsWith ("Automation clip colours") || t.startsWith ("Mix snapshots")
- || t.startsWith ("Helix") || t.contains ("Echoform") || t.contains ("Halo") || t.contains ("Lattice") || t.contains ("LuxeVerb")
- || t.contains ("Texture") || t.contains ("Beats'") || t.startsWith ("Warped") || t.contains ("deactivated")
- || t.contains ("Facet") || t.contains ("MIDI Out") || t.contains ("hosted CLAP") || t.contains ("nested Playlist")
- || t.contains ("CURVE") || t.startsWith ("Slide notes") || t.contains ("crossfader") || t.contains ("return tracks")
- || t.contains ("Controls tab") || t.startsWith ("Harmor") || t.startsWith ("Newtone")
- || t.contains ("Peak Controller") || t.contains ("console law") || t.startsWith ("Mixer lock") || t.contains ("take lane")
- || t.contains ("Crest") || t.startsWith ("Lock states") || t.startsWith ("Ember") || t.startsWith ("Prism")
- || t.contains ("L2 law") || t.startsWith ("Glow") || t.startsWith ("Reeverb 2") || t.startsWith ("Quell")
- || t.contains ("audio clip channels") || t.startsWith ("Apex") || t.startsWith ("Sentry") || t.startsWith ("Spiral")
- || t.contains ("scene follow") || t.startsWith ("Horizon") || t.startsWith ("Nebula") || t.startsWith ("Orbit")
- || t.startsWith ("Compressor's") || t.startsWith ("Gemini") || t.startsWith ("LYNX Tune") || t.contains ("Repeat")
- || t.startsWith ("Low Lifter") || t.startsWith ("Aether") || t.startsWith ("Ridge Strip's omni") || t.startsWith ("Hush De-esser's Renaissance")
- || t.startsWith ("Fruity Multiband") || t.contains ("zipped") || t.contains ("Current mixer track") || t.contains ("window layout")
- || t.startsWith ("Effector's Kilohearts") || t.startsWith ("Launched pattern clips");
- }))
- rollup030Result = "ERROR a plain project reports a loss it does not have";
- }
- // rollup 0.1.31 step 1 (round 190no): File › "Save a copy for an older LYNX" for 0.1.30 drops or converts what the
- // 0.1.31 rounds save (190ni LYNX Model, 190nh Kilohearts part-2 laws, 190ne track clips, 190nc Solo / Cue); round
- // 190nb's laws (0.1.30 has them) stay; the copy for 0.1.28 runs this step first; a plain project loses nothing
- juce::String rollup031Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef model;
- model.name = "Bars";
- model.instrument = lynx::InstrumentKind::lynxModel;
- model.modelParams = { 0.0f, 0.5f, 0.3f };
- song.channels.push_back (model);
- auto comb = lynx::makeEffectSlot (lynx::EffectKind::effector);
- comb.params[(std::size_t) lynx::khsdsp::lawParam] = lynx::khsdsp::lawValue (lynx::khsdsp::Law::comb);
- comb.params[(std::size_t) lynx::khsdsp::valueParam] = 0.4f;
- auto resonator = lynx::makeEffectSlot (lynx::EffectKind::effector);
- resonator.params[(std::size_t) lynx::khsdsp::lawParam] = lynx::khsdsp::lawValue (lynx::khsdsp::Law::resonator);
- resonator.params[(std::size_t) lynx::khsdsp::valueParam] = 0.5f;
- song.mixer[3].effects.push_back (comb); // [0]
- song.mixer[3].effects.push_back (resonator); // [1]
- song.patterns[0].trackClip = true;
- if (song.playlistTracks.empty())
- song.playlistTracks.resize (1);
- song.playlistTracks[0].ownClips = true;
- lynx::launcher::ensureGrid (song);
- song.clipGrid->cue.cueMode = true;
- song.clipGrid->cue.out = 2;
- song.mixer[2].cue = true;
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- const auto older = lynx::olderlynx::forRelease (song, "0.1.28");
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- const auto count = [] (const lynx::olderlynx::Copy& c, const char* start) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [start] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (start); });
- };
- const auto parsed = juce::JSON::parse (copy.json);
- const auto& fx = parsed["mixer"][3]["effects"];
- juce::String bars;
- if (const auto* channels = parsed["channels"].getArray())
- for (const auto& c : *channels)
- if (c["name"].toString() == "Bars")
- bars = c["instrument"].toString() + (c.hasProperty ("modelParams") ? "+params" : "");
- const char* lines[] = { "LYNX Model is not in this release", "Effector's newer Kilohearts laws", "{0} track clip(s) show as ordinary patterns",
- "Live's Solo/Cue settings" };
- if (! copy.ok || ! back)
- rollup031Result = "ERROR copy " + copy.error + why;
- else if (! parsed["savedBy"].toString().equalsIgnoreCase ("0.1.30") || lynx::olderlynx::releases()[1] != "0.1.30") // (rollup 0.1.32: 0.1.31 is [0])
- rollup031Result = "ERROR release list / stamp";
- else if (bars != "sampler")
- rollup031Result = "ERROR LYNX Model channel: " + bars;
- else if (fx[0]["params"].size() > lynx::khsdsp::lawParam || fx[1]["params"].size() <= lynx::khsdsp::lawParam
- || lynx::khsdsp::lawOf ((float) (double) fx[1]["params"][lynx::khsdsp::lawParam]) != lynx::khsdsp::Law::resonator)
- rollup031Result = "ERROR Kilohearts laws (comb params " + juce::String (fx[0]["params"].size()) + ")";
- else if (copy.json.contains ("\"trackClip\"") || copy.json.contains ("playlistOwnClips") || parsed["clipGrid"].hasProperty ("cue")
- || parsed["mixer"][2].hasProperty ("cue"))
- rollup031Result = "ERROR 0.1.31 keys left in the copy";
- else if (std::any_of (std::begin (lines), std::end (lines), [&] (const char* l) { return count (copy, l) != 1 || count (older, l) != 1; }))
- rollup031Result = "ERROR loss lines (each once, in both copies)";
- else if (! older.ok || older.json.contains ("lynxmodel") || juce::JSON::parse (older.json)["mixer"][3]["effects"][1]["params"].size() > lynx::khsdsp::lawParam
- || count (older, "Effector's Kilohearts laws") != 1)
- rollup031Result = "ERROR copy for 0.1.28 after the 0.1.30 step";
- else if (const auto plain = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.30"); ! plain.ok || ! plain.lost.empty())
- rollup031Result = "ERROR a plain project loses something in the copy for 0.1.30";
- }
- // rollup 0.1.31 step 2 (round 190nv): what the step's rounds save needs nothing in the copies for 0.1.30 / 0.1.28 —
- // 190ns's Created date (#231, ProjectInfo.created: 0.1.30 reads it), its linked audio track ⇄ insert names and
- // colours (#235: the same mixerTrack / name / colour fields; only the syncing is new), 190nq's "(target deleted)"
- // automation names (#226: text) — and 190np's onboarding, 190nq's ruler / fade switches and 190nr's installed-files
- // list live in the profile, never in a project. Checked: the copy keeps them, reports no loss and has every key of
- // the project (the copy keeps every key the project has, none dropped or renamed)
- juce::String rollup031s2Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- song.info.created = 1763600000.0;
- if (song.mixer.size() < 3)
- song.mixer.resize (3);
- song.playlistTracks.resize (std::max<std::size_t> (2, song.playlistTracks.size()));
- auto& vox = song.playlistTracks[1];
- vox.mode = lynx::PlaylistTrackMode::audio;
- vox.mixerTrack = 2;
- vox.name = song.mixer[2].name = "Vox";
- vox.colour = song.mixer[2].colour = 0xff8040c0;
- song.patterns[0].name = lynx::mixerops::targetDeletedName ("BEAT BUS - Send level");
- const auto keysOf = [] (const juce::var& v) {
- std::set<juce::String> keys;
- std::function<void (const juce::var&, const juce::String&)> walk = [&] (const juce::var& x, const juce::String& path) {
- if (auto* o = x.getDynamicObject())
- for (const auto& p : o->getProperties())
- {
- if (path.isEmpty() && (p.name.toString() == "savedBy" || p.name.toString() == "copiedFrom")) // (the copy's stamp)
- continue;
- keys.insert (path + "/" + p.name.toString());
- walk (p.value, path + "/" + p.name.toString());
- }
- else if (auto* a = x.getArray())
- for (const auto& e : *a)
- walk (e, path + "[]");
- };
- walk (v, {});
- return keys;
- };
- const auto original = juce::JSON::parse (lynx::ProjectFile::toJson (song));
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- const auto copy = lynx::olderlynx::forRelease (song, release);
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- if (! copy.ok || ! back)
- rollup031s2Result = juce::String ("ERROR copy ") + release + " " + copy.error + why;
- else if (back->info.created != song.info.created)
- rollup031s2Result = juce::String ("ERROR Created date in the copy for ") + release;
- else if (back->playlistTracks.size() < 2 || back->playlistTracks[1].mixerTrack != 2 || back->playlistTracks[1].colour != vox.colour
- || back->playlistTracks[1].name != "Vox" || back->mixer[2].colour != vox.colour || back->mixer[2].name != "Vox")
- rollup031s2Result = juce::String ("ERROR linked track / insert in the copy for ") + release;
- else if (back->patterns[0].name != song.patterns[0].name)
- rollup031s2Result = juce::String ("ERROR automation name in the copy for ") + release;
- else if (! copy.lost.empty())
- rollup031s2Result = juce::String ("ERROR loss lines in the copy for ") + release + ": " + juce::String (copy.lost.front().text);
- else if (const auto kept = keysOf (juce::JSON::parse (copy.json)), all = keysOf (original); juce::String (release) == "0.1.30" && kept != all)
- {
- juce::StringArray diff;
- for (const auto& k : all)
- if (kept.count (k) == 0)
- diff.add ("-" + k);
- for (const auto& k : kept)
- if (all.count (k) == 0)
- diff.add ("+" + k);
- rollup031s2Result = "ERROR keys differ in the copy for 0.1.30: " + diff.joinIntoString (" ").substring (0, 300);
- }
- if (rollup031s2Result != "OK")
- break;
- }
- }
- // rollup 0.1.31 step 3 (round 190ny): the copies for 0.1.30 / 0.1.28 drop what this step's rounds save and nothing
- // else — 190nu's key markers' keys ("markerKeys" beside each pattern's marker list; the markers and their names
- // stay) and 190nw's tracker view settings (root "tracker"; the notes are the patterns' own) — each with its one
- // line, in both copies; 190nx (offline switch, --demo) and 190nt (site) save nothing in a project
- juce::String rollup031s3Result = "OK";
- {
- using namespace lynx::keyregions;
- auto song = lynx::Song::makeDefault();
- auto& p = song.patterns[(std::size_t) song.currentPattern];
- p.markers.push_back ({ 2 * lynx::ppq, "Verse", 0, 4 });
- addKeyMarker (p, 0, { State::key, { 9, flScaleNamed ("Minor Harmonic") } });
- addKeyMarker (p, 4 * lynx::ppq, { State::key, { 2, flScaleNamed ("Other Dorian") } });
- for (int c = 0; c < 2; ++c)
- song.channels.emplace_back().name = "S3-" + std::to_string (c);
- lynx::uids::normalize (song);
- song.tracker.rowsPerBeat = 6;
- song.tracker.showPan = true;
- song.tracker.groups.push_back ({ "Pair", { song.channels[song.channels.size() - 2].uid, song.channels.back().uid } });
- const auto keysOf = [] (const juce::var& v) {
- std::set<juce::String> keys;
- std::function<void (const juce::var&, const juce::String&)> walk = [&] (const juce::var& x, const juce::String& path) {
- if (auto* o = x.getDynamicObject())
- for (const auto& prop : o->getProperties())
- {
- if (path.isEmpty() && (prop.name.toString() == "savedBy" || prop.name.toString() == "copiedFrom")) // (the copy's stamp)
- continue;
- keys.insert (path + "/" + prop.name.toString());
- walk (prop.value, path + "/" + prop.name.toString());
- }
- else if (auto* a = x.getArray())
- for (const auto& e : *a)
- walk (e, path + "[]");
- };
- walk (v, {});
- return keys;
- };
- const auto json = lynx::ProjectFile::toJson (song);
- auto expected = keysOf (juce::JSON::parse (json));
- for (auto it = expected.begin(); it != expected.end();)
- it = it->startsWith ("/tracker") || it->contains ("/markerKeys") ? expected.erase (it) : std::next (it);
- const char* lines[] = { "key marker(s) in the Piano roll", "The tracker's view settings" };
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- const auto copy = lynx::olderlynx::forRelease (song, release);
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- const auto count = [©] (const char* l) {
- return (int) std::count_if (copy.lost.begin(), copy.lost.end(), [l] (const lynx::olderlynx::Loss& x) { return juce::String (x.text).contains (l); });
- };
- if (! copy.ok || ! back)
- rollup031s3Result = juce::String ("ERROR copy ") + release + " " + copy.error + why;
- else if (copy.json.contains ("markerKeys") || copy.json.contains ("\"tracker\""))
- rollup031s3Result = juce::String ("ERROR 0.1.31 keys left in the copy for ") + release;
- else if (std::any_of (std::begin (lines), std::end (lines), [&] (const char* l) { return count (l) != 1; }))
- rollup031s3Result = juce::String ("ERROR loss lines in the copy for ") + release + " (" + juce::String ((int) copy.lost.size()) + ")";
- else if (const auto& bp = back->patterns[(std::size_t) back->currentPattern];
- bp.markers.size() != p.markers.size() || bp.notes != p.notes
- || std::any_of (bp.markers.begin(), bp.markers.end(), [] (const lynx::Marker& m) { return keyOf (m).has_value(); }))
- rollup031s3Result = juce::String ("ERROR markers / notes in the copy for ") + release;
- else if (juce::String (release) == "0.1.30" && (copy.lost.size() != 2 || keysOf (juce::JSON::parse (copy.json)) != expected))
- rollup031s3Result = "ERROR the copy for 0.1.30 drops more than the two (" + juce::String ((int) copy.lost.size()) + " lines)";
- if (rollup031s3Result != "OK")
- break;
- }
- }
- // round chord2_190nu (discussion #105): the Piano roll's key markers come back from a project (their keys beside the
- // marker list, so older releases keep the markers), the copy for 0.1.30 / 0.1.28 drops the keys with a line, and
- // a MIDI file carries them as key signatures (with the exact scale in a "Key: ..." marker meta event)
- juce::String keys190nuResult = "OK";
- {
- using namespace lynx::keyregions;
- auto song = lynx::Song::makeDefault();
- auto& p = song.patterns[(std::size_t) song.currentPattern];
- const auto bar = 4 * lynx::ppq;
- const lynx::projectkey::Key dorian { 2, flScaleNamed ("Other Dorian") }, harmonic { 0, flScaleNamed ("Minor Harmonic") };
- p.markers.push_back ({ bar / 2, "Verse", 0, 4 });
- addKeyMarker (p, 0, { State::key, dorian });
- addKeyMarker (p, bar, { State::key, harmonic });
- addKeyMarker (p, 2 * bar, { State::none, {} });
- lynx::Note n;
- n.key = 62;
- n.length = lynx::ppq;
- p.notes.push_back (n);
- p.lengthTicks = 3 * bar; // (a MIDI file gets the key changes within the pattern's length)
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- bool oldShape = true; // (every marker array as 0.1.30 reads it: 4 or 5 items)
- const auto parsedJson = juce::JSON::parse (json); // (kept: operator[] refers into it)
- if (auto* patterns = parsedJson["patterns"].getArray())
- for (const auto& pv : *patterns)
- if (auto* ms = pv["markers"].getArray())
- for (const auto& m : *ms)
- oldShape = oldShape && m.isArray() && (m.size() == 4 || m.size() == 5);
- const auto for130 = lynx::olderlynx::forRelease (song, "0.1.30");
- const auto for128 = lynx::olderlynx::forRelease (song, "0.1.28");
- const auto copy130 = for130.ok ? lynx::ProjectFile::fromJson (for130.json, why) : std::optional<lynx::Song> {};
- const auto said = std::any_of (for130.lost.begin(), for130.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("key marker(s)"); });
- const auto file = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-keys190nu.mid");
- juce::String midiError;
- const auto saved = lynx::MidiFileIo::savePattern (song, song.currentPattern, file, midiError);
- const auto parsed = saved ? lynx::MidiFileIo::parseFile (file, midiError) : std::nullopt;
- const auto loaded = saved ? lynx::MidiFileIo::loadSong (file, midiError) : std::nullopt;
- file.deleteFile();
- const auto& bp = back ? back->patterns[(std::size_t) back->currentPattern] : p;
- if (! back || bp.markers != p.markers)
- keys190nuResult = "ERROR project round trip " + why;
- else if (! oldShape)
- keys190nuResult = "ERROR marker arrays an older release skips";
- else if (! copy130 || for130.json.contains ("markerKeys") || ! said || ! for128.ok || for128.json.contains ("markerKeys"))
- keys190nuResult = "ERROR copy for 0.1.30 / 0.1.28";
- else if (const auto& cp = copy130->patterns[(std::size_t) copy130->currentPattern];
- cp.markers.size() != 4 || cp.markers[0].name != "D Other Dorian" || cp.markers[0].action != lynx::Marker::keyScale || keyOf (cp.markers[0]))
- keys190nuResult = "ERROR the copy's markers";
- else if (! parsed || parsed->keys.size() != 2 || parsed->keys[0].tick != 0 || parsed->keys[0].flScale != dorian.flScale || parsed->keys[0].root != 2
- || parsed->keys[1].tick != bar || parsed->keys[1].flScale != harmonic.flScale)
- keys190nuResult = "ERROR MIDI key signatures " + midiError;
- else if (! loaded || ! (lynx::projectkey::get (*loaded) == dorian) || ! (stateAt (loaded->patterns[0], bar).value == harmonic))
- keys190nuResult = "ERROR MIDI file opened as a project " + midiError;
- }
- // round 190oc: the copy for 0.1.30 cuts Helix round 4's block (revision 4 back to 3; a loss line only when a unison
- // or reverse grains play) and the Kilohearts Nonlinear Filter law (code 49, its own loss line); the copy for 0.1.28
- // still turns Helix into an empty Sampler after it; a Helix channel of revision 4 at the block's defaults loses nothing
- juce::String helix4khs190ocResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- if (song.mixer.size() < 3)
- song.mixer.resize (3);
- lynx::ChannelDef plain, swarm;
- plain.name = "Plain", swarm.name = "Swarm";
- plain.instrument = swarm.instrument = lynx::InstrumentKind::helix;
- const auto d = lynx::helixDefaults();
- plain.modelParams = swarm.modelParams = d;
- swarm.modelParams[(std::size_t) (lynx::wt::ext4Base + lynx::wt::ext4::grainUnison)] = 5.0f;
- swarm.modelParams[(std::size_t) (lynx::wt::ext4Base + lynx::wt::ext4::grainReverse)] = 0.4f;
- song.channels.push_back (plain);
- song.channels.push_back (swarm);
- auto nlf = lynx::makeEffectSlot (lynx::EffectKind::effector);
- nlf.params[(std::size_t) lynx::khsdsp::lawParam] = lynx::khsdsp::lawValue (lynx::khsdsp::Law::nonlinearFilter);
- nlf.params[(std::size_t) lynx::khsdsp::valueParam + 2] = 0.5f;
- song.mixer[2].effects.push_back (nlf);
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- const auto older = lynx::olderlynx::forRelease (song, "0.1.28");
- const auto count = [] (const lynx::olderlynx::Copy& c, const char* start) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [start] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (start); });
- };
- const auto parsed = juce::JSON::parse (copy.json);
- int helixCut = 0, revisions3 = 0;
- juce::String lossDetail;
- for (const auto& l : copy.lost)
- if (juce::String (l.text).startsWith ("Helix's unison"))
- lossDetail = l.detail;
- if (const auto* channels = parsed["channels"].getArray())
- for (const auto& c : *channels)
- if (c["instrument"].toString() == "helix")
- {
- auto values = juce::StringArray::fromTokens (c["modelParams"].toString(), " ", "");
- values.removeEmptyStrings();
- helixCut += values.size() == lynx::wt::ext4Base ? 1 : 0;
- revisions3 += values.size() > lynx::wt::extBase && values[lynx::wt::extBase].getFloatValue() == 3.0f ? 1 : 0;
- }
- if (! copy.ok || ! older.ok)
- helix4khs190ocResult = "ERROR copy " + copy.error + older.error;
- else if (helixCut != 2 || revisions3 != 2)
- helix4khs190ocResult = "ERROR Helix block in the copy (cut " + juce::String (helixCut) + ", revision 3 " + juce::String (revisions3) + ")";
- else if (count (copy, "Helix's unison") != 1 || ! lossDetail.contains ("Swarm") || lossDetail.contains ("Plain"))
- helix4khs190ocResult = "ERROR Helix loss line: " + lossDetail;
- else if (parsed["mixer"][2]["effects"][0]["params"].size() > lynx::khsdsp::lawParam || count (copy, "Effector's Kilohearts Nonlinear Filter") != 1
- || count (copy, "Effector's newer Kilohearts laws") != 0)
- helix4khs190ocResult = "ERROR Nonlinear Filter law in the copy";
- else if (older.json.contains ("\"helix\"") || count (older, "Helix is not in this release") != 1)
- helix4khs190ocResult = "ERROR copy for 0.1.28 after the 0.1.30 step";
- }
- // rollup 0.1.31 step 4 (round 190oi): the copies for 0.1.30 / 0.1.28 of a project with everything step 4 brought:
- // 190oc's Helix round-4 block and Effector law 49 (each one line), 190od's slide of the note properties (#236: the
- // key goes; one line counting only slide notes that move something), 190od's #239 colours and icons by name and a
- // #238 "no colour" channel (ordinary project data: kept as they are), 190nz's clipboard (no project data), 190oa's
- // main (monitor) volume and Gross Beat's scratch offset (merge 4; its window places are not in a copy: the copy is
- // the song's JSON without the window layout). The 0.1.30 copy keeps every key but "slideNoteProps" and "mainVolume";
- // a project whose slide notes move nothing, or saved before #236, gets no slide line
- juce::String rollup031s4Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- if (song.mixer.size() < 3)
- song.mixer.resize (3);
- song.slideNoteProps = true;
- lynx::ChannelDef bass, lead, swarm, plain;
- bass.name = "Bass 808", lead.name = "Lead", swarm.name = "Swarm", plain.name = "No colour";
- swarm.instrument = lynx::InstrumentKind::helix;
- swarm.modelParams = lynx::helixDefaults();
- swarm.modelParams[(std::size_t) (lynx::wt::ext4Base + lynx::wt::ext4::specUnison)] = 4.0f;
- for (auto* c : { &bass, &lead, &swarm, &plain })
- song.channels.push_back (*c);
- const int bassIndex = (int) song.channels.size() - 4, leadIndex = bassIndex + 1;
- auto nlf = lynx::makeEffectSlot (lynx::EffectKind::effector);
- nlf.params[(std::size_t) lynx::khsdsp::lawParam] = lynx::khsdsp::lawValue (lynx::khsdsp::Law::nonlinearFilter);
- song.mixer[2].effects.push_back (nlf);
- // merge 4 (190oa): the toolbar's main (monitor) volume off 0 dB and Gross Beat's scratch offset set (DF-21, DP-8)
- song.mainVolume = 0.5f;
- auto gross = lynx::makeEffectSlot (lynx::EffectKind::grossBeat);
- gross.params[8] = 0.25f;
- song.mixer[2].effects.push_back (gross);
- lynx::autolook::Rules rules;
- rules.on = true;
- rules.list.push_back ({ "bass", lynx::autolook::Match::contains, 0xFF2266AAu, 7, lynx::autolook::everything });
- const auto coloured = lynx::autolook::applyAll (song, rules);
- auto& p = song.patterns[(std::size_t) song.currentPattern];
- const auto note = [] (int channel, juce::int64 start, int key, float velocity, float pan, bool slide) {
- lynx::Note n;
- n.channel = channel, n.start = start, n.length = lynx::ppq, n.key = key, n.velocity = velocity, n.pan = pan, n.slide = slide;
- return n;
- };
- p.notes.push_back (note (bassIndex, 0, 36, 0.78f, 0.0f, false));
- p.notes.push_back (note (bassIndex, lynx::ppq / 2, 43, 0.3f, 0.0f, true)); // moves the velocity
- p.notes.push_back (note (bassIndex, lynx::ppq, 41, 0.78f, -0.5f, true)); // moves the pan
- p.notes.push_back (note (leadIndex, 0, 60, 0.78f, 0.0f, false));
- p.notes.push_back (note (leadIndex, lynx::ppq / 2, 64, 0.78f, 0.0f, true)); // pitch only: sounds the same in 0.1.30
- p.sortNotes(); // (the order a project reads back in)
- lynx::uids::normalize (song);
- const auto keysOf = [] (const juce::var& v) {
- std::set<juce::String> keys;
- std::function<void (const juce::var&, const juce::String&)> walk = [&] (const juce::var& x, const juce::String& path) {
- if (auto* o = x.getDynamicObject())
- for (const auto& prop : o->getProperties())
- {
- if (path.isEmpty() && (prop.name.toString() == "savedBy" || prop.name.toString() == "copiedFrom"))
- continue;
- keys.insert (path + "/" + prop.name.toString());
- walk (prop.value, path + "/" + prop.name.toString());
- }
- else if (auto* a = x.getArray())
- for (const auto& e : *a)
- walk (e, path + "[]");
- };
- walk (v, {});
- return keys;
- };
- auto expected = keysOf (juce::JSON::parse (lynx::ProjectFile::toJson (song)));
- const auto hadKey = expected.erase ("/slideNoteProps") == 1 && expected.erase ("/mainVolume") == 1;
- const auto countOf = [] (const lynx::olderlynx::Copy& c, const char* start) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [start] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (start); });
- };
- const char* slideLine = "{0} slide note(s) move only the pitch";
- if (coloured != 1 || ! hadKey)
- rollup031s4Result = "ERROR set-up (coloured " + juce::String (coloured) + ")";
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (rollup031s4Result != "OK")
- break;
- const auto copy = lynx::olderlynx::forRelease (song, release);
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- juce::String slideDetail;
- for (const auto& l : copy.lost)
- if (juce::String (l.text).startsWith (slideLine))
- slideDetail = l.detail;
- const auto is130 = juce::String (release) == "0.1.30";
- if (! copy.ok || ! back)
- rollup031s4Result = juce::String ("ERROR copy ") + release + " " + copy.error + why;
- else if (copy.json.contains ("slideNoteProps") || back->slideNoteProps)
- rollup031s4Result = juce::String ("ERROR slideNoteProps left in the copy for ") + release;
- else if (countOf (copy, slideLine) != 1 || slideDetail != "2")
- rollup031s4Result = juce::String ("ERROR the slide line in the copy for ") + release + " (" + slideDetail + ")";
- else if (countOf (copy, "Effector's Kilohearts Nonlinear Filter") != 1 || (is130 && countOf (copy, "Helix's unison") != 1)
- || (! is130 && countOf (copy, "Helix is not in this release") != 1))
- rollup031s4Result = juce::String ("ERROR 190oc's lines in the copy for ") + release;
- else if (countOf (copy, "The main (monitor) volume") != 1 || countOf (copy, "Gross Beat's scratch offset") != 1
- || copy.json.contains ("mainVolume") || juce::JSON::parse (copy.json)["mixer"][2]["effects"][1]["params"].size() != 8)
- rollup031s4Result = juce::String ("ERROR 190oa's main volume / Gross Beat offset in the copy for ") + release;
- else if (back->patterns[(std::size_t) back->currentPattern].notes != p.notes)
- rollup031s4Result = juce::String ("ERROR the notes in the copy for ") + release;
- else if (back->channels[(std::size_t) bassIndex].colour != 0xFF2266AAu || back->channels[(std::size_t) bassIndex].icon != 7
- || back->channels[(std::size_t) bassIndex + 3].colour != 0 || back->channels[(std::size_t) leadIndex].colour != song.channels[(std::size_t) leadIndex].colour)
- rollup031s4Result = juce::String ("ERROR #239 / #238 colours in the copy for ") + release;
- else if (is130 && (copy.lost.size() != 5 || keysOf (juce::JSON::parse (copy.json)) != expected))
- rollup031s4Result = "ERROR the copy for 0.1.30 drops more than step 4's five (" + juce::String ((int) copy.lost.size()) + " lines)";
- }
- // slide notes that move nothing, and a project saved before #236 (key off): no slide line
- if (rollup031s4Result == "OK")
- {
- auto still = song;
- auto& sp = still.patterns[(std::size_t) still.currentPattern];
- sp.notes.erase (std::remove_if (sp.notes.begin(), sp.notes.end(), [bassIndex] (const lynx::Note& n) { return n.slide && n.channel == bassIndex; }), sp.notes.end());
- auto before = song;
- before.slideNoteProps = false;
- const auto a = lynx::olderlynx::forRelease (still, "0.1.30"), b = lynx::olderlynx::forRelease (before, "0.1.30");
- if (! a.ok || ! b.ok || countOf (a, slideLine) != 0 || countOf (b, slideLine) != 0)
- rollup031s4Result = "ERROR a slide line where nothing moves";
- }
- }
- // rollup 0.1.31 step 5 (round 190or): Save a copy for 0.1.30 / 0.1.28 with everything step 5 saves. 190ol's sections
- // (plain markers at their starts, one view line); 190ol's Simple time signature changes (ordinary signature markers
- // 0.1.30 has: kept, n/1 and 7/8 included); 190oh's wrapper GUI flags on a channel's plugin and an insert's plugin (keys
- // dropped, one view line naming both); gap190og's transport mappings (the Overdub key mapping dropped with a line,
- // the Play one kept); 190ob's tracker volume automation (a channel Volume multiplier clip: kept point for point);
- // 190on's stacked lanes and palette are profile settings and 190og's .flm export keeps no settings (the song is the
- // same after an export). The 0.1.30 copy keeps every key but the three dropped ones and has exactly three lines
- const auto autolinks190ovResult = runAutoLinks190ovCheck(); // round 190ov (src/AutoLinks190ovCheck.inc)
- juce::String rollup031s5Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- if (song.mixer.size() < 3)
- song.mixer.resize (3);
- // 190ol: two sections; Simple signature changes at the start (5/1, BandLab's n/1: the song's meter) and on bar 9 (7/8:
- // a signature marker)
- lynx::sections::add (song, "Intro");
- lynx::sections::add (song, "Verse");
- lynx::signatureedit::set (song, 0, 5, 1);
- lynx::signatureedit::set (song, song.barAt (0).tick + 8 * 5 * lynx::ppq * 4, 7, 8);
- std::vector<lynx::Marker> signatures;
- for (const auto& m : song.markers())
- if (m.isSignature())
- signatures.push_back (m);
- // 190oh: a plugin channel with DPI aware off, an insert plugin with Scale editor dimensions on
- lynx::ChannelDef synth;
- synth.name = "Old Synth";
- synth.instrument = lynx::InstrumentKind::plugin;
- synth.plugin.id = "VST3:old-synth";
- synth.plugin.name = "Old Synth";
- synth.plugin.dpiAware = false;
- synth.smartDisable = true; // (merge 6, 190ok D2: dropped without a line)
- song.channels.push_back (synth);
- const auto synthIndex = (int) song.channels.size() - 1;
- lynx::EffectSlot fx;
- fx.kind = lynx::EffectKind::plugin;
- fx.plugin.id = "VST3:tiny-eq";
- fx.plugin.name = "Tiny EQ";
- fx.plugin.scaleEditorDimensions = true;
- song.mixer[2].effects.push_back (fx);
- auto ember = lynx::makeEffectSlot (lynx::EffectKind::ember); // (merge 6, 190ok D3: engine revision 2 -> 1 in the copies)
- song.mixer[2].effects.push_back (ember);
- // gap190og: a key mapped to Arrangement Overdub (newer) and one to Play (0.1.30 has it)
- lynx::RemoteMapping overdub, play;
- overdub.source = play.source = lynx::RemoteMapping::Source::key;
- overdub.key = 'O', overdub.action = lynx::RemoteAction::overdub;
- play.key = 'P', play.action = lynx::RemoteAction::play;
- song.remoteMappings = { overdub, play };
- // 190ob: the tracker import's volume automation (the channel's Levels "Volume multiplier", 5000 = 100 %)
- lynx::Automation volume;
- volume.name = "Old Synth volume (ch 1)";
- volume.target.kind = lynx::AutomationTargetKind::channelAdjust;
- volume.target.index = synthIndex;
- volume.target.param = lynx::leveladjust::volume;
- volume.points = { { 0, 0.5f }, { lynx::ppq, 0.25f }, { 2 * lynx::ppq, 0.4f } };
- song.automations.push_back (volume);
- lynx::uids::normalize (song);
- const auto json = lynx::ProjectFile::toJson (song);
- const auto keysOf = [] (const juce::var& v) {
- std::set<juce::String> keys;
- std::function<void (const juce::var&, const juce::String&)> walk = [&] (const juce::var& x, const juce::String& path) {
- if (auto* o = x.getDynamicObject())
- for (const auto& prop : o->getProperties())
- {
- if (path.isEmpty() && (prop.name.toString() == "savedBy" || prop.name.toString() == "copiedFrom"))
- continue;
- keys.insert (path + "/" + prop.name.toString());
- walk (prop.value, path + "/" + prop.name.toString());
- }
- else if (auto* a = x.getArray())
- for (const auto& e : *a)
- walk (e, path + "[]");
- };
- walk (v, {});
- return keys;
- };
- auto expected = keysOf (juce::JSON::parse (json));
- const auto hadKeys = expected.erase ("/arrangements[]/sections") == 1 && expected.erase ("/channels[]/plugin/dpiAware") == 1
- && expected.erase ("/mixer[]/effects[]/plugin/scaleEditorDimensions") == 1 && expected.erase ("/channels[]/smartDisable") == 1;
- const auto countOf = [] (const lynx::olderlynx::Copy& c, const char* start) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [start] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (start); });
- };
- const auto detailOf = [] (const lynx::olderlynx::Copy& c, const char* start) {
- for (const auto& l : c.lost)
- if (juce::String (l.text).startsWith (start))
- return juce::String (l.detail);
- return juce::String();
- };
- if (! hadKeys || song.sections().size() != 2 || song.beatsPerBar != 5 || song.beatUnit != 1 || signatures.size() != 1 || signatures[0].numerator != 7)
- rollup031s5Result = "ERROR set-up (" + juce::String ((int) signatures.size()) + " signature changes)";
- // (190og: the .flm export reads the song and keeps nothing in it)
- if (rollup031s5Result == "OK")
- {
- const auto flm = lynx::exportFlm (song);
- if (flm.bytes.empty() || lynx::ProjectFile::toJson (song) != json)
- rollup031s5Result = "ERROR the .flm export (" + juce::String ((int) flm.bytes.size()) + " bytes)";
- }
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (rollup031s5Result != "OK")
- break;
- const auto copy = lynx::olderlynx::forRelease (song, release);
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- const auto is130 = juce::String (release) == "0.1.30";
- std::vector<lynx::Marker> backSignatures;
- int sectionMarkers = 0;
- if (back)
- {
- for (const auto& m : back->markers())
- {
- if (m.isSignature())
- backSignatures.push_back (m);
- else if (m.name == "Intro" || m.name == "Verse")
- ++sectionMarkers;
- }
- }
- const auto bars = song.barsBetween (0, 400 * lynx::ppq);
- const auto backBars = back ? back->barsBetween (0, 400 * lynx::ppq) : std::vector<lynx::Bar> {};
- const auto backFx = back && back->mixer.size() > 2 && back->mixer[2].effects.size() >= 2 ? back->mixer[2].effects[back->mixer[2].effects.size() - 2].plugin : lynx::PluginRef {};
- const auto backEmberRev = back && back->mixer.size() > 2 && ! back->mixer[2].effects.empty() ? back->mixer[2].effects.back().engineRev : -1;
- if (! copy.ok || ! back)
- rollup031s5Result = juce::String ("ERROR copy ") + release + " " + copy.error + why;
- else if (copy.json.contains ("\"sections\"") || ! back->sections().empty() || sectionMarkers != 2
- || countOf (copy, "{0} song section(s) of the Sections lane") != 1)
- rollup031s5Result = juce::String ("ERROR 190ol's sections in the copy for ") + release;
- else if (backSignatures.size() != signatures.size()
- || ! std::equal (signatures.begin(), signatures.end(), backSignatures.begin(), [] (const lynx::Marker& a, const lynx::Marker& b) {
- return a.tick == b.tick && a.numerator == b.numerator && a.denominator == b.denominator;
- })
- || back->beatsPerBar != song.beatsPerBar || back->beatUnit != song.beatUnit
- || ! std::equal (bars.begin(), bars.end(), backBars.begin(), backBars.end(), [] (const lynx::Bar& a, const lynx::Bar& b) {
- return a.tick == b.tick && a.length == b.length && a.number == b.number;
- }))
- rollup031s5Result = juce::String ("ERROR 190ol's time signature changes in the copy for ") + release;
- else if (copy.json.contains ("dpiAware") || copy.json.contains ("scaleEditorDimensions") || ! back->channels[(std::size_t) synthIndex].plugin.dpiAware
- || backFx.scaleEditorDimensions || backFx.name != "Tiny EQ"
- || countOf (copy, "FL's wrapper GUI settings") != 1 || ! detailOf (copy, "FL's wrapper GUI settings").contains ("Old Synth")
- || ! detailOf (copy, "FL's wrapper GUI settings").contains ("Tiny EQ"))
- rollup031s5Result = juce::String ("ERROR 190oh's wrapper GUI settings in the copy for ") + release + " (" + detailOf (copy, "FL's wrapper GUI settings") + ")";
- else if (back->remoteMappings.size() != 1 || back->remoteMappings[0].action != lynx::RemoteAction::play
- || countOf (copy, "{0} key / MIDI mapping(s) of Overdub") != 1 || detailOf (copy, "{0} key / MIDI mapping(s) of Overdub") != "1")
- rollup031s5Result = juce::String ("ERROR gap190og's transport mappings in the copy for ") + release;
- else if (copy.json.contains ("smartDisable") || back->channels[(std::size_t) synthIndex].smartDisable || song.mixer[2].effects.back().engineRev < 2 // (round 190qz: 3 is current)
- || backEmberRev != (is130 ? 1 : 0))
- rollup031s5Result = juce::String ("ERROR 190ok's smart disable / engine revision in the copy for ") + release + " (rev " + juce::String (backEmberRev) + ")";
- else if (back->automations != song.automations)
- rollup031s5Result = juce::String ("ERROR 190ob's volume automation in the copy for ") + release;
- else if (is130 && (copy.lost.size() != 3 || keysOf (juce::JSON::parse (copy.json)) != expected))
- rollup031s5Result = "ERROR the copy for 0.1.30 drops more than step 5's three (" + juce::String ((int) copy.lost.size()) + " lines)";
- }
- // a project without any of them: no step-5 line (the default song)
- if (rollup031s5Result == "OK")
- {
- const auto plain = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.30");
- if (! plain.ok || ! plain.lost.empty())
- rollup031s5Result = "ERROR lines for a project with none of step 5's data (" + juce::String ((int) plain.lost.size()) + ")";
- }
- }
- // round 190pi: "Save a copy for 0.1.30" of FL's slide law (Song::slideNoteProps): a slide note over a chord (FL moves
- // every held note by one interval) and a Slide arpeggio (its voice at the first held note's velocity) each get one
- // sound line; a project with neither gets none of them; the copy reads back
- juce::String slides190piResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- song.slideNoteProps = true;
- if (song.patterns.empty())
- song.patterns.emplace_back();
- if (song.channels.empty())
- song.channels.emplace_back();
- song.patterns[0].notes.clear();
- const auto count = [] (const lynx::olderlynx::Copy& copy, const char* start) {
- return (int) std::count_if (copy.lost.begin(), copy.lost.end(), [start] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).startsWith (start) && l.sound;
- });
- };
- const auto plain = lynx::olderlynx::forRelease (song, "0.1.30");
- lynx::Note a, b, slide;
- a.start = 0, a.length = 4 * lynx::ppq, a.key = 60, a.channel = 0;
- b = a, b.key = 67;
- slide = a, slide.start = lynx::ppq, slide.length = lynx::ppq / 2, slide.slide = true;
- song.patterns[0].notes = { a, b, slide };
- song.channels[0].arp.direction = 1;
- song.channels[0].arp.slide = true;
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- if (! plain.ok || count (plain, "{0} slide note(s) over chords") != 0 || count (plain, "{0} channel(s) with a Slide arpeggio") != 0)
- slides190piResult = "ERROR lines for a project without chord slides or Slide arpeggios";
- else if (! copy.ok || count (copy, "{0} slide note(s) over chords") != 1 || count (copy, "{0} channel(s) with a Slide arpeggio") != 1)
- slides190piResult = "ERROR the copy's lines " + copy.error;
- else if (! back || back->slideNoteProps || copy.json.contains ("slideNoteProps"))
- slides190piResult = "ERROR the copy read back " + why;
- }
- // round 190qo (issues #270, #271): LYNX's typing chord layouts follow FL's own four chord files; "Save a copy for 0.1.31"
- // of a SoundFont channel with slide notes (engine revision 5: slide velocity and pan) gets one sound line and
- // revision 3, a project without slide notes none
- juce::String issues190qoResult = "OK";
- {
- const auto rule = lynx::keys::typingpiano::chordRuleCheck();
- auto song = lynx::Song::makeDefault();
- if (song.patterns.empty())
- song.patterns.emplace_back();
- lynx::ChannelDef sf;
- sf.instrument = lynx::InstrumentKind::soundfont;
- sf.name = "SF 190qo";
- song.channels.push_back (sf);
- const auto ch = (int) song.channels.size() - 1;
- lynx::Note a, slide;
- a.start = 0, a.length = 4 * lynx::ppq, a.key = 60, a.channel = ch;
- slide = a, slide.start = lynx::ppq, slide.length = lynx::ppq, slide.slide = true, slide.velocity = 0.1f;
- song.patterns[0].notes = { a };
- const auto lines = [] (const lynx::olderlynx::Copy& copy) {
- return (int) std::count_if (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).startsWith ("Slide notes move only the pitch on these channels") && l.sound;
- });
- };
- const auto plain = lynx::olderlynx::forRelease (song, "0.1.31");
- song.patterns[0].notes.push_back (slide);
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.31");
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- if (rule != "OK")
- issues190qoResult = "ERROR typing chord rule " + juce::String (rule);
- else if (! plain.ok || lines (plain) != 0)
- issues190qoResult = "ERROR a line for a project without SoundFont slides";
- else if (! copy.ok || lines (copy) != 1)
- issues190qoResult = "ERROR the copy's line " + copy.error;
- else if (! back || back->channels.back().engineRev > 3)
- issues190qoResult = "ERROR the copy read back " + why;
- }
- // round 190pr: "Save a copy for 0.1.30" of the export's marker actions (Song::exportMarkers: one sound line when an
- // arrangement has a skip or Start marker, none otherwise; the key goes), of Harmor's automation and of Sytrus'
- // note Mod X / Y (engine revision 3: written at 2, one line each naming the clip / channel); the .lynx keys read back
- juce::String flparity190prResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- song.exportMarkers = true;
- const auto has = [] (const lynx::olderlynx::Copy& copy, const char* start) {
- return std::any_of (copy.lost.begin(), copy.lost.end(), [start] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).startsWith (start) && l.sound;
- });
- };
- const char* markerLine = "The export plays the song straight through in this release";
- const char* harmorLine = "Automation of Harmor's filter frequencies";
- const auto plain = lynx::olderlynx::forRelease (song, "0.1.30");
- lynx::Marker skip;
- skip.tick = 4 * lynx::ppq, skip.action = lynx::Marker::markerSkip, skip.name = "Skip";
- song.addMarker (skip);
- lynx::ChannelDef harmorChannel;
- harmorChannel.name = "Harmor 190pr";
- harmorChannel.instrument = lynx::InstrumentKind::harmor;
- song.channels.push_back (harmorChannel);
- lynx::ChannelDef sytrusChannel;
- sytrusChannel.name = "Sytrus 190pr";
- sytrusChannel.instrument = lynx::InstrumentKind::sytrus;
- song.channels.push_back (sytrusChannel);
- if (song.patterns.empty())
- song.patterns.emplace_back();
- lynx::Note click;
- click.channel = (int) song.channels.size() - 1, click.key = 60, click.length = lynx::ppq, click.modY = 190.0f / 256.0f;
- song.patterns[0].notes.push_back (click);
- const char* sytrusLine = "Sytrus plays every note at the default Mod X / Y";
- lynx::Automation clip;
- clip.name = "Cutoff 190pr";
- clip.target = { lynx::AutomationTargetKind::channelParam, (int) song.channels.size() - 2, 0, 52 };
- song.automations.push_back (clip);
- const auto json = lynx::ProjectFile::toJson (song);
- juce::String why;
- const auto back = lynx::ProjectFile::fromJson (json, why);
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- juce::String why2;
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why2) : std::optional<lynx::Song> {};
- const auto n = song.channels.size();
- if (! plain.ok || has (plain, markerLine) || has (plain, harmorLine) || has (plain, sytrusLine))
- flparity190prResult = "ERROR lines for a project without markers, Harmor automation or Sytrus Mod X / Y";
- else if (! json.contains ("exportMarkers") || ! back || ! back->exportMarkers || back->channels.size() != n
- || back->channels[n - 2].engineRev < 3 || back->channels[n - 1].engineRev < 3) // (round 190py: 4 is current)
- flparity190prResult = "ERROR the .lynx keys " + why;
- else if (! copy.ok || ! has (copy, markerLine) || ! has (copy, harmorLine) || ! has (copy, sytrusLine))
- flparity190prResult = "ERROR the copy's lines " + copy.error;
- else if (! old || old->exportMarkers || copy.json.contains ("exportMarkers") || old->channels.size() != n
- || old->channels[n - 2].engineRev != 2 || old->channels[n - 1].engineRev != 2)
- flparity190prResult = "ERROR the copy read back " + why2;
- }
- // round 190oz: FL's held step notes (Note::held) in .lynx ("heldNotes", only when a pattern has one), back from it,
- // and the copy for 0.1.30 (the marks dropped with one sound line, the notes kept one step long)
- juce::String heldSteps190ozResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- const auto plainJson = lynx::ProjectFile::toJson (song);
- if (song.patterns.empty())
- song.patterns.emplace_back();
- auto& notes = song.patterns[0].notes;
- notes.clear();
- lynx::Note held, plain;
- held.start = 0, held.channel = 0, held.held = true;
- plain.start = lynx::ticksPerStep * 4, plain.channel = 0;
- notes = { held, plain };
- const auto json = lynx::ProjectFile::toJson (song);
- juce::String why;
- const auto back = lynx::ProjectFile::fromJson (json, why);
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- const auto lines = (int) std::count_if (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).startsWith ("{0} FL step note(s) on generators") && l.detail == "1" && l.sound;
- });
- juce::String why2;
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why2) : std::optional<lynx::Song> {};
- if (plainJson.contains ("heldNotes") || ! json.contains ("heldNotes"))
- heldSteps190ozResult = "ERROR the .lynx key";
- else if (! back || back->patterns.empty() || back->patterns[0].notes.size() != 2 || ! back->patterns[0].notes[0].held
- || back->patterns[0].notes[1].held || back->patterns[0].notes[0].start != 0)
- heldSteps190ozResult = "ERROR the .lynx round trip " + why;
- else if (! copy.ok || copy.json.contains ("heldNotes") || lines != 1 || ! old || old->patterns.empty()
- || old->patterns[0].notes.size() != 2 || old->patterns[0].notes[0].held)
- heldSteps190ozResult = "ERROR the copy for 0.1.30 (" + juce::String (lines) + " lines) " + copy.error + why2;
- }
- // rollup 0.1.31 step 6: "Save a copy for 0.1.30 / 0.1.28" over every round of the step. One project with: 190om's SimSynth
- // (engine revision 2, the velocity law), two patterns' event lanes on one control and a note with a pitch curve in a
- // Playlist clip (decisions 4 / 5: lines only); 190op's hidden track and deactivated insert; 190oq's ARA plugin on an
- // insert (#243); 190ot's "Duck under..."; 190ov's clip linked to two controls with a scale; 190ow's step on an
- // automation row, a re-ranged clip and a muted clip; 190ox's Steps modulator. Each line once in each copy, none of the
- // new keys left in the 0.1.30 copy, both copies read back; the default song gets none of these lines
- juce::String rollup031s6Result = "OK";
- {
- namespace st = lynx::simpletracks;
- auto song = lynx::Song::makeDefault();
- st::Request q;
- q.kind = st::Kind::audio;
- q.name = "Kick";
- const auto kick = st::addTrack (song, q).insert;
- q.name = "Pad";
- const auto pad = st::addTrack (song, q).insert;
- const auto duckSet = st::setDuck (song, pad, kick, 0.6f) == st::DuckResult::set;
- lynx::ChannelDef sim;
- sim.name = "Sim Lead";
- sim.instrument = lynx::InstrumentKind::simsynth; // (engineRev 2: a new channel)
- song.channels.push_back (sim);
- const auto simIndex = (int) song.channels.size() - 1;
- while (song.patterns.size() < 2)
- song.patterns.push_back (song.patterns.front());
- song.patterns[0].name = "Lanes A";
- song.patterns[1].name = "Lanes B";
- lynx::AutomationTarget simVolume;
- simVolume.kind = lynx::AutomationTargetKind::channelVolume;
- simVolume.index = simIndex;
- for (int p = 0; p < 2; ++p)
- {
- lynx::PatternEvents lane;
- lane.target = simVolume;
- lane.events = { { 0, 0.3f + 0.2f * (float) p } };
- song.patterns[(std::size_t) p].events.push_back (lane);
- lynx::Clip clip;
- clip.pattern = p;
- clip.track = 0;
- clip.start = (std::int64_t) p * 4 * lynx::ppq;
- clip.length = 4 * lynx::ppq;
- song.playlist.push_back (clip);
- }
- {
- lynx::Note bent;
- bent.channel = simIndex;
- bent.length = lynx::ppq;
- lynx::NoteCurves curves;
- curves.lane (lynx::NoteCurveLane::pitch) = { { 0.0f, 0.0f }, { (float) lynx::ppq, 200.0f } };
- bent.curves = curves;
- song.patterns[0].notes.push_back (bent);
- }
- if (song.playlistTracks.size() < 4)
- song.playlistTracks.resize (4);
- song.playlistTracks[3].hidden = true;
- song.mixer[(std::size_t) kick].deactivated = true;
- lynx::EffectSlot ara;
- ara.kind = lynx::EffectKind::plugin;
- ara.plugin.id = "VST3:ara-editor";
- ara.plugin.name = "ARA Editor";
- ara.ara = true;
- song.mixer[(std::size_t) pad].effects.push_back (ara);
- // 190ov: a clip linked to two controls, the first with a scale; 190ow: a step on its row, a re-ranged clip, a muted one
- lynx::Automation linked;
- linked.name = "Linked";
- linked.target = simVolume;
- lynx::Automation::Link first, second;
- first.target = simVolume;
- first.scale = { 0.0f, 0.4f, 1.0f };
- second.target.kind = lynx::AutomationTargetKind::channelPan;
- second.target.index = simIndex;
- linked.links = { first, second };
- linked.points = { { 0, 0.2f }, { lynx::ppq, 0.8f } };
- song.automations.push_back (linked);
- const auto linkedIndex = (int) song.automations.size() - 1;
- lynx::Clip autoClip;
- autoClip.kind = lynx::ClipKind::automation;
- autoClip.automation = linkedIndex;
- autoClip.track = 2;
- autoClip.length = 4 * lynx::ppq;
- song.playlist.push_back (autoClip);
- lynx::Automation ranged = linked;
- ranged.name = "Ranged";
- ranged.links.clear();
- ranged.target.kind = lynx::AutomationTargetKind::mixerVolume;
- ranged.target.index = pad;
- ranged.rangeMin = 0.25f;
- ranged.rangeMax = 0.75f;
- song.automations.push_back (ranged);
- lynx::Automation muted = ranged;
- muted.name = "Muted";
- muted.rangeMin = 0.0f;
- muted.rangeMax = 1.0f;
- muted.target.kind = lynx::AutomationTargetKind::mixerPan;
- muted.muted = true;
- song.automations.push_back (muted);
- lynx::Note step;
- step.channel = (int) song.automations.size() - 2; // ("Ranged": a step on its rack row)
- step.length = 0;
- song.patterns[1].autoNotes.push_back (step);
- auto steps = lynx::Modulator::make (lynx::ModKind::steps);
- steps.name = "Steps 1";
- lynx::ModRoute route;
- route.target.kind = lynx::AutomationTargetKind::mixerPan;
- route.target.index = pad;
- steps.routes.push_back (route);
- song.modulators.push_back (steps);
- lynx::uids::normalize (song);
- const auto countOf = [] (const lynx::olderlynx::Copy& c, const char* start) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [start] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (start); });
- };
- const char* const lines[] = { "SimSynth plays every note at full level", "Controls that several patterns' event lanes drive",
- "In Song mode these patterns' notes play without", "{0} hidden Playlist track(s) show again",
- "Deactivated channels and inserts load their plugins again", "ARA plugins on mixer inserts play as ordinary",
- "{0} \"Duck under...\" effect(s)", "Automation clips linked to several controls move them 1:1",
- "{0} step(s) or note(s) on automation clip rows start no clip", "An automation clip's LFO keeps",
- "Muted automation clips lose their target", "These modulators are not in this release" };
- const auto hasLane = [&simVolume] (const lynx::Pattern& p) {
- return std::any_of (p.events.begin(), p.events.end(), [&simVolume] (const lynx::PatternEvents& l) { return l.target == simVolume && ! l.events.empty(); });
- };
- if (! duckSet || kick <= 0 || pad <= 0 || song.channels[(std::size_t) simIndex].engineRev < 2) // (≥ 2: round 190pr's 3 too)
- rollup031s6Result = "ERROR set-up";
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (rollup031s6Result != "OK")
- break;
- const auto is130 = juce::String (release) == "0.1.30";
- const auto copy = lynx::olderlynx::forRelease (song, release);
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- if (! copy.ok || ! back)
- {
- rollup031s6Result = juce::String ("ERROR copy ") + release + " " + copy.error + why;
- break;
- }
- for (const auto* line : lines)
- {
- // (no LFO on the re-ranged clip: that line must not show)
- const auto want = juce::String (line).startsWith ("An automation clip's LFO") ? 0 : 1;
- if (countOf (copy, line) != want)
- {
- rollup031s6Result = juce::String ("ERROR the copy for ") + release + ": \"" + line + "\" " + juce::String (countOf (copy, line)) + " times";
- break;
- }
- }
- if (rollup031s6Result != "OK")
- break;
- const auto json = copy.json;
- if (json.contains ("playlistTracksHidden") || json.contains ("\"deactivated\"") || json.contains ("\"ara\": true") || json.contains ("autoNotes")
- || json.contains ("modulators190ox"))
- rollup031s6Result = juce::String ("ERROR a new key is left in the copy for ") + release;
- else if (is130 && back->channels[(std::size_t) simIndex].engineRev != 1)
- rollup031s6Result = "ERROR SimSynth's revision in the copy for 0.1.30 (" + juce::String (back->channels[(std::size_t) simIndex].engineRev) + ")";
- else if (! back->mixer[(std::size_t) kick].muted || back->mixer[(std::size_t) kick].deactivated || (back->playlistTracks.size() > 3 && back->playlistTracks[3].hidden))
- rollup031s6Result = juce::String ("ERROR 190op's units in the copy for ") + release;
- else if (is130 && (back->patterns.size() < 2 || ! hasLane (back->patterns[0]) || ! hasLane (back->patterns[1])
- || std::none_of (back->patterns[0].notes.begin(), back->patterns[0].notes.end(), [] (const lynx::Note& n) { return n.curves.has(); })))
- rollup031s6Result = "ERROR the copy for 0.1.30 lost 190om's lanes or curves (lines only)";
- else if (back->automations.size() < 3 || (is130 && back->automations[(std::size_t) linkedIndex].links.size() != 2)
- || (! back->automations[(std::size_t) linkedIndex].links.empty() && ! back->automations[(std::size_t) linkedIndex].links[0].scale.empty()) || back->automations.back().target.kind != lynx::AutomationTargetKind::none
- || back->automations[back->automations.size() - 2].reranged())
- rollup031s6Result = juce::String ("ERROR 190ov / 190ow's clips in the copy for ") + release;
- else if (is130 && (back->modulators.size() != song.modulators.size() - 1))
- rollup031s6Result = "ERROR 190ox's Steps modulator in the copy for 0.1.30 (" + juce::String ((int) back->modulators.size()) + ")";
- }
- // the default song: none of these lines
- if (rollup031s6Result == "OK")
- {
- const auto plain = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.30");
- if (! plain.ok || ! plain.lost.empty())
- rollup031s6Result = "ERROR lines for a project with none of step 6's data (" + juce::String ((int) plain.lost.size()) + ")";
- }
- }
- // rollup 0.1.31 step 7: Save a copy for 0.1.30 / 0.1.28 of everything step 7 brought. One project with 190pf's Chord
- // lane (2 chords, a following channel), 190pe's track versions (2 on a track), 190pa's write mode (Latch) and range,
- // 190pj's JSFX insert, 190pi's Ogun (engine revision 2) and an automation clip of Sytrus' Mod X; each copy: every line
- // once (the Ogun line only for a patch with link velocity: none here without FL's files), the chords as markers,
- // none of the new keys left, Ogun at revision 1 (0.1.30), both copies read back; the default song gets none of them.
- // (Note repeats / conditions, research190oe P19: not built, nothing to convert; the header gear's choice is window
- // state, never in a copy.)
- juce::String rollup031s7Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- if (song.playlistTracks.size() < 3)
- song.playlistTracks.resize (3);
- lynx::SongChord am, g7;
- am.start = 0, am.length = 4 * lynx::ppq, am.root = 9, am.quality = 1;
- g7.start = 4 * lynx::ppq, g7.length = 4 * lynx::ppq, g7.root = 7, g7.quality = 0, g7.extensions = { 10 }, g7.bass = 11;
- song.chords() = { am, g7 };
- lynx::ChannelDef follower;
- follower.name = "Follower";
- follower.followChords = 1;
- song.channels.push_back (follower);
- lynx::ChannelDef ogun;
- ogun.name = "Ogun Pad";
- ogun.instrument = lynx::InstrumentKind::ogun; // (engineRev 2: a new channel)
- song.channels.push_back (ogun);
- const auto ogunIndex = (int) song.channels.size() - 1;
- lynx::ChannelDef sytrus;
- sytrus.name = "Sytrus Lead";
- sytrus.instrument = lynx::InstrumentKind::sytrus;
- song.channels.push_back (sytrus);
- lynx::Automation modX;
- modX.name = "Sytrus Mod X";
- modX.target.kind = lynx::AutomationTargetKind::channelParam;
- modX.target.index = (int) song.channels.size() - 1;
- modX.target.param = 18;
- modX.points = { { 0, 0.2f }, { lynx::ppq, 0.8f } };
- song.automations.push_back (modX);
- song.automationWriteMode = 2; // (Latch)
- song.trackRange.from = 0, song.trackRange.to = 2 * lynx::ppq, song.trackRange.tracks = { 0, 1 };
- lynx::EffectSlot jsfx;
- jsfx.kind = lynx::EffectKind::plugin;
- jsfx.plugin.id = "JSFX-chokehold/soft_clipper";
- jsfx.plugin.name = "soft_clipper";
- if (song.mixer.size() < 3)
- song.mixer.resize (3);
- song.mixer[2].effects.push_back (jsfx);
- lynx::Clip clip;
- clip.pattern = 0;
- clip.track = 1;
- clip.length = 4 * lynx::ppq;
- song.playlist.push_back (clip);
- const auto versioned = lynx::trackversions::add (song, 1, lynx::trackversions::Start::empty, "Take B", "Take A") >= 0;
- lynx::uids::normalize (song);
- const auto countOf = [] (const lynx::olderlynx::Copy& c, const char* start) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [start] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (start); });
- };
- const char* const lines[] = { "{0} chord(s) of the Chord lane become plain Playlist markers", "{0} channel(s) followed the Chord lane",
- "{0} track version(s) that are not active are left out", "The automation write mode ({0}) goes back",
- "The range selected on some Playlist tracks is left out", "JSFX scripts are not in this release",
- "Automation of Sytrus' main knobs" };
- if (! versioned || song.channels[(std::size_t) ogunIndex].engineRev < 2) // (≥ 2: round 190pr's 3 too)
- rollup031s7Result = "ERROR set-up";
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (rollup031s7Result != "OK")
- break;
- const auto is130 = juce::String (release) == "0.1.30";
- const auto copy = lynx::olderlynx::forRelease (song, release);
- juce::String why;
- const auto back = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- if (! copy.ok || ! back)
- {
- rollup031s7Result = juce::String ("ERROR copy ") + release + " " + copy.error + why;
- break;
- }
- for (const auto* line : lines)
- if (countOf (copy, line) != 1)
- {
- rollup031s7Result = juce::String ("ERROR the copy for ") + release + ": \"" + line + "\" " + juce::String (countOf (copy, line)) + " times";
- break;
- }
- if (rollup031s7Result != "OK")
- break;
- const auto& json = copy.json;
- const auto markerNamed = [&back] (const char* name) {
- return std::any_of (back->markers().begin(), back->markers().end(), [name] (const lynx::Marker& m) { return m.name == name; });
- };
- if (countOf (copy, "Ogun and Autogun play every note") != 0)
- rollup031s7Result = juce::String ("ERROR an Ogun line without a link-velocity patch in the copy for ") + release;
- else if (json.contains ("\"chords\"") || json.contains ("followChords") || json.contains ("playlistTrackVersions")
- || json.contains ("automationWriteMode") || json.contains ("trackRange") || json.contains ("JSFX-"))
- rollup031s7Result = juce::String ("ERROR a new key is left in the copy for ") + release;
- else if (! markerNamed ("Am") || ! markerNamed ("G7/B"))
- rollup031s7Result = juce::String ("ERROR the chords are not markers in the copy for ") + release;
- else if (is130 && back->channels[(std::size_t) ogunIndex].engineRev != 1)
- rollup031s7Result = "ERROR Ogun's revision in the copy for 0.1.30 (" + juce::String (back->channels[(std::size_t) ogunIndex].engineRev) + ")";
- else if ((back->playlistTracks.size() > 1 && ! back->playlistTracks[1].versions.empty()) // (an empty default row may not be written)
- || std::any_of (back->playlist.begin(), back->playlist.end(), [] (const lynx::Clip& c) { return c.track == 1; }))
- rollup031s7Result = juce::String ("ERROR track 2 is not its active (empty) version in the copy for ") + release + " (rows "
- + juce::String ((int) back->playlistTracks.size()) + ", clips on it "
- + juce::String ((int) std::count_if (back->playlist.begin(), back->playlist.end(), [] (const lynx::Clip& c) { return c.track == 1; })) + ")";
- else if (back->automations.empty() || back->automations[0].points.size() != 2)
- rollup031s7Result = juce::String ("ERROR the Sytrus clip's data in the copy for ") + release;
- }
- if (rollup031s7Result == "OK")
- {
- const auto plain = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.30");
- if (! plain.ok || ! plain.lost.empty())
- rollup031s7Result = "ERROR lines for a project with none of step 7's data (" + juce::String ((int) plain.lost.size()) + ")";
- }
- }
- // rollup 0.1.31 step 8: Save a copy for 0.1.30 / 0.1.28 of engine revision 3 (round 190pr, ChannelDef::engineRev: FL
- // imports and new channels) and of the export's marker switch (Song::exportMarkers). One project with a channel of
- // every kind a revision gates (SimSynth, Ogun, Autogun: 2; Harmor, Sytrus: 3) and a plain Synth, all new (3), a
- // Harmor filter clip, a Sytrus note off the default Mod Y, a Start marker after bar 1 and a skip marker. Each copy:
- // 190pr's three lines once, no exportMarkers key, the markers kept as markers; 0.1.30: SimSynth / Ogun / Autogun at 1,
- // Harmor / Sytrus / the Synth at 2; 0.1.28: no revision at all (0). Revisions stay ordered: a project saved before
- // (every channel at 2, the switch off) reads back as it was saved and gets none of 190pr's lines.
- juce::String rollup031s8Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- song.exportMarkers = true;
- lynx::Marker start, skip;
- start.tick = 4 * lynx::ppq, start.action = lynx::Marker::start, start.name = "Start 190s8";
- skip.tick = 8 * lynx::ppq, skip.action = lynx::Marker::markerSkip, skip.name = "Skip 190s8";
- song.addMarker (start);
- song.addMarker (skip);
- const lynx::InstrumentKind kinds[] = { lynx::InstrumentKind::simsynth, lynx::InstrumentKind::ogun, lynx::InstrumentKind::autogun,
- lynx::InstrumentKind::harmor, lynx::InstrumentKind::sytrus, lynx::InstrumentKind::synth };
- const int want130[] = { 1, 1, 1, 2, 2, 2 };
- const auto first = (int) song.channels.size();
- for (const auto kind : kinds)
- {
- lynx::ChannelDef c;
- c.name = "Rev3 " + std::to_string ((int) song.channels.size() - first + 1);
- c.instrument = kind;
- song.channels.push_back (c);
- }
- const auto harmorIndex = first + 3, sytrusIndex = first + 4;
- if (song.patterns.empty())
- song.patterns.emplace_back();
- lynx::Note click;
- click.channel = sytrusIndex, click.key = 60, click.length = lynx::ppq, click.modY = 0.8f;
- song.patterns[0].notes.push_back (click);
- lynx::Automation cutoff;
- cutoff.name = "Harmor cutoff s8";
- cutoff.target = { lynx::AutomationTargetKind::channelParam, harmorIndex, 0, 52 };
- cutoff.points = { { 0, 0.2f }, { lynx::ppq, 0.8f } };
- song.automations.push_back (cutoff);
- const auto countOf = [] (const lynx::olderlynx::Copy& c, const char* begin) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [begin] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (begin); });
- };
- const char* const lines[] = { "The export plays the song straight through in this release", "Automation of Harmor's filter frequencies",
- "Sytrus plays every note at the default Mod X / Y" };
- const auto markersKept = [] (const lynx::Song& s) {
- const auto& m = s.markers();
- return std::any_of (m.begin(), m.end(), [] (const lynx::Marker& x) { return x.name == "Start 190s8"; })
- && std::any_of (m.begin(), m.end(), [] (const lynx::Marker& x) { return x.name == "Skip 190s8"; });
- };
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- const auto n = (int) song.channels.size();
- if (std::any_of (song.channels.begin() + first, song.channels.end(), [] (const lynx::ChannelDef& c) { return c.engineRev < 3; }))
- rollup031s8Result = "ERROR set-up: a new channel is not at revision 3 or later"; // (round 190py: 4 is current)
- else if (! back || ! back->exportMarkers || (int) back->channels.size() != n
- || std::any_of (back->channels.begin() + first, back->channels.end(), [] (const lynx::ChannelDef& c) { return c.engineRev < 3; }))
- rollup031s8Result = "ERROR the .lynx did not keep revision 3 / the export's markers " + why;
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (rollup031s8Result != "OK")
- break;
- const auto is130 = juce::String (release) == "0.1.30";
- const auto copy = lynx::olderlynx::forRelease (song, release);
- juce::String why2;
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why2) : std::optional<lynx::Song> {};
- if (! copy.ok || ! old || (int) old->channels.size() != n)
- {
- rollup031s8Result = juce::String ("ERROR copy ") + release + " " + copy.error + why2;
- break;
- }
- for (const auto* line : lines)
- if (countOf (copy, line) != 1)
- {
- rollup031s8Result = juce::String ("ERROR the copy for ") + release + ": \"" + line + "\" " + juce::String (countOf (copy, line)) + " times";
- break;
- }
- if (rollup031s8Result != "OK")
- break;
- if (copy.json.contains ("exportMarkers") || old->exportMarkers)
- rollup031s8Result = juce::String ("ERROR the export's marker switch is left in the copy for ") + release;
- else if (! markersKept (*old))
- rollup031s8Result = juce::String ("ERROR the Start / skip markers are gone from the copy for ") + release;
- else if (! is130 && copy.json.contains ("engineRev"))
- rollup031s8Result = "ERROR a revision is left in the copy for 0.1.28";
- else
- for (int k = 0; k < (int) std::size (kinds); ++k)
- if (const auto rev = old->channels[(std::size_t) (first + k)].engineRev; rev != (is130 ? want130[k] : 0))
- {
- rollup031s8Result = juce::String ("ERROR the copy for ") + release + ": channel " + juce::String (first + k + 1)
- + " at revision " + juce::String (rev) + " (want " + juce::String (is130 ? want130[k] : 0) + ")";
- break;
- }
- }
- if (rollup031s8Result == "OK")
- {
- auto before = song; // (a project saved before round 190pr: revision 2 at most, the switch off)
- before.exportMarkers = false;
- for (auto& c : before.channels)
- c.engineRev = std::min (c.engineRev, 2);
- juce::String why3;
- const auto again = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (before), why3);
- const auto copy = lynx::olderlynx::forRelease (before, "0.1.30");
- if (! again || again->exportMarkers
- || std::any_of (again->channels.begin() + first, again->channels.end(), [] (const lynx::ChannelDef& c) { return c.engineRev != 2; }))
- rollup031s8Result = "ERROR a project saved before 190pr does not read back as saved " + why3;
- else if (! copy.ok || std::any_of (std::begin (lines), std::end (lines), [&] (const char* l) { return countOf (copy, l) != 0; }))
- rollup031s8Result = "ERROR 190pr's lines for a project saved before it";
- else if (const auto plain = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.30"); ! plain.ok || ! plain.lost.empty())
- rollup031s8Result = "ERROR lines for the default song (" + juce::String ((int) plain.lost.size()) + ")";
- }
- }
- // rollup 0.1.32 step 1 (round 190qn): Save a copy for 0.1.31 (the new first step, toRelease0131) and the chain under it.
- // One project with every 0.1.32 format addition: 12 effects on an insert with 14 rows and an automation of slot 12 (PR
- // #260), a note with 4 ratchets and one with a Condition (190pm), a 3x Osc at revision 4 with an automation of one of
- // its FL parameters and a channel PITCH clip (190py), Effector at the Kilohearts Flanger (50) and Ensemble (52) laws
- // (190py-khs). The copy for 0.1.31: 10 effects and no slotRows, the ratchets as 4 notes and no note past [20], every
- // channel at revision 3 or lower, Effector's [12 …] cut, each line once, stamped 0.1.31; the copies for 0.1.30 and
- // 0.1.28 run it first: each line once there too, revisions 2 / none. The default song: no line. Round 190px's caches are
- // not in projects: a stretched copy of a stereo file with identical channels is written with header channels -2 (one
- // channel; 0.1.31 accepts only 1 / 2 and stretches again) and reads back as both channels; a streamed one (over 30 s)
- // keeps .L.pcm + .R.same and no .R.pcm (0.1.31 wants both .pcm files, so it decodes again).
- juce::String rollup032Result = "OK";
- {
- auto song = lynx::Song::makeDefault();
- if (song.mixer.size() < 3)
- song.mixer = lynx::Song::defaultMixer (4);
- auto& bus = song.mixer[1];
- bus.name = "Bus 190qn";
- bus.effects.clear();
- for (int i = 0; i < 12; ++i)
- {
- auto fx = lynx::makeEffectSlot (i == 0 ? lynx::EffectKind::effector : i == 1 ? lynx::EffectKind::effector : lynx::EffectKind::utility);
- fx.row = i;
- if (i < 2)
- fx.params[(std::size_t) lynx::khsdsp::lawParam] = lynx::khsdsp::lawValue (i == 0 ? lynx::khsdsp::Law::flanger : lynx::khsdsp::Law::ensemble2);
- bus.effects.push_back (fx);
- }
- bus.slotRows = 14;
- lynx::Automation slotGain;
- slotGain.name = "Slot 12 gain 190qn";
- slotGain.target = { lynx::AutomationTargetKind::effectParam, 1, 11, 0 };
- slotGain.points = { { 0, 0.25f }, { lynx::ppq, 0.75f } };
- song.automations.push_back (slotGain);
- const auto first = (int) song.channels.size();
- lynx::ChannelDef osc;
- osc.name = "3x Osc 190qn";
- osc.instrument = lynx::InstrumentKind::threeosc;
- song.channels.push_back (osc);
- int oscParam = -1;
- for (int k = 0; k < 120 && oscParam < 0; ++k)
- if (lynx::threeosc::isFlTarget (k))
- oscParam = k;
- lynx::Automation oscClip, pitchClip;
- oscClip.name = "3x Osc param 190qn";
- oscClip.target = { lynx::AutomationTargetKind::channelParam, first, 0, oscParam };
- oscClip.points = { { 0, 0.2f }, { lynx::ppq, 0.8f } };
- pitchClip.name = "Pitch 190qn";
- pitchClip.target = { lynx::AutomationTargetKind::channelParam, 0, 0, lynx::channelPitchParam };
- pitchClip.points = { { 0, 0.5f }, { lynx::ppq, 0.75f } };
- song.automations.push_back (oscClip);
- song.automations.push_back (pitchClip);
- // rollup 0.1.32 step 2: round 190qo's engine revision 5 (issue #271): a SoundFont channel with a slide note and a
- // quiet note, a BooBass channel with a quiet note
- const auto fontChannel = (int) song.channels.size();
- lynx::ChannelDef font, boo;
- font.name = "SoundFont 190qv";
- font.instrument = lynx::InstrumentKind::soundfont;
- boo.name = "BooBass 190qv";
- boo.instrument = lynx::InstrumentKind::boobass;
- song.channels.push_back (font);
- song.channels.push_back (boo);
- // round 190qz: an Envelope Controller (channel revision 6) and a Peak Controller (slot revision 3) with links; an
- // Effector at round 190qz-khs's law 55 (kHs Delay) on insert 2
- lynx::ChannelDef envelope;
- envelope.name = "Envelope 190qz";
- envelope.instrument = lynx::InstrumentKind::controller;
- envelope.controllerState = lynx::writeEnvelopeController (lynx::defaultEnvelopeController());
- song.channels.push_back (envelope);
- {
- auto& bus2 = song.mixer[2];
- bus2.effects.clear();
- auto peakCtl = lynx::makeEffectSlot (lynx::EffectKind::peakController);
- auto delay55 = lynx::makeEffectSlot (lynx::EffectKind::effector);
- delay55.row = 1;
- delay55.params[(std::size_t) lynx::khsdsp::lawParam] = lynx::khsdsp::lawValue (lynx::khsdsp::Law::delay);
- bus2.effects = { peakCtl, delay55 };
- lynx::Automation envLink, peakLink;
- envLink.name = "Envelope link 190qz";
- envLink.target = { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 };
- envLink.source.channel = fontChannel + 2;
- peakLink.name = "Peak link 190qz";
- peakLink.target = { lynx::AutomationTargetKind::mixerVolume, 0, 0, 0 };
- peakLink.source.track = 2;
- peakLink.source.slot = 0;
- song.automations.push_back (envLink);
- song.automations.push_back (peakLink);
- }
- if (song.patterns.empty())
- song.patterns.emplace_back();
- auto& notes = song.patterns[0].notes;
- notes.clear();
- lynx::Note ratchet, conditioned;
- ratchet.channel = 0, ratchet.key = 60, ratchet.start = 0, ratchet.length = lynx::ppq, ratchet.ratchets = 4;
- conditioned.channel = 0, conditioned.key = 64, conditioned.start = 2 * lynx::ppq, conditioned.length = lynx::ppq;
- conditioned.cycle = 4, conditioned.cycleMask = 2; // 2:4
- notes.push_back (ratchet);
- notes.push_back (conditioned);
- lynx::Note fontNote, fontSlide, booNote;
- fontNote.channel = fontChannel, fontNote.key = 48, fontNote.start = 0, fontNote.length = 2 * lynx::ppq, fontNote.velocity = 0.3f;
- fontSlide.channel = fontChannel, fontSlide.key = 55, fontSlide.start = lynx::ppq, fontSlide.length = lynx::ppq / 2, fontSlide.slide = true;
- booNote.channel = fontChannel + 1, booNote.key = 36, booNote.start = 0, booNote.length = lynx::ppq, booNote.velocity = 0.4f;
- notes.push_back (fontNote);
- notes.push_back (fontSlide);
- notes.push_back (booNote);
- const char* const lines[] = { "This release holds 10 effect slots", "{0} note(s) with ratchets become their strikes",
- "{0} note(s) with a Condition", "Automation of a channel's Pitch knob does nothing",
- "Automation of 3x Osc's parameters does nothing", "Effector's newer Kilohearts laws (the Comb Filter",
- "Effector's Kilohearts Flanger and Dual Delay laws",
- "Slide notes move only the pitch on these channels", // (round 190qo, revision 5)
- "SoundFont channels play low velocities much quieter", "BooBass plays every note at full level",
- "Peak and Envelope Controller links set their targets from the start", // (round 190qz)
- "Effector's newer Kilohearts laws (the kHs Ring Mod's oversampled path" }; // (round 190qz-khs)
- const auto countOf = [] (const lynx::olderlynx::Copy& c, const char* begin) {
- return (int) std::count_if (c.lost.begin(), c.lost.end(), [begin] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).startsWith (begin); });
- };
- const auto rels = lynx::olderlynx::releases();
- if (oscParam < 0)
- rollup032Result = "ERROR set-up: no 3x Osc FL target";
- else if (song.channels[(std::size_t) first].engineRev != 6 || song.channels[(std::size_t) fontChannel].engineRev != 6) // (round 190qo: 5, issue #271's slide velocity; round 190qz: 6)
- rollup032Result = "ERROR set-up: a new channel is not at revision 6";
- else if (rels.size() != 4 || rels[0] != "0.1.31" || rels[1] != "0.1.30" || rels[2] != "0.1.28" || rels[3] != "0.1.27")
- rollup032Result = "ERROR the release list: " + rels.joinIntoString (" ");
- for (const auto* release : { "0.1.31", "0.1.30", "0.1.28" })
- {
- if (rollup032Result != "OK")
- break;
- const auto rel = juce::String (release);
- const auto copy = lynx::olderlynx::forRelease (song, rel);
- const auto root = juce::JSON::parse (copy.json);
- juce::String why;
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- if (! copy.ok || ! old)
- {
- rollup032Result = "ERROR copy " + rel + " " + copy.error + why;
- break;
- }
- for (const auto* l : lines)
- if (countOf (copy, l) != 1)
- {
- rollup032Result = "ERROR the copy for " + rel + ": \"" + l + "\" " + juce::String (countOf (copy, l)) + " times";
- break;
- }
- if (rollup032Result != "OK")
- break;
- const auto& fx = root["mixer"][1]["effects"];
- int longest = 0, struck = 0;
- if (const auto* ns = root["patterns"][0]["notes"].getArray())
- for (const auto& n : *ns)
- {
- longest = std::max (longest, n.size());
- struck += (int) n[3] == 60 ? 1 : 0;
- }
- bool detached = false;
- if (const auto* autos = root["automations"].getArray())
- for (const auto& a : *autos)
- if (a["name"].toString() == "Slot 12 gain 190qn")
- detached = a["target"][0].toString() == "none";
- const auto maxRev = rel == "0.1.31" ? 3 : rel == "0.1.30" ? 2 : 0;
- const auto revOk = std::all_of (old->channels.begin(), old->channels.end(), [maxRev] (const lynx::ChannelDef& c) { return c.engineRev <= maxRev; })
- && (rel != "0.1.28" || ! copy.json.contains ("engineRev"))
- && (rel != "0.1.31" || (old->channels[(std::size_t) first].engineRev == 3 && old->channels[(std::size_t) fontChannel].engineRev == 3));
- if (! root["savedBy"].toString().equalsIgnoreCase (rel))
- rollup032Result = "ERROR the copy for " + rel + " is stamped " + root["savedBy"].toString();
- else if (fx.size() != 10 || copy.json.contains ("slotRows") || ! detached)
- rollup032Result = "ERROR the copy for " + rel + ": slots (" + juce::String (fx.size()) + " effects)";
- else if (longest > 21 || struck != 4)
- rollup032Result = "ERROR the copy for " + rel + ": notes (longest " + juce::String (longest) + ", strikes " + juce::String (struck) + ")";
- else if (fx[0]["params"].size() > lynx::khsdsp::lawParam || fx[1]["params"].size() > lynx::khsdsp::lawParam)
- rollup032Result = "ERROR the copy for " + rel + ": Effector's [12] is left";
- else if (! revOk)
- rollup032Result = "ERROR the copy for " + rel + ": engine revisions";
- else if ((int) root["mixer"][2]["effects"][0]["engineRev"] > 2 || root["mixer"][2]["effects"][1]["params"].size() > lynx::khsdsp::lawParam)
- rollup032Result = "ERROR the copy for " + rel + ": round 190qz's Peak Controller revision / Effector law 55";
- }
- if (rollup032Result == "OK")
- if (const auto plain = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.31"); ! plain.ok || ! plain.lost.empty())
- rollup032Result = "ERROR lines for the default song (" + juce::String ((int) plain.lost.size()) + ")";
- // round 190px's caches (not in projects; what 0.1.31 does with them)
- if (rollup032Result == "OK")
- {
- const auto dir = lynx::SampleLibrary::cacheFolder().getParentDirectory().getChildFile ("selftest-190qn");
- dir.deleteRecursively();
- dir.createDirectory();
- const auto writeSame = [&dir] (const juce::String& name, int frames) {
- const auto wav = dir.getChildFile (name);
- juce::WavAudioFormat format;
- juce::AudioBuffer<float> audio (2, frames);
- for (int i = 0; i < frames; ++i)
- {
- const auto v = 0.4f * std::sin (0.031f * (float) i) + 0.2f * std::sin (0.0071f * (float) i);
- audio.setSample (0, i, v);
- audio.setSample (1, i, v);
- }
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 44100.0, 2, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- return wav;
- };
- const auto cache = lynx::SampleLibrary::cacheFolder();
- const auto newest = [&cache] (const juce::String& pattern, juce::Time since) {
- juce::File found;
- for (const auto& f : cache.findChildFiles (juce::File::findFiles, false, pattern))
- if (f.getLastModificationTime() >= since && (found == juce::File() || f.getLastModificationTime() > found.getLastModificationTime()))
- found = f;
- return found;
- };
- const auto since = juce::Time::getCurrentTime() - juce::RelativeTime::seconds (2.0);
- lynx::SampleLibrary library;
- const auto shortWav = writeSame ("same 190qn.wav", 44100);
- // (a ratio within resampleTolerance: the copy is resampled channel by channel, so identical channels stay identical,
- // as Thief's near-tempo stems; the spectral stretchers' stereo output need not be bit-identical across channels)
- const auto stretched = library.loadStretched (shortWav.getFullPathName(), 1.0005);
- // (the copy is written by the cache's writer thread: the new .str file whose frames are this copy's)
- juce::File str;
- juce::MemoryBlock bytes;
- std::int32_t channels = 0;
- std::int64_t frames = 0;
- for (int tries = 0; tries < 600 && str == juce::File() && stretched != nullptr; ++tries) // (rollup 0.1.32 step 2: up to 30 s — the writer thread queues behind the self-test's other cache writes; 10 s ran out once under load)
- {
- juce::Thread::sleep (50);
- for (const auto& f : cache.findChildFiles (juce::File::findFiles, false, "*.str"))
- {
- juce::MemoryBlock b;
- std::int64_t n = 0;
- if (f.getLastModificationTime() < since || ! f.loadFileAsData (b) || b.getSize() < 32)
- continue;
- std::memcpy (&n, static_cast<const char*> (b.getData()) + 16, 8);
- if (n != (std::int64_t) stretched->frames() || (juce::int64) b.getSize() < 32 + n * (juce::int64) sizeof (float))
- continue;
- str = f, bytes = b, frames = n;
- std::memcpy (&channels, static_cast<const char*> (b.getData()) + 24, 4);
- break;
- }
- }
- // 0.1.31's acceptance (SampleLibrary.cpp readStretched at v0.1.31-alpha): channels 1 or 2 and the size they make
- const auto acceptedBy0131 = frames > 0 && (channels == 1 || channels == 2)
- && (juce::int64) bytes.getSize() == 32 + frames * channels * (juce::int64) sizeof (float);
- if (stretched == nullptr || ! stretched->isStereo() || str == juce::File())
- rollup032Result = juce::String ("ERROR stretch cache: nothing written (")
- + (stretched == nullptr ? "no copy" : ! stretched->isStereo() ? "the copy is mono" : "no new .str in 30 s") + ")";
- else if (channels != -2 || frames != (std::int64_t) stretched->frames() || (juce::int64) bytes.getSize() != 32 + frames * (juce::int64) sizeof (float)
- || std::memcmp (static_cast<const char*> (bytes.getData()) + 32, stretched->leftData(), (std::size_t) frames * sizeof (float)) != 0
- || std::memcmp (stretched->leftData(), stretched->rightData(), (std::size_t) frames * sizeof (float)) != 0)
- rollup032Result = "ERROR stretch cache: header channels " + juce::String (channels) + ", frames " + juce::String ((juce::int64) frames);
- else if (acceptedBy0131)
- rollup032Result = "ERROR stretch cache: 0.1.31 would read the one-channel file";
- if (rollup032Result == "OK")
- {
- const auto longWav = writeSame ("same long 190qn.wav", 44100 * 31);
- const auto streamed = library.load (longWav.getFullPathName());
- const auto same = newest ("*.R.same", since);
- const auto key = same.getFileName().upToFirstOccurrenceOf (".R.same", false, false);
- if (streamed == nullptr || ! streamed->isMapped() || ! streamed->isStereo() || streamed->rightData() != streamed->leftData())
- rollup032Result = "ERROR stream cache: not mapped as one channel";
- else if (same == juce::File() || ! cache.getChildFile (key + ".L.pcm").existsAsFile() || cache.getChildFile (key + ".R.pcm").existsAsFile())
- rollup032Result = "ERROR stream cache files (" + same.getFileName() + ")";
- }
- dir.deleteRecursively();
- }
- }
- // rollup 0.1.31 step 7 (PRs #248 / #256 by FKHR26): the docked channel window's header shows by default; its gear hides
- // it, a window of the same channel opened again hides it too (the choice kept per window), the project's window
- // places carry it ([key, "headerHidden"]) and give it back, an older project's places (0.1.30's shape) none; the gear
- // shows it again
- juce::String headerGearResult = "OK";
- {
- lynx::AudioEngine e (false);
- lynx::windowplaces::fromVar ({});
- const auto shownIn = [] (juce::Component* w) { return w == nullptr ? std::optional<bool> {} : lynx::channelWindowHeaderShown (*w); };
- auto first = lynx::makeChannelWindowForShot (e, 0, 0);
- if (shownIn (first.get()) != std::optional<bool> (true))
- headerGearResult = "ERROR not shown by default";
- else if (! lynx::pressChannelHeaderGear (*first) || shownIn (first.get()) != std::optional<bool> (false))
- headerGearResult = "ERROR the gear did not hide it";
- first.reset();
- if (headerGearResult == "OK")
- {
- auto again = lynx::makeChannelWindowForShot (e, 0, 0);
- const auto saved = lynx::windowplaces::toVar();
- const auto savedText = juce::JSON::toString (saved, true);
- if (shownIn (again.get()) != std::optional<bool> (false))
- headerGearResult = "ERROR the choice was not kept for the window";
- else if (! savedText.contains ("headerHidden"))
- headerGearResult = "ERROR the places do not carry it: " + savedText;
- else
- {
- again.reset();
- lynx::windowplaces::fromVar (juce::JSON::parse (juce::String ("[[\"ch:1\", 10, 10, 300, 200, false]]")));
- auto older = lynx::makeChannelWindowForShot (e, 0, 0);
- if (shownIn (older.get()) != std::optional<bool> (true))
- headerGearResult = "ERROR hidden after an older project's places";
- older.reset();
- lynx::windowplaces::fromVar (saved);
- auto restored = lynx::makeChannelWindowForShot (e, 0, 0);
- if (headerGearResult == "OK" && shownIn (restored.get()) != std::optional<bool> (false))
- headerGearResult = "ERROR the saved places did not give it back";
- else if (headerGearResult == "OK" && (! lynx::pressChannelHeaderGear (*restored) || shownIn (restored.get()) != std::optional<bool> (true)
- || ! lynx::windowplaces::hiddenHeaders().empty()))
- headerGearResult = "ERROR the gear did not show it again";
- }
- }
- lynx::windowplaces::fromVar ({});
- }
- // round 190pw (PR #259 by FKHR26): the channel window is the size of the tab it shows, as FL's (FL 2026: Sytrus
- // 860 px wide on its plugin tab, 568 on Misc): a Synth channel's window (docked look) on its plugin tab, then Misc
- // (another size), back (the first size again), and with the header hidden by the gear, each less the header
- // round 190qf (PR #260 by codewithamoako): FL 2026.2's effect slots, up to 25 per insert (src/Slots260Shot190qf.inc)
- const auto slots260Result = slots260Checks ({});
- juce::String perTab259Result = "OK";
- {
- lynx::AudioEngine e (false);
- lynx::windowplaces::fromVar ({});
- e.editSong ([] (lynx::Song& s) {
- lynx::ChannelDef d;
- d.instrument = lynx::InstrumentKind::synth;
- d.name = "Synth";
- d.mixerTrack = s.claimFreeInsert();
- s.channels.push_back (d);
- });
- e.dispatchPendingMessages();
- const auto header = lynx::channelFrameHeaderHeight();
- if (auto w = lynx::makeChannelWindowForShot (e, (int) e.getSong().channels.size() - 1, 0))
- {
- const auto first = w->getBounds();
- lynx::showChannelWindowTab (*w, -1);
- const auto misc = w->getBounds();
- lynx::showChannelWindowTab (*w, 0);
- const auto back = w->getBounds();
- lynx::pressChannelHeaderGear (*w);
- const auto hiddenFirst = w->getBounds();
- lynx::showChannelWindowTab (*w, -1);
- const auto hiddenMisc = w->getBounds();
- if (misc.getWidth() == first.getWidth() && misc.getHeight() == first.getHeight())
- perTab259Result = "ERROR Misc has the plugin tab's size " + first.toString();
- else if (back != first)
- perTab259Result = "ERROR back on the plugin tab " + back.toString() + ", first " + first.toString();
- else if (hiddenFirst.getHeight() != first.getHeight() - header || hiddenMisc.getHeight() != misc.getHeight() - header)
- perTab259Result = "ERROR header hidden " + hiddenFirst.toString() + " / " + hiddenMisc.toString();
- }
- else
- perTab259Result = "ERROR no window";
- // round 190qd: FL's Sampler window keeps one size on all its tabs (Sample, Envelope / instrument, Misc)
- e.editSong ([] (lynx::Song& s) {
- lynx::ChannelDef d;
- d.instrument = lynx::InstrumentKind::sampler;
- d.name = "Sampler";
- d.mixerTrack = s.claimFreeInsert();
- s.channels.push_back (d);
- });
- e.dispatchPendingMessages();
- if (auto w = perTab259Result == "OK" ? lynx::makeChannelWindowForShot (e, (int) e.getSong().channels.size() - 1, 0) : nullptr)
- {
- const auto first = w->getBounds();
- lynx::showChannelWindowTab (*w, 1);
- const auto envelope = w->getBounds();
- lynx::showChannelWindowTab (*w, -1);
- const auto misc = w->getBounds();
- if (envelope != first || misc != first)
- perTab259Result = "ERROR Sampler tabs differ " + first.toString() + " / " + envelope.toString() + " / " + misc.toString();
- }
- else if (perTab259Result == "OK")
- perTab259Result = "ERROR no Sampler window";
- lynx::windowplaces::fromVar ({});
- }
- // hotfix 0.1.31.1 (round 190qp): a docked window's place in the dock's coordinates (src/HotfixUi190qp.inc)
- const auto hotfixPlacesResult = hotfixPlaces190qpCheck();
- // round 190pv (issue #258): a cloned channel's own automation clip drives its sound (src/Issue258Test.inc: the app's
- // engine, render-ahead off and on; Transistor Bass when FL Studio is here, LYNX Synth always)
- juce::String issue258Log;
- const auto issue258Result = issue258Check (issue258Log);
- // round 190qp (0.1.31.1, issue #253 / Discord): an imported FL project's mixer volume, send level and Fruity Filter
- // cutoff automation heard and shown through the app's engine, as imported, with a flat lane added and with the
- // clips moved into lanes, render-ahead off / on, Clip-launch's override (src/Hotfix190qpTest.inc)
- juce::String autolive190qpLog;
- const auto autolive190qpResult = autoLiveCheck (autoLiveFlSong(), autolive190qpLog, 2, true);
- // round 190qs (issue #282): FL's trial mark travels with its plugin in Export to FL Studio (src/Issue282Check.inc)
- juce::String issue282Log;
- const auto issue282Result = issue282Check (issue282Log);
- // round 190qr (issues #274-#281): markers' Delete, the rack's time signature, FL's deepest zoom and the samples drawn
- // there, the zoom-around-the-song-position and gain-handle extras (src/Issues190qrCheck.inc)
- juce::String issues190qrLog;
- const auto issues190qrResult = issues190qrCheck (issues190qrLog);
- // round 190rb (0.1.32 quality release): the crash / memory fixes of the crash reports, the sanitizer build and the
- // UI monkey test (src/Qa190rbCheck.inc)
- juce::String qa190rbLog;
- const auto qa190rbResult = qa190rbCheck (qa190rbLog);
- // round 190qh (research190qa R5, Mixer QoL): FL's rule for a switched-off slot through the app's own publish
- // (D2-MX9, REA 190qc: its latency leaves the plan at once, a muted insert keeps it), the theme's own meter
- // thresholds in a .lynxtheme (D2-MX7; none written for the default look), the three unbound actions (D2-MX1, MX8)
- // and the strips' extras (D2-VF5, MX3: off by default, under the read-out when on, the meters shorter by them)
- juce::String mixerqol190qhResult = "OK";
- {
- lynx::AudioEngine e (false);
- const auto before = e.getLatencySamples(); // (the default song's own: its Master limiter)
- e.editSong ([] (lynx::Song& s) {
- auto limiter = lynx::makeEffectSlot (lynx::EffectKind::fruityLimiter);
- limiter.params[3] = 0.401f; // (FL's look-ahead, about 11 ms: round 188e)
- s.mixer[1].effects.push_back (limiter);
- });
- const auto on = e.getLatencySamples();
- e.editSong ([] (lynx::Song& s) { s.mixer[1].effects[0].enabled = false; });
- const auto off = e.getLatencySamples();
- e.editSong ([] (lynx::Song& s) {
- s.mixer[1].effects[0].enabled = true;
- s.mixer[1].muted = true;
- });
- const auto muted = e.getLatencySamples();
- if (on <= before || off != before || muted != on)
- mixerqol190qhResult = "ERROR PDC before / on / off / muted " + juce::String (before) + " / " + juce::String (on) + " / " + juce::String (off) + " / "
- + juce::String (muted);
- lynx::themes::Spec spec;
- const auto plain = lynx::themeui::toJson (spec);
- spec.meterZones = true;
- spec.meterYellowDb = -12.0f;
- spec.meterRedDb = -3.0f;
- const auto back = lynx::themeui::fromJson (lynx::themeui::toJson (spec));
- if (plain.contains ("meterYellowDb") || ! back || ! back->meterZones || back->meterYellowDb != -12.0f || back->meterRedDb != -3.0f
- || lynx::themeui::fromJson (plain)->meterZones)
- mixerqol190qhResult = "ERROR theme meter thresholds";
- for (const auto* id : { "mixer.unsoloAll", "mixer.unmuteAll", "mixer.inputMonitoring" })
- if (const auto* a = lynx::keys::findAction (id); a == nullptr || ! lynx::keys::KeyMap().chordsFor (id).empty())
- mixerqol190qhResult = "ERROR action " + juce::String (id);
- const auto keptPeaks = lynx::MixerStrips::showPeakValues, keptCorrelation = lynx::MixerStrips::showCorrelation;
- {
- lynx::MixerComponent mixer (e);
- mixer.setSize (1400, 800);
- auto& strips = mixer.getStripsForSnapshot();
- strips.setShowPeakValues (false);
- strips.setShowCorrelation (false);
- const auto fader = strips.faderAreaForSnapshot (1);
- const auto none = strips.peakValueAreaForSnapshot (1).isEmpty() && strips.correlationAreaForSnapshot (1).isEmpty();
- strips.setShowPeakValues (true);
- strips.setShowCorrelation (true);
- const auto peak = strips.peakValueAreaForSnapshot (1), corr = strips.correlationAreaForSnapshot (1);
- const auto shorter = strips.faderAreaForSnapshot (1);
- if (! none || peak.isEmpty() || corr.isEmpty() || corr.getY() <= shorter.getBottom() || peak.getY() < corr.getBottom()
- || fader.getHeight() - shorter.getHeight() != lynx::MixerStrips::correlationRowHeight + lynx::MixerStrips::peakRowHeight
- || ! e.getMeters().correlationWanted.load())
- mixerqol190qhResult = "ERROR strip extras " + peak.toString() + " / " + corr.toString() + " / " + fader.toString() + " / " + shorter.toString();
- strips.setShowPeakValues (false);
- strips.setShowCorrelation (false);
- }
- lynx::MixerStrips::showPeakValues = keptPeaks;
- lynx::MixerStrips::showCorrelation = keptCorrelation;
- }
- // round 190qe (TOP-NEXT R1): the edge scroll at FL's speed, the view stack, the zoom glide and anchor, Restore
- // selection, Keep labels on screen, through the real Playlist / Piano roll off screen (src/Feel190qeTest.inc)
- juce::String feel190qeResult;
- runFeel190qeTest ({}, {}, {}, &feel190qeResult);
- // round 190qg: every toolbar item on the toolbar or in its overflow at every preset, Interface size and width
- juce::String toolbar190qgLog;
- const auto toolbar190qgResult = toolbar190qgCheck (toolbar190qgLog);
- // round 190qu (Discord 11-24): automation clips into lanes play what they played (held value between clips, the
- // control's own value before, FL's MIN / MAX), in the engine's first 1024 slots, and back into clips; FL's Split by
- // channel; Convert to Track-only keeps every note; a Track-only instrument track's pencil draws new clips
- juce::String discord190quResult = "OK";
- {
- using namespace lynx;
- auto s = Song::makeDefault();
- s.playlist.clear();
- s.channels.clear();
- s.automations.clear();
- s.channels.push_back (mididrop::newChannel ("Lead"));
- trackmodes::makeInstrumentTrack (s, 2, 0);
- s.channels[0].volume = 0.62f;
- Automation a;
- a.target = { AutomationTargetKind::channelVolume, 0, 0, 0 };
- a.points = { { 0, 0.0f, 0.0f }, { 4 * ppq, 1.0f, 0.0f } };
- a.rangeMin = 0.2f;
- a.rangeMax = 0.6f;
- s.automations.push_back (a);
- for (int k = 0; k < 1030; ++k) // (more automations than the engine's slots after it, on the tempo: no owner track)
- {
- Automation t;
- t.target = { AutomationTargetKind::tempo, 0, 0, 0 };
- t.points = { { 0, 0.5f, 0.0f } };
- s.automations.push_back (t);
- }
- Clip c;
- c.kind = ClipKind::automation;
- c.automation = 0;
- c.track = 5;
- c.start = 4 * ppq;
- c.length = 4 * ppq;
- s.playlist.push_back (c);
- const auto moved = laneview::clipsToLanes (s);
- const auto lane = s.playlistTracks.size() > 2 && ! s.playlistTracks[2].lanes.empty() ? s.playlistTracks[2].lanes[0].automation : -1;
- if (moved != 1 || lane < 0 || lane >= RackState::maxAutomations)
- discord190quResult = "ERROR lane slot " + juce::String (lane);
- else
- {
- const auto& points = s.automations[(std::size_t) lane];
- const auto atStart = points.valueAt ((double) ppq), mid = points.valueAt (6.0 * ppq), held = points.valueAt (20.0 * ppq);
- if (std::abs (atStart - 0.62f) > 1.0e-4f || std::abs (mid - 0.4f) > 1.0e-3f || std::abs (held - 0.6f) > 1.0e-4f)
- discord190quResult = "ERROR lane values " + juce::String (atStart) + " / " + juce::String (mid) + " / " + juce::String (held);
- else if (autolanes::lanesToClips (s) != 1 || laneview::laneCount (s) != 0)
- discord190quResult = "ERROR lanes back to clips";
- }
- auto p = Song::makeDefault();
- p.patterns.assign (1, Pattern {});
- p.patterns[0].notes = { { 0, ticksPerStep, 0, 60 }, { ticksPerStep, ticksPerStep, 2, 60 } };
- Clip pc;
- pc.kind = ClipKind::pattern;
- pc.track = 0;
- pc.length = p.barTicks();
- p.playlist = { pc };
- auto split = p;
- if (discord190quResult == "OK"
- && (splitPatternByChannel (split, 0) != 1 || split.patterns[0].name != split.channels[0].name || split.playlist.size() != 1))
- discord190quResult = "ERROR split by channel";
- const auto report = trackonly::convertProject (p);
- if (discord190quResult == "OK" && (report.patternsSplit != 1 || report.clipsMoved != 2 || trackmodes::instrumentTracksOf (p, 2).empty()))
- discord190quResult = "ERROR convert " + juce::String (report.patternsSplit) + " / " + juce::String (report.clipsMoved);
- const auto layout = layoutstyle::current();
- const auto trackOnly = trackonly::enabled();
- layoutstyle::setCurrent (layoutstyle::Style::pattern);
- trackonly::setEnabled (true);
- const auto home = trackmodes::instrumentTracksOf (p, 0);
- if (discord190quResult == "OK" && (home.empty() || ! trackclips::pencilMakesNewClip (p, home.front())))
- discord190quResult = "ERROR pencil";
- trackonly::setEnabled (trackOnly);
- layoutstyle::setCurrent (layout);
- }
- // round 190ot (research190oe P5): the Simple layout's "Duck under..." and shared Echo send in .lynx (the duck's goal,
- // Amount, side input and level-0 route; the Echo send) and in the copies for 0.1.30 / 0.1.28: the same slot, side input,
- // route and sends (an ordinary Fruity Limiter there), one view line, none for a project without a duck
- // round 190pe (research190oe P20 / P11): a track's versions in .lynx (every version, the active one), a switch as one
- // undo step that restores the song bit for bit, the copies for 0.1.30 / 0.1.28 (only the active version, one line;
- // none without versions), and tracks of another project imported as one undo step
- juce::String tracks190peResult = "OK";
- {
- namespace tv = lynx::trackversions;
- auto song = lynx::Song::makeDefault();
- song.playlist.clear();
- lynx::ChannelDef vox;
- vox.name = "Vox";
- vox.instrument = lynx::InstrumentKind::audioClip;
- vox.samplePath = "vox.wav";
- const auto ins = song.nextFreeInsert(); // (an insert of its own: the version's chain)
- vox.mixerTrack = ins;
- song.channels.push_back (vox);
- song.mixer[(std::size_t) ins].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::eq));
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = (int) song.channels.size() - 1;
- c.track = 1;
- c.length = 4 * lynx::ppq;
- song.playlist.push_back (c);
- song.playlistTracks.resize (2);
- song.playlistTracks[1].name = "Vox";
- const auto plain = lynx::ProjectFile::toJson (song);
- tv::add (song, 1, tv::Start::duplicate, "B", "A");
- for (auto& k : song.playlist)
- if (k.track == 1)
- k.length = lynx::ppq;
- song.mixer[(std::size_t) ins].effects[0].enabled = false;
- juce::String why;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (plain.contains ("playlistTrackVersions"))
- tracks190peResult = "ERROR a project without versions writes the key";
- else if (! back || back->playlistTracks.size() < 2 || back->playlistTracks[1].versions != song.playlistTracks[1].versions
- || back->playlistTracks[1].activeVersion != 1 || back->playlist != song.playlist)
- tracks190peResult = "ERROR .lynx round trip " + why;
- if (tracks190peResult == "OK")
- {
- lynx::AudioEngine e (false);
- e.setSong (song);
- // (editSongStructural first adds the working time so far to the song: the undo step holds that)
- const auto json = [] (lynx::Song s) {
- s.info.workSeconds = 0.0;
- return lynx::ProjectFile::toJson (s);
- };
- const auto before = json (e.getSong());
- e.editSongStructural ([] (lynx::Song& s) { tv::switchTo (s, 1, 0); });
- const auto switched = tv::active (e.getSong(), 1) == 0 && e.getSong().mixer[(std::size_t) ins].effects[0].enabled;
- e.undo();
- if (! switched || json (e.getSong()) != before)
- tracks190peResult = juce::String ("ERROR undo of a version switch (switched ") + (switched ? "yes" : "no") + ")";
- // tracks of another project: one undo step
- if (tracks190peResult == "OK")
- {
- auto other = song;
- lynx::trackimport::Result r;
- e.editSongStructural ([&r, &other] (lynx::Song& s) { r = lynx::trackimport::importTracks (s, other, { 1 }, {}); });
- const auto came = r.ok && r.tracks.size() == 1 && r.inserts.size() == 1 && tv::count (e.getSong(), r.tracks[0]) == 2;
- e.undo();
- if (! came || json (e.getSong()) != before)
- tracks190peResult = juce::String ("ERROR import of a track and its undo (came ") + (came ? "yes" : "no") + ")";
- }
- }
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (tracks190peResult != "OK")
- break;
- const auto copy = lynx::olderlynx::forRelease (song, release);
- const auto lines = std::count_if (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("track version"); });
- const auto opened = lynx::ProjectFile::fromJson (copy.json, why);
- if (! copy.ok || lines != 1 || copy.json.contains ("playlistTrackVersions") || ! opened || opened->playlist != song.playlist
- || opened->mixer[(std::size_t) ins].effects[0].enabled)
- tracks190peResult = juce::String ("ERROR the copy for ") + release + " (" + juce::String ((int) lines) + " lines) " + why;
- }
- if (tracks190peResult == "OK")
- {
- const auto copy = lynx::olderlynx::forRelease (lynx::Song::makeDefault(), "0.1.30");
- if (std::any_of (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("track version"); }))
- tracks190peResult = "ERROR a version line without versions";
- }
- }
- juce::String simpleDuck190otResult = "OK";
- {
- namespace st = lynx::simpletracks;
- auto song = lynx::Song::makeDefault();
- st::Request q;
- q.kind = st::Kind::audio;
- q.name = "Kick";
- const auto kick = st::addTrack (song, q).insert;
- q.name = "Pad";
- const auto pad = st::addTrack (song, q).insert;
- const auto set = st::setDuck (song, pad, kick, 0.7f) == st::DuckResult::set && st::setEchoSend (song, pad, 0.3f);
- const auto keeps = [&] (const std::optional<lynx::Song>& back) {
- if (! back || (int) back->mixer.size() <= pad)
- return false;
- const auto slot = st::duckSlot (*back, pad);
- return slot >= 0 && st::duckTrigger (*back, pad) == kick && back->routes (kick, pad) && back->routeLevel (kick, pad) == 0.0f
- && std::abs (back->mixer[(std::size_t) pad].effects[(std::size_t) slot].goalAmount - 0.7f) < 1.0e-4f
- && st::sharedEcho (*back) == st::sharedEcho (song) && std::abs (st::echoSend (*back, pad) - 0.3f) < 1.0e-4f;
- };
- juce::String why;
- if (! set || kick <= 0 || pad <= 0)
- simpleDuck190otResult = "ERROR set-up";
- else if (! keeps (lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why)))
- simpleDuck190otResult = "ERROR .lynx round trip " + why;
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (simpleDuck190otResult != "OK")
- break;
- const auto copy = lynx::olderlynx::forRelease (song, release);
- const auto lines = std::count_if (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("Duck under"); });
- if (! copy.ok || ! keeps (lynx::ProjectFile::fromJson (copy.json, why)) || lines != 1)
- simpleDuck190otResult = juce::String ("ERROR the copy for ") + release + " (" + juce::String ((int) lines) + " duck lines) " + why;
- }
- if (simpleDuck190otResult == "OK")
- {
- st::setDuck (song, pad, -1);
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- if (std::any_of (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("Duck under"); }))
- simpleDuck190otResult = "ERROR a duck line without a duck";
- }
- }
- // round 190pm (research190oe P19): Note Repeats and Conditions in .lynx (every field), through the online sessions' note
- // codec (optional fields), and in the copies for 0.1.30 / 0.1.28 (ratchets as notes of their own, one view line;
- // conditions dropped, one sound line), none of it for a project without them
- juce::String repeats190pmResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- if (song.patterns.empty())
- song.patterns.resize (1);
- if (song.channels.empty())
- song.channels.resize (1);
- lynx::Note a;
- a.start = 0;
- a.length = lynx::ppq;
- a.ratchets = 4;
- a.ratchetVelocity = -0.5f;
- lynx::Note b = a;
- b.start = lynx::ppq;
- b.ratchets = 0;
- b.ratchetVelocity = 0.0f;
- b.condition = lynx::notecondition::notFirst;
- b.cycle = 4;
- b.cycleMask = 0b1010;
- song.patterns[0].notes = { a, b };
- juce::String why;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (! back || back->patterns[0].notes != song.patterns[0].notes)
- repeats190pmResult = "ERROR .lynx round trip " + why;
- for (const auto& n : song.patterns[0].notes)
- if (repeats190pmResult == "OK" && lynx::remote_notes::fromValue (lynx::remote_notes::toValue (n), song.channels.size()) != n)
- repeats190pmResult = "ERROR the online sessions' note codec";
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (repeats190pmResult != "OK")
- break;
- const auto copy = lynx::olderlynx::forRelease (song, release);
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::optional<lynx::Song> {};
- const auto lines = std::count_if (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).contains ("ratchets") || juce::String (l.text).contains ("Condition");
- });
- if (! old || old->patterns[0].notes.size() != 5 || lines != 2)
- repeats190pmResult = juce::String ("ERROR the copy for ") + release + " (" + juce::String ((int) lines) + " lines) " + why;
- }
- song.patterns[0].notes = { lynx::Note {} };
- if (repeats190pmResult == "OK")
- for (const auto& l : lynx::olderlynx::forRelease (song, "0.1.30").lost)
- if (juce::String (l.text).contains ("ratchets") || juce::String (l.text).contains ("Condition"))
- repeats190pmResult = "ERROR a line without ratchets or conditions";
- }
- // round 190ol (research190oe P1 / P6): the Sections lane in .lynx (both arrangements, and a project without sections
- // keeps its JSON with no "sections" key), a section move as one undo step that restores the song bit for bit, the
- // copies for 0.1.30 / 0.1.28 (sections become plain markers at their starts, one view line), and a 4/4 -> 7/8 -> 4/4
- // song's metronome table (core/SignatureEdit.h)
- juce::String sections190olResult = "OK";
- {
- const auto bar = 4 * (std::int64_t) lynx::ppq;
- auto song = lynx::Song::makeDefault();
- song.playlistTracks.resize (std::max<std::size_t> (2, song.playlistTracks.size())); // (std::max: juce::jmax<std::size_t> instantiates SIMDRegister<unsigned long> on macOS arm64)
- lynx::Clip c;
- c.pattern = 0;
- c.track = 0;
- c.length = 2 * bar;
- song.playlist = { c };
- c.start = 2 * bar;
- c.track = 1;
- song.playlist.push_back (c);
- song.sections() = { { 0, 2 * bar, "Intro", 0, 1 }, { 2 * bar, 2 * bar, "Verse", 0xFF336699u, 2 } };
- song.addArrangement ("Second", true);
- song.sections().push_back ({ 4 * bar, bar, "Outro", 0, 3 });
- song.selectArrangement (0);
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (! back || back->arrangements.size() != 2 || back->arrangements[0].sections != song.arrangements[0].sections
- || back->arrangements[1].sections != song.arrangements[1].sections || back->sections().size() != 2 || back->sections()[1].colour != 0xFF336699u)
- sections190olResult = "ERROR round trip " + why;
- else if (lynx::ProjectFile::toJson (lynx::Song::makeDefault()).contains ("\"sections\""))
- sections190olResult = "ERROR a project without sections writes the key";
- // one undo step, bit for bit
- if (sections190olResult == "OK")
- {
- lynx::AudioEngine e (false);
- e.setSong (song);
- const auto before = lynx::ProjectFile::toJson (e.getSong());
- e.editSong ([] (lynx::Song& s) { lynx::sections::move (s, 1, 0); });
- const auto moved = e.getSong().sections().size() == 2 && e.getSong().sections()[0].name == "Verse";
- e.undo();
- if (! moved || lynx::ProjectFile::toJson (e.getSong()) != before)
- sections190olResult = juce::String ("ERROR undo of a section move (moved ") + (moved ? "yes" : "no") + ")";
- }
- // the copies for older LYNX: plain markers at the sections' starts, "sections" gone, one line
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (sections190olResult != "OK")
- break;
- const auto copy = lynx::olderlynx::forRelease (song, release);
- const auto lines = std::count_if (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).contains ("Sections lane");
- });
- juce::String why2;
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why2) : std::nullopt;
- if (! copy.ok || copy.json.contains ("\"sections\"") || lines != 1 || ! old)
- sections190olResult = juce::String ("ERROR the copy for ") + release;
- else if (old->arrangements[0].markers.size() != 2 || old->arrangements[0].markers[1].name != "Verse" || old->arrangements[0].markers[1].tick != 2 * bar
- || old->arrangements[1].markers.size() != 3 || ! old->arrangements[0].sections.empty())
- sections190olResult = juce::String ("ERROR the markers in the copy for ") + release;
- }
- // P6: the metronome follows 4/4 -> 7/8 (bar 3) -> 4/4 (bar 5)
- if (sections190olResult == "OK")
- {
- auto meter = lynx::Song::makeDefault();
- const auto seven = 7 * (std::int64_t) lynx::ppq / 2;
- lynx::signatureedit::set (meter, 2 * bar, 7, 8);
- lynx::signatureedit::set (meter, 2 * bar + 2 * seven, 4, 4);
- lynx::AudioEngine e (false);
- e.setSong (meter);
- e.dispatchPendingMessages();
- const auto& t = e.getTransport();
- if (t.signatureCount.load() != 3 || t.signatureTick[1].load() != 2 * bar || t.signatureLength[1].load() != seven
- || t.signatureBeat[1].load() != (std::int64_t) lynx::ppq / 2 || t.signatureTick[2].load() != 2 * bar + 2 * seven
- || t.signatureLength[2].load() != bar || meter.barAt (2 * bar + 2 * seven).number != 5)
- sections190olResult = "ERROR the metronome's signature table (" + juce::String (t.signatureCount.load()) + " entries)";
- }
- }
- // round 190pf (research190oe P13 / P12): the Chord lane in .lynx (both arrangements; a channel's follow mode; a project
- // without chords keeps its JSON without the keys), a chord edit and Smart Tempo's write as one undo step each that
- // restore the song bit for bit, and the copies for 0.1.30 / 0.1.28 (chords become plain markers named after them,
- // "chords" and "followChords" gone, a line each)
- juce::String chordlane190pfResult = "OK";
- {
- const auto bar = 4 * (std::int64_t) lynx::ppq;
- auto song = lynx::Song::makeDefault();
- song.playlistTracks.resize (std::max<std::size_t> (2, song.playlistTracks.size())); // (std::max: juce::jmax<std::size_t> instantiates SIMDRegister<unsigned long> on macOS arm64)
- lynx::Clip c;
- c.pattern = 0;
- c.track = 0;
- c.length = 2 * bar;
- song.playlist = { c };
- const auto chord = [] (int root, int shape, std::int64_t start, std::int64_t length, int bass = -1) {
- auto x = lynx::chordlane::make (root, shape, bass);
- x.start = start;
- x.length = length;
- return x;
- };
- song.chords() = { chord (0, 0, 0, bar), chord (9, 4, bar, bar), chord (7, 2, 2 * bar, bar, 11) };
- lynx::chordlane::normalize (song.chords());
- song.addArrangement ("Second", true);
- song.chords().push_back (chord (5, 3, 4 * bar, bar));
- lynx::chordlane::normalize (song.chords());
- song.selectArrangement (0);
- song.channels.front().followChords = lynx::chordlane::followBass;
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (! back || back->arrangements.size() != 2 || back->arrangements[0].chords != song.arrangements[0].chords
- || back->arrangements[1].chords != song.arrangements[1].chords || back->chords().size() != 3 || back->chords()[2].bass != 11
- || back->channels.front().followChords != lynx::chordlane::followBass)
- chordlane190pfResult = "ERROR round trip " + why;
- else if (const auto plain = lynx::ProjectFile::toJson (lynx::Song::makeDefault()); plain.contains ("\"chords\"") || plain.contains ("followChords"))
- chordlane190pfResult = "ERROR a project without chords writes the keys";
- if (chordlane190pfResult == "OK")
- {
- lynx::AudioEngine e (false);
- e.setSong (song);
- const auto before = lynx::ProjectFile::toJson (e.getSong());
- e.editSong ([bar] (lynx::Song& s) { lynx::chordlane::move (s.chords(), 0, 3 * bar); });
- const auto moved = e.getSong().chords().back().start == 3 * bar;
- e.undo();
- if (! moved || lynx::ProjectFile::toJson (e.getSong()) != before)
- chordlane190pfResult = juce::String ("ERROR undo of a chord move (moved ") + (moved ? "yes" : "no") + ")";
- }
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- if (chordlane190pfResult != "OK")
- break;
- const auto copy = lynx::olderlynx::forRelease (song, release);
- const auto lines = std::count_if (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) {
- return juce::String (l.text).contains ("Chord lane");
- });
- juce::String why2;
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why2) : std::nullopt;
- if (! copy.ok || copy.json.contains ("\"chords\"") || copy.json.contains ("followChords") || lines != 2 || ! old)
- chordlane190pfResult = juce::String ("ERROR the copy for ") + release + " (" + juce::String ((int) lines) + " lines)";
- else if (old->arrangements[0].markers.size() != 3 || old->arrangements[0].markers[1].name != "Am7" || old->arrangements[0].markers[2].name != "G7/B"
- || old->arrangements[0].markers[1].tick != bar || old->arrangements[1].markers.size() != 4 || ! old->arrangements[0].chords.empty())
- chordlane190pfResult = juce::String ("ERROR the markers in the copy for ") + release;
- }
- // Smart Tempo: one undo step, bit for bit (the plan of a steady 120 BPM pulse on a clip at bar 2)
- if (chordlane190pfResult == "OK")
- {
- auto take = lynx::Song::makeDefault();
- take.playlist.clear();
- lynx::ChannelDef audio;
- audio.instrument = lynx::InstrumentKind::audioClip;
- take.channels.push_back (audio);
- lynx::Clip a;
- a.kind = lynx::ClipKind::audio;
- a.channel = (int) take.channels.size() - 1;
- a.start = bar;
- a.length = 8 * bar;
- take.playlist.push_back (a);
- std::vector<double> bars;
- for (int k = 0; k <= 8; ++k)
- bars.push_back (0.25 + k * 2.1);
- const auto plan = lynx::smarttempo::plan (take, 0, bars, 20.0);
- lynx::AudioEngine e (false);
- e.setSong (take);
- const auto before = lynx::ProjectFile::toJson (e.getSong());
- auto ok = false;
- e.editSong ([&] (lynx::Song& s) { ok = lynx::smarttempo::apply (s, 0, plan); });
- const auto written = lynx::tempomarkers::list (e.getSong()).size();
- e.undo();
- if (! ok || written != 8 || lynx::ProjectFile::toJson (e.getSong()) != before)
- chordlane190pfResult = "ERROR Smart Tempo's undo (" + juce::String ((int) written) + " markers)";
- }
- }
- // round 190dr: the Session mixer's sections come back from a project (a project without them: Live's defaults);
- // a device dragged to another track and a Warp switch are one undo step each in a real engine
- juce::String livescr190drResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- lynx::launcher::ensureGrid (song);
- juce::String why;
- const auto plain = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- song.clipGrid->mixerView.io = false;
- song.clipGrid->mixerView.trackOptions = true;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (! plain || ! plain->clipGrid || ! (plain->clipGrid->mixerView == lynx::SessionMixerView {}))
- livescr190drResult = "ERROR view defaults " + why;
- else if (! back || ! back->clipGrid || back->clipGrid->mixerView.io || ! back->clipGrid->mixerView.trackOptions || ! back->clipGrid->mixerView.shown)
- livescr190drResult = "ERROR view round trip " + why;
- lynx::AudioEngine e (false);
- e.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() < 4)
- s.mixer.resize (4);
- s.mixer[2].effects.clear();
- s.mixer[3].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::compressor })
- {
- lynx::EffectSlot fx;
- fx.kind = kind;
- s.mixer[2].effects.push_back (fx);
- }
- lynx::Automation a;
- a.target = { lynx::AutomationTargetKind::effectMix, 2, 1, 0 };
- s.automations.push_back (a);
- }, false);
- const auto id = e.getSong().mixer[2].effects[1].instance.id;
- const auto automations = e.getSong().automations.size();
- e.editSongStructural ([] (lynx::Song& s) { lynx::detailchain::moveEffectToInsert (s, 2, 1, 3, false); });
- const auto& moved = e.getSong();
- if (livescr190drResult == "OK"
- && (moved.mixer[2].effects.size() != 1 || moved.mixer[3].effects.size() != 1 || moved.mixer[3].effects[0].instance.id != id
- || moved.automations.size() != automations || moved.automations.back().target.index != 3 || moved.automations.back().target.slot != 0))
- livescr190drResult = "ERROR device move";
- e.undo();
- const auto& undone = e.getSong();
- if (livescr190drResult == "OK"
- && (undone.mixer[2].effects.size() != 2 || undone.mixer[3].effects.size() != 0 || undone.mixer[2].effects[1].instance.id != id
- || undone.automations.back().target.index != 2 || undone.automations.back().target.slot != 1))
- livescr190drResult = "ERROR device move undo";
- e.editSong ([] (lynx::Song& s) {
- s.channels.resize (std::max<std::size_t> (s.channels.size(), 1));
- s.channels[0].sampler.stretchBeats = 16.0f;
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = 0;
- c.offset = 4 * lynx::ppq;
- c.length = 8 * lynx::ppq;
- lynx::launcher::setClip (s, 0, 0, c);
- }, false);
- e.editSong ([] (lynx::Song& s) { lynx::clipsample::setWarp (s, 0, false, 4.0); });
- const auto* off = e.getSong().clipGrid ? lynx::launcher::clipAt (*e.getSong().clipGrid, 0, 0) : nullptr;
- if (livescr190drResult == "OK" && (e.getSong().channels[0].sampler.stretchBeats != 0.0f || off == nullptr || off->length != (std::int64_t) std::llround (8.0 * lynx::ppq * (4.0 * e.getSong().bpm / 60.0) / 16.0)))
- livescr190drResult = "ERROR warp off";
- e.undo();
- const auto* on = e.getSong().clipGrid ? lynx::launcher::clipAt (*e.getSong().clipGrid, 0, 0) : nullptr;
- if (livescr190drResult == "OK" && (e.getSong().channels[0].sampler.stretchBeats != 16.0f || on == nullptr || on->length != 8 * lynx::ppq))
- livescr190drResult = "ERROR warp undo";
- }
- // round 190ef: the map modes' storage (.lynx round trip of key / MIDI mappings and a link's Min / Max; an older
- // reader keeps the plain link), and in a real engine: a link's range, MIDI Map Mode catching the control instead
- // of moving anything, a slot's MIDI mapping firing on its press and release
- juce::String livewf190efResult = "OK";
- {
- using namespace lynx::remotemap;
- auto song = lynx::Song::makeDefault();
- lynx::launcher::ensureGrid (song);
- const lynx::AutomationTarget vol { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 };
- assignMidi (song, Target::parameter (vol), { 0, 20, -1 });
- assignMidi (song, Target::slot (0, 0), { 0, lynx::linkNoteBase + 36, 2 });
- assignKey (song, Target::sceneLaunch (0), 'S');
- assignKey (song, Target::parameter ({ lynx::AutomationTargetKind::tempo, 0, 0, 0 }), 'T');
- setRange (song, rows (song, Mode::midi)[0], 0.25f, 0.75f);
- setRange (song, rows (song, Mode::key)[1], 0.9f, 0.1f);
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (! back || back->remoteMappings != song.remoteMappings || back->midiLinks != song.midiLinks)
- livewf190efResult = "ERROR round trip " + why;
- auto parsed = juce::JSON::parse (json);
- if (auto* o = parsed.getDynamicObject())
- {
- o->removeProperty ("remoteMappings");
- o->removeProperty ("midiLinkSettings");
- }
- const auto older = lynx::ProjectFile::fromJson (juce::JSON::toString (parsed), why);
- if (livewf190efResult == "OK" && (! older || ! older->remoteMappings.empty() || older->midiLinks.size() != 1 || older->midiLinks[0].max != 1.0f))
- livewf190efResult = "ERROR older reader";
- const auto plain = lynx::ProjectFile::toJson (lynx::Song::makeDefault());
- if (livewf190efResult == "OK" && plain.contains ("remoteMappings"))
- livewf190efResult = "ERROR written without mappings";
- lynx::AudioEngine e (false);
- e.editSong ([vol] (lynx::Song& s) {
- if (s.mixer.size() < 3)
- s.mixer.resize (3);
- lynx::MidiLink l { 20, 0, vol };
- l.min = 0.25f;
- l.max = 0.75f;
- s.midiLinks = { l };
- lynx::launcher::ensureGrid (s);
- assignMidi (s, Target::slot (0, 0), { 0, 21, -1 });
- });
- e.injectControllerForTest (20, 0, 127);
- const auto top = e.currentTargetValue (vol);
- e.injectControllerForTest (20, 0, 0);
- const auto bottom = e.currentTargetValue (vol);
- if (livewf190efResult == "OK" && (std::abs (top - 0.75f) > 0.01f || std::abs (bottom - 0.25f) > 0.01f))
- livewf190efResult = "ERROR range " + juce::String (bottom) + " " + juce::String (top);
- std::vector<Fire> fired;
- e.onRemoteFire = [&fired] (const Fire& f) { fired.push_back (f); };
- e.injectControllerForTest (21, 0, 127);
- e.injectControllerForTest (21, 0, 127); // (still down: no new press)
- e.injectControllerForTest (21, 0, 0);
- if (livewf190efResult == "OK"
- && (fired.size() != 2 || fired[0].edge != Edge::press || fired[1].edge != Edge::release || ! (fired[0].target == Target::slot (0, 0))))
- livewf190efResult = "ERROR slot fire " + juce::String ((int) fired.size());
- e.setMapMode (Mode::midi);
- fired.clear();
- e.injectControllerForTest (20, 0, 127);
- e.injectControllerForTest (21, 0, 127);
- const auto caught = e.takeMapCapture();
- if (livewf190efResult == "OK" && (std::abs (e.currentTargetValue (vol) - 0.25f) > 0.01f || ! fired.empty()))
- livewf190efResult = "ERROR mappings acted in MIDI Map Mode";
- else if (livewf190efResult == "OK" && (! caught || caught->number != 21 || caught->channel != 0 || e.takeMapCapture().has_value()))
- livewf190efResult = "ERROR map capture";
- e.setMapMode (Mode::off);
- e.onRemoteFire = nullptr;
- }
- // round 190em: a scene's time signature denominator (.lynx round trip; an older file without it reads n/4; a
- // launch of a 6 / 8 scene gives the song a 3-beat bar), and Capture MIDI in the clip grid of a real engine: the
- // armed track, the selected scene's slot, the tempo from a phrase played while stopped (8 notes at 148 BPM), the
- // new clip launched and the transport started
- juce::String livewf190emResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- auto& grid = lynx::launcher::ensureGrid (song);
- grid.scenes.resize (3);
- lynx::session::setSceneSignature (song, 1, 6, 8);
- lynx::session::setSceneTempo (song, 1, 100.0);
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (! back || ! back->clipGrid || back->clipGrid->scenes != song.clipGrid->scenes || back->clipGrid->scenes[1].beatUnit != 8)
- livewf190emResult = "ERROR round trip " + why;
- {
- // a captured clip's blank label (ClipGridSlot::blankName) survives the round trip
- auto withClip = song;
- lynx::Clip c;
- c.pattern = 0;
- c.length = 4 * lynx::ppq;
- if (withClip.patterns.empty())
- withClip.patterns.emplace_back();
- const auto slot = lynx::launcher::setClip (withClip, 0, 0, c);
- if (slot >= 0)
- withClip.clipGrid->slots[(std::size_t) slot].blankName = true;
- const auto again = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (withClip), why);
- const auto* keptClip = again && again->clipGrid ? lynx::launcher::clipAt (*again->clipGrid, 0, 0) : nullptr;
- const auto* kept = keptClip != nullptr ? &again->clipGrid->slots[(std::size_t) keptClip->gridSlot] : nullptr;
- if (livewf190emResult == "OK" && (slot < 0 || kept == nullptr || ! kept->blankName))
- livewf190emResult = "ERROR blank clip name round trip";
- }
- auto parsed = juce::JSON::parse (json);
- if (auto* scenes = parsed.getProperty ("clipGrid", {}).getProperty ("scenes", {}).getArray(); scenes != nullptr && scenes->size() > 1)
- if (auto* o = (*scenes)[1].getDynamicObject())
- o->removeProperty ("beatUnit");
- const auto older = lynx::ProjectFile::fromJson (juce::JSON::toString (parsed), why);
- if (livewf190emResult == "OK" && (! older || ! older->clipGrid || older->clipGrid->scenes.size() < 2 || older->clipGrid->scenes[1].beatUnit != 4
- || older->clipGrid->scenes[1].beatsPerBar != 6))
- livewf190emResult = "ERROR older reader";
- if (livewf190emResult == "OK" && lynx::ProjectFile::toJson (lynx::Song::makeDefault()).contains ("beatUnit"))
- livewf190emResult = "ERROR beatUnit written by default";
- // round 190fg: the song meter's denominator round-trips through .lynx; a file without it reads n/4
- {
- auto six = lynx::Song::makeDefault();
- six.beatsPerBar = 6;
- six.beatUnit = 8;
- const auto text = lynx::ProjectFile::toJson (six);
- juce::String why2;
- const auto back = lynx::ProjectFile::fromJson (text, why2);
- auto json = juce::JSON::parse (text);
- if (auto* o = json.getDynamicObject())
- o->removeProperty ("beatUnit");
- const auto old = lynx::ProjectFile::fromJson (juce::JSON::toString (json), why2);
- if (livewf190emResult == "OK" && (! back || back->beatsPerBar != 6 || back->beatUnit != 8 || ! old || old->beatsPerBar != 6 || old->beatUnit != 4))
- livewf190emResult = "ERROR song meter round trip";
- }
- lynx::AudioEngine e (false);
- e.editSong ([] (lynx::Song& s) {
- s.bpm = 120.0;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 4));
- auto& g = lynx::launcher::ensureGrid (s);
- g.scenes.resize (3);
- lynx::session::setSceneSignature (s, 2, 6, 8);
- lynx::session::setSceneTempo (s, 2, 90.0);
- }, false);
- e.launcherCommand ({ lynx::launcher::Command::Type::launchScene, 0, 2 });
- // (round 190fg: the song takes the scene's 6 / 8 as it is: six eighths a bar, 3 quarters long)
- if (livewf190emResult == "OK" && (e.getSong().beatsPerBar != 6 || e.getSong().beatUnit != 8 || e.getSong().barTicks() != 3 * lynx::ppq
- || e.getSong().bpm != 90.0))
- livewf190emResult = "ERROR scene launch " + juce::String (e.getSong().beatsPerBar) + "/" + juce::String (e.getSong().beatUnit) + " "
- + juce::String (e.getSong().bpm);
- e.stop();
- e.editSong ([] (lynx::Song& s) {
- s.bpm = 120.0;
- s.beatsPerBar = 4;
- s.beatUnit = 4;
- }, false);
- e.setGridTrackArmed (2, true, true);
- const auto now = juce::Time::getMillisecondCounterHiRes();
- const auto beat = 60000.0 / 148.0;
- for (int i = 0; i < 8; ++i)
- {
- const auto at = now - 9.0 * beat + i * beat;
- e.logPlayedNoteForTest (at, 0, 60 + (i % 4) * 2, 0.8f, true);
- e.logPlayedNoteForTest (at + beat * 0.5, 0, 60 + (i % 4) * 2, 0.8f, false);
- }
- int placed = -1;
- bool into = true;
- const auto r = e.captureMidiToSlot (2, 1, placed, into);
- const auto& g = *e.getSong().clipGrid;
- const auto* clip = lynx::launcher::clipAt (g, 2, 1);
- if (livewf190emResult == "OK" && (r.notes != 8 || placed != 1 || into || clip == nullptr || clip->length != 8 * lynx::ppq))
- livewf190emResult = "ERROR capture " + juce::String (r.notes) + " " + juce::String (placed) + (clip == nullptr ? " no clip" : " " + juce::String ((int) clip->length));
- else if (livewf190emResult == "OK" && std::abs (e.getSong().bpm - 148.0) > 0.5)
- livewf190emResult = "ERROR tempo " + juce::String (e.getSong().bpm, 2);
- else if (livewf190emResult == "OK" && ! e.getTransport().playing.load())
- livewf190emResult = "ERROR the capture did not start the transport";
- e.stop();
- }
- const auto mixerBasics = lynx::mixerbasics::run();
- // issue #142: every font has a typeface, and one without does not crash (fonts get theirs through the
- // look and feel, as in the app)
- auto& lookBefore = juce::LookAndFeel::getDefaultLookAndFeel();
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto fontsResult = lynx::theme::fontSelfTest();
- auto paintCachesResult = lynx::theme::paintCacheSelfTest(); // (round 190gr)
- if (paintCachesResult.startsWith ("OK")) // (round 190ki: the Pattern toolbar's cached FL tiles, the pixels of painting them straight)
- {
- const auto tiles = lynx::flTileCacheSelfTest();
- paintCachesResult = tiles == "OK" ? paintCachesResult + ", FL tiles exact at x1 / x2" : tiles;
- }
- // round 190ne (0.1.31, core/TrackClips.h): track clips. A .lynx round trip keeps the flags and an older file opens
- // unchanged; in a real engine a track clip goes with its last clip in the same undo step (Undo brings both back),
- // ordinary patterns stay; the copy for 0.1.28 drops the flags with a loss line; an .flp export merges identical
- // track clips.
- juce::String trackclips190neResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- if (song.patterns.empty())
- song.patterns.emplace_back().name = "Pattern 1";
- lynx::ChannelDef synth;
- synth.name = "Lead";
- song.channels.push_back (synth);
- const auto channel = (int) song.channels.size() - 1;
- lynx::trackmodes::makeInstrumentTrack (song, 2, channel);
- lynx::trackclips::setOwnClips (song, 2, true);
- const auto a = lynx::trackclips::newClip (song, 2, 4 * lynx::ppq);
- song.patterns[(std::size_t) a].notes.push_back ({});
- song.patterns[(std::size_t) a].notes.back().channel = channel;
- song.patterns[(std::size_t) a].notes.back().key = 60;
- song.patterns[(std::size_t) a].notes.back().length = lynx::ppq;
- const auto b = lynx::trackclips::newClip (song, 2, 4 * lynx::ppq);
- song.patterns[(std::size_t) b].notes = song.patterns[(std::size_t) a].notes;
- for (const auto p : { a, a, b })
- {
- lynx::Clip c;
- c.pattern = p;
- c.track = 2;
- c.start = (std::int64_t) song.playlist.size() * 4 * lynx::ppq;
- c.length = 4 * lynx::ppq;
- song.playlist.push_back (c);
- }
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (! back || back->patterns != song.patterns || back->playlistTracks.size() <= 2 || ! back->playlistTracks[2].ownClips
- || ! back->patterns[(std::size_t) a].trackClip || back->playlist.size() != song.playlist.size())
- trackclips190neResult = "ERROR round trip " + why;
- // an older project (no flags): opens unchanged, nothing becomes a track clip
- const auto plain = lynx::Song::makeDefault();
- const auto plainJson = lynx::ProjectFile::toJson (plain);
- if (trackclips190neResult == "OK" && (plainJson.contains ("trackClip") || plainJson.contains ("playlistOwnClips")))
- trackclips190neResult = "ERROR flags written for a project without track clips";
- if (const auto reread = lynx::ProjectFile::fromJson (plainJson, why); trackclips190neResult == "OK"
- && (! reread || lynx::trackclips::count (*reread) != 0 || lynx::ProjectFile::toJson (*reread) != plainJson))
- trackclips190neResult = "ERROR an older project changed";
- // the copy for 0.1.28: no flags, one loss line
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.28");
- const auto said = [©] (const char* text) {
- return std::any_of (copy.lost.begin(), copy.lost.end(), [text] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains (text); });
- };
- if (trackclips190neResult == "OK" && (! copy.ok || copy.json.contains ("\"trackClip\"") || copy.json.contains ("playlistOwnClips") || ! said ("track clip(s) show as ordinary patterns")))
- trackclips190neResult = "ERROR copy for 0.1.28";
- // .flp export: clips a and b hold the same notes: one pattern in FL, every clip kept
- lynx::flpexport::Report flpReport;
- const auto flp = flp::parseProject (lynx::flpexport::exportFlp (song, {}, flpReport));
- auto other = song; // (b with other notes: nothing to merge)
- other.patterns[(std::size_t) b].notes.front().key += 1;
- const auto flpOther = flp::parseProject (lynx::flpexport::exportFlp (other, {}, flpReport));
- if (trackclips190neResult == "OK" && flp.patterns.size() + 1 != flpOther.patterns.size())
- trackclips190neResult = "ERROR flp merge " + juce::String ((int) flp.patterns.size()) + " / " + juce::String ((int) flpOther.patterns.size());
- // a real engine: delete the last clip of b -> b goes in the same undo step; Undo brings it back
- lynx::AudioEngine e (false);
- e.editSong ([&song] (lynx::Song& s) { s = song; });
- const auto before = e.getSong().patterns.size();
- e.editSong ([] (lynx::Song& s) { s.playlist.pop_back(); }); // (the only clip of b)
- if (trackclips190neResult == "OK" && (e.getSong().patterns.size() + 1 != before || e.getSong().playlist.size() != 2))
- trackclips190neResult = "ERROR auto-delete " + juce::String ((int) e.getSong().patterns.size());
- e.undo();
- if (trackclips190neResult == "OK" && (e.getSong().patterns.size() != before || e.getSong().playlist.size() != 3))
- trackclips190neResult = "ERROR undo of the auto-delete";
- // an ordinary pattern without clips stays (FL)
- e.editSong ([] (lynx::Song& s) { s.patterns.emplace_back().name = "Kept"; });
- e.editSong ([] (lynx::Song& s) { s.playlist.erase (s.playlist.begin()); }); // (a's first clip: a still has one)
- if (trackclips190neResult == "OK" && (e.getSong().patterns.size() != before + 1 || e.getSong().patterns.back().name != "Kept"))
- trackclips190neResult = "ERROR an ordinary pattern or a linked clip went";
- }
- // round 190op (P4 / P7, LYNX extras): Hide and Deactivate tracks, Capture automation. Renders in a real engine: a
- // hidden track plays the same (null), a deactivated channel and a deactivated insert are silent, Reactivate gives
- // the same audio back (null), each in one undo step; the .lynx round trip keeps the flags and writes nothing for
- // a project without them; the copy for 0.1.30 drops them with loss lines (deactivated units come back muted);
- // the .flp export reports them; Capture automation writes the last gesture of each moved control in one undo step.
- juce::String trackstates190opResult = "OK";
- {
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (4);
- song.bpm = 120.0;
- for (int c = 0; c < 2; ++c)
- {
- lynx::ChannelDef d;
- d.name = c == 0 ? "Lead" : "Bass";
- d.instrument = lynx::InstrumentKind::synth;
- d.mixerTrack = c + 1;
- song.channels.push_back (d);
- }
- song.patterns.clear();
- auto& p = song.patterns.emplace_back();
- p.name = "Both";
- for (int i = 0; i < 4; ++i)
- for (int c = 0; c < 2; ++c)
- {
- lynx::Note n;
- n.channel = c;
- n.key = c == 0 ? 72 + i : 40 + i;
- n.start = i * lynx::ppq;
- n.length = lynx::ppq / 2;
- p.notes.push_back (n);
- }
- song.playlist.clear();
- lynx::Clip clip;
- clip.pattern = 0;
- clip.track = 1;
- clip.start = 0;
- clip.length = 4 * lynx::ppq;
- song.playlist.push_back (clip);
- clip.track = 2;
- clip.start = 24 * lynx::ppq; // (past the renders: the song is seven bars long, Capture's ticks don't fold)
- song.playlist.push_back (clip);
- song.mode = lynx::PlayMode::song;
- const auto render = [] (lynx::AudioEngine& engine) {
- std::vector<float> out;
- lynx::AudioEngine::RenderOptions o;
- o.seconds = 2.5;
- o.sampleRate = 44100.0;
- o.capture = [&out] (const float* l, const float* r, int n) {
- for (int i = 0; i < n; ++i)
- {
- out.push_back (l[i]);
- out.push_back (r[i]);
- }
- };
- engine.renderOffline (o);
- return out;
- };
- const auto peak = [] (const std::vector<float>& v) {
- float m = 0.0f;
- for (const auto x : v)
- m = std::max (m, std::abs (x));
- return m;
- };
- // (every comparison renders the first time on its engine: see the note below)
- const auto renderSong = [&render] (const lynx::Song& s) {
- lynx::AudioEngine fresh (false);
- fresh.setSong (s);
- return render (fresh);
- };
- const auto plain = renderSong (song);
- lynx::AudioEngine e (false);
- e.setSong (song);
- // hide: the same samples, one undo step
- e.editSong ([] (lynx::Song& s) { lynx::trackstates::setHidden (s, { 1 }, true); });
- const auto hidden = renderSong (e.getSong());
- if (peak (plain) < 0.01f || hidden != plain)
- trackstates190opResult = "ERROR hidden track render differs (peak " + juce::String (peak (plain), 4) + ")";
- e.undo();
- if (trackstates190opResult == "OK" && lynx::trackstates::isHidden (e.getSong(), 1))
- trackstates190opResult = "ERROR undo of Hide";
- // (each render below is the first of its engine: a second render of one engine here plays nothing — the
- // notes of a render are not scheduled again — so every state gets its own engine)
- // deactivate the Bass channel (the real menu path: states captured first, one undo step): Lead alone
- auto lead = song;
- lead.channels[1].muted = true;
- const auto leadOnly = renderSong (lead);
- lynx::AudioEngine e1 (false);
- e1.setSong (song);
- e1.setDeactivated ({ 1 }, {}, true);
- const auto noBass = render (e1);
- float diff = 0.0f;
- for (std::size_t i = 0; i < std::min (noBass.size(), leadOnly.size()); ++i)
- diff = std::max (diff, std::abs (noBass[i] - leadOnly[i]));
- if (trackstates190opResult == "OK"
- && (! e1.channelDeactivated (1) || noBass.size() != leadOnly.size() || diff > 1.0e-6f || peak (noBass) < 0.01f))
- trackstates190opResult = "ERROR deactivated channel is not silent (diff " + juce::String (diff, 7) + ")";
- // then insert 1, into which Lead plays (Lead goes with it): silence
- lynx::AudioEngine e2 (false);
- e2.setSong (song);
- e2.setDeactivated ({ 1 }, {}, true);
- e2.setDeactivated ({}, { 1 }, true);
- const auto silent = render (e2);
- if (trackstates190opResult == "OK" && (! e2.channelDeactivated (0) || ! e2.insertDeactivated (1) || peak (silent) > 1.0e-6f))
- trackstates190opResult = "ERROR deactivated insert is not silent (peak " + juce::String (peak (silent), 7) + ")";
- // Reactivate (two undo steps) on an engine that ran the placeholders: its first render nulls with the plain
- // song's (a placeholder kept for a reactivated unit would play nothing)
- lynx::AudioEngine e3 (false);
- e3.setSong (song);
- const auto opened = e3.getSong(); // (as the engine holds it: ids given)
- e3.setDeactivated ({ 1 }, {}, true);
- e3.capturePluginStates(); // (as a save in between does: the shape keeps the placeholders)
- e3.setDeactivated ({}, { 1 }, true);
- e3.undo();
- e3.undo();
- const auto back = render (e3);
- float backDiff = back.size() == plain.size() ? 0.0f : 1.0f;
- for (std::size_t i = 0; i < std::min (back.size(), plain.size()); ++i)
- backDiff = std::max (backDiff, std::abs (back[i] - plain[i]));
- if (trackstates190opResult == "OK"
- && (backDiff > 1.0e-6f || e3.channelDeactivated (1) || e3.insertDeactivated (1) || e3.getSong().channels != opened.channels
- || e3.getSong().mixer != opened.mixer))
- trackstates190opResult = "ERROR reactivated render differs (peak " + juce::String (peak (back), 4) + " / " + juce::String (peak (plain), 4)
- + ", diff " + juce::String (backDiff, 8) + ", channels " + juce::String (e3.getSong().channels == opened.channels ? "same" : "differ")
- + ", mixer " + juce::String (e3.getSong().mixer == opened.mixer ? "same" : "differ") + ")";
- // the .lynx round trip, an older project, the copy for 0.1.30, the .flp report
- auto flagged = song;
- lynx::trackstates::setHidden (flagged, { 3 }, true);
- flagged.channels[1].deactivated = true;
- flagged.mixer[2].deactivated = true;
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (flagged);
- const auto reread = lynx::ProjectFile::fromJson (json, why);
- if (trackstates190opResult == "OK"
- && (! reread || ! lynx::trackstates::isHidden (*reread, 3) || ! reread->channels[1].deactivated || ! reread->mixer[2].deactivated
- || reread->channels[0].deactivated || reread->mixer[1].deactivated))
- trackstates190opResult = "ERROR round trip " + why;
- const auto plainJson = lynx::ProjectFile::toJson (song);
- if (trackstates190opResult == "OK" && (plainJson.contains ("playlistTracksHidden") || plainJson.contains ("\"deactivated\"")))
- trackstates190opResult = "ERROR flags written for a project without them";
- const auto copy = lynx::olderlynx::forRelease (flagged, "0.1.30");
- const auto said = [©] (const char* text) {
- return std::any_of (copy.lost.begin(), copy.lost.end(), [text] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains (text); });
- };
- const auto old = copy.ok ? lynx::ProjectFile::fromJson (copy.json, why) : std::nullopt;
- if (trackstates190opResult == "OK"
- && (! copy.ok || copy.json.contains ("playlistTracksHidden") || copy.json.contains ("\"deactivated\"") || ! said ("hidden Playlist track(s) show again")
- || ! said ("Deactivated channels and inserts") || ! old || ! old->channels[1].muted || ! old->mixer[2].muted || old->channels[0].muted))
- trackstates190opResult = "ERROR copy for 0.1.30";
- const auto copy28 = lynx::olderlynx::forRelease (flagged, "0.1.28");
- if (trackstates190opResult == "OK" && (! copy28.ok || copy28.json.contains ("playlistTracksHidden") || copy28.json.contains ("\"deactivated\"")))
- trackstates190opResult = "ERROR copy for 0.1.28";
- lynx::flpexport::Report flpReport;
- (void) lynx::flpexport::exportFlp (flagged, {}, flpReport);
- const auto noted = [&flpReport] (const char* text) {
- return std::any_of (flpReport.notes.begin(), flpReport.notes.end(), [text] (const std::string& n) { return n.find (text) != std::string::npos; });
- };
- if (trackstates190opResult == "OK" && (! noted ("Hidden tracks: 1 track(s) written visible") || ! noted ("Deactivated: Bass")))
- trackstates190opResult = "ERROR flp export report";
- // Capture automation: two controls moved while playing (Song mode, Pattern layout, lanes off): two automation
- // clips with the last gesture's ticks, one undo step; a second capture takes nothing
- lynx::AudioEngine cap (false);
- cap.setSong (song);
- const lynx::AutomationTarget volume { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 };
- const lynx::AutomationTarget pan { lynx::AutomationTargetKind::mixerPan, 2, 0, 0 };
- const auto bar = (double) song.barTicks();
- auto sample = [&cap] (const lynx::AutomationTarget& t, double ms, double tick, float v) {
- lynx::captureauto::Entry x;
- x.target = t;
- x.ms = ms;
- x.tick = tick;
- x.value = v;
- cap.addAutomationCaptureSample (x);
- };
- sample (volume, 1000.0, 0.0, 0.2f); // gesture 1 (dropped: a gap of three bars follows)
- sample (volume, 1100.0, 0.25 * bar, 0.3f);
- sample (volume, 3000.0, 3.25 * bar, 0.5f); // gesture 2: the one captured
- sample (volume, 3100.0, 3.5 * bar, 0.7f);
- sample (pan, 3200.0, 3.5 * bar, 0.1f);
- sample (pan, 3300.0, 3.75 * bar, 0.9f);
- const auto automations = cap.getSong().automations.size();
- const auto undoBefore = cap.getHistoryPosition();
- const auto r = cap.captureAutomation();
- const auto& as = cap.getSong().automations;
- const auto clipOf = [&cap] (int automation) {
- for (const auto& c : cap.getSong().playlist)
- if (c.kind == lynx::ClipKind::automation && c.automation == automation)
- return c;
- return lynx::Clip {};
- };
- if (trackstates190opResult == "OK" && (r.controls != 2 || as.size() != automations + 2 || cap.getHistoryPosition() != undoBefore + 1))
- trackstates190opResult = "ERROR capture " + juce::String (r.controls) + " controls, " + juce::String ((int) (as.size() - automations)) + " automations";
- else if (trackstates190opResult == "OK")
- {
- const auto a = (int) automations;
- const auto c0 = clipOf (a), c1 = clipOf (a + 1);
- if (! (as[(std::size_t) a].target == volume) || ! (as[(std::size_t) a + 1].target == pan) || c0.kind != lynx::ClipKind::automation
- || c0.start - c0.offset + (as[(std::size_t) a].points.empty() ? 0 : as[(std::size_t) a].points.front().tick) != (std::int64_t) (3.25 * bar)
- || c1.start - c1.offset + (as[(std::size_t) a + 1].points.empty() ? 0 : as[(std::size_t) a + 1].points.front().tick) != (std::int64_t) (3.5 * bar))
- trackstates190opResult = "ERROR capture ticks: clip " + juce::String (c0.start) + " first point "
- + juce::String (as[(std::size_t) a].points.empty() ? -1 : as[(std::size_t) a].points.front().tick);
- }
- if (trackstates190opResult == "OK" && cap.captureAutomation().controls != 0)
- trackstates190opResult = "ERROR a second capture took the same moves again";
- }
- // round 190pa (research190oe P21 / P14, LYNX extras): automation write modes and range edits on chosen tracks. The
- // .lynx round trip keeps the mode and the range and writes neither for a project without them; the copies for
- // 0.1.30 / 0.1.28 drop them with a line each; Capture automation in a real engine with Latch holds the gesture's
- // last value to where its play pass stopped and Write writes its first value from where the pass started (Read
- // as before); a range Delete / Duplicate on two tracks changes only them and is one undo step, undone bit for bit.
- juce::String automodes190paResult = "OK";
- {
- const auto bar = (std::int64_t) 4 * lynx::ppq;
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (4);
- song.bpm = 120.0;
- song.mode = lynx::PlayMode::song;
- song.patterns.resize (4);
- for (int t = 0; t < 4; ++t)
- {
- lynx::Clip c;
- c.pattern = t;
- c.track = t;
- c.start = 0;
- c.length = 16 * bar;
- song.playlist.push_back (c);
- }
- song.playlistTracks.resize (4);
- juce::String why;
- const auto plainJson = lynx::ProjectFile::toJson (song);
- if (plainJson.contains ("trackRange") || plainJson.contains ("automationWriteMode"))
- automodes190paResult = "ERROR written for a project without them";
- auto flagged = song;
- flagged.automationWriteMode = 2;
- flagged.trackRange = lynx::rangeedit::fromCorners (4 * bar, 8 * bar, 1, 2);
- const auto reread = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (flagged), why);
- if (automodes190paResult == "OK" && (! reread || reread->automationWriteMode != 2 || ! (reread->trackRange == flagged.trackRange)))
- automodes190paResult = "ERROR round trip " + why;
- for (const char* release : { "0.1.30", "0.1.28" })
- {
- const auto copy = lynx::olderlynx::forRelease (flagged, release);
- const auto said = [©] (const char* text) {
- return std::any_of (copy.lost.begin(), copy.lost.end(), [text] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains (text); });
- };
- if (automodes190paResult == "OK"
- && (! copy.ok || copy.json.contains ("trackRange") || copy.json.contains ("automationWriteMode") || ! said ("automation write mode")
- || ! said ("range selected on some Playlist tracks")))
- automodes190paResult = "ERROR copy for " + juce::String (release);
- }
- // Capture automation per mode: one gesture of insert 1's volume at bars 2..2.5 of a pass that played 1..4
- for (int mode = 0; mode < 4 && automodes190paResult == "OK"; ++mode)
- {
- lynx::AudioEngine cap (false);
- auto s = song;
- s.automationWriteMode = mode;
- cap.setSong (s);
- const lynx::AutomationTarget volume { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 };
- auto& buffer = cap.automationCaptureForTests();
- buffer.notePlaying ((double) bar);
- for (int i = 0; i <= 4; ++i)
- {
- lynx::captureauto::Entry x;
- x.target = volume;
- x.ms = 1000.0 + 100.0 * i;
- x.tick = (double) (2 * bar) + i * (double) bar / 8.0;
- x.value = 0.2f + 0.15f * (float) i;
- x.pass = buffer.currentPass();
- buffer.notePlaying (x.tick);
- cap.addAutomationCaptureSample (x);
- }
- buffer.notePlaying ((double) (4 * bar));
- buffer.noteStopped();
- if (cap.captureAutomation().controls != 1)
- {
- automodes190paResult = "ERROR capture in mode " + juce::String (mode);
- break;
- }
- const auto& song2 = cap.getSong();
- const auto& a = song2.automations.back();
- const lynx::Clip* clip = nullptr;
- for (const auto& c : song2.playlist)
- if (c.kind == lynx::ClipKind::automation && c.automation == (int) song2.automations.size() - 1)
- clip = &c;
- if (clip == nullptr)
- {
- automodes190paResult = "ERROR no automation clip in mode " + juce::String (mode);
- break;
- }
- const auto valueAt = [&] (double songTick) { return a.valueAt (songTick - (double) clip->start + (double) clip->offset); };
- const auto lastPoint = a.points.empty() ? (std::int64_t) -1 : a.points.back().tick + clip->start - clip->offset;
- const auto firstPoint = a.points.empty() ? (std::int64_t) -1 : a.points.front().tick + clip->start - clip->offset;
- const auto holds = std::abs (valueAt (3.5 * (double) bar) - 0.8f) < 0.01f && lastPoint >= 4 * bar - 1;
- const auto fromStart = firstPoint <= bar && std::abs (valueAt (1.5 * (double) bar) - 0.2f) < 0.01f;
- const bool ok = mode == 0 || mode == 1 ? (! holds && ! fromStart && firstPoint == 2 * bar)
- : mode == 2 ? (holds && ! fromStart && firstPoint == 2 * bar)
- : (holds && fromStart);
- if (! ok)
- automodes190paResult = "ERROR capture curve in mode " + juce::String (mode) + " (first " + juce::String (firstPoint) + ", last "
- + juce::String (lastPoint) + ")";
- }
- // range edits on tracks 2-3 (1, 2): one undo step each, the other tracks untouched, undo bit for bit
- if (automodes190paResult == "OK")
- {
- lynx::AudioEngine e (false);
- e.setSong (song);
- const auto before = e.getSong().playlist;
- e.editSong ([bar] (lynx::Song& s) { s.trackRange = lynx::rangeedit::fromCorners (4 * bar, 8 * bar, 1, 2); }, false);
- const auto steps = e.getHistoryPosition();
- e.editSong ([] (lynx::Song& s) { lynx::rangeedit::clearRange (s, s.trackRange); });
- const auto& after = e.getSong().playlist;
- const auto count = [] (const std::vector<lynx::Clip>& list, int track) {
- return (int) std::count_if (list.begin(), list.end(), [track] (const lynx::Clip& c) { return c.track == track; });
- };
- if (e.getHistoryPosition() != steps + 1 || count (after, 0) != 1 || count (after, 3) != 1 || count (after, 1) != 2 || count (after, 2) != 2)
- automodes190paResult = "ERROR range delete";
- e.undo();
- if (automodes190paResult == "OK" && ! (e.getSong().playlist == before))
- automodes190paResult = "ERROR range delete undo";
- e.editSong ([] (lynx::Song& s) { s.trackRange = lynx::rangeedit::duplicateRange (s, s.trackRange); });
- if (automodes190paResult == "OK" && (e.getSong().trackRange.from != 8 * bar || count (e.getSong().playlist, 1) != 3 || count (e.getSong().playlist, 0) != 1))
- automodes190paResult = "ERROR range duplicate";
- e.undo();
- if (automodes190paResult == "OK" && (! (e.getSong().playlist == before) || e.getSong().trackRange.from != 4 * bar))
- automodes190paResult = "ERROR range duplicate undo";
- }
- }
- // round 190nw (0.1.31): the tracker. Its settings are saved only when changed (an older project's file stays the
- // same bytes) and come back; the copies for 0.1.30 / 0.1.28 drop them with one loss line; a module imports in a
- // real engine (one note, one Sampler channel, its sample written) and its notes render.
- juce::String tracker190nwResult = "OK", tracker190obResult = "OK", tracker190omResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- juce::String why;
- const auto plainJson = lynx::ProjectFile::toJson (song);
- if (plainJson.contains ("\"tracker\""))
- tracker190nwResult = "ERROR settings written for a project that never changed them";
- if (const auto reread = lynx::ProjectFile::fromJson (plainJson, why); tracker190nwResult == "OK" && (! reread || lynx::ProjectFile::toJson (*reread) != plainJson))
- tracker190nwResult = "ERROR an older project changed";
- for (int c = 0; c < 2; ++c)
- song.channels.emplace_back().name = "T" + std::to_string (c);
- lynx::uids::normalize (song);
- song.tracker.rowsPerBeat = 8;
- song.tracker.showPan = true;
- song.tracker.groups.push_back ({ "Drums", { song.channels[song.channels.size() - 2].uid, song.channels.back().uid } });
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (tracker190nwResult == "OK" && (! back || ! (back->tracker == song.tracker)))
- tracker190nwResult = "ERROR round trip " + why;
- for (const auto* release : { "0.1.30", "0.1.28" })
- {
- const auto copy = lynx::olderlynx::forRelease (song, release);
- const auto said = std::any_of (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("tracker's view settings"); });
- if (tracker190nwResult == "OK" && (! copy.ok || copy.json.contains ("\"tracker\"") || ! said))
- tracker190nwResult = "ERROR copy for " + juce::String (release);
- }
- // a ProTracker module of one note, through the engine's import (its sample written beside it)
- const auto folder = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-selftest-190nw-" + juce::String (juce::Time::currentTimeMillis()));
- folder.createDirectory();
- std::vector<std::uint8_t> mod (1084 + 1024 + 128, 0);
- std::memcpy (mod.data(), "selftest", 8);
- mod[20 + 22] = 0, mod[20 + 23] = 64, mod[20 + 25] = 64, mod[20 + 29] = 1; // sample 1: 128 bytes, volume 64, no loop
- for (int k = 1; k < 31; ++k)
- mod[(std::size_t) (20 + k * 30 + 29)] = 1;
- mod[950] = 1, mod[951] = 127;
- std::memcpy (mod.data() + 1080, "M.K.", 4);
- mod[1084] = 0x01, mod[1085] = 0xAC, mod[1086] = 0x10; // row 0: C-2 (428), sample 1
- for (int i = 0; i < 128; ++i)
- mod[(std::size_t) (1084 + 1024 + i)] = (std::uint8_t) (std::int8_t) std::lround (90.0 * std::sin (i * 0.39));
- const auto modFile = folder.getChildFile ("one note.mod");
- modFile.replaceWithData (mod.data(), mod.size());
- lynx::AudioEngine e (false);
- juce::String error;
- if (tracker190nwResult == "OK" && ! e.importFlpFile (modFile, error))
- tracker190nwResult = "ERROR module import: " + error;
- const auto& imported = e.getSong();
- if (tracker190nwResult == "OK" && (imported.channels.size() != 1 || imported.patterns.empty() || imported.patterns.front().notes.size() != 1
- || ! folder.getChildFile ("one note samples").getChildFile ("01-01.wav").existsAsFile()))
- tracker190nwResult = "ERROR module import: " + juce::String ((int) imported.channels.size()) + " channel(s), "
- + juce::String (imported.patterns.empty() ? 0 : (int) imported.patterns.front().notes.size()) + " note(s)";
- if (tracker190nwResult == "OK")
- {
- const auto peak = e.renderOffline (1.0, 44100.0, nullptr);
- if (peak < 0.01f)
- tracker190nwResult = "ERROR the imported note is silent (peak " + juce::String (peak) + ")";
- }
- // round 190ob: the same note, its sample looping, with a volume set on row 1 (C10, no note): its channel's
- // Volume multiplier automation comes in, is saved and read back the same, and the note still sounds
- if (tracker190obResult == "OK")
- {
- mod[1084 + 16 + 2] = 0x0C, mod[1084 + 16 + 3] = 0x10;
- mod[20 + 28] = 0, mod[20 + 29] = 64; // (the sample loops whole: the note still sounds on row 1)
- const auto volumeFile = folder.getChildFile ("one note volume.mod");
- volumeFile.replaceWithData (mod.data(), mod.size());
- lynx::AudioEngine ve (false);
- if (! ve.importFlpFile (volumeFile, error))
- tracker190obResult = "ERROR module import: " + error;
- else
- {
- const auto& vs = ve.getSong();
- const auto automation = std::find_if (vs.automations.begin(), vs.automations.end(), [] (const lynx::Automation& a) {
- return a.target.kind == lynx::AutomationTargetKind::channelAdjust && a.target.param == lynx::leveladjust::volume && a.target.index == 0;
- });
- // (round 190om: a pattern played once changes its volume as pattern events of the multiplier)
- const auto events = std::any_of (vs.patterns.begin(), vs.patterns.end(), [] (const lynx::Pattern& p) {
- return std::any_of (p.events.begin(), p.events.end(), [] (const lynx::PatternEvents& l) {
- return l.target.kind == lynx::AutomationTargetKind::channelAdjust && l.target.param == lynx::leveladjust::volume && l.target.index == 0
- && l.events.size() >= 2;
- });
- });
- if ((automation == vs.automations.end() || automation->points.size() < 2) && ! events)
- tracker190obResult = "ERROR no volume automation";
- else if (const auto reread = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (vs), why); ! reread || reread->automations != vs.automations
- || reread->patterns != vs.patterns)
- tracker190obResult = "ERROR the automation changed on the .lynx round trip " + why;
- else if (ve.renderOffline (1.0, 44100.0, nullptr) < 0.001f)
- tracker190obResult = "ERROR the note is silent";
- }
- }
- // round 190om: a pitch slide (102 on row 1) on that note: its pitch curve and the volume set's pattern events
- // come in, are saved and read back the same, and it sounds; SimSynth's velocity law and its copy for 0.1.30
- {
- mod[1084 + 16 + 2] = 0x01, mod[1084 + 16 + 3] = 0x02;
- mod[1084 + 32 + 2] = 0x0C, mod[1084 + 32 + 3] = 0x10;
- const auto slideFile = folder.getChildFile ("one note slide.mod");
- slideFile.replaceWithData (mod.data(), mod.size());
- lynx::AudioEngine se (false);
- if (! se.importFlpFile (slideFile, error))
- tracker190omResult = "ERROR module import: " + error;
- else
- {
- const auto& ss = se.getSong();
- const auto curved = std::any_of (ss.patterns.begin(), ss.patterns.end(), [] (const lynx::Pattern& p) {
- return std::any_of (p.notes.begin(), p.notes.end(), [] (const lynx::Note& n) { return n.curves.has() && n.curves->moves (lynx::NoteCurveLane::pitch); });
- });
- const auto events = std::any_of (ss.patterns.begin(), ss.patterns.end(), [] (const lynx::Pattern& p) { return ! p.events.empty(); });
- if (! curved || ! events)
- tracker190omResult = juce::String ("ERROR import: ") + (curved ? "" : "no pitch curve ") + (events ? "" : "no pattern events");
- else if (const auto reread = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (ss), why); ! reread || reread->patterns != ss.patterns)
- tracker190omResult = "ERROR the curves or events changed on the .lynx round trip " + why;
- else if (se.renderOffline (1.0, 44100.0, nullptr) < 0.001f)
- tracker190omResult = "ERROR the note is silent";
- }
- }
- if (tracker190omResult == "OK")
- {
- auto song = lynx::Song::makeDefault();
- auto& sim = song.channels.emplace_back();
- sim.name = "Sim";
- sim.instrument = lynx::InstrumentKind::simsynth;
- sim.pluginState = lynx::simsynth::defaultState();
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- const auto said = std::any_of (copy.lost.begin(), copy.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("SimSynth plays every note at full level"); });
- auto older = song;
- older.channels.back().engineRev = 1;
- const auto olderCopy = lynx::olderlynx::forRelease (older, "0.1.30");
- const auto olderSaid = std::any_of (olderCopy.lost.begin(), olderCopy.lost.end(), [] (const lynx::olderlynx::Loss& l) { return juce::String (l.text).contains ("SimSynth plays every note"); });
- juce::String why2;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why2);
- if (sim.engineRev < 2 || ! copy.ok || ! said || olderSaid || ! back || back->channels.back().engineRev != sim.engineRev) // (≥ 2: round 190pr's 3 too)
- tracker190omResult = "ERROR SimSynth revision: copy " + juce::String (said ? "said" : "silent") + (olderSaid ? ", old one said" : "");
- }
- folder.deleteRecursively();
- }
- // round 190oo (design review 2, PAT-7; core/RackAutomation.h): the automation clips' Channel rack rows. A .lynx
- // round trip keeps each clip's place; a clip without one (every clip of an older file) writes nothing and reads
- // back after the channels; the copy for 0.1.30 drops the key without a loss line.
- juce::String rackauto190ooResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- for (int c = 0; c < 3; ++c)
- song.channels.emplace_back().name = "R" + std::to_string (c);
- lynx::Automation placed, appended;
- placed.name = "placed";
- placed.points = { { 0, 0.2f, 0.0f }, { lynx::ppq, 0.8f, 0.0f } };
- placed.rackSlot = 1;
- appended = placed;
- appended.name = "appended";
- appended.rackSlot = -1;
- song.automations.push_back (placed);
- song.automations.push_back (appended);
- juce::String why;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, why);
- if (! back || back->automations.size() != 2 || back->automations[0].rackSlot != 1 || back->automations[1].rackSlot != -1
- || lynx::rackauto::order (*back) != lynx::rackauto::order (song))
- rackauto190ooResult = "ERROR round trip " + why;
- const auto plain = lynx::Song::makeDefault();
- const auto plainJson = lynx::ProjectFile::toJson (plain);
- if (rackauto190ooResult == "OK" && plainJson.contains ("rackSlot"))
- rackauto190ooResult = "ERROR rackSlot written for a project without placed clips";
- auto older = song;
- older.automations[0].rackSlot = -1; // (as a file saved before round 190oo)
- if (const auto reread = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (older), why); rackauto190ooResult == "OK"
- && (! reread || reread->automations.size() != 2 || reread->automations[0].rackSlot != -1 || lynx::ProjectFile::toJson (older).contains ("rackSlot")))
- rackauto190ooResult = "ERROR an older project's clips";
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- if (rackauto190ooResult == "OK" && (! copy.ok || copy.json.contains ("rackSlot")))
- rackauto190ooResult = "ERROR copy for 0.1.30";
- }
- // round 190ow (PAT-7 rest, details DE-123; core/RackAutomation.h): what the automation clip rows play. A .lynx round
- // trip keeps the steps / notes on the rows (Pattern::autoNotes), the clips' MIN / MAX and their mute light; a
- // project without them writes none of the keys; the copy for 0.1.30 drops the steps (a loss line: 0.1.30 starts
- // no clip from a pattern), writes the MIN / MAX into the points (the same values play there) and leaves a muted
- // clip without a target (it stays silent), with a loss line each.
- juce::String rackauto190owResult = "OK";
- {
- auto song = lynx::Song::makeDefault();
- lynx::Automation duck;
- duck.name = "duck";
- duck.points = { { 0, 0.0f, 0.0f }, { lynx::ppq, 1.0f, 0.0f } };
- duck.target = { lynx::AutomationTargetKind::mixerVolume, 0, 0, 0 };
- duck.rangeMin = 0.25f;
- duck.rangeMax = 0.75f;
- auto quiet = duck;
- quiet.name = "quiet";
- quiet.rangeMin = 0.0f;
- quiet.rangeMax = 1.0f;
- quiet.muted = true;
- song.automations = { duck, quiet };
- song.patterns[0].toggleAutoStep (0, 0);
- song.patterns[0].toggleAutoStep (0, 4);
- lynx::Note held;
- held.start = 8 * lynx::ticksPerStep;
- held.length = 0; // (FL's step of no length)
- held.channel = 1;
- held.key = 64;
- song.patterns[0].autoNotes.push_back (held);
- song.patterns[0].sortNotes();
- juce::String why;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), why);
- if (! back || back->patterns.empty() || back->patterns[0].autoNotes != song.patterns[0].autoNotes || back->automations.size() != 2
- || back->automations[0].rangeMin != 0.25f || back->automations[0].rangeMax != 0.75f || back->automations[1].muted != true
- || back->automations[0].muted || ! back->patterns[0].hasAutoStep (0, 4))
- rackauto190owResult = "ERROR round trip " + why;
- const auto plainJson = lynx::ProjectFile::toJson (lynx::Song::makeDefault());
- if (rackauto190owResult == "OK" && (plainJson.contains ("autoNotes") || plainJson.contains ("\"range\"")))
- rackauto190owResult = "ERROR keys written for a project without them";
- const auto copy = lynx::olderlynx::forRelease (song, "0.1.30");
- int lossLines = 0;
- for (const auto& l : copy.lost)
- lossLines += juce::String (l.text).contains ("automation clip") || juce::String (l.text).contains ("Muted automation") ? 1 : 0;
- if (rackauto190owResult == "OK" && (! copy.ok || copy.json.contains ("autoNotes") || copy.json.contains ("\"range\"") || lossLines < 2))
- rackauto190owResult = "ERROR copy for 0.1.30 (" + juce::String (lossLines) + " loss lines)";
- if (rackauto190owResult == "OK")
- if (const auto old = lynx::ProjectFile::fromJson (copy.json, why); ! old || old->automations.size() != 2
- || std::abs (old->automations[0].points[0].value - 0.25f) > 1.0e-3f || std::abs (old->automations[0].points[1].value - 0.75f) > 1.0e-3f
- || old->automations[1].target.kind != lynx::AutomationTargetKind::none)
- rackauto190owResult = "ERROR the copy's values";
- const auto copy28 = lynx::olderlynx::forRelease (song, "0.1.28");
- if (rackauto190owResult == "OK" && (! copy28.ok || copy28.json.contains ("autoNotes")))
- rackauto190owResult = "ERROR copy for 0.1.28";
- }
- const auto motionOverlayResult = lynx::ui::MotionOverlay::selfTest(); // (round 190ip)
- // round 190bm (0.1.25 showed the Mixer and the Playlist black): their cached pictures shown on native and
- // software targets against straight paints (ui/PictureCheck.h; --picturetest runs more sizes and scales)
- juce::String picturesResult = "OK";
- {
- lynx::AudioEngine pictureEngine (false);
- auto pictureFailures = 0;
- juce::String lines;
- {
- lynx::PlaylistComponent playlist (pictureEngine);
- playlist.setBounds (0, 0, 1200, 700);
- playlist.setVisible (true);
- lines << lynx::ui::picturecheck::run (playlist, "Playlist 1200 x 700", { 1.0f, 1.5f }, pictureFailures, {});
- }
- {
- lynx::MixerComponent mixer (pictureEngine);
- mixer.setBounds (0, 0, 1200, 500);
- mixer.setVisible (true);
- lines << lynx::ui::picturecheck::run (mixer, "Mixer 1200 x 500", { 1.0f, 1.5f }, pictureFailures, {});
- }
- if (pictureFailures > 0 || ! lines.contains (": ok"))
- picturesResult = "ERROR " + lines.trim().replace ("\n", "; ");
- }
- // round 190ci (the 0.1.26 release candidate ended when an FPC channel was added): every built-in generator and
- // effect, its editor built as the Channel Rack / mixer opens it and painted once. The report file names the
- // plugin being opened, so a run that dies there says which one.
- const auto editorsResult = lynx::pluginthumbs::checkEditors ([&reportPath] (const juce::String& key) {
- if (reportPath.isNotEmpty())
- juce::File (reportPath).replaceWithText ("(opening the editor of " + key + ")\n");
- });
- // round 190ci: a fault leaves a crash file, also on a stack Windows cannot walk (that FPC fault left none)
- const auto faultResult = faultReportSelfTest();
- const auto stemsResult = stemsSinglePassSelfTest(); // round 190gj
- const auto exportFormatsResult = lynx::shortexport::formatsCheck(); // AIFF and M4A (owner decision D5)
- const auto hotfix190qpWfResult = hotfix190qpWfCheck(); // round 190qp (0.1.31.1): track clips' notes, Export... with folders
- const auto renderAgainResult = lynx::renderagain::check(); // round 190ou: offline renders made again
- const auto determinismResult = lynx::determinism190po::check(); // round 190po: one render on any threads (Windows' x87)
- juce::LookAndFeel::setDefaultLookAndFeel (&lookBefore);
- const auto ok = editorsResult.startsWith ("OK") && ! faultResult.startsWith ("ERROR") && stemsResult == "OK" && exportFormatsResult.startsWith ("OK")
- && mixerBasics == "OK" && fontsResult == "OK" && paintCachesResult.startsWith ("OK") && picturesResult == "OK" && audioOk && projectOk && trackModes122Ok && richOk && hwOutOk && hostKeysOk && pluginLevelsOk && flp168jOk && clipFades180dOk && blocksOk && takeoverOk && compOk && polyOk && latencyOk && preSendOk && lowLatencyOk && previewInTimeOk && substituteOk && patcherOk && rackResult == "OK" && nativesOk && undoOk && projectSaveOk && recordOk && recordUndoOk && cancelRecordOk && midiOk && packageOk
- && sessionResult == "OK" && liveResult.startsWith ("OK")
- && wavpack != "ERROR" && effectsOk && driverPanel == "OK" && deviceChange.startsWith ("OK") && exportParity.startsWith ("OK") && exportLive.startsWith ("OK") && midiHotplug.startsWith ("OK") && midiOutPorts.startsWith ("OK") && metronomeOk && artResult == "OK" && effectParamsResult == "OK"
- && sidechainResult == "OK" && lanesResult == "OK" && arrange190cgResult == "OK" && livescr190drResult == "OK" && livewf190efResult == "OK" && livewf190emResult == "OK" && trackclips190neResult == "OK" && tracker190nwResult == "OK" && tracker190obResult == "OK" && rackauto190ooResult == "OK" && tracker190omResult == "OK" && rackauto190owResult == "OK" && versionsResult == "OK" && pluginsOffResult == "OK" && missingFilesResult == "OK"
- && midigen190fmResult == "OK" && clipenv190giResult == "OK" && beatslaw190gxResult == "OK" && warplaw190ikResult == "OK" && editorScale190heResult == "OK" && sfModBase190heResult == "OK" && trackauto190gzResult == "OK" && community190hqResult == "OK" && rollup030Result == "OK" && rollup031Result == "OK" && rollup031s2Result == "OK"
- && keys190nuResult == "OK" && rollup031s3Result == "OK"
- && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && issues190qrResult == "OK" && qa190rbResult == "OK" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "OK" && extras190qkResult == "OK" && discord190quResult == "OK" && chordlane190pfResult == "OK" && autolinks190ovResult == "OK"
- && trackstates190opResult == "OK" && rollup031s6Result == "OK" // (round 190op's item, reported but not counted in its branch: rollup 0.1.31 step 6)
- && rollup031s7Result == "OK" && rollup031s8Result == "OK" && rollup032Result == "OK" && headerGearResult == "OK" && perTab259Result == "OK" && slots260Result == "OK" && hotfixPlacesResult == "OK" // (round 190qf: slots260) (rollup 0.1.31 step 7, round 190pw; and the three rounds' items its branches reported but did not count:)
- && slides190piResult == "OK" && automodes190paResult == "OK" && heldSteps190ozResult == "OK"
- && issues190qoResult == "OK" // (round 190qo)
- && flparity190prResult == "OK"
- && hotfix190qpWfResult == "OK" // (round 190qp)
- && renderAgainResult.startsWith ("OK") && determinismResult.startsWith ("OK")
- && remoteHistoryResult.startsWith ("OK") && hostedStateLockResult.startsWith ("OK")
- && hostedStateContentionResult.startsWith ("OK") && modulators190oxResult == "OK"
- && generatorSmartResult.startsWith ("OK") && jsfxResult.startsWith ("OK") && jsfxFpResult == "OK"
- && danceWindowResult == "OK" && clickActivationResult == "OK" && motionOverlayResult.startsWith ("OK")
- && editorHolesResult.startsWith ("OK") && picker190qiResult == "OK";
- juce::String report;
- report << "connections=" << offline.getNumGraphConnections() << "\n"
- << "peak=" << peak << "\n"
- << "stems_single_pass=" << stemsResult << "\n"
- << "export_formats=" << exportFormatsResult << "\n"
- << "project=" << (projectOk ? "OK" : "ERROR " + error) << "\n"
- << "playlist_track_modes_roundtrip=" << (trackModes122Ok ? "OK" : "ERROR") << "\n"
- << "project_features=" << (richOk ? "OK" : "ERROR") << "\n"
- << "hardware_outputs=" << (hwOutOk ? "OK" : "ERROR") << "\n"
- << "plugin_host_keys_option=" << (hostKeysOk ? "OK" : "ERROR") << "\n"
- << "plugin_levels_new_project=" << (pluginLevelsOk ? "OK" : "ERROR") << "\n"
- << "flp168j_fields=" << (flp168jOk ? "OK" : "ERROR") << "\n"
- << "clip_fades_180d=" << (clipFades180dOk ? "OK" : "ERROR") << "\n"
- << "pattern_blocks=" << (blocksOk ? "OK" : "ERROR") << "\n"
- << "pattern_clip_takeover=" << (takeoverOk ? "OK" : "ERROR") << "\n"
- << "comp_crossfades=" << (compOk ? "OK" : "ERROR") << "\n"
- << "channel_polyphony=" << (polyOk ? "OK" : "ERROR") << "\n"
- << "track_latency=" << (latencyOk ? "OK" : "ERROR") << "\n"
- << "pre_fader_sends=" << (preSendOk ? "OK" : "ERROR") << "\n"
- << "low_latency_recording=" << (lowLatencyOk ? "OK" : "ERROR") << "\n"
- << "preview_in_time=" << (previewInTimeOk ? "OK" : "ERROR") << " (2 s loop prepared in " << juce::String (previewPrepareMs, 1) << " ms)\n"
- << "plugin_substitutes=" << (substituteOk ? "OK" : "ERROR") << "\n"
- << "patcher=" << (patcherOk ? "OK" : "ERROR") << "\n"
- << "racks=" << rackResult << "\n"
- << "native_engines=" << nativesResult << " (" << nativesMade << " made)\n"
- << "undo=" << (undoOk ? "OK" : "ERROR") << "\n"
- << "mixer_basics=" << mixerBasics << "\n"
- << "remote_history=" << remoteHistoryResult << "\n"
- << "hosted_state_lock=" << hostedStateLockResult << "\n"
- << "hosted_state_contention=" << hostedStateContentionResult << "\n"
- << "modulators190ox=" << modulators190oxResult << "\n"
- << "generator_smart_disable=" << generatorSmartResult << "\n"
- << "fonts=" << fontsResult << "\n"
- << "paint_caches=" << paintCachesResult << "\n"
- << "motion_overlay=" << motionOverlayResult << "\n"
- << "cached_pictures=" << picturesResult << "\n"
- << "plugin_editors=" << editorsResult << "\n"
- << "fault_report=" << faultResult << "\n"
- << "recording=" << (recordOk && recordUndoOk ? "OK" : "ERROR") << "\n"
- << "cancel_recording=" << (cancelRecordOk ? "OK" : "ERROR") << "\n"
- << "midi=" << (midiOk ? "OK" : "ERROR") << "\n"
- << "package=" << (packageOk ? "OK" : "ERROR") << "\n"
- << "projectSave=" << (projectSaveOk ? "OK" : "ERROR") << "\n"
- << "online_session=" << sessionResult << "\n"
- << "live_session=" << liveResult << "\n"
- << "wavpack=" << wavpack << "\n"
- << "effects=" << (effectsOk ? "OK" : "NONFINITE") << "\n"
- << "effect_params_saved=" << effectParamsResult << "\n"
- << "driver_panel=" << driverPanel << "\n"
- << "device_change=" << deviceChange << "\n"
- << "export_parity=" << exportParity << "\n"
- << "export_live=" << exportLive << "\n"
- << "midi_hotplug=" << midiHotplug << "\n"
- << "midi_out_ports=" << midiOutPorts.replace ("\n", " | ").trimCharactersAtEnd (" |") << "\n"
- << "plugin_art=" << artResult << "\n"
- << "plugin_sidechain=" << sidechainResult << "\n"
- << "jsfx190pj=" << jsfxResult << "\n"
- << "jsfx_fp_environment=" << jsfxFpResult << "\n"
- << "picker190qi=" << picker190qiResult << "\n"
- << "versions_panel=" << versionsResult << "\n"
- << "plugins_off=" << pluginsOffResult << "\n"
- << "missing_files_rows=" << missingFilesResult << "\n"
- << "dance_window=" << danceWindowResult << "\n"
- << "dance_window_detail=" << danceWindowDetail << "\n"
- << "click_activation=" << clickActivationResult << "\n"
- << "editor_holes=" << editorHolesResult << "\n"
- << "lanes_saved=" << lanesResult << "\n"
- << "arrange190cg_saved=" << arrange190cgResult << "\n"
- << "livescr190dr=" << livescr190drResult << "\n"
- << "livewf190ef=" << livewf190efResult << "\n"
- << "livewf190em=" << livewf190emResult << "\n"
- << "trackclips190ne=" << trackclips190neResult << "\n"
- << "trackstates190op=" << trackstates190opResult << "\n"
- << "automodes190pa=" << automodes190paResult << "\n"
- << "tracker190nw=" << tracker190nwResult << "\n"
- << "tracker190ob=" << tracker190obResult << "\n"
- << "rackauto190oo=" << rackauto190ooResult << "\n"
- << "tracker190om=" << tracker190omResult << "\n"
- << "rackauto190ow=" << rackauto190owResult << "\n"
- << "midigen190fm_saved=" << midigen190fmResult << "\n"
- << "trackauto190gz_saved=" << trackauto190gzResult << "\n"
- << "clipenv190gi_saved=" << clipenv190giResult << "\n"
- << "beatslaw190gx_saved=" << beatslaw190gxResult << "\n"
- << "warplaw190ik_saved=" << warplaw190ikResult << "\n"
- << "editor_scale190he_saved=" << editorScale190heResult << "\n"
- << "sf_mod_base190he=" << sfModBase190heResult << "\n"
- << "community190hq_saved=" << community190hqResult << "\n"
- << "rollup030_copy_for_0128=" << rollup030Result << "\n"
- << "rollup031_copy_for_0130=" << rollup031Result << "\n"
- << "rollup031s2_copy_for_0130=" << rollup031s2Result << "\n"
- << "keys190nu_key_markers=" << keys190nuResult << "\n"
- << "rollup031s3_copy_for_0130=" << rollup031s3Result << "\n"
- << "helix4_khs190oc_copy_for_0130=" << helix4khs190ocResult << "\n"
- << "rollup031s4_copy_for_0130=" << rollup031s4Result << "\n"
- << "rollup031s5_copy_for_0130=" << rollup031s5Result << "\n"
- << "rollup031s6_copy_for_0130=" << rollup031s6Result << "\n"
- << "rollup031s7_copy_for_0130=" << rollup031s7Result << "\n"
- << "rollup031s8_copy_for_0130=" << rollup031s8Result << "\n"
- << "rollup032_copy_for_0131=" << rollup032Result << "\n"
- << "headergear248=" << headerGearResult << "\n"
- << "pertab259=" << perTab259Result << "\n"
- << "slots260=" << slots260Result << "\n"
- << "simpleduck190ot=" << simpleDuck190otResult << "\n"
- << "tracks190pe=" << tracks190peResult << "\n"
- << "feel190qe=" << feel190qeResult << "\n"
- << "issue258=" << issue258Result << "\n"
- << "autolive190qp=" << autolive190qpResult << "\n"
- << "issue282=" << issue282Result << (issue282Result == "OK" ? juce::String() : " | " + issue282Log.replace ("\n", "; ")) << "\n"
- << "issues190qr=" << issues190qrResult << "\n"
- << "qa190rb=" << qa190rbResult << "\n"
- << "repeats190pm=" << repeats190pmResult << "\n"
- << "mixerqol190qh=" << mixerqol190qhResult << "\n"
- << "hotfixplaces190qp=" << hotfixPlacesResult << "\n"
- << "toolbar_overflow_190qg=" << toolbar190qgResult << "\n"
- << "extras190qk=" << extras190qkResult << "\n"
- << "discord190qu=" << discord190quResult << "\n"
- << "autolinks190ov=" << autolinks190ovResult << "\n"
- << "sections190ol=" << sections190olResult << "\n"
- << "heldsteps190oz=" << heldSteps190ozResult << "\n"
- << "slides190pi=" << slides190piResult << "\n"
- << "issues190qo=" << issues190qoResult << "\n"
- << "flparity190pr=" << flparity190prResult << "\n"
- << "chordlane190pf=" << chordlane190pfResult << "\n"
- << "renderagain190ou=" << renderAgainResult << "\n"
- << "determinism190po=" << determinismResult << "\n"
- << "hotfix190qp_wf=" << hotfix190qpWfResult << "\n"
- << "metronome=" << metronomeResult << " (FL sounds " << metronomeFlSounds << "/" << lynx::metronome::soundCount
- << ", downbeat peak " << juce::String (metronomeMaster, 4) << ")\n";
- // issue #138 (round 190c): a short note at the very start of the Playlist against the same note at bar 2, through
- // the Export window's path (its own thread while the message loop runs: the report is finished from there)
- if (reportPath.isNotEmpty())
- juce::File (reportPath).replaceWithText (report + "(short_export running)\n");
- lynx::shortexport::run (false, 1, {}, {}, [this, report, ok, reportPath] (juce::String shortExport) {
- const auto all = ok && shortExport.startsWith ("OK");
- const auto text = report + "short_export=" + shortExport + "\nresult=" + (all ? "OK" : "FAILED") + "\n";
- if (reportPath.isNotEmpty())
- juce::File (reportPath).replaceWithText (text);
- setApplicationReturnValue (all ? 0 : 1);
- if (selfTestTemp != juce::File())
- selfTestTemp.deleteRecursively(); // (round 190mo: this run's own temp folder)
- quit();
- });
- }
- // Every built-in effect in its native editor: random / extreme parameters, mouse drags over the editor, the editor
- // painted, audio rendered at 44.1 / 48 / 96 kHz. Returns false when an effect output NaN / inf (muted by the
- // renderer's guard). The report lists each effect. Used by --fxfuzz and (a short run) by --selftest.
- bool runEffectFuzz (int rounds, const juce::String& reportPath, bool drags = false)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::setNativeEditorDemo (true);
- juce::String report;
- auto allFinite = true;
- {
- lynx::AudioEngine offline (false);
- juce::Random random (111);
- const auto value = [&] { const auto r = random.nextInt (6); return r == 0 ? 0.0f : r == 1 ? 1.0f : random.nextFloat(); };
- for (int k = 0; k <= (int) lynx::lastEffectKind; ++k)
- {
- const auto kind = (lynx::EffectKind) k;
- if (! lynx::NativeEffectWindows::canOpen (kind) || kind == lynx::EffectKind::patcher) // (the Patcher's editor is a graph window)
- continue;
- const auto before = lynx::RackRenderer::nonFiniteEffectBlocks();
- const auto& info = lynx::effectInfo (kind);
- // (FL engines: a fresh instance as the menus make it, from the user's FL installation; round 142)
- auto fx = lynx::natives::newEffect (kind, lynx::flStudioAccess()).value_or (lynx::makeEffectSlot (kind));
- int dragged = 0; // parameter changes made by the mouse drags
- for (int round = 0; round < rounds; ++round)
- {
- if (round > 0)
- for (std::size_t p = 0; p < info.params.size(); ++p)
- fx.params[p] = round == 1 ? 0.0f : round == 2 ? 1.0f : value();
- auto song = lynx::Song::makeDefault(); // its demo beat feeds the effect
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.assign (1, fx);
- for (auto& channel : song.channels)
- channel.mixerTrack = 1;
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- const auto pages = juce::jmax (1, (int) lynx::plugui::layoutFor (kind).pages.size());
- for (int page = 0; page < pages; ++page)
- {
- auto editor = kind == lynx::EffectKind::facetEq ? lynx::makeFacetEqEditor (offline, 1, 0, false)
- : lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, page);
- if (editor == nullptr || editor->getWidth() <= 0 || editor->getHeight() <= 0)
- continue;
- juce::Image image (juce::Image::ARGB, editor->getWidth(), editor->getHeight(), true);
- const auto paint = [&] {
- juce::Graphics g (image);
- editor->paintEntireComponent (g, false);
- };
- paint();
- // drags from a grid of points, as a user moving every control (plain left button)
- if (round >= 3 && drags)
- {
- const auto source = juce::Desktop::getInstance().getMainMouseSource();
- const auto step = juce::jmax (12, juce::jmin (editor->getWidth(), editor->getHeight()) / 8);
- for (int y = step / 2; y < editor->getHeight(); y += step)
- for (int x = step / 2; x < editor->getWidth(); x += step)
- {
- auto* target = editor->getComponentAt (x, y);
- if (target == nullptr)
- continue;
- const auto at = target->getLocalPoint (editor.get(), juce::Point<float> ((float) x, (float) y));
- const auto now = juce::Time::getCurrentTime();
- const auto event = [&] (juce::Point<float> p, juce::ModifierKeys mods) {
- return juce::MouseEvent (source, p, mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, target, target, now, at, now, 1, false);
- };
- const auto down = juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier);
- const juce::Component::SafePointer<juce::Component> alive (target);
- target->mouseDown (event (at, down));
- const auto dy = (float) (random.nextBool() ? 400 : -400), dx = (float) (random.nextInt (401) - 200);
- if (alive != nullptr)
- target->mouseDrag (event (at + juce::Point<float> (dx * 0.5f, dy * 0.5f), down));
- if (alive != nullptr)
- target->mouseDrag (event (at + juce::Point<float> (dx, dy), down));
- if (alive != nullptr)
- target->mouseUp (event (at + juce::Point<float> (dx, dy), juce::ModifierKeys()));
- juce::PopupMenu::dismissAllActiveMenus();
- offline.dispatchPendingMessages();
- }
- paint();
- }
- }
- for (const auto rate : { 44100.0, 48000.0, 96000.0 })
- offline.renderOffline (0.05, rate);
- if (round == 0 || round >= 3) // keep what the drags set for the next round
- if (offline.getSong().mixer.size() > 1 && ! offline.getSong().mixer[1].effects.empty())
- {
- const auto& now = offline.getSong().mixer[1].effects[0];
- for (std::size_t p = 0; p < fx.params.size(); ++p)
- dragged += now.params[p] != fx.params[p] ? 1 : 0;
- dragged += now.state != fx.state ? 1 : 0;
- fx = now;
- }
- }
- const auto broken = lynx::RackRenderer::nonFiniteEffectBlocks() - before;
- allFinite = allFinite && broken == 0;
- report << info.name << ": " << (broken == 0 ? juce::String ("OK") : "non-finite output in " + juce::String ((juce::int64) broken) + " blocks")
- << " (" << dragged << " changes by mouse)\n";
- if (reportPath.isNotEmpty())
- juce::File (reportPath).replaceWithText (report + "(running)\n"); // what was reached, if it crashes
- }
- }
- lynx::setNativeEditorDemo (false);
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- report << "result=" << (allFinite ? "OK" : "NONFINITE") << "\n";
- if (reportPath.isNotEmpty())
- juce::File (reportPath).replaceWithText (report);
- return allFinite;
- }
- // --opentest (round 157a): see the command line. Runs on the message loop (the editors' timers, animations and
- // native windows are real); one step per timer tick.
- void runOpenTest (const juce::String& reportPath, bool visible, std::function<void (bool)> done)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- struct OpenTest final : juce::Timer
- {
- juce::String reportPath, report;
- bool visible = false, ok = true;
- std::function<void (bool)> done;
- std::unique_ptr<lynx::AudioEngine> engine;
- std::vector<std::pair<juce::String, std::function<void()>>> steps;
- std::size_t next = 0;
- std::atomic<std::int64_t> lastStep { 0 };
- std::atomic<bool> finished { false };
- std::thread watchdog;
- juce::String current;
- std::mutex currentLock;
- int opened = 0, painted = 0;
- // LYNX_OPENTEST_TIMEOUT (seconds): longer for sanitizer builds
- const std::int64_t timeoutMs = 1000 * juce::jmax (5, juce::SystemStats::getEnvironmentVariable ("LYNX_OPENTEST_TIMEOUT", "20").getIntValue());
- static std::int64_t now() { return (std::int64_t) juce::Time::getMillisecondCounter(); }
- void write (const juce::String& tail = {}) { juce::File (reportPath).replaceWithText (report + tail); }
- ~OpenTest() override
- {
- finished = true;
- if (watchdog.joinable())
- watchdog.join();
- }
- void start()
- {
- lastStep = now();
- // the UI hang watch runs during the whole test (5 s): a slow step leaves its stack next to the report
- const auto folder = juce::File (reportPath).getParentDirectory().getChildFile ("opentest-hang");
- folder.deleteRecursively();
- folder.createDirectory();
- lynx::crashguard::startHangWatch (folder.getFullPathName().replaceCharacter ('\\', '/').toStdString(), 5000);
- watchdog = std::thread ([this] {
- while (! finished)
- {
- std::this_thread::sleep_for (std::chrono::milliseconds (200));
- if (now() - lastStep.load() > timeoutMs)
- {
- juce::String at;
- {
- const std::lock_guard<std::mutex> l (currentLock);
- at = current;
- }
- juce::File (reportPath).replaceWithText (report + "HANG at " + at + " (no progress for " + juce::String (timeoutMs / 1000) + " s; stack in opentest-hang)\nresult=HANG\n");
- lynx::crashguard::exitNow (3);
- }
- }
- });
- startTimer (30);
- }
- // every LYNX window but none of the main one (there is none here): moved off-screen, painted once into an image
- void touchWindows (bool resize, bool large)
- {
- auto& desktop = juce::Desktop::getInstance();
- for (int i = desktop.getNumComponents(); --i >= 0;)
- if (auto* c = desktop.getComponent (i); c != nullptr && c->isVisible())
- {
- if (! visible && c->getScreenX() > -3000)
- c->setTopLeftPosition (-6000, -6000);
- if (resize)
- if (auto* w = dynamic_cast<juce::ResizableWindow*> (c))
- {
- const auto b = w->getBounds();
- w->setSize (large ? b.getWidth() * 2 : juce::jmax (40, b.getWidth() / 3), large ? b.getHeight() * 2 : juce::jmax (40, b.getHeight() / 3));
- }
- if (c->getWidth() > 0 && c->getHeight() > 0 && c->getWidth() < 8000 && c->getHeight() < 8000)
- {
- juce::Image image (juce::Image::ARGB, c->getWidth(), c->getHeight(), true);
- juce::Graphics g (image);
- c->paintEntireComponent (g, false);
- ++painted;
- // LYNX_OPENTEST_SHOTS=folder: each window as first painted (before the resizes), for a look
- if (const auto shots = juce::SystemStats::getEnvironmentVariable ("LYNX_OPENTEST_SHOTS", {}); shots.isNotEmpty() && ! resize)
- {
- juce::FileOutputStream out (juce::File (shots).getChildFile (juce::String (painted).paddedLeft ('0', 4) + ".png"));
- if (out.openedOk())
- {
- out.setPosition (0), out.truncate();
- juce::PNGImageFormat().writeImageToStream (c->createComponentSnapshot (c->getLocalBounds()), out);
- }
- }
- }
- }
- }
- void timerCallback() override
- {
- if (next >= steps.size())
- {
- stopTimer();
- lynx::NativeEffectWindows::closeAll();
- lynx::closeChannelSettings();
- // the UI hang watch itself: the message thread spins past the stall time; the watcher must write the stack
- {
- const auto before = lynx::crashguard::lastHangFile();
- for (const auto until = now() + 7000; now() < until;)
- lastStep = now(); // (busy: no heartbeat; the test's own watchdog stays quiet)
- for (const auto until = now() + 1500; now() < until && lynx::crashguard::lastHangFile() == before;)
- std::this_thread::sleep_for (std::chrono::milliseconds (20));
- lynx::crashguard::stopHangWatch();
- const juce::File hang (juce::String::fromUTF8 (lynx::crashguard::lastHangFile().c_str()));
- const auto text = hang.loadFileAsString();
- const auto frames = juce::StringArray::fromLines (text).size() - 2;
- #if JUCE_WINDOWS
- const auto hangOk = lynx::crashguard::lastHangFile() != before && hang.existsAsFile() && text.contains ("LYNX.exe+0x") && frames >= 3;
- #else
- const auto hangOk = lynx::crashguard::lastHangFile() != before && hang.existsAsFile() && frames >= 3;
- #endif
- report << "hang watch: " << (hangOk ? "OK" : "FAIL") << " (" << hang.getFileName() << ", " << frames << " lines"
- << (before.empty() ? juce::String() : "; a step stalled > 5 s earlier: " + juce::String::fromUTF8 (before.c_str())) << ")\n";
- ok = ok && hangOk;
- }
- report << "windows opened: " << opened << ", paints: " << painted << "\nresult=" << (ok ? "OK" : "FAIL") << "\n";
- write();
- finished = true;
- if (done)
- done (ok);
- return;
- }
- auto& [label, fn] = steps[next++];
- {
- const std::lock_guard<std::mutex> l (currentLock);
- current = label;
- }
- fn();
- lastStep = now();
- lynx::crashguard::heartbeat();
- }
- };
- auto* test = new OpenTest();
- test->reportPath = reportPath;
- test->visible = visible;
- test->engine = std::make_unique<lynx::AudioEngine> (false);
- test->done = [test, done] (bool ok) {
- juce::MessageManager::callAsync ([test, done, ok] {
- delete test;
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- done (ok);
- });
- };
- auto& engine = *test->engine;
- lynx::setNativeEditorDemo (true); // live displays animate without an audio device
- const auto songWith = [] (const lynx::EffectSlot& fx) {
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.assign (1, fx);
- for (auto& channel : song.channels)
- channel.mixerTrack = 1;
- return song;
- };
- // an older project's slot: its parameter list cut to `count` and read back by the project reader (the
- // parameters a newer LYNX added after them take their defaults)
- const auto oldState = [songWith] (const lynx::EffectSlot& fx, std::size_t count) -> std::optional<lynx::Song> {
- auto json = juce::JSON::parse (lynx::ProjectFile::toJson (songWith (fx)));
- if (auto* mixer = json["mixer"].getArray(); mixer != nullptr && mixer->size() > 1)
- if (auto* effects = (*mixer)[1]["effects"].getArray(); effects != nullptr && ! effects->isEmpty())
- if (auto* params = (*effects)[0]["params"].getArray())
- params->removeRange ((int) count, params->size());
- juce::String error;
- return lynx::ProjectFile::fromJson (juce::JSON::toString (json), error);
- };
- auto& steps = test->steps;
- juce::Random random (157);
- for (int k = 0; k <= (int) lynx::lastEffectKind; ++k)
- {
- const auto kind = (lynx::EffectKind) k;
- if (! lynx::NativeEffectWindows::canOpen (kind) || kind == lynx::EffectKind::patcher)
- continue;
- const auto& info = lynx::effectInfo (kind);
- const auto base = lynx::natives::newEffect (kind, lynx::flStudioAccess()).value_or (lynx::makeEffectSlot (kind));
- const auto n = info.params.size();
- std::vector<std::pair<juce::String, std::function<std::optional<lynx::Song>()>>> variants;
- variants.push_back ({ "default", [=] { return std::optional<lynx::Song> (songWith (base)); } });
- for (const auto value : { 0.0f, 1.0f })
- variants.push_back ({ value == 0.0f ? "all 0" : "all 1", [=] {
- auto fx = base;
- for (std::size_t p = 0; p < n; ++p) fx.params[p] = value;
- return std::optional<lynx::Song> (songWith (fx));
- } });
- const auto seed = random.nextInt64();
- variants.push_back ({ "random", [=] {
- juce::Random r (seed);
- auto fx = base;
- for (std::size_t p = 0; p < n; ++p) fx.params[p] = r.nextFloat();
- return std::optional<lynx::Song> (songWith (fx));
- } });
- std::vector<std::size_t> cuts { n / 2 };
- for (const auto c : { (std::size_t) 90, (std::size_t) 114, (std::size_t) 128, (std::size_t) 160 }) // (Facet's 90 → 114 params; the 128 → 160 → 192 slot)
- if (c < n) cuts.push_back (c);
- for (const auto c : cuts)
- variants.push_back ({ "old project (" + juce::String ((int) c) + " of " + juce::String ((int) n) + " params)", [=] { return oldState (base, c); } });
- for (const auto& [variant, makeSong] : variants)
- {
- const auto label = juce::String::fromUTF8 (info.name) + " / " + variant;
- steps.push_back ({ label + ": open", [test, &engine, label, makeSong = makeSong] {
- auto song = makeSong();
- if (! song)
- {
- test->report << "FAIL " << label << ": project reader refused the state\n";
- test->ok = false;
- return;
- }
- engine.setSong (std::move (*song));
- engine.dispatchPendingMessages();
- lynx::NativeEffectWindows::open (engine, 1, 0);
- ++test->opened;
- test->touchWindows (false, false);
- } });
- steps.push_back ({ label + ": run", [test, &engine] {
- for (const auto rate : { 44100.0, 48000.0, 96000.0 })
- engine.renderOffline (0.03, rate);
- test->touchWindows (false, false);
- } });
- steps.push_back ({ label + ": small", [test] { test->touchWindows (true, false); } });
- steps.push_back ({ label + ": large", [test] { test->touchWindows (true, true); } });
- steps.push_back ({ label + ": close", [test, label] {
- lynx::NativeEffectWindows::closeAll();
- test->report << label << ": OK\n";
- test->write ("(running)\n");
- } });
- }
- }
- // instruments: the channel window the Channel rack opens (Patcher: its graph window, not here)
- for (int k = 0; k <= (int) lynx::InstrumentKind::soundfont; ++k)
- {
- const auto kind = (lynx::InstrumentKind) k;
- if (kind == lynx::InstrumentKind::plugin || kind == lynx::InstrumentKind::patcher)
- continue;
- for (const auto* variant : { "default", "old project (saved and read back)", "odd settings" })
- {
- if (juce::String (variant) == "odd settings" && kind != lynx::InstrumentKind::soundfont)
- continue;
- const auto label = "instrument " + juce::String (k) + " / " + variant;
- steps.push_back ({ label + ": open", [test, &engine, kind, label, variant = juce::String (variant), old = juce::String (variant) != "default"] {
- auto song = lynx::Song::makeDefault();
- auto channel = lynx::natives::makeChannel (kind, lynx::flStudioAccess());
- lynx::ChannelDef def;
- def.instrument = kind;
- def.name = "Test";
- song.channels.push_back (channel ? *channel : def);
- if (kind == lynx::InstrumentKind::soundfont && variant != "default")
- {
- // a real font when FL's is there; NaN / huge / truncated settings
- const auto& roots = lynx::flStudioAccess().roots;
- if (! roots.data.empty())
- song.channels.back().samplePath = (juce::File (juce::String::fromUTF8 (roots.data.c_str()))
- .getChildFile ("Patches/Soundfonts/STR_Ensemble.sf2"))
- .getFullPathName().toStdString();
- if (variant == "odd settings")
- song.channels.back().modelParams = { NAN, 1.0e9f, -1.0e9f, 0.5f, 7.0f };
- }
- if (old)
- {
- juce::String error;
- if (auto again = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error))
- song = std::move (*again);
- }
- const auto index = (int) song.channels.size() - 1;
- engine.setSong (std::move (song));
- engine.dispatchPendingMessages();
- lynx::openChannelSettings (engine, index);
- ++test->opened;
- test->touchWindows (false, false);
- } });
- steps.push_back ({ label + ": run", [test, &engine] {
- engine.renderOffline (0.03, 48000.0);
- test->touchWindows (false, false);
- } });
- steps.push_back ({ label + ": small", [test] { test->touchWindows (true, false); } });
- steps.push_back ({ label + ": large", [test] { test->touchWindows (true, true); } });
- steps.push_back ({ label + ": close", [test, label] {
- lynx::closeChannelSettings();
- test->report << label << ": OK\n";
- test->write ("(running)\n");
- } });
- }
- }
- test->start();
- }
- void runPluginOptionsTest (const juce::String& pluginPath, const juce::String& reportPath, const juce::String& shotsPath)
- {
- struct Test final : juce::Timer
- {
- juce::String reportPath, report;
- juce::File shots;
- std::unique_ptr<lynx::AudioEngine> engine;
- std::unique_ptr<juce::DocumentWindow> mainWindow, other; // LYNX's main window stand-in; another secondary window
- bool instrument = false, ok = true;
- int channelIndex = -1, phase = 0;
- juce::uint32 phaseStart = 0;
- juce::AudioPluginInstance* instance = nullptr;
- std::function<void (bool)> done;
- void step (const juce::String& line)
- {
- report << line << "\n";
- juce::File (reportPath).replaceWithText (report);
- }
- void expect (const juce::String& name, bool value)
- {
- step (name + "=" + juce::String ((int) value));
- ok = ok && value;
- }
- void next (int to)
- {
- phase = to;
- phaseStart = juce::Time::getMillisecondCounter();
- }
- int elapsed() const { return (int) (juce::Time::getMillisecondCounter() - phaseStart); }
- lynx::PluginRef* ref (lynx::Song& song) const
- {
- if (instrument)
- return channelIndex < 0 || channelIndex >= (int) song.channels.size() ? nullptr : &song.channels[(size_t) channelIndex].plugin;
- return song.mixer.size() < 2 || song.mixer[1].effects.empty() ? nullptr : &song.mixer[1].effects[0].plugin;
- }
- const lynx::PluginRef& refNow() const { return *ref (const_cast<lynx::Song&> (engine->getSong())); }
- juce::AudioPluginInstance* find()
- {
- if (instrument)
- {
- if (auto* p = dynamic_cast<lynx::PluginInstrument*> (engine->getChannelInstrument (channelIndex).get()))
- return &p->getInstance();
- }
- else if (auto* p = dynamic_cast<lynx::PluginEffect*> (engine->getEffect (1, 0).get()))
- return &p->getInstance();
- return nullptr;
- }
- void openWindow()
- {
- std::shared_ptr<void> owner = instrument ? std::shared_ptr<void> (engine->getChannelInstrument (channelIndex))
- : std::shared_ptr<void> (engine->getEffect (1, 0));
- lynx::PluginWindows::open (owner, *instance, instance->getName(),
- { engine.get(), [this] (lynx::Song& song) { return ref (song); }, instrument, instrument ? -1 : 1,
- instrument ? -1 : 0, {}, {} });
- }
- void shot (const char* name, bool settingsPage = false)
- {
- if (shots != juce::File() && instance != nullptr)
- step (juce::String ("shot_") + name + "=" + juce::String ((int) lynx::PluginWindows::saveWindowShot (*instance, shots.getChildFile (juce::String (name) + ".png"), settingsPage)));
- }
- // the plugin window is in front of the other secondary window
- bool pluginInFront()
- {
- auto* plug = lynx::PluginWindows::hostWindowHandle (*instance);
- #if JUCE_WINDOWS
- return plug != nullptr && lynx::nativechild::isAbove (plug, other->getWindowHandle());
- #else
- auto& desktop = juce::Desktop::getInstance();
- for (int i = 0; i < desktop.getNumComponents(); ++i)
- if (auto* c = desktop.getComponent (i); c->getWindowHandle() == plug)
- return c->isAlwaysOnTop() || desktop.getComponent (desktop.getNumComponents() - 1) == c;
- return false;
- #endif
- }
- void timerCallback() override
- {
- if (phase == 0) // waiting for the engine to host the plugin
- {
- instance = find();
- if (instance == nullptr)
- {
- if (elapsed() > 20000)
- finish ("not hosted");
- return;
- }
- step ("hosted=" + instance->getName() + " format=" + instance->getPluginDescription().pluginFormatName);
- openWindow();
- next (1);
- return;
- }
- if (phase == 1 && elapsed() >= 800) // Pin on top: off for a new plugin
- {
- expect ("pin_off_by_default", ! lynx::PluginWindows::isPinnedOnTop (*instance) && ! refNow().pinned);
- shot ("pin-off");
- const auto history = engine->getHistoryPosition();
- lynx::PluginWindows::setPinnedOnTop (*instance, true);
- expect ("pin_set", lynx::PluginWindows::isPinnedOnTop (*instance) && refNow().pinned);
- expect ("pin_no_undo_step_project_modified", engine->getHistoryPosition() == history && engine->isModified());
- // another secondary window brought in front of it
- other = std::make_unique<juce::DocumentWindow> ("Another LYNX window", juce::Colours::darkslategrey, juce::DocumentWindow::closeButton);
- other->setUsingNativeTitleBar (true);
- other->setBounds (mainWindow->getX() + 60, mainWindow->getY() + 60, 420, 300);
- other->setVisible (true);
- lynx::keepAboveMainWindow (*other);
- lynx::forceForegroundForTest (*other);
- other->toFront (true);
- next (2);
- return;
- }
- if (phase == 2 && elapsed() >= 1200)
- {
- expect ("pinned_stays_in_front_of_a_clicked_window", pluginInFront());
- shot ("pin-on");
- // closed and opened again: the pin comes back from the project
- lynx::PluginWindows::close (*instance);
- openWindow();
- next (3);
- return;
- }
- if (phase == 3 && elapsed() >= 600)
- {
- expect ("pin_remembered_when_reopened", lynx::PluginWindows::isPinnedOnTop (*instance));
- lynx::PluginWindows::setPinnedOnTop (*instance, false);
- expect ("pin_cleared", ! lynx::PluginWindows::isPinnedOnTop (*instance) && ! refNow().pinned);
- other->toFront (true);
- next (4);
- return;
- }
- if (phase == 4 && elapsed() >= 1000)
- {
- #if JUCE_WINDOWS
- expect ("unpinned_goes_behind_a_clicked_window", ! pluginInFront());
- #endif
- other = nullptr;
- // the wrapper settings page: LYNX's Velocity row in the MIDI group (instruments), default = follow
- expect ("velocity_follows_midi_settings_by_default", refNow().velocityMode == lynx::prefs::pluginVelocityFollow
- && refNow().fixedVelocity == lynx::prefs::defaultFixedVelocity);
- shot ("wrapper-velocity-default", true);
- engine->editSong ([this] (lynx::Song& song) {
- if (auto* r = ref (song))
- {
- r->velocityMode = lynx::prefs::pluginVelocityFixed;
- r->fixedVelocity = 96;
- }
- });
- next (5);
- return;
- }
- if (phase == 5 && elapsed() >= 400)
- {
- expect ("velocity_change_keeps_the_running_plugin", find() == instance);
- shot ("wrapper-velocity-fixed", true);
- engine->undo();
- expect ("velocity_undo", refNow().velocityMode == lynx::prefs::pluginVelocityFollow && find() == instance);
- // the preset menu's "Play a note when a preset loads": off by default, a user setting
- expect ("audition_off_by_default", ! lynx::pluginpresetui::auditionOnLoad());
- lynx::pluginpresetui::setAuditionOnLoad (true);
- expect ("audition_menu_opened", lynx::PluginWindows::showPresetMenu (*instance));
- next (6);
- return;
- }
- if (phase == 6 && elapsed() >= 500) // the menu, as drawn
- {
- auto found = false;
- auto& desktop = juce::Desktop::getInstance();
- for (int c = desktop.getNumComponents(); --c >= 0 && ! found;)
- if (auto* menu = desktop.getComponent (c); dynamic_cast<juce::TopLevelWindow*> (menu) == nullptr && menu->isVisible()
- && menu->getHeight() > 60 && shots != juce::File())
- {
- const auto image = menu->createComponentSnapshot (menu->getLocalBounds(), true, 1.0f);
- juce::FileOutputStream out (shots.getChildFile ("preset-menu-audition.png"));
- found = out.openedOk() && juce::PNGImageFormat().writeImageToStream (image, out);
- }
- step ("shot_preset-menu-audition=" + juce::String ((int) found));
- juce::PopupMenu::dismissAllActiveMenus();
- // a preset loaded while the song is stopped: the note waits a moment, sounds, ends
- const auto asked = engine->auditionPreset (*instance);
- expect ("audition_only_for_channel_instruments", asked == instrument);
- expect ("audition_waits_first", ! instrument || engine->auditionState() == 1);
- next (7);
- return;
- }
- if (phase == 7 && elapsed() >= 300)
- {
- expect ("audition_sounds", ! instrument || engine->auditionState() == 2);
- next (8);
- return;
- }
- if (phase == 8 && elapsed() >= 700)
- {
- expect ("audition_ends", engine->auditionState() == 0);
- engine->getTransport().playing.store (true); // the song plays: no audition
- expect ("no_audition_while_playing", ! engine->auditionPreset (*instance) && engine->auditionState() == 0);
- engine->getTransport().playing.store (false);
- lynx::pluginpresetui::setAuditionOnLoad (false);
- expect ("audition_setting_off_again", ! lynx::pluginpresetui::auditionOnLoad());
- finish ({});
- }
- }
- void finish (const juce::String& failure)
- {
- stopTimer();
- if (failure.isNotEmpty())
- step ("failed=" + failure);
- ok = ok && failure.isEmpty();
- step (ok ? "result=OK" : "result=FAILED");
- lynx::PluginWindows::closeAll();
- done (ok);
- }
- };
- auto* test = new Test();
- test->reportPath = reportPath;
- if (shotsPath.isNotEmpty())
- {
- test->shots = juce::File (shotsPath);
- test->shots.createDirectory();
- }
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- test->done = [this, test] (bool ok) {
- setApplicationReturnValue (ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] {
- lynx::setMainWindowForOwnership (nullptr);
- test->other = nullptr;
- test->mainWindow = nullptr;
- test->engine = nullptr;
- delete test;
- quit();
- });
- };
- test->engine = std::make_unique<lynx::AudioEngine> (false);
- test->mainWindow = std::make_unique<juce::DocumentWindow> ("LYNX test main window", juce::Colours::darkgrey, 0);
- test->mainWindow->setBounds (20, 20, 300, 200);
- test->mainWindow->setVisible (true);
- lynx::setMainWindowForOwnership (test->mainWindow.get());
- auto& host = test->engine->getPluginHost();
- test->step ("plugins_in_file=" + juce::String (host.addPluginFile (juce::File (pluginPath))));
- std::optional<juce::PluginDescription> chosen;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName() || type.fileOrIdentifier == pluginPath
- || (pluginPath.endsWithIgnoreCase (".lv2") && type.pluginFormatName == "LV2")) // (round 190rf: an LV2 bundle's plugin, known by URI)
- {
- chosen = type;
- break;
- }
- if (! chosen)
- {
- test->step ("result=FAILED (no plugin)");
- test->done (false);
- return;
- }
- test->instrument = chosen->isInstrument;
- lynx::PluginRef ref;
- ref.id = chosen->createIdentifierString().toStdString();
- ref.name = chosen->name.toStdString();
- test->engine->editSong ([&] (lynx::Song& song) {
- if (test->instrument)
- {
- lynx::ChannelDef c;
- c.name = ref.name;
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin = ref;
- test->channelIndex = (int) song.channels.size();
- song.channels.push_back (c);
- }
- else
- {
- while (song.mixer.size() < 2)
- song.mixer.emplace_back();
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::plugin;
- slot.plugin = ref;
- song.mixer[1].effects.push_back (slot);
- }
- });
- test->engine->markSaved();
- test->step ("plugin=" + chosen->name + " instrument=" + juce::String ((int) test->instrument));
- test->next (0);
- test->startTimerHz (20);
- }
- void runReloadTest (const juce::String& pluginPath, const juce::String& reportPath, const juce::String& shotsPath, bool waitKill)
- {
- struct Test final : juce::Timer
- {
- juce::String reportPath, report;
- juce::File shots;
- std::unique_ptr<lynx::AudioEngine> engine;
- std::unique_ptr<juce::DocumentWindow> mainWindow; // stands for LYNX's main window (window ownership)
- bool instrument = false, waitKill = false, ok = true;
- int channelIndex = -1, phase = 0, round = 0;
- juce::uint32 phaseStart = 0;
- int firstPid = 0, pid = 0, historyBefore = 0;
- bool modifiedBefore = false;
- float captured = -1.0f;
- juce::AudioPluginInstance* instance = nullptr;
- std::vector<lynx::ChannelDef> channelsBefore;
- std::function<void (bool)> done;
- lynx::AudioEngine::HostedSlot where() const { return instrument ? lynx::AudioEngine::HostedSlot { channelIndex, -1, -1 } : lynx::AudioEngine::HostedSlot { -1, 1, 0 }; }
- void step (const juce::String& line)
- {
- report << line << "\n";
- juce::File (reportPath).replaceWithText (report);
- }
- void expect (const juce::String& name, bool value)
- {
- step (name + "=" + juce::String ((int) value));
- ok = ok && value;
- }
- void next (int to)
- {
- phase = to;
- phaseStart = juce::Time::getMillisecondCounter();
- }
- int elapsed() const { return (int) (juce::Time::getMillisecondCounter() - phaseStart); }
- juce::AudioPluginInstance* find()
- {
- if (instrument)
- {
- if (auto* p = dynamic_cast<lynx::PluginInstrument*> (engine->getChannelInstrument (channelIndex).get()))
- return &p->getInstance();
- }
- else if (auto* p = dynamic_cast<lynx::PluginEffect*> (engine->getEffect (1, 0).get()))
- return &p->getInstance();
- return nullptr;
- }
- // a few blocks through the plugin (the offline engine has no audio thread): they carry parameter changes to
- // the plugin's process and its values back
- void pump (int blocks)
- {
- std::vector<float> l (512), r (512);
- lynx::EffectParams none {};
- for (int b = 0; b < blocks; ++b)
- {
- std::fill (l.begin(), l.end(), 0.0f);
- std::fill (r.begin(), r.end(), 0.0f);
- if (instrument)
- {
- if (auto in = engine->getChannelInstrument (channelIndex))
- in->render (l.data(), r.data(), 512, 1.0f, 1.0f);
- }
- else if (auto fx = engine->getEffect (1, 0))
- fx->process (l.data(), r.data(), 512, none, 120.0);
- }
- }
- juce::AudioProcessorParameter* firstParam()
- {
- if (instance != nullptr)
- for (auto* candidate : instance->getParameters())
- if (candidate->isAutomatable() && ! candidate->isMetaParameter() && candidate != instance->getBypassParameter())
- return candidate;
- return nullptr;
- }
- void openWindow()
- {
- std::shared_ptr<void> owner = instrument ? std::shared_ptr<void> (engine->getChannelInstrument (channelIndex))
- : std::shared_ptr<void> (engine->getEffect (1, 0));
- lynx::PluginWindows::WrapperContext context { engine.get(), [this] (lynx::Song& song) -> lynx::PluginRef* {
- if (instrument)
- return channelIndex < 0 || channelIndex >= (int) song.channels.size()
- ? nullptr : &song.channels[(size_t) channelIndex].plugin;
- return song.mixer.size() < 2 || song.mixer[1].effects.empty() ? nullptr : &song.mixer[1].effects[0].plugin;
- }, instrument, instrument ? -1 : 1, instrument ? -1 : 0, {}, {} };
- context.reload = [] {}; // (the test reloads by itself; with it the window shows the notice)
- lynx::PluginWindows::open (owner, *instance, instance->getName(), std::move (context));
- }
- void shot (const char* name, bool settingsPage = false)
- {
- if (shots != juce::File() && instance != nullptr)
- step (juce::String ("shot_") + name + "=" + juce::String ((int) lynx::PluginWindows::saveWindowShot (*instance, shots.getChildFile (juce::String (name) + ".png"), settingsPage)));
- }
- void timerCallback() override
- {
- if (phase == 0) // waiting for the engine to host the plugin
- {
- instance = find();
- if (instance == nullptr)
- {
- if (elapsed() > 20000)
- finish ("not hosted");
- return;
- }
- pid = firstPid = lynx::sandboxedPluginProcessId (*instance);
- step ("hosted=" + instance->getName() + " format=" + instance->getPluginDescription().pluginFormatName + " pid=" + juce::String (pid));
- expect ("separate_process", lynx::isSandboxedPlugin (*instance) && pid != 0);
- expect ("running", ! engine->hostedPluginDown (where()) && engine->downHostedPlugins().empty());
- // a setting that is captured (what a save or a backup does), then one that is not
- if (auto* param = firstParam())
- {
- param->setValue (param->getValue() > 0.5f ? 0.13f : 0.87f);
- pump (4);
- engine->capturePluginStates();
- captured = param->getValue();
- param->setValue (captured > 0.5f ? 0.31f : 0.69f);
- pump (4);
- step ("param=" + param->getName (64) + " captured=" + juce::String (captured, 4) + " then=" + juce::String (param->getValue(), 4));
- }
- else
- {
- engine->capturePluginStates();
- step ("param=none");
- }
- channelsBefore = engine->getSong().channels;
- historyBefore = engine->getHistoryPosition();
- modifiedBefore = engine->isModified();
- if (shots != juce::File())
- openWindow();
- next (1);
- return;
- }
- if (phase == 1 && elapsed() >= 600) // the plugin's process goes
- {
- shot (round == 0 ? "window-running" : "window-reloaded");
- if (waitKill && round == 0)
- {
- juce::File (reportPath + ".pid").replaceWithText (juce::String (pid));
- step ("waiting_for_kill pid=" + juce::String (pid));
- }
- else
- lynx::crashSandboxedPluginForTest (*instance);
- next (2);
- return;
- }
- if (phase == 2) // LYNX notices
- {
- if (! engine->hostedPluginDown (where()))
- {
- pump (1); // (as the audio thread would: a block that gets no answer marks it too)
- if (elapsed() > (waitKill && round == 0 ? 120000 : 10000))
- finish ("the plugin never went down");
- return;
- }
- step ("down_after_ms=" + juce::String (elapsed()));
- const auto down = engine->downHostedPlugins();
- expect ("listed_down", down.size() == 1 && down.front() == where());
- expect ("listed_by_name", engine->downHostedPlugins (nameInSong()).size() == 1 && engine->downHostedPlugins ("no such plugin").empty());
- next (3);
- return;
- }
- if (phase == 3 && elapsed() >= 1500) // nothing reloads by itself
- {
- expect ("still_down_without_asking", engine->hostedPluginDown (where()) && find() == instance
- && lynx::sandboxedPluginProcessId (*instance) == pid);
- shot (round == 0 ? "reload-notice" : "reload-notice-again");
- if (shots != juce::File() && round == 0)
- {
- lynx::PluginWindows::close (*instance);
- lynx::PluginWindows::promptReload (*engine, where(), {});
- next (4);
- return;
- }
- next (5);
- return;
- }
- if (phase == 4 && elapsed() >= 500) // the prompt a click on the channel / slot shows
- {
- auto found = false;
- for (int c = juce::Desktop::getInstance().getNumComponents(); --c >= 0;)
- if (auto* alert = dynamic_cast<juce::AlertWindow*> (juce::Desktop::getInstance().getComponent (c)))
- {
- const auto image = alert->createComponentSnapshot (alert->getLocalBounds(), true, 1.0f);
- juce::FileOutputStream out (shots.getChildFile ("reload-prompt.png"));
- found = out.openedOk() && juce::PNGImageFormat().writeImageToStream (image, out);
- alert->exitModalState (0); // Close: nothing reloads
- break;
- }
- step ("shot_reload-prompt=" + juce::String ((int) found));
- next (45);
- return;
- }
- if (phase == 45 && elapsed() >= 300)
- {
- expect ("still_down_after_close", engine->hostedPluginDown (where()));
- next (5);
- return;
- }
- if (phase == 5) // Reload, as the notice's button / the prompt / the menu item do
- {
- auto* old = instance;
- const auto running = lynx::PluginWindows::reload (*engine, { where() });
- instance = find();
- const auto newPid = instance != nullptr ? lynx::sandboxedPluginProcessId (*instance) : 0;
- expect ("reloaded", running == 1 && instance != nullptr && ! engine->hostedPluginDown (where()) && engine->downHostedPlugins().empty());
- expect ("new_process", newPid != 0 && newPid != pid);
- step ("pid=" + juce::String (newPid) + " same_object=" + juce::String ((int) (instance == old)));
- expect ("old_window_closed", ! lynx::PluginWindows::isOpen (*old) || instance == old);
- pid = newPid;
- if (instance != nullptr)
- {
- pump (4);
- if (auto* param = firstParam(); param != nullptr && captured >= 0.0f)
- {
- step ("param_after_reload=" + juce::String (param->getValue(), 4));
- expect ("state_captured_last", std::abs (param->getValue() - captured) < 0.02f);
- }
- }
- expect ("song_untouched", engine->getSong().channels == channelsBefore);
- expect ("no_undo_step", engine->getHistoryPosition() == historyBefore && engine->isModified() == modifiedBefore);
- if (instance == nullptr)
- {
- finish ("no instance after the reload");
- return;
- }
- if (shots != juce::File())
- openWindow();
- if (round == 0) // once more: a plugin that crashes again waits for the user again
- {
- round = 1;
- next (1);
- return;
- }
- next (6);
- return;
- }
- if (phase == 6 && elapsed() >= 400) // an edit and its undo keep the reloaded plugin
- {
- shot ("window-reloaded-twice");
- auto* before = find();
- engine->editSong ([] (lynx::Song& song) { song.bpm += 1.0f; });
- engine->undo();
- expect ("undo_keeps_the_reloaded_plugin", find() == before && ! engine->hostedPluginDown (where()));
- lynx::PluginWindows::closeAll();
- finish ({});
- }
- }
- std::string nameInSong() const
- {
- const auto& song = engine->getSong();
- return instrument ? song.channels[(size_t) channelIndex].plugin.name : song.mixer[1].effects[0].plugin.name;
- }
- void finish (const juce::String& failure)
- {
- stopTimer();
- if (failure.isNotEmpty())
- step ("failed=" + failure);
- ok = ok && failure.isEmpty();
- step (ok ? "result=OK" : "result=FAILED");
- lynx::PluginWindows::closeAll();
- done (ok);
- }
- };
- lynx::setPluginSandboxAlerts (true); // (the deaths are recorded as in the app; no box: there is no main component)
- auto* test = new Test();
- test->reportPath = reportPath;
- test->waitKill = waitKill;
- if (shotsPath.isNotEmpty())
- {
- test->shots = juce::File (shotsPath);
- test->shots.createDirectory();
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- }
- juce::File (reportPath + ".pid").deleteFile();
- test->done = [this, test] (bool ok) {
- setApplicationReturnValue (ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] {
- lynx::setMainWindowForOwnership (nullptr);
- test->mainWindow = nullptr;
- test->engine = nullptr;
- delete test;
- quit();
- });
- };
- test->engine = std::make_unique<lynx::AudioEngine> (false);
- if (shotsPath.isNotEmpty())
- {
- test->mainWindow = std::make_unique<juce::DocumentWindow> ("LYNX test main window", juce::Colours::darkgrey, 0);
- test->mainWindow->setBounds (20, 20, 300, 200);
- test->mainWindow->setVisible (true);
- lynx::setMainWindowForOwnership (test->mainWindow.get());
- }
- auto& host = test->engine->getPluginHost();
- test->step ("plugins_in_file=" + juce::String (host.addPluginFile (juce::File (pluginPath))));
- std::optional<juce::PluginDescription> chosen;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName() || type.fileOrIdentifier == pluginPath
- || (pluginPath.endsWithIgnoreCase (".lv2") && type.pluginFormatName == "LV2")) // (round 190rf: an LV2 bundle's plugin, known by URI)
- {
- chosen = type;
- break;
- }
- if (! chosen)
- {
- test->step ("result=FAILED (no plugin)");
- test->done (false);
- return;
- }
- test->instrument = chosen->isInstrument;
- lynx::PluginRef ref;
- ref.separateProcess = true;
- ref.id = chosen->createIdentifierString().toStdString();
- ref.name = chosen->name.toStdString();
- test->engine->editSong ([&] (lynx::Song& song) {
- if (test->instrument)
- {
- lynx::ChannelDef c;
- c.name = ref.name;
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin = ref;
- test->channelIndex = (int) song.channels.size();
- song.channels.push_back (c);
- }
- else
- {
- while (song.mixer.size() < 2)
- song.mixer.emplace_back();
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::plugin;
- slot.plugin = ref;
- song.mixer[1].effects.push_back (slot);
- }
- });
- test->step ("plugin=" + chosen->name + " instrument=" + juce::String ((int) test->instrument));
- test->next (0);
- test->startTimerHz (20);
- }
- void runPlugWinTest (const juce::String& pluginPath, const juce::String& reportPath, const juce::String& only, int seconds)
- {
- struct Test final : juce::Timer
- {
- juce::String reportPath, report;
- std::unique_ptr<lynx::AudioEngine> engine;
- bool instrument = false;
- int phase = 0, ticks = 0, seconds = 15, dockStep = 0;
- juce::uint32 phaseStartMs = 0; // (phase 1 counts real time: the timer's ticks ran faster than 20 Hz here)
- juce::AudioPluginInstance* instance = nullptr;
- juce::AudioProcessorParameter* checked = nullptr;
- std::unique_ptr<juce::DocumentWindow> mainWindow; // stands for LYNX's main window (window ownership)
- lynx::Workspace* workspace = nullptr; // LYNX_PLUGWIN_DOCK=1: the real main window's desktop (issue #116)
- int channelIndex = -1; // an instrument: its channel (added after the song's own channels)
- int stepMs = 3000; // dock mode: each state held that long (screenshots)
- bool keysDone = false;
- bool dockOk = true;
- std::function<void (bool)> done;
- // LYNX_PLUGWIN_DROP=<sample> (issue #174): a Sample browser window beside the plugin window with that file
- // selected. The report gives the row's and the editor's places on screen with what LYNX sees there (for a
- // real drag by xdotool / SendInput in that time), and, before the plugin is removed, whether the plugin took
- // the file (its saved state names it).
- juce::File dropFile;
- std::unique_ptr<juce::DocumentWindow> dropWindow;
- lynx::BrowserComponent* dropBrowser = nullptr;
- int dropStage = 0;
- juce::uint32 dropReadyMs = 0; // (the Browser may take long to list a big library: the time counts from here)
- void dropTick (int elapsedMs)
- {
- if (dropStage == 0 && elapsedMs >= 1000)
- {
- lynx::externaldrag::install();
- auto content = lynx::BrowserComponent::makeSampleBrowserContent (*engine, [this] (lynx::BrowserComponent& b) { dropBrowser = &b; });
- dropWindow = std::make_unique<juce::DocumentWindow> ("LYNX test sample browser", juce::Colours::darkgrey, 0);
- dropWindow->setContentOwned (content.release(), false);
- dropWindow->setBounds (20, 240, 340, 520);
- dropWindow->setVisible (true);
- if (dropBrowser != nullptr)
- {
- dropBrowser->showFilterForSnapshot (dropFile.getParentDirectory(), lynx::browserview::ContentFilter::all);
- step ("drop_locate=" + juce::String ((int) dropBrowser->locateFile (dropFile)));
- }
- dropStage = 1;
- }
- else if (dropStage == 1 && elapsedMs >= 2500)
- {
- using namespace lynx::externaldrag;
- const auto row = dropBrowser != nullptr ? dropBrowser->selectedRowScreenBounds() : juce::Rectangle<int>();
- const auto from = row.getCentre();
- // (physical pixels too: SendInput / xdotool work in those)
- auto physical = [] (juce::Point<int> p) {
- const auto q = juce::Desktop::getInstance().getDisplays().logicalToPhysical (p);
- return " phys=" + juce::String (q.x) + "," + juce::String (q.y);
- };
- step ("drop_source=" + juce::String (from.x) + "," + juce::String (from.y) + " place=" + placeName (placeAt (from)) + physical (from));
- if (const auto pid = lynx::sandboxedPluginProcessId (*instance); pid != 0)
- step ("drop_target_pid=" + juce::String (pid)); // (its window is the other process's)
- else if (auto* editor = instance->getActiveEditor())
- {
- const auto to = editor->getScreenBounds().getCentre();
- step ("drop_target=" + juce::String (to.x) + "," + juce::String (to.y) + " place=" + placeName (placeAt (to)) + physical (to));
- }
- const auto files = filesOf (juce::String (lynx::BrowserComponent::dragDescription) + "|" + dropFile.getFullPathName(), nullptr);
- step ("drop_files=" + files.joinIntoString (";"));
- dropStage = 2;
- dropReadyMs = juce::Time::getMillisecondCounter();
- }
- }
- void dropResult()
- {
- juce::MemoryBlock state;
- instance->getStateInformation (state);
- const auto name = dropFile.getFileNameWithoutExtension().toStdString();
- auto holds = [&name] (const juce::MemoryBlock& block) {
- const auto* bytes = static_cast<const char*> (block.getData());
- return ! name.empty() && std::search (bytes, bytes + block.getSize(), name.begin(), name.end()) != bytes + block.getSize();
- };
- auto received = holds (state);
- // (JUCE's VST3 host keeps the plugin's own state base64-encoded inside an XML of its own)
- auto xml = juce::AudioProcessor::getXmlFromBinary (state.getData(), (int) state.getSize());
- if (xml == nullptr)
- xml = juce::parseXML (state.toString());
- if (! received && xml != nullptr)
- for (auto* e : xml->getChildIterator())
- {
- juce::MemoryBlock inner;
- if (inner.fromBase64Encoding (e->getAllSubText().trim()) && holds (inner))
- received = true;
- }
- step ("drop_received=" + juce::String ((int) received));
- }
- // issue #116 (with LYNX_DOCKED_PLUGINS=1 and LYNX_PLUGWIN_DOCK=1), FL's f116 sequence for every floating
- // panel: the docked plugin window goes behind a clicked panel and comes back in front when clicked; a
- // panel called by its key comes in front too; Detached reopens it as a window of its own, which stays above
- // every panel clicked (it is owned by the main window).
- const std::array<lynx::workspace::Panel, 4> dockPanels { lynx::workspace::Panel::channelRack, lynx::workspace::Panel::playlist,
- lynx::workspace::Panel::pianoRoll, lynx::workspace::Panel::mixer };
- const int dockSteps = 2 * 4 + 18; // (the last one reports dock_result)
- int danceChannel = -1; // issue #116 slice 4: a dance channel's dancer over the docked plugin
- lynx::MainComponent* ui = nullptr; // dock mode: the real main window's contents
- struct ScaleSpy final : juce::ComponentPeer::ScaleFactorListener
- {
- int calls = 0;
- double last = 0.0;
- void nativeScaleFactorChanged (double s) override { ++calls; last = s; }
- } scaleSpy;
- juce::ComponentPeer* spiedPeer = nullptr;
- void* panelHandle (lynx::workspace::Panel p) const { return workspace->getFrame (p).getWindowHandle(); }
- void dockCheck (int at)
- {
- using lynx::workspace::Panel;
- auto* main = mainWindow->getWindowHandle();
- auto* plug = lynx::PluginWindows::hostWindowHandle (*instance);
- auto expect = [this] (const juce::String& name, bool value) {
- step (name + "=" + juce::String ((int) value));
- dockOk = dockOk && value;
- };
- auto id = [] (Panel p) { return juce::String (lynx::workspace::panelId (p)); };
- if (at == 0)
- {
- expect ("docked", lynx::PluginWindows::isDocked (*instance));
- expect ("plugin_native_child", plug != nullptr && lynx::nativechild::parentOf (plug) == main);
- for (auto p : dockPanels)
- {
- auto* h = panelHandle (p);
- expect (id (p) + "_visible", workspace->isPanelVisible (p));
- expect (id (p) + "_native_child", h != nullptr && h != main && lynx::nativechild::parentOf (h) == main);
- expect ("plugin_above_" + id (p) + "_when_opened", lynx::nativechild::isAbove (plug, h));
- }
- expect ("browser_plain", ! workspace->isNativePanel (Panel::browser));
- }
- if (at < 2 * 4)
- {
- const auto p = dockPanels[at / 2];
- if (at % 2 == 0)
- {
- workspace->activate (p); // a click on the panel
- expect (id (p) + "_above_plugin_after_its_click", lynx::nativechild::isAbove (panelHandle (p), plug));
- // the plugin stays above the panels nobody clicked
- for (auto other : dockPanels)
- if (other != p)
- expect ("plugin_above_" + id (other) + "_after_" + id (p) + "_click", lynx::nativechild::isAbove (plug, panelHandle (other)));
- }
- else
- {
- lynx::PluginWindows::open ({}, *instance, {}); // (open again = a click on the plugin)
- expect ("plugin_above_" + id (p) + "_after_plugin_click", lynx::nativechild::isAbove (plug, panelHandle (p)));
- }
- return;
- }
- if (at == 8)
- {
- // a layout change elsewhere (a panel resized, the Browser shown) keeps the plugin in front; a panel
- // called by its key comes in front of it
- workspace->hide (Panel::browser);
- workspace->show (Panel::browser);
- for (auto p : dockPanels)
- expect ("plugin_above_" + id (p) + "_after_layout_change", lynx::nativechild::isAbove (plug, panelHandle (p)));
- workspace->show (Panel::mixer);
- expect ("mixer_above_plugin_after_show", lynx::nativechild::isAbove (panelHandle (Panel::mixer), plug));
- }
- else if (at == 9)
- {
- // the setup wizard (Options › Setup wizard; first start) in front of the native panels and the plugin
- ui->showSetupWizard();
- }
- else if (at == 10)
- {
- auto* overlay = ui->setupOverlayForTest();
- auto* h = overlay != nullptr ? overlay->getWindowHandle() : nullptr;
- expect ("setup_overlay_native_child", h != nullptr && h != main && lynx::nativechild::parentOf (h) == main);
- expect ("setup_overlay_above_plugin", lynx::nativechild::isAbove (h, plug));
- for (auto p : dockPanels)
- expect ("setup_overlay_above_" + id (p), lynx::nativechild::isAbove (h, panelHandle (p)));
- workspace->activate (Panel::playlist); // (a panel brought in front by code: the overlay stays in front)
- lynx::PluginWindows::open ({}, *instance, {});
- expect ("setup_overlay_stays_in_front", lynx::nativechild::isAbove (h, plug) && lynx::nativechild::isAbove (h, panelHandle (Panel::playlist)));
- }
- else if (at == 11)
- {
- ui->closeSetupWizardForSnapshot();
- expect ("setup_overlay_closed", ui->setupOverlayForTest() == nullptr);
- // drops: JUCE's list of windows in the native stacking order once a drag starts
- workspace->activate (Panel::mixer);
- workspace->hide (Panel::browser);
- workspace->show (Panel::browser);
- lynx::matchWindowOrderToScreen();
- auto children = lynx::nativechild::attachedChildren (main);
- auto& desktop = juce::Desktop::getInstance();
- int last = -1;
- bool ordered = children.size() >= 5;
- for (auto* c : children)
- if (c->isVisible())
- {
- int at2 = -1;
- for (int k = 0; k < desktop.getNumComponents(); ++k)
- if (desktop.getComponent (k) == c)
- at2 = k;
- ordered = ordered && at2 > last;
- last = at2;
- }
- expect ("drop_order_matches_screen", ordered);
- }
- else if (at == 12)
- {
- // the main window's scale changes (a display with another scale): every native child placed again in
- // physical pixels, the docked editor's window told (JUCE tells child windows nothing by itself)
- for (int i = 0; i < juce::ComponentPeer::getNumPeers(); ++i)
- if (auto* peer = juce::ComponentPeer::getPeer (i); peer != nullptr && peer->getNativeHandle() == plug)
- spiedPeer = peer;
- if (spiedPeer != nullptr)
- spiedPeer->addScaleFactorListener (&scaleSpy);
- lynx::nativechild::notifyScaleListenersForTest (*mainWindow);
- juce::Desktop::getInstance().setGlobalScaleFactor (1.25f); // and LYNX's own UI zoom
- }
- else if (at == 13)
- {
- bool placed = true;
- for (auto* c : lynx::nativechild::attachedChildren (main))
- placed = placed && (! c->isVisible() || lynx::nativechild::placedPhysically (*c));
- expect ("native_children_placed_at_125", placed);
- expect ("docked_editor_told_the_scale", scaleSpy.calls > 0 && spiedPeer != nullptr
- && std::abs (scaleSpy.last - spiedPeer->getPlatformScaleFactor()) < 0.001);
- if (spiedPeer != nullptr && juce::ComponentPeer::isValidPeer (spiedPeer))
- spiedPeer->removeScaleFactorListener (&scaleSpy);
- juce::Desktop::getInstance().setGlobalScaleFactor (1.0f);
- lynx::PluginWindows::setDetached (*instance, true);
- }
- else if (at == 14)
- {
- expect ("detached_reopened", lynx::PluginWindows::isOpen (*instance) && ! lynx::PluginWindows::isDocked (*instance));
- expect ("detached_owned_by_main", plug != nullptr && lynx::nativechild::ownerOf (plug) == main);
- expect ("detached_saved", find() == instance && engineRef() != nullptr && engineRef()->detached);
- for (auto p : dockPanels)
- workspace->activate (p);
- }
- else if (at == 15)
- {
- // (an owned top-level window: above the main window and so above all its child windows)
- expect ("detached_stays_above_clicked_panels", plug != nullptr && lynx::nativechild::ownerOf (plug) == main
- && lynx::nativechild::parentOf (plug) != main && lynx::PluginWindows::isOpen (*instance));
- lynx::PluginWindows::setDetached (*instance, false);
- }
- else if (at == 16)
- {
- // issue #116 slice 4: a Fruity Dance dancer standing on the docked plugin window, in front of it
- auto* stage = dynamic_cast<lynx::DanceStage*> (ui->danceStageForTest());
- juce::Rectangle<int> over;
- for (auto* c : lynx::nativechild::attachedChildren (main))
- if (c->getWindowHandle() == plug)
- over = ui->getLocalArea (nullptr, c->getScreenBounds());
- expect ("dance_stage", stage != nullptr && ! over.isEmpty());
- lynx::dance::Settings s;
- s.move = lynx::dance::held; // (a still pose: the pixels tested below stay where they are)
- s.x = over.getCentreX();
- s.y = over.getCentreY() + 70;
- const auto state = lynx::dance::toState (s);
- engine->editSongStructural ([this, state] (lynx::Song& song) {
- lynx::ChannelDef c;
- c.name = "Fruity Dance";
- c.instrument = lynx::InstrumentKind::fruitydance;
- c.pluginState = state;
- danceChannel = (int) song.channels.size();
- song.channels.push_back (c);
- });
- engine->dispatchPendingMessages();
- if (stage != nullptr)
- stage->update();
- }
- else if (at == 17)
- {
- auto* stage = dynamic_cast<lynx::DanceStage*> (ui->danceStageForTest());
- auto* w = stage != nullptr ? stage->windowOf (danceChannel) : nullptr;
- auto* h = w != nullptr ? w->getWindowHandle() : nullptr;
- expect ("dancer_window_native_child", h != nullptr && h != main && lynx::nativechild::parentOf (h) == main);
- expect ("dancer_window_layered", lynx::nativechild::isLayered (h));
- expect ("dancer_above_plugin", lynx::nativechild::isAbove (h, plug));
- for (auto p : dockPanels)
- expect ("dancer_above_" + id (p), lynx::nativechild::isAbove (h, panelHandle (p)));
- // panels and the plugin brought in front (clicks, keys): the dancer stays in front of them
- workspace->activate (Panel::mixer);
- workspace->show (Panel::pianoRoll);
- lynx::PluginWindows::open ({}, *instance, {});
- expect ("dancer_stays_in_front", lynx::nativechild::isAbove (h, plug) && lynx::nativechild::isAbove (h, panelHandle (Panel::mixer))
- && lynx::nativechild::isAbove (h, panelHandle (Panel::pianoRoll)));
- // the mouse: the dancer's body takes it, its window's transparent pixels let it through
- if (w != nullptr)
- {
- const auto picture = w->createComponentSnapshot (w->getLocalBounds(), true, 1.0f);
- const auto body = stage->bodyOf (danceChannel) - (w->getScreenPosition() - stage->getScreenPosition());
- juce::Point<int> solid { -1, -1 }, clear { -1, -1 };
- for (int y = body.getCentreY() - 10; y < body.getBottom() && solid.x < 0; ++y)
- for (int x = body.getX(); x < body.getRight() && solid.x < 0; ++x)
- if (picture.getBounds().contains (x, y) && picture.getPixelAt (x, y).getAlpha() == 255)
- solid = { x, y };
- for (int y = 0; y < picture.getHeight() && clear.x < 0; y += 2)
- for (int x = 0; x < picture.getWidth() && clear.x < 0; x += 2)
- if (picture.getPixelAt (x, y).getAlpha() == 0 && ! body.expanded (8).contains (x, y))
- clear = { x, y };
- step ("dancer_window=" + w->getBounds().toString() + " solid=" + solid.toString() + " clear=" + clear.toString());
- auto* atSolid = lynx::nativechild::windowAt (*w, solid);
- auto* atClear = lynx::nativechild::windowAt (*w, clear);
- expect ("dancer_takes_its_body_clicks", solid.x >= 0 && atSolid == h);
- expect ("dancer_lets_clicks_through", clear.x >= 0 && atClear != nullptr && atClear != h);
- expect ("stage_leaves_the_mouse", ! stage->hitTest (stage->bodyOf (danceChannel).getCentreX(), stage->bodyOf (danceChannel).getCentreY()));
- }
- }
- else if (at == 18)
- {
- // no dance channel: no dancer window (nothing drawn, no cost)
- auto* stage = dynamic_cast<lynx::DanceStage*> (ui->danceStageForTest());
- engine->editSongStructural ([this] (lynx::Song& song) {
- if (danceChannel >= 0 && danceChannel < (int) song.channels.size())
- song.channels.erase (song.channels.begin() + danceChannel);
- });
- engine->dispatchPendingMessages();
- if (stage != nullptr)
- stage->update();
- expect ("dancer_window_gone", stage != nullptr && stage->windowCount() == 0);
- }
- else if (at == 19 || at == 20)
- {
- // round 190ev (issue #152, "flickering windows"): on Windows a docked panel no longer fades by its
- // window's alpha (each fade switched its drawing surface twice and the panel flashed); it shows and
- // hides at once, as FL's docked windows. Elsewhere round 190i's fade stays.
- auto& frame = workspace->getFrame (Panel::mixer);
- if (at == 19)
- {
- workspace->show (Panel::mixer);
- expect ("mixer_above_plugin_when_shown", lynx::nativechild::isAbove (panelHandle (Panel::mixer), plug));
- workspace->hide (Panel::mixer);
- expect ("mixer_hides_at_once", ! frame.isVisible() && workspace->nativeFadeDirection (Panel::mixer) == 0
- && frame.getAlpha() == 1.0f && ! lynx::nativechild::isLayered (frame.getWindowHandle()));
- }
- else
- {
- workspace->show (Panel::mixer);
- expect ("mixer_shows_at_once", frame.isVisible() && frame.getAlpha() == 1.0f && workspace->nativeFadeDirection (Panel::mixer) == 0
- && ! lynx::nativechild::isLayered (frame.getWindowHandle())
- && lynx::nativechild::isAbove (panelHandle (Panel::mixer), plug));
- }
- }
- else if (at >= 21 && at <= 23)
- {
- // round 190ev (issue #152, "the Channel rack almost never comes to the front"): LYNX's own editor
- // windows (here a channel's settings) are docked like FL's plugin windows, so a click on the rack
- // brings the rack in front of them and a click on one brings it back; a click inside a docked
- // plugin's own view (a native window JUCE never hears of) brings that plugin window in front.
- auto docked = [] {
- auto& desktop = juce::Desktop::getInstance();
- for (int i = 0; i < desktop.getNumComponents(); ++i)
- if (auto* c = desktop.getComponent (i); c != nullptr && c->isVisible() && (bool) c->getProperties()["lynxDockedWindow"])
- return c;
- return (juce::Component*) nullptr;
- };
- auto* rack = panelHandle (Panel::channelRack);
- if (at == 21)
- {
- lynx::openChannelSettings (*engine, 0);
- auto* ed = docked();
- auto* h = ed != nullptr ? ed->getWindowHandle() : nullptr;
- expect ("editor_docked", h != nullptr && lynx::nativechild::parentOf (h) == main && lynx::nativechild::ownerOf (h) == nullptr);
- expect ("editor_above_rack_when_opened", h != nullptr && lynx::nativechild::isAbove (h, rack));
- workspace->activate (Panel::channelRack); // a click on the rack
- expect ("rack_above_editor_after_its_click", h != nullptr && lynx::nativechild::isAbove (rack, h));
- // a real click (a message to the editor's own window) on its title bar, at a point where the editor
- // can be seen. Round 190fc (0.1.27 RC M1): JUCE takes a button-down only where the system says its
- // window is the one under the point (HWNDComponentPeer::contains asks WindowFromPoint), so the old
- // fixed point (60, 8) was dropped whenever the rack, raised just above, covered it there: the
- // check read 0 while real clicks (on what can be seen) raise the editor.
- if (h != nullptr && ed != nullptr)
- {
- juce::Point<int> at (-1, -1);
- for (int x = 30; x < ed->getWidth() - 40 && at.x < 0; x += 12)
- if (lynx::nativechild::windowAt (*ed, { x, 8 }) == h)
- at = { x, 8 };
- step (juce::String ("editor_title_visible_at=") + juce::String (at.x));
- if (at.x >= 0)
- {
- const auto scale = ed->getPeer() != nullptr ? ed->getPeer()->getPlatformScaleFactor() * (double) ed->getDesktopScaleFactor() : 1.0;
- lynx::nativechild::postClickForTest (h, (at.toDouble() * scale).roundToInt());
- }
- }
- }
- else if (at == 22)
- {
- auto* ed = docked();
- auto* h = ed != nullptr ? ed->getWindowHandle() : nullptr;
- expect ("editor_above_rack_after_its_click", h != nullptr && lynx::nativechild::isAbove (h, rack));
- workspace->activate (Panel::channelRack);
- expect ("rack_above_plugin_after_its_click", lynx::nativechild::isAbove (rack, plug));
- auto* view = lynx::nativechild::innermostChild (plug);
- step (juce::String ("plugin_view_window=") + (view != nullptr ? "1" : "0"));
- if (view != nullptr) // a click in the plugin's own view, near its top-left corner
- lynx::nativechild::postClickForTest (view, { 2, 2 });
- }
- else
- {
- if (lynx::nativechild::innermostChild (plug) != nullptr)
- expect ("plugin_above_rack_after_click_in_its_view", lynx::nativechild::isAbove (plug, rack));
- lynx::closeChannelSettings();
- // FL's Tools > Macros > Switch all plugin editors to > Detached (round 190i)
- lynx::PluginWindows::setAllDetached (*engine, true);
- }
- }
- else if (at == 24)
- {
- expect ("macro_detached_the_open_editor", lynx::PluginWindows::isOpen (*instance) && ! lynx::PluginWindows::isDocked (*instance)
- && plug != nullptr && lynx::nativechild::ownerOf (plug) == main);
- expect ("macro_detached_saved", find() == instance && engineRef() != nullptr && engineRef()->detached);
- lynx::PluginWindows::setAllDetached (*engine, false); // ... > Attached
- }
- else
- {
- expect ("docked_again", lynx::PluginWindows::isDocked (*instance) && engineRef() != nullptr && ! engineRef()->detached);
- step (juce::String ("dock_result=") + (dockOk ? "OK" : "FAILED"));
- }
- }
- const lynx::PluginRef* engineRef() const
- {
- const auto& song = engine->getSong();
- if (instrument)
- return channelIndex < 0 || channelIndex >= (int) song.channels.size() ? nullptr : &song.channels[(size_t) channelIndex].plugin;
- return song.mixer.size() < 2 || song.mixer[1].effects.empty() ? nullptr : &song.mixer[1].effects[0].plugin;
- }
- void step (const juce::String& line)
- {
- report << line << "\n";
- juce::File (reportPath).replaceWithText (report);
- }
- juce::AudioPluginInstance* find()
- {
- if (instrument)
- {
- if (auto* p = dynamic_cast<lynx::PluginInstrument*> (engine->getChannelInstrument (channelIndex).get()))
- return &p->getInstance();
- }
- else if (auto* p = dynamic_cast<lynx::PluginEffect*> (engine->getEffect (1, 0).get()))
- return &p->getInstance();
- return nullptr;
- }
- void timerCallback() override
- {
- ++ticks;
- if (phase == 0) // waiting for the engine to host the plugin
- {
- instance = find();
- if (instance == nullptr)
- {
- if (ticks > 200)
- {
- step ("result=FAILED (not hosted)");
- stopTimer();
- done (false);
- }
- return;
- }
- step ("hosted=" + instance->getName() + " format=" + instance->getPluginDescription().pluginFormatName);
- step ("programs=" + juce::String (instance->getNumPrograms()));
- for (int p = 0; p < juce::jmin (5, instance->getNumPrograms()); ++p)
- step ("program" + juce::String (p) + "=" + instance->getProgramName (p));
- step ("save_formats=" + lynx::pluginpresetui::saveWildcard (*instance));
- // preset round trip: save, change the first parameter, load, compare
- juce::AudioProcessorParameter* param = nullptr;
- for (auto* candidate : instance->getParameters())
- if (candidate->isAutomatable() && ! candidate->isMetaParameter() && candidate != instance->getBypassParameter())
- {
- param = candidate;
- break;
- }
- if (param != nullptr)
- {
- step ("param=" + param->getName (64));
- checked = param;
- const auto file = lynx::pluginpresetui::folderFor (instance->getName()).getChildFile ("plugwintest.lynxpreset");
- juce::String error;
- const auto before = param->getValue();
- const auto saved = lynx::pluginpresetui::save (*instance, file, "plugwintest", error);
- param->setValueNotifyingHost (before > 0.5f ? 0.1f : 0.9f);
- const auto changed = param->getValue();
- const auto loaded = saved && lynx::pluginpresetui::load (*instance, file, error);
- step ("preset_roundtrip saved=" + juce::String ((int) saved) + " loaded=" + juce::String ((int) loaded) + " param0 before="
- + juce::String (before, 4) + " changed=" + juce::String (changed, 4) + " after=" + juce::String (param->getValue(), 4)
- + (error.isNotEmpty() ? " error=" + error : juce::String()));
- for (const auto* ext : { "fxp", "fxb", "vstpreset" })
- {
- juce::String e2;
- const auto f2 = file.withFileExtension (ext);
- const auto ok2 = lynx::pluginpresetui::save (*instance, f2, "plugwintest", e2) && lynx::pluginpresetui::load (*instance, f2, e2);
- step (juce::String ("preset_") + ext + "=" + juce::String ((int) ok2) + (e2.isNotEmpty() ? " (" + e2 + ")" : juce::String()));
- f2.deleteFile();
- }
- step ("browser_lists=" + juce::String (lynx::pluginpresetui::userPresets (instance->getName()).size()));
- }
- std::shared_ptr<void> owner = instrument ? std::shared_ptr<void> (engine->getChannelInstrument (channelIndex))
- : std::shared_ptr<void> (engine->getEffect (1, 0));
- lynx::PluginWindows::open (owner, *instance, instance->getName(),
- { engine.get(), [this] (lynx::Song& song) -> lynx::PluginRef* {
- if (instrument)
- return channelIndex < 0 || channelIndex >= (int) song.channels.size()
- ? nullptr : &song.channels[(size_t) channelIndex].plugin;
- return song.mixer.size() < 2 || song.mixer[1].effects.empty() ? nullptr : &song.mixer[1].effects[0].plugin;
- }, instrument });
- owner.reset();
- step ("window_open=" + juce::String ((int) lynx::PluginWindows::isOpen (*instance)));
- phase = 1;
- ticks = 0;
- phaseStartMs = juce::Time::getMillisecondCounter();
- return;
- }
- if (phase == 1 && ticks >= 30 && ! keysDone && juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGWIN_KEYS", {}).isNotEmpty() && instance->getActiveEditor() != nullptr)
- keysDone = ! lynx::pluginKeysTestTick (*instance->getActiveEditor(),
- [this] (bool on) {
- engine->editSong ([this, on] (lynx::Song& song) {
- (instrument ? song.channels[(size_t) channelIndex].plugin : song.mixer[1].effects[0].plugin).hostKeysFirst = on;
- });
- },
- [this] (const juce::String& line) { step (line); });
- const auto elapsedMs = (int) (juce::Time::getMillisecondCounter() - phaseStartMs);
- if (phase == 1 && ticks == 20 && checked != nullptr)
- step ("param_after_1s=" + juce::String (checked->getValue(), 4));
- // round 190in: LYNX_PLUGWIN_MENU=<png>: FL's ▸ wrapper menu of the open window (two columns for a channel)
- if (const auto menuShot = juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGWIN_MENU", {}); phase == 1 && ticks == 10 && menuShot.isNotEmpty())
- if (const auto menu = lynx::PluginWindows::wrapperMenuForSnapshot (*instance))
- {
- juce::PopupMenu left, right;
- auto* to = &left;
- for (juce::PopupMenu::MenuItemIterator it (*menu); it.next();)
- {
- to->addItem (it.getItem());
- if (it.getItem().shouldBreakAfter)
- to = &right;
- }
- juce::StringArray names { "Plugin" };
- std::vector<juce::PopupMenu> menus { left };
- if (right.getNumItems() > 0)
- {
- names.add ("Channel");
- menus.push_back (right);
- }
- LynxApplication::saveMenus (names, menus, menuShot);
- step ("wrapper_menu_items=" + juce::String (left.getNumItems()) + "+" + juce::String (right.getNumItems()));
- }
- // (3 s apart: time for screenshots of each state)
- if (phase == 1 && workspace != nullptr && dockStep < dockSteps && elapsedMs >= (dockStep + 1) * stepMs)
- dockCheck (dockStep++);
- if (phase == 1 && dropFile.existsAsFile())
- dropTick (elapsedMs);
- // (with LYNX_PLUGWIN_DROP: `seconds` after the drop places were reported, time for the drag)
- const auto dropDone = ! dropFile.existsAsFile()
- || (dropStage == 2 && (int) (juce::Time::getMillisecondCounter() - dropReadyMs) >= seconds * 1000);
- if (phase == 1 && elapsedMs >= seconds * 1000 && dropDone && (workspace == nullptr || dockStep >= dockSteps)) // remove the plugin from the song
- {
- if (dropFile.existsAsFile())
- dropResult();
- engine->editSong ([this] (lynx::Song& song) {
- if (instrument)
- {
- if (channelIndex >= 0 && channelIndex < (int) song.channels.size())
- song.channels.erase (song.channels.begin() + channelIndex);
- }
- else
- song.mixer[1].effects.clear();
- });
- step ("removed");
- phase = 2;
- ticks = 0;
- return;
- }
- if (phase == 2 && ticks >= 40)
- {
- const auto open = lynx::PluginWindows::isOpen (*instance);
- step ("window_open_after_remove=" + juce::String ((int) open));
- step (open || ! dockOk ? "result=FAILED" : "result=OK");
- stopTimer();
- lynx::PluginWindows::closeAll();
- done (! open && dockOk);
- }
- }
- };
- // round 190in: LYNX_PLUGWIN_ZOOM=<percent>: LYNX's interface zoom for the run (the wrapper's header at 150 %)
- if (const auto zoom = juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGWIN_ZOOM", {}).getIntValue(); zoom >= 50 && zoom <= 300)
- juce::Desktop::getInstance().setGlobalScaleFactor ((float) zoom / 100.0f);
- auto* test = new Test();
- test->reportPath = reportPath;
- test->seconds = seconds;
- if (const auto drop = juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGWIN_DROP", {}); drop.isNotEmpty())
- test->dropFile = juce::File (drop);
- test->done = [this, test] (bool ok) {
- setApplicationReturnValue (ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] {
- lynx::setMainWindowForOwnership (nullptr);
- lynx::PluginWindows::setDockWorkspace (nullptr);
- test->dropWindow = nullptr; // (its Browser before the engine)
- test->workspace = nullptr;
- test->mainWindow = nullptr; // (dock mode: the main component with it, before the engine)
- test->engine = nullptr;
- delete test;
- quit();
- });
- };
- test->engine = std::make_unique<lynx::AudioEngine> (false);
- test->mainWindow = std::make_unique<juce::DocumentWindow> ("LYNX test main window", juce::Colours::darkgrey, 0);
- test->mainWindow->setBounds (20, 20, 300, 200);
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGWIN_DOCK", {}) == "1" && lynx::nativechild::dockingEnabled())
- {
- // the real main window's contents (it docks plugin windows in its own desktop), so the panels are real
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- auto* ui = new lynx::MainComponent (*test->engine, false);
- test->mainWindow->setUsingNativeTitleBar (true);
- test->mainWindow->setContentOwned (ui, false);
- test->mainWindow->setBounds (20, 20, 1500, 900);
- test->workspace = &ui->workspaceForTest();
- test->ui = ui;
- if (const auto ms = juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGWIN_STEP_MS", {}).getIntValue(); ms > 0)
- test->stepMs = ms;
- }
- test->mainWindow->setVisible (true);
- lynx::setMainWindowForOwnership (test->mainWindow.get());
- if (test->workspace != nullptr)
- {
- using lynx::workspace::Panel;
- for (auto p : { Panel::playlist, Panel::mixer, Panel::pianoRoll, Panel::channelRack })
- test->workspace->show (p);
- test->step ("dock_test=2 rack_visible=" + juce::String ((int) test->workspace->isPanelVisible (Panel::channelRack)));
- }
- auto& host = test->engine->getPluginHost();
- test->step ("plugins_in_file=" + juce::String (host.addPluginFile (juce::File (pluginPath))));
- std::optional<juce::PluginDescription> chosen;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if ((juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName() || type.fileOrIdentifier == pluginPath
- || (pluginPath.endsWithIgnoreCase (".lv2") && type.pluginFormatName == "LV2")) // (round 190rf: an LV2 bundle's plugin, known by URI)
- && (only.isEmpty() || type.name == only))
- {
- chosen = type;
- break;
- }
- if (! chosen)
- {
- test->step ("result=FAILED (no plugin)");
- test->done (false);
- return;
- }
- test->instrument = chosen->isInstrument;
- lynx::PluginRef ref;
- ref.separateProcess = juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGWIN_SEPARATE", {}) == "1"; // (issue #96's other-process check)
- ref.id = chosen->createIdentifierString().toStdString();
- ref.name = chosen->name.toStdString();
- test->engine->editSong ([&] (lynx::Song& song) {
- if (test->instrument)
- {
- lynx::ChannelDef c;
- c.name = ref.name;
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin = ref;
- test->channelIndex = (int) song.channels.size();
- song.channels.push_back (c);
- }
- else
- {
- while (song.mixer.size() < 2)
- song.mixer.emplace_back();
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::plugin;
- slot.plugin = ref;
- song.mixer[1].effects.push_back (slot);
- }
- });
- test->step ("plugin=" + chosen->name + " instrument=" + juce::String ((int) test->instrument));
- test->startTimerHz (20);
- }
- void runEditorCrashTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- struct CrashTest final : juce::Timer
- {
- juce::String reportPath, report;
- std::unique_ptr<lynx::PluginHost> host;
- juce::AudioPluginInstance* plugin = nullptr;
- std::shared_ptr<juce::AudioPluginInstance> keep; // a window whose plugin nobody else holds is closed as orphaned
- std::function<void (bool)> done;
- int ticks = 0, crashesBefore = 0;
- void step (const juce::String& line)
- {
- report << line << "\n";
- juce::File (reportPath).replaceWithText (report); // at each step: a crash leaves the last one
- }
- void timerCallback() override
- {
- ++ticks;
- const auto crashes = lynx::PluginWindows::editorCrashCount() - crashesBefore;
- const auto open = lynx::PluginWindows::isOpen (*plugin);
- if ((crashes > 0 && ! open) || ticks >= 50) // 100 ms ticks: up to 5 s
- {
- stopTimer();
- step ("editor_crashes=" + juce::String (crashes) + " window_open=" + juce::String ((int) open) + " ticks=" + juce::String (ticks));
- bool traced = false;
- if (crashes > 0)
- {
- const auto last = lynx::PluginWindows::editorCrashes().back();
- traced = last.traceFile.existsAsFile() && last.traceFile.loadFileAsString().contains ("LYNX Test Crash");
- step ("plugin=" + last.plugin + " detail=" + last.detail + " trace=" + last.traceFile.getFileName() + " traced="
- + juce::String ((int) traced));
- last.traceFile.deleteFile();
- }
- // still alive: one more message through the loop after the fault
- juce::MessageManager::callAsync ([this, ok = crashes == 1 && ! open && traced] {
- step ("message_loop_after_fault=1");
- step (juce::String ("result=") + (ok ? "OK" : "FAILED"));
- done (ok);
- });
- }
- }
- };
- auto* test = new CrashTest();
- test->reportPath = reportPath;
- test->done = [this, test] (bool ok)
- {
- setApplicationReturnValue (ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] { lynx::PluginWindows::closeAll(); delete test; quit(); });
- };
- #if ! JUCE_WINDOWS
- test->step ("result=SKIPPED (Windows only: on macOS / Linux a plugin fault is a signal, see docs/analise/REA_rodada174a.md)");
- test->done (true);
- return;
- #else
- _putenv_s ("LYNX_TEST_CRASH", "editor");
- test->host = std::make_unique<lynx::PluginHost> (false);
- test->step ("plugins_in_file=" + juce::String (test->host->addPluginFile (juce::File (pluginPath))));
- std::shared_ptr<juce::AudioPluginInstance> instance;
- for (const auto& type : test->host->getKnownPlugins().getTypes())
- {
- if (juce::File (type.fileOrIdentifier).getFileName() != juce::File (pluginPath).getFileName())
- continue;
- juce::String error;
- instance = std::shared_ptr<juce::AudioPluginInstance> (lynx::createRightInstance (test->host->getFormats(), type, 48000.0, 512, error).release());
- test->step ("plugin=" + type.name + (instance == nullptr ? " error=" + error : juce::String()));
- break;
- }
- if (instance == nullptr || ! instance->hasEditor())
- {
- test->step ("result=FAILED (no plugin with an editor)");
- test->done (false);
- return;
- }
- lynx::preparePlugin (*instance, 48000.0, 512);
- test->plugin = instance.get();
- test->keep = instance;
- test->crashesBefore = lynx::PluginWindows::editorCrashCount();
- lynx::PluginWindows::open (instance, *instance, instance->getName()); // (the window keeps the plugin alive)
- test->step ("window_open=" + juce::String ((int) lynx::PluginWindows::isOpen (*instance)));
- test->startTimer (100);
- #endif
- }
- void runEditorTest (const juce::String& pluginPath, const juce::String& reportPath, const juce::String& only)
- {
- struct EditorTest final : juce::Timer
- {
- juce::String reportPath, report;
- std::unique_ptr<lynx::PluginHost> host;
- std::unique_ptr<juce::AudioPluginInstance> plugin;
- std::unique_ptr<juce::DocumentWindow> window;
- std::function<void (bool)> done;
- void step (const juce::String& line)
- {
- report << line << "\n";
- juce::File (reportPath).replaceWithText (report); // written at each step: a crash leaves the last one
- }
- void timerCallback() override
- {
- stopTimer();
- window = nullptr;
- step ("step=closed");
- plugin = nullptr;
- step ("result=OK");
- done (true);
- }
- };
- auto* test = new EditorTest();
- test->reportPath = reportPath;
- test->done = [this, test] (bool ok)
- {
- setApplicationReturnValue (ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] { delete test; quit(); });
- };
- test->host = std::make_unique<lynx::PluginHost> (false);
- test->step ("plugins_in_file=" + juce::String (test->host->addPluginFile (juce::File (pluginPath))));
- test->step ("exe=" + juce::File::getSpecialLocation (juce::File::currentExecutableFile).getFullPathName());
- for (const auto& type : test->host->getKnownPlugins().getTypes())
- {
- if (juce::File (type.fileOrIdentifier).getFileName() != juce::File (pluginPath).getFileName()
- || (only.isNotEmpty() && type.name != only))
- continue;
- juce::String error;
- test->plugin = lynx::createRightInstance (test->host->getFormats(), type, 48000.0, 512, error);
- test->step ("plugin=" + type.name + (test->plugin == nullptr ? " error=" + error : juce::String()));
- break;
- }
- if (test->plugin == nullptr)
- {
- test->step ("result=FAILED");
- test->done (false);
- return;
- }
- lynx::preparePlugin (*test->plugin, 48000.0, 512);
- test->step ("step=create_editor");
- test->window = std::make_unique<juce::DocumentWindow> (test->plugin->getName(), juce::Colours::black, juce::DocumentWindow::closeButton);
- test->window->setUsingNativeTitleBar (true);
- if (auto* editor = test->plugin->createEditorIfNeeded())
- test->window->setContentOwned (editor, true);
- else
- test->step ("no_editor");
- test->step ("step=show");
- test->window->centreWithSize (test->window->getWidth(), test->window->getHeight());
- test->window->setVisible (true);
- test->step ("step=shown");
- test->startTimer (4000);
- }
- void runFitTest (const juce::String& reportPath, int percent)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- struct FitTest final : juce::Timer
- {
- juce::String path, report;
- bool ok = true;
- int step = 0, percent = 150;
- std::unique_ptr<juce::DocumentWindow> tall, big;
- std::function<void()> done;
- // `whole`: the window must fit entirely (a resizable one); else its title bar and close button must be on the screen
- void check (const juce::String& what, juce::Component& w, bool whole)
- {
- juce::BorderSize<int> frame;
- if (auto* peer = w.getPeer())
- if (const auto f = peer->getFrameSizeIfPresent())
- frame = *f;
- auto outer = frame.addedTo (w.getBounds());
- const auto* display = juce::Desktop::getInstance().getDisplays().getDisplayForRect (outer);
- const auto area = display != nullptr ? display->userArea : outer;
- #if JUCE_LINUX
- // round 164: a compositor that draws the frame itself (WSLg's Weston) reports its invisible shadow in
- // the frame (59 px on top, 38 around at 100%): only what is visible is checked, give or take 4 px
- const auto shadow = frame.getLeft() >= 16 ? frame.getLeft() : 0;
- outer = outer.reduced (shadow);
- const auto slack = shadow > 0 ? 4 : 0;
- #else
- const auto slack = 0;
- #endif
- const auto passed = outer.getY() >= area.getY() - slack && outer.getRight() <= area.getRight() + slack && outer.getX() >= area.getX() - slack
- && (! whole || outer.getBottom() <= area.getBottom() + 1 + slack);
- report << (passed ? "ok " : "FAIL ") << what << " window=" << outer.toString() << " (frame " << frame.getTop() << ","
- << frame.getLeft() << ") screen=" << area.toString() << "\n";
- ok = ok && passed;
- }
- void start()
- {
- report << "scale=" << percent << "%\n";
- juce::Desktop::getInstance().setGlobalScaleFactor ((float) percent / 100.0f);
- // a tool window taller than the screen, centred (its title bar would be above the screen)
- tall = std::make_unique<juce::DocumentWindow> ("LYNX fit test - tall", lynx::theme::colour::bg2, juce::DocumentWindow::closeButton);
- tall->setUsingNativeTitleBar (true);
- auto* content = new juce::Component();
- const auto area = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea;
- content->setSize (500, area.getHeight() + 200);
- tall->setContentOwned (content, true);
- tall->setCentrePosition (area.getCentre());
- tall->setVisible (true);
- lynx::keepAboveMainWindow (*tall);
- // LYNX_FITTEST_MS: how long each window stays (default 700 ms; longer to take screenshots of them)
- startTimer (juce::jlimit (300, 60000, juce::SystemStats::getEnvironmentVariable ("LYNX_FITTEST_MS", "700").getIntValue()));
- }
- void timerCallback() override
- {
- ++step;
- if (step == 1)
- {
- check ("tall tool window: title bar and close button on the screen", *tall, false);
- tall.reset();
- // round 164: a fixed-size LYNX tool window whose content is taller than the screen: it scrolls
- auto content = std::make_unique<juce::Component>();
- const auto screen = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea;
- content->setSize (520, screen.getHeight() + 300);
- lynx::openToolWindow (std::move (content), "LYNX fit test - fixed size", "fittest-fixed");
- return;
- }
- if (step == 2)
- {
- if (auto* w = lynx::findToolWindow ("fittest-fixed"))
- {
- check ("fixed-size tool window taller than the screen: fits (its content scrolls)", *w, true);
- const auto scrolls = w->getContentComponent() != nullptr && w->getContentComponent()->getNumChildComponents() > 0
- && dynamic_cast<juce::Viewport*> (w->getContentComponent()->getChildComponent (0)) != nullptr;
- report << (scrolls ? "ok " : "FAIL ") << "its content is in a scrolling viewport\n";
- ok = ok && scrolls;
- }
- else
- {
- report << "FAIL fixed-size tool window not found\n";
- ok = false;
- }
- lynx::closeAllToolWindows();
- // a resizable window that fits at 100%, then the zoom goes up (the main window's case)
- juce::Desktop::getInstance().setGlobalScaleFactor (1.0f);
- big = std::make_unique<juce::DocumentWindow> ("LYNX fit test - zoom", lynx::theme::colour::bg2, juce::DocumentWindow::allButtons);
- big->setUsingNativeTitleBar (true);
- big->setResizable (true, false);
- big->setResizeLimits (400, 300, 10000, 10000);
- const auto area = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea;
- big->setBounds (area.getX() + 40, area.getY() + 60, area.getWidth() * 9 / 10 - 40, area.getHeight() * 9 / 10 - 60);
- big->setVisible (true);
- return;
- }
- if (step == 3)
- {
- juce::Desktop::getInstance().setGlobalScaleFactor ((float) percent / 100.0f);
- juce::Timer::callAfterDelay (200, [] { lynx::fitAllWindowsOnScreen(); });
- return;
- }
- if (step == 4)
- {
- check ("resizable window after the zoom change: fits the screen", *big, true);
- big.reset();
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (path).replaceWithText (report);
- stopTimer();
- if (done)
- done();
- }
- }
- };
- static std::unique_ptr<FitTest> test;
- test = std::make_unique<FitTest>();
- test->path = reportPath;
- test->percent = juce::jlimit (50, 300, percent);
- test->done = [this] { juce::MessageManager::callAsync ([this] { test.reset(); quit(); }); };
- test->start();
- }
- void runFocusTest (const juce::String& reportPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- struct FocusTest final : juce::Timer
- {
- juce::String reportPath, report;
- bool ok = true;
- int stepIndex = 0;
- std::unique_ptr<lynx::AudioEngine> engine;
- lynx::MainComponent* ui = nullptr;
- std::unique_ptr<juce::DocumentWindow> main;
- std::function<void()> done;
- void line (const juce::String& text)
- {
- report << text << "\n";
- juce::File (reportPath).replaceWithText (report);
- }
- void check (const juce::String& what, bool passed)
- {
- line ((passed ? "ok " : "FAIL ") + what);
- ok = ok && passed;
- }
- juce::ComponentPeer* mainPeer() const { return main != nullptr ? main->getPeer() : nullptr; }
- bool focusInMain() const
- {
- auto* f = juce::Component::getCurrentlyFocusedComponent();
- return f != nullptr && main->isParentOf (f);
- }
- // a click (press and release) at the middle of the panel's content, through the native window it is in
- static void click (juce::Component& frame, bool right)
- {
- auto* peer = frame.getPeer();
- if (peer == nullptr)
- return;
- const auto at = peer->getComponent().getLocalPoint (&frame, frame.getLocalBounds().getCentre().toFloat());
- const auto button = right ? juce::ModifierKeys::rightButtonModifier : juce::ModifierKeys::leftButtonModifier;
- const auto now = juce::Time::currentTimeMillis();
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, juce::ModifierKeys (button), 1.0f, 0.0f, now);
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, juce::ModifierKeys(), 1.0f, 0.0f, now + 40);
- }
- bool space()
- {
- auto* peer = mainPeer(); // (the system sends the key to the window with the focus: the main one)
- return peer != nullptr && peer->handleKeyPress (juce::KeyPress (juce::KeyPress::spaceKey, juce::ModifierKeys(), ' '));
- }
- juce::TextEditor* firstField (juce::Component& c)
- {
- if (auto* t = dynamic_cast<juce::TextEditor*> (&c); t != nullptr && t->isShowing() && t->getWantsKeyboardFocus())
- return t;
- for (auto* child : c.getChildren())
- if (auto* t = firstField (*child))
- return t;
- return nullptr;
- }
- // the user tabs away and comes back with a click in `panel`
- void backWithClickIn (lynx::workspace::Panel panel, bool right)
- {
- auto& frame = ui->workspaceForTest().getFrame (panel);
- const auto name = juce::String (lynx::workspace::panelId (panel)) + (right ? " (right click)" : "");
- auto* peer = mainPeer();
- line (name + ": native child window=" + juce::String ((int) lynx::nativechild::isAttached (frame)));
- check (name + ": the main window has the keys before", ui->hasKeyboardFocus (true));
- peer->handleFocusLoss(); // (another app is in front: the main window lost the system focus)
- check (name + ": nothing in LYNX has the keys while it is in the background", ! focusInMain());
- // the cause: JUCE answers the system's "activate?" from the panel's own component, which takes no focus on a click
- line (name + ": JUCE's answer alone would activate the window=" + juce::String ((int) frame.getMouseClickGrabsKeyboardFocus()));
- const auto activates = lynx::nativechild::clickActivatesWindow (frame, false);
- check (name + ": a click in it activates the inactive main window", activates);
- #if JUCE_WINDOWS
- if (lynx::nativechild::isAttached (frame))
- check (name + ": its native window answers WM_MOUSEACTIVATE with MA_ACTIVATE",
- lynx::nativechild::mouseActivateAnswerForTest (frame, true) == 1 /* MA_ACTIVATE */);
- #endif
- if (activates)
- peer->handleFocusGain(); // (the system activates the main window and gives it the focus)
- click (frame, right);
- }
- void spacePlays (lynx::workspace::Panel panel, bool right)
- {
- const auto name = juce::String (lynx::workspace::panelId (panel)) + (right ? " (right click)" : "");
- check (name + ": the main window has the keys after the click", ui->hasKeyboardFocus (true));
- auto& transport = engine->getTransport();
- if (transport.playing.load())
- engine->stop();
- const auto used = space();
- check (name + ": Space starts playback", used && transport.playing.load());
- engine->stop();
- }
- void timerCallback() override
- {
- using lynx::workspace::Panel;
- auto& ws = ui->workspaceForTest();
- switch (stepIndex++)
- {
- case 0:
- line ("docking=" + juce::String ((int) lynx::nativechild::dockingEnabled()));
- ws.show (Panel::playlist);
- ws.show (Panel::pianoRoll);
- ui->grabKeyboardFocus();
- break;
- case 1: backWithClickIn (Panel::playlist, false); break;
- case 2: spacePlays (Panel::playlist, false); ui->grabKeyboardFocus(); break;
- case 3: backWithClickIn (Panel::pianoRoll, false); break;
- case 4: spacePlays (Panel::pianoRoll, false); ui->grabKeyboardFocus(); break;
- case 5: backWithClickIn (Panel::playlist, true); break;
- case 6:
- juce::PopupMenu::dismissAllActiveMenus(); // (the right click's menu)
- spacePlays (Panel::playlist, true);
- break;
- case 7:
- {
- // a text field (the Browser's search box) keeps the keys through a switch to another app and back:
- // nothing in LYNX takes them from it (no periodic grab); inside the active window the click's
- // activation answer is unchanged, and a click in the Playlist ends the typing as before (issue #9,
- // as FL ends typing in its search field)
- auto* field = firstField (*ui);
- line ("text field found=" + juce::String ((int) (field != nullptr)));
- if (field != nullptr)
- {
- auto& frame = ws.getFrame (Panel::playlist);
- field->grabKeyboardFocus();
- check ("the text field has the keys", field->hasKeyboardFocus (false));
- mainPeer()->handleFocusLoss();
- mainPeer()->handleFocusGain(); // (back with Alt+Tab, or a click that activates the window)
- check ("the text field gets the keys back with the window", field->hasKeyboardFocus (false));
- check ("active window: a click in a panel does not activate it again", ! lynx::nativechild::clickActivatesWindow (frame, true));
- click (frame, false);
- check ("a click in the Playlist ends the typing: the main window has the keys", ui->hasKeyboardFocus (true) && ! field->hasKeyboardFocus (false));
- }
- line (ok ? "result=OK" : "result=FAILED");
- stopTimer();
- done();
- break;
- }
- default:
- break;
- }
- }
- };
- auto* test = new FocusTest();
- test->reportPath = reportPath;
- startFocusTestWindow (*test);
- test->startTimer (600);
- }
- // --simplekeytest (round 190fc, 0.1.27 RC H2): in the Simple layout Space often did nothing after a click in the
- // window (the dock, a track header, the grid, the Lyrics button) or after a demo opened from Welcome › Start from. The
- // main window in the Simple layout; each step clicks as the system would (through the native window under the point)
- // and presses Space where the system sends it (the native window of the component with the focus): playback must
- // start, except while a text field the user clicked into has the keys (it types). Shows a window (Windows: GUI lock).
- void runSimpleKeyTest (const juce::String& reportPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- struct KeyTest final : juce::Timer
- {
- juce::String reportPath, report;
- bool ok = true;
- int stepIndex = 0, instrumentTrack = 0;
- std::unique_ptr<lynx::AudioEngine> engine;
- lynx::MainComponent* ui = nullptr;
- std::unique_ptr<juce::DocumentWindow> main;
- std::function<void()> done;
- void line (const juce::String& text)
- {
- report << text << "\n";
- juce::File (reportPath).replaceWithText (report);
- }
- void check (const juce::String& what, bool passed)
- {
- line ((passed ? "ok " : "FAIL ") + what);
- ok = ok && passed;
- }
- static juce::String describe (juce::Component* c)
- {
- if (c == nullptr)
- return "nothing";
- juce::String path;
- for (auto* p = c; p != nullptr && path.length() < 160; p = p->getParentComponent())
- {
- auto name = p->getComponentID().isNotEmpty() ? p->getComponentID() : p->getName();
- if (name.isEmpty())
- name = juce::String (typeid (*p).name()).fromLastOccurrenceOf ("::", false, false).substring (0, 28);
- path << (path.isEmpty() ? "" : " < ") << name;
- }
- return path;
- }
- // the first showing component with this ID in the main window or a native child window of it
- juce::Component* find (const juce::String& id)
- {
- std::function<juce::Component* (juce::Component&)> in = [&] (juce::Component& root) -> juce::Component* {
- if (root.getComponentID() == id && root.isShowing())
- return &root;
- for (auto* c : root.getChildren())
- if (auto* f = in (*c))
- return f;
- return nullptr;
- };
- if (auto* f = in (*main))
- return f;
- if (auto* peer = main->getPeer())
- for (auto* attached : lynx::nativechild::attachedChildren (peer->getNativeHandle()))
- if (auto* f = in (*attached))
- return f;
- return nullptr;
- }
- // a click (press and release) at `local` in `c`, through the native window it is in
- juce::String lastHit;
- void click (juce::Component& c, juce::Point<int> local)
- {
- auto* peer = c.getPeer();
- if (peer == nullptr)
- return;
- const auto at = peer->getComponent().getLocalPoint (&c, local.toFloat());
- lastHit = describe (peer->getComponent().getComponentAt (at.roundToInt()));
- line (" click at " + local.toString() + " in " + describe (&c).upToFirstOccurrenceOf (" < ", false, false) + " -> " + lastHit);
- const auto now = juce::Time::currentTimeMillis();
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier), 1.0f, 0.0f, now);
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, juce::ModifierKeys(), 1.0f, 0.0f, now + 40);
- }
- void click (juce::Component& c) { click (c, c.getLocalBounds().getCentre()); }
- // Space where the system sends it: the native window of the focused component (else the main one)
- bool space()
- {
- // Windows: posted to the window with the system's focus, as a real key goes (the system's own routing)
- if (lynx::nativechild::pressSpaceForTest (main->getWindowHandle()))
- return true;
- auto* focused = juce::Component::getCurrentlyFocusedComponent();
- auto* peer = focused != nullptr && focused->getPeer() != nullptr ? focused->getPeer() : main->getPeer();
- return peer != nullptr && peer->handleKeyPress (juce::KeyPress (juce::KeyPress::spaceKey, juce::ModifierKeys(), ' '));
- }
- void spacePlays (const juce::String& after)
- {
- line (" keys at: " + describe (juce::Component::getCurrentlyFocusedComponent()));
- auto& transport = engine->getTransport();
- if (transport.playing.load())
- engine->stop();
- space();
- check ("Space plays after " + after, transport.playing.load());
- engine->stop();
- }
- void timerCallback() override
- {
- auto* simple = ui->getSimpleWorkflowForSnapshot();
- auto& playlist = ui->getPlaylistForSnapshot();
- switch (stepIndex++)
- {
- case 0:
- ui->setLayoutStyle (lynx::layoutstyle::Style::simple);
- ui->grabKeyboardFocus();
- break;
- case 1:
- check ("the Simple workflow is up", simple != nullptr);
- if (simple == nullptr)
- return finish();
- spacePlays ("the layout came up");
- simple->showWelcome();
- break;
- case 2:
- if (auto* demo = find ("tour.welcome.demo"))
- click (*demo); // Welcome › Open a demo song: the Start from list
- else
- check ("Welcome > Open a demo song found", false);
- break;
- case 3:
- {
- if (! simple->isStartFromShowing()) // (X11: a child window just mapped may miss the first click)
- if (auto* demo = find ("tour.welcome.demo"))
- {
- line (" the first click was not taken: once more");
- click (*demo);
- }
- check ("Start from is up", simple->isStartFromShowing());
- if (auto* start = dynamic_cast<lynx::StartFromPanel*> (simple->startFromForSnapshot()))
- check ("a demo song opens from it", start->openForSnapshot (1));
- break;
- }
- case 4:
- check ("Start from closed with the demo open", ! simple->isStartFromShowing() && ! engine->getSong().playlist.empty());
- spacePlays ("a demo opened from Welcome > Start from");
- instrumentTrack = [] (const lynx::Song& song) { // the first Instrument track (the dock's Keyboard and Editor tabs are for it)
- for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
- if (lynx::simpletracks::kindOf (song, t) == lynx::simpletracks::Kind::instrument)
- return t;
- return 0;
- } (engine->getSong());
- line ("instrument track: " + juce::String (instrumentTrack));
- playlist.selectTrack (instrumentTrack);
- simple->trackSelected (instrumentTrack);
- break;
- case 5:
- if (auto* dock = simple->dockForSnapshot(); dock != nullptr && dock->isShowing())
- {
- click (*dock, { dock->getWidth() - 6, dock->getHeight() - 6 }); // (its empty corner)
- spacePlays ("a click in the dock");
- }
- else
- check ("the dock shows", false);
- break;
- case 6:
- if (auto* tab = find ("simple.dock.keyboard"))
- {
- click (*tab);
- spacePlays ("a click on a dock tab (Keyboard)");
- }
- if (auto* tab = find ("simple.dock.editor"))
- {
- click (*tab);
- spacePlays ("a click on a dock tab (Editor)");
- }
- break;
- case 7:
- if (auto* lyrics = find ("simple.lyrics"))
- {
- click (*lyrics);
- spacePlays ("a click on the Lyrics button");
- }
- else
- check ("the Lyrics button found", false);
- break;
- case 8:
- {
- const auto lane = playlist.trackRowForSnapshot (instrumentTrack).withTrimmedLeft (playlist.headerWidth);
- click (playlist, { juce::jmax (4, playlist.headerWidth / 2), lane.getCentreY() });
- spacePlays ("a click on a track header");
- click (playlist, lane.getCentre() + juce::Point<int> (40, 0));
- spacePlays ("a click in the Playlist grid");
- break;
- }
- case 9:
- {
- // a text field the user clicks into keeps its typing keys; a click outside gives Space back
- // a dock knob clicked keeps the arrow keys, and Space still plays from it
- for (auto tab : { lynx::SimpleDock::Tab::effects, lynx::SimpleDock::Tab::instrument })
- {
- juce::Component* knob = nullptr;
- std::function<void (juce::Component&)> seek = [&] (juce::Component& c) {
- if (knob == nullptr && c.isShowing() && (bool) c.getProperties().getWithDefault ("lynxClickKeepsKeys", false))
- knob = &c;
- for (auto* child : c.getChildren())
- seek (*child);
- };
- if (auto* dock = simple->dockForSnapshot())
- {
- dock->setTab (tab);
- seek (*dock);
- }
- if (knob != nullptr)
- {
- click (*knob);
- spacePlays ("a click on a dock knob");
- break;
- }
- }
- if (auto* dock = simple->dockForSnapshot())
- dock->setTab (lynx::SimpleDock::Tab::instrument);
- juce::TextEditor* field = nullptr;
- std::function<void (juce::Component&)> look = [&] (juce::Component& c) {
- if (auto* t = dynamic_cast<juce::TextEditor*> (&c); t != nullptr && t->isShowing() && field == nullptr)
- field = t;
- for (auto* child : c.getChildren())
- look (*child);
- };
- if (auto* dock = simple->dockForSnapshot())
- look (*dock);
- line ("text field in the dock found=" + juce::String ((int) (field != nullptr)));
- if (field != nullptr)
- {
- click (*field);
- const auto before = field->getText();
- space();
- check ("Space types into the text field the user clicked", field->getText() != before && ! engine->getTransport().playing.load());
- engine->stop();
- field->clear();
- const auto lane = playlist.trackRowForSnapshot (instrumentTrack).withTrimmedLeft (playlist.headerWidth);
- click (playlist, lane.getCentre() + juce::Point<int> (60, 0));
- spacePlays ("a click in the grid after typing");
- }
- // H1: the first-song tour's card in front of the native panels, taking no keys (started on the demo
- // as it is: Help's question about a new project is a dialog)
- if (auto* tour = simple->tourForSnapshot())
- tour->start();
- break;
- }
- case 10:
- {
- auto* tour = simple->tourForSnapshot();
- auto* card = tour != nullptr ? tour->cardForSnapshot() : nullptr;
- check ("the tour runs", tour != nullptr && tour->isRunning() && card != nullptr && card->isVisible());
- if (card == nullptr)
- return finish();
- auto& frame = ui->workspaceForTest().getFrame (lynx::workspace::Panel::playlist);
- const auto native = lynx::nativechild::dockingEnabled() && lynx::nativechild::isAttached (frame);
- line ("playlist native child window=" + juce::String ((int) native) + ", tour card native child window="
- + juce::String ((int) lynx::nativechild::isAttached (*card)));
- if (native)
- {
- check ("the tour card is a native child window of the main window (not under the panels)", lynx::nativechild::isAttached (*card));
- #if JUCE_WINDOWS
- check ("the tour card is above the Playlist's native window", lynx::nativechild::isAbove (card->getWindowHandle(), frame.getWindowHandle()));
- juce::Component* layer = nullptr;
- for (auto* c : lynx::nativechild::attachedChildren (main->getPeer()->getNativeHandle()))
- if (c != nullptr && c->getComponentID() == "tour.layer")
- layer = c;
- check ("the ring's layer is above the Playlist too", layer != nullptr && lynx::nativechild::isAbove (layer->getWindowHandle(), frame.getWindowHandle()));
- check ("the ring's layer lets clicks through to the Playlist",
- layer != nullptr && lynx::nativechild::windowAt (*layer, layer->getLocalBounds().getCentre()) != layer->getWindowHandle());
- #endif
- }
- check ("the tour card took no keys", ! card->hasKeyboardFocus (true));
- spacePlays ("the tour came up");
- if (auto* next = card->findChildWithID ("tour.next"); next != nullptr && next->isShowing())
- {
- click (*next);
- check ("a click on the card took no keys", ! card->hasKeyboardFocus (true));
- spacePlays ("a click on the tour card");
- }
- finish();
- break;
- }
- default:
- break;
- }
- }
- void finish()
- {
- line (ok ? "result=OK" : "result=FAILED");
- stopTimer();
- done();
- }
- };
- auto* test = new KeyTest();
- test->reportPath = reportPath;
- startFocusTestWindow (*test);
- // Windows: kept above other apps' windows for its few seconds (JUCE takes a button-down only where the system finds
- // its window under the point, and the test clicks through LYNX's own peers, not the system's input)
- #if JUCE_WINDOWS
- test->main->setAlwaysOnTop (true); // (Linux: JUCE makes the X11 window again for it; the private X server has no other windows)
- #endif
- test->startTimer (700);
- }
- template <typename Test>
- void startFocusTestWindow (Test& t)
- {
- auto* test = &t;
- test->engine = std::make_unique<lynx::AudioEngine> (false);
- test->main = std::make_unique<juce::DocumentWindow> ("LYNX focus test", lynx::theme::window, juce::DocumentWindow::allButtons);
- test->main->setUsingNativeTitleBar (true);
- test->ui = new lynx::MainComponent (*test->engine, false);
- test->main->setContentOwned (test->ui, true);
- test->main->setResizable (true, true);
- test->main->centreWithSize (1280, 760);
- test->main->setVisible (true);
- lynx::setMainWindowForOwnership (test->main.get());
- test->done = [this, test] {
- setApplicationReturnValue (test->ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] {
- lynx::setMainWindowForOwnership (nullptr);
- test->main = nullptr;
- delete test;
- quit();
- });
- };
- }
- void runWindowTest (const juce::String& reportPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- struct WindowTest final : juce::Timer
- {
- juce::String reportPath, report;
- bool ok = true;
- int stepIndex = 0;
- std::unique_ptr<lynx::AudioEngine> engine;
- lynx::MainComponent* ui = nullptr;
- std::unique_ptr<juce::DocumentWindow> main, pluginLike;
- juce::TextEditor* pluginField = nullptr;
- std::unique_ptr<juce::AlertWindow> nameDialog;
- std::function<void()> done;
- void line (const juce::String& text)
- {
- report << text << "\n";
- juce::File (reportPath).replaceWithText (report);
- }
- void check (const juce::String& what, bool passed)
- {
- line ((passed ? "ok " : "FAIL ") + what);
- ok = ok && passed;
- }
- bool isAbove (juce::Component* w) { return w != nullptr && lynx::isAboveMainWindow (*w); }
- bool focusIn (juce::Component* w)
- {
- auto* f = juce::Component::getCurrentlyFocusedComponent();
- return w != nullptr && f != nullptr && (f == w || w->isParentOf (f));
- }
- void timerCallback() override
- {
- switch (stepIndex++)
- {
- case 0:
- line ("foreground=" + juce::String (juce::Process::isForegroundProcess() ? 1 : 0));
- ui->openQuickAddForTest();
- break;
- case 1:
- {
- auto* w = lynx::findToolWindow ("quickadd");
- check ("quick-add palette open", w != nullptr);
- check ("quick-add palette active", w != nullptr && w->isActiveWindow());
- check ("quick-add palette owned by the main window", w != nullptr && lynx::isOwnedByMainWindow (*w));
- check ("quick-add palette above the main window", isAbove (w));
- auto* f = juce::Component::getCurrentlyFocusedComponent();
- check ("quick-add search box has the keyboard focus", focusIn (w) && dynamic_cast<juce::TextEditor*> (f) != nullptr && f->hasKeyboardFocus (false) && w->isActiveWindow());
- lynx::closeAllToolWindows();
- lynx::openAudioEditor (*engine);
- break;
- }
- case 2:
- {
- auto* w = lynx::findToolWindow ("audioeditor");
- check ("audio editor open", w != nullptr);
- check ("audio editor active", w != nullptr && w->isActiveWindow());
- check ("audio editor owned by the main window", w != nullptr && lynx::isOwnedByMainWindow (*w));
- check ("audio editor above the main window", isAbove (w));
- lynx::forceForegroundForTest (*main); // the user clicks the main window
- break;
- }
- case 3:
- {
- auto* w = lynx::findToolWindow ("audioeditor");
- check ("audio editor stays above the main window after clicking it", isAbove (w));
- lynx::closeAllToolWindows();
- // a plugin editor's window: its own controls keep the keyboard focus
- pluginLike = std::make_unique<juce::DocumentWindow> ("Plugin", juce::Colours::black, juce::DocumentWindow::closeButton);
- pluginLike->setUsingNativeTitleBar (true);
- auto* field = new juce::TextEditor();
- field->setSize (300, 120);
- pluginLike->setContentOwned (field, true);
- pluginLike->centreWithSize (300, 120);
- pluginLike->setVisible (true);
- lynx::keepAboveMainWindow (*pluginLike);
- pluginLike->toFront (true);
- field->grabKeyboardFocus();
- pluginField = field;
- break;
- }
- case 4:
- check ("plugin window active", pluginLike->isActiveWindow());
- check ("plugin window keeps the keyboard focus", pluginField->hasKeyboardFocus (false) && pluginLike->isActiveWindow());
- check ("plugin window above the main window", isAbove (pluginLike.get()));
- pluginLike = nullptr;
- lynx::forceForegroundForTest (*main);
- juce::Component::unfocusAllComponents();
- break;
- case 5:
- check ("main window takes the keyboard focus back when it is active", ui->hasKeyboardFocus (true));
- // round 165q: a name dialog (F4's next empty pattern, Rename and color...) opens ready to type
- nameDialog = lynx::makeNameAndColourDialog ("Rename pattern", "Pattern 2", 0xff808080u);
- nameDialog->enterModalState (true, nullptr, false);
- lynx::keepAboveMainWindow (*nameDialog);
- break;
- case 6:
- {
- auto* f = juce::Component::getCurrentlyFocusedComponent();
- auto* field = dynamic_cast<juce::TextEditor*> (f);
- check ("name dialog: its text field has the keyboard focus", field != nullptr && focusIn (nameDialog.get()));
- if (field != nullptr)
- field->keyPressed (juce::KeyPress ('x', {}, 'x'));
- check ("name dialog: typing replaces the name", nameDialog->getTextEditorContents ("name") == "x");
- nameDialog->exitModalState (0);
- nameDialog = nullptr;
- line (ok ? "result=OK" : "result=FAILED");
- stopTimer();
- done();
- break;
- }
- default:
- break;
- }
- }
- };
- auto* test = new WindowTest();
- test->reportPath = reportPath;
- test->engine = std::make_unique<lynx::AudioEngine> (false);
- test->main = std::make_unique<juce::DocumentWindow> ("LYNX window test", lynx::theme::window, juce::DocumentWindow::allButtons);
- test->main->setUsingNativeTitleBar (true);
- test->ui = new lynx::MainComponent (*test->engine, false);
- test->main->setContentOwned (test->ui, true);
- test->main->setResizable (true, true);
- test->main->centreWithSize (1280, 760);
- test->main->setVisible (true);
- lynx::setMainWindowForOwnership (test->main.get());
- lynx::forceForegroundForTest (*test->main);
- test->main->toFront (true);
- test->done = [this, test] {
- setApplicationReturnValue (test->ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] {
- lynx::closeAllToolWindows();
- lynx::setMainWindowForOwnership (nullptr);
- test->main = nullptr;
- delete test;
- quit();
- });
- };
- test->startTimer (1500);
- }
- // --minimizeclicktest (issue #188): see the option. The main window holds a component that counts its mouse-downs.
- void runMinimizeClickTest (const juce::String& reportPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- struct ClickPad final : juce::Component
- {
- int downs = 0;
- void paint (juce::Graphics& g) override { g.fillAll (juce::Colours::darkslategrey); }
- void mouseDown (const juce::MouseEvent&) override { ++downs; }
- };
- struct MinimizeTest final : juce::Timer
- {
- juce::String reportPath, report;
- bool ok = true;
- int stepIndex = 0, waits = 0;
- std::unique_ptr<juce::DocumentWindow> main;
- ClickPad* pad = nullptr;
- juce::DocumentWindow* tool = nullptr;
- juce::Point<int> inside, outside; // screen points: where the tool window is, and beside it
- std::function<void()> done;
- void line (const juce::String& text)
- {
- report << text << "\n";
- juce::File (reportPath).replaceWithText (report);
- }
- void check (const juce::String& what, bool passed)
- {
- line ((passed ? "ok " : "FAIL ") + what);
- ok = ok && passed;
- }
- // a left click at a screen point through the main window's peer: the path an X ButtonPress takes
- bool clickReachesPad (juce::Point<int> screen)
- {
- auto* peer = main->getPeer();
- if (peer == nullptr)
- return false;
- const auto before = pad->downs;
- const auto local = peer->globalToLocal (screen.toFloat());
- const auto now = juce::Time::currentTimeMillis();
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, local, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier),
- juce::MouseInputSource::defaultPressure, juce::MouseInputSource::defaultOrientation, now);
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, local, juce::ModifierKeys(),
- juce::MouseInputSource::defaultPressure, juce::MouseInputSource::defaultOrientation, now + 1);
- return pad->downs == before + 1;
- }
- bool toolMinimised() const { return tool != nullptr && tool->getPeer() != nullptr && tool->getPeer()->isMinimised(); }
- void timerCallback() override
- {
- switch (stepIndex)
- {
- case 0:
- {
- auto content = std::make_unique<juce::Component>();
- content->setSize (420, 300);
- tool = lynx::openToolWindow (std::move (content), "Tap tempo (test)", "minimizetest");
- ++stepIndex;
- return;
- }
- case 1:
- {
- check ("tool window open", tool != nullptr && tool->isShowing());
- if (tool == nullptr)
- break;
- const auto r = tool->getScreenBounds();
- inside = r.getCentre();
- outside = { main->getScreenBounds().getX() + 40, main->getScreenBounds().getBottom() - 40 };
- line ("main " + main->getScreenBounds().toString() + " tool " + r.toString());
- lynx::matchWindowOrderToScreen();
- check ("a click beside the tool window reaches the main window", clickReachesPad (outside));
- check ("a click on the shown tool window does not reach the main window", ! clickReachesPad (inside));
- tool->setMinimised (true);
- ++stepIndex;
- return;
- }
- case 2:
- if (! toolMinimised() && ++waits < 20)
- return;
- check ("the window manager minimised the tool window", toolMinimised());
- check ("the tool window stays visible for JUCE (as in the report)", tool->isVisible());
- main->toFront (true); // a click on the main window: LYNX puts its secondary windows back above it in JUCE's list
- lynx::matchWindowOrderToScreen();
- ++stepIndex;
- return;
- case 3:
- check ("a click where the minimised tool window was reaches the main window", clickReachesPad (inside));
- check ("a click beside it still reaches the main window", clickReachesPad (outside));
- tool->setMinimised (false);
- waits = 0;
- ++stepIndex;
- return;
- case 4:
- if (toolMinimised() && ++waits < 20)
- return;
- tool->toFront (false);
- lynx::matchWindowOrderToScreen();
- ++stepIndex;
- return;
- case 5:
- check ("the tool window is back", ! toolMinimised());
- check ("a click on the restored tool window does not reach the main window", ! clickReachesPad (inside));
- break;
- default:
- return;
- }
- line (ok ? "result=OK" : "result=FAILED");
- stopTimer();
- done();
- }
- };
- auto* test = new MinimizeTest();
- test->reportPath = reportPath;
- test->main = std::make_unique<juce::DocumentWindow> ("LYNX minimise test", lynx::theme::window, juce::DocumentWindow::allButtons);
- test->main->setUsingNativeTitleBar (true);
- test->pad = new ClickPad();
- test->pad->setSize (1200, 760);
- test->main->setContentOwned (test->pad, true);
- test->main->setTopLeftPosition (60, 60);
- test->main->setVisible (true);
- lynx::setMainWindowForOwnership (test->main.get());
- test->main->toFront (true);
- test->done = [this, test] {
- setApplicationReturnValue (test->ok ? 0 : 1);
- juce::MessageManager::callAsync ([this, test] {
- lynx::closeAllToolWindows();
- lynx::setMainWindowForOwnership (nullptr);
- test->main = nullptr;
- delete test;
- quit();
- });
- };
- test->startTimer (700);
- }
- // LYNX.exe --plugintest plugin.vst3 report.txt ["name"]: loads the plugin (or the one named in a shell), plays notes if it is an
- // instrument (and runs audio through it if it is an effect) and measures the audio.
- // Round 190fw: an instrument plugin file on channel 5 of an offline engine (Image-Line's "FL Studio VSTi", which
- // runs FL Studio inside it). Without a project: four chords at 137 BPM, rendered (notes.wav), the plugin's state
- // saved in <folder>/vstitest.lynx. With a project (one saved by LYNX with the plugin on a channel, e.g. after its
- // window was used): that project. Then: the project loaded back from the file renders the same (reload.wav) and
- // gives the same state back; the project's own notes removed, rendered at 100 and 150 BPM (tempo-100/150.wav), the
- // onsets of what the plugin plays by itself must follow the host tempo; and the outputs the plugin offers.
- void runVstiTest (const juce::String& pluginPath, const juce::String& folderPath, const juce::String& projectPath)
- {
- juce::String report;
- auto ok = true;
- const juce::File folder (folderPath);
- folder.createDirectory();
- const auto check = [&] (const juce::String& name, bool passed) {
- report << name << "=" << (passed ? "OK" : "FAILED") << "\n";
- ok = ok && passed;
- };
- struct Take
- {
- float peak = 0.0f;
- std::vector<float> left;
- };
- // renders `song` with the plugin file known to the engine's host; `wav` (in the folder) gets the audio
- const auto render = [&] (const lynx::Song& song, double seconds, const juce::String& wav, std::function<void (lynx::AudioEngine&)> after = {}) {
- Take take;
- lynx::AudioEngine engine (false);
- engine.getPluginHost().addPluginFile (juce::File (pluginPath));
- engine.setSong (song);
- const auto file = folder.getChildFile (wav);
- file.deleteFile();
- std::unique_ptr<juce::AudioFormatWriter> writer;
- if (auto stream = file.createOutputStream())
- {
- juce::WavAudioFormat format;
- writer.reset (format.createWriterFor (stream.get(), 48000.0, 2, 24, {}, 0));
- if (writer != nullptr)
- stream.release();
- }
- lynx::AudioEngine::RenderOptions o;
- o.seconds = seconds;
- o.sampleRate = 48000.0;
- o.output = writer.get();
- o.capture = [&take] (const float* l, const float*, int n) { take.left.insert (take.left.end(), l, l + n); };
- take.peak = engine.renderOffline (o);
- writer.reset();
- if (after)
- after (engine);
- return take;
- };
- // the channel that holds the plugin
- const auto pluginChannel = [&] (const lynx::Song& song) {
- for (std::size_t c = 0; c < song.channels.size(); ++c)
- if (song.channels[c].instrument == lynx::InstrumentKind::plugin
- && juce::String (song.channels[c].plugin.name).containsIgnoreCase (juce::File (pluginPath).getFileNameWithoutExtension().upToFirstOccurrenceOf (" (", false, false)))
- return (int) c;
- return -1;
- };
- lynx::Song song;
- const auto saved = folder.getChildFile ("vstitest.lynx");
- if (projectPath.isEmpty())
- {
- lynx::AudioEngine scanner (false);
- report << "plugins_in_file=" << scanner.getPluginHost().addPluginFile (juce::File (pluginPath)) << "\n";
- std::optional<juce::PluginDescription> type;
- for (const auto& t : scanner.getPluginHost().getKnownPlugins().getTypes())
- if (t.isInstrument && juce::File (t.fileOrIdentifier) == juce::File (pluginPath))
- type = t;
- check ("instrument_found", type.has_value());
- if (! type)
- {
- juce::File (folder.getChildFile ("report.txt")).replaceWithText (report + "result=FAILED\n");
- setApplicationReturnValue (1);
- quit();
- return;
- }
- report << "plugin=" << type->name << " (" << type->manufacturerName << ") outputs=" << type->numOutputChannels << "\n";
- song = lynx::Song::makeDefault();
- song.bpm = 137.0;
- auto& c = song.channels[4];
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin = {};
- c.plugin.id = type->createIdentifierString().toStdString();
- c.plugin.name = type->name.toStdString();
- c.name = type->name.toStdString();
- c.volume = 1.0f;
- for (std::size_t k = 0; k < song.channels.size(); ++k)
- song.channels[k].muted = k != 4;
- song.patterns[0].notes.clear();
- for (int beat = 0; beat < 8; ++beat) // a chord per beat, two bars
- for (int key : { 60, 64, 67 })
- song.patterns[0].notes.push_back ({ (std::int64_t) beat * lynx::ppq, lynx::ppq / 2, 4, key + (beat / 4) * 5, 0.9f });
- song.patterns[0].sortNotes();
- const auto notes = render (song, 4.0, "notes.wav", [&song] (lynx::AudioEngine& engine) {
- engine.capturePluginStates();
- song = engine.getSong();
- });
- report << "notes_peak=" << notes.peak << "\n";
- check ("notes_play", notes.peak > 0.001f && notes.peak < 10.0f);
- juce::String error;
- check ("project_saved", lynx::ProjectFile::save (song, saved, error));
- }
- else
- {
- juce::String error;
- const auto loaded = lynx::ProjectFile::load (juce::File (projectPath), error);
- check ("project_loaded", loaded.has_value());
- if (loaded)
- song = *loaded;
- juce::File (projectPath).copyFileTo (saved);
- }
- const auto channel = pluginChannel (song);
- check ("plugin_channel", channel >= 0);
- if (channel >= 0)
- {
- const auto& plugin = song.channels[(std::size_t) channel].plugin;
- juce::MemoryBlock state;
- state.fromBase64Encoding (juce::String (plugin.state));
- report << "channel=" << channel + 1 << " state_bytes=" << (int) state.getSize() << "\n";
- check ("state_saved", state.getSize() > 0);
- // the project read back from the file: the same sound, and the same state handed back
- juce::String error;
- const auto again = lynx::ProjectFile::load (saved, error);
- check ("project_reloaded", again.has_value());
- if (again)
- {
- std::string stateBack;
- const auto first = render (*again, 4.0, "reload-a.wav");
- const auto second = render (*again, 4.0, "reload-b.wav", [&] (lynx::AudioEngine& engine) {
- engine.capturePluginStates();
- stateBack = engine.getSong().channels[(std::size_t) channel].plugin.state;
- });
- // two loads of the same project: the same audio (sample for sample, or within -60 dB for a plugin
- // with free-running modulation)
- double energy = 0.0, difference = 0.0;
- const auto n = std::min (first.left.size(), second.left.size());
- for (std::size_t k = 0; k < n; ++k)
- {
- energy += (double) first.left[k] * first.left[k];
- difference += ((double) first.left[k] - second.left[k]) * ((double) first.left[k] - second.left[k]);
- }
- const auto ratioDb = energy > 0.0 ? 10.0 * std::log10 (std::max (difference, 1e-30) / energy) : 0.0;
- report << "reload_peak=" << first.peak << " reload_difference_db=" << juce::String (ratioDb, 1) << "\n";
- check ("reload_plays", first.peak > 0.001f);
- check ("reload_same_sound", energy > 0.0 && ratioDb < -60.0);
- juce::MemoryBlock back;
- back.fromBase64Encoding (juce::String (stateBack));
- report << "state_back_bytes=" << (int) back.getSize() << " identical=" << (int) (back == state) << "\n";
- check ("state_handed_back", back.getSize() > 0);
- }
- // the host tempo: what the plugin plays by itself (FL Studio's own patterns inside FL Studio VSTi) at two
- // tempos, without the project's notes
- auto self = song;
- for (std::size_t k = 0; k < self.channels.size(); ++k)
- self.channels[k].muted = (int) k != channel;
- for (auto& pattern : self.patterns)
- pattern.notes.erase (std::remove_if (pattern.notes.begin(), pattern.notes.end(), [channel] (const lynx::Note& n) { return n.channel == channel; }),
- pattern.notes.end());
- const auto onsets = [] (const std::vector<float>& x) {
- // envelope rises over a threshold (10 ms hold-off of 60 ms): the times in seconds
- std::vector<double> at;
- float peak = 0.0f;
- for (const auto v : x)
- peak = std::max (peak, std::abs (v));
- const auto threshold = peak * 0.3f;
- auto quietFor = 1 << 30;
- for (std::size_t k = 0; k < x.size(); ++k)
- {
- const auto loud = std::abs (x[k]) >= threshold;
- if (loud && quietFor >= 48000 * 60 / 1000)
- at.push_back ((double) k / 48000.0);
- quietFor = loud ? 0 : quietFor + 1;
- }
- return at;
- };
- const auto medianGap = [] (const std::vector<double>& at) {
- std::vector<double> gaps;
- for (std::size_t k = 1; k < at.size(); ++k)
- gaps.push_back (at[k] - at[k - 1]);
- if (gaps.empty())
- return 0.0;
- std::sort (gaps.begin(), gaps.end());
- return gaps[gaps.size() / 2];
- };
- self.bpm = 100.0;
- const auto slow = render (self, 6.0, "tempo-100.wav");
- self.bpm = 150.0;
- const auto fast = render (self, 6.0, "tempo-150.wav");
- const auto gapSlow = medianGap (onsets (slow.left)), gapFast = medianGap (onsets (fast.left));
- report << "self_peak_100=" << slow.peak << " self_peak_150=" << fast.peak << " onsets_100=" << (int) onsets (slow.left).size()
- << " onsets_150=" << (int) onsets (fast.left).size() << " gap_100=" << juce::String (gapSlow, 4) << " gap_150="
- << juce::String (gapFast, 4) << "\n";
- if (slow.peak > 0.001f && gapFast > 0.0)
- {
- report << "tempo_ratio=" << juce::String (gapSlow / gapFast, 3) << " (expected 1.5)\n";
- check ("follows_host_tempo", std::abs (gapSlow / gapFast - 1.5) < 0.05);
- }
- else
- report << "tempo: the plugin plays nothing by itself in this project\n";
- // the outputs it offers (FL Studio VSTi (Multi): FL's mixer tracks as separate outputs)
- lynx::AudioEngine engine (false);
- engine.getPluginHost().addPluginFile (juce::File (pluginPath));
- engine.setSong (song);
- engine.renderOffline (0.2, 48000.0);
- if (auto instrument = std::dynamic_pointer_cast<lynx::PluginInstrument> (engine.getChannelInstrument (channel)))
- {
- report << "outputs=" << (int) instrument->outputs().size() << ":";
- for (const auto& o : instrument->outputs())
- report << " [" << o.name << "]";
- report << "\n";
- check ("outputs_listed", ! instrument->outputs().empty());
- }
- else
- check ("instrument_loaded", false);
- }
- report << "plugin_crashes=" << lynx::pluginCrashCount() << "\n";
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- folder.getChildFile ("report.txt").replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- void runPluginTest (const juce::String& pluginPath, const juce::String& reportPath, const juce::String& only = {})
- {
- juce::String report;
- bool ok = false;
- {
- lynx::AudioEngine offline (false);
- auto& host = offline.getPluginHost();
- const auto added = host.addPluginFile (juce::File (pluginPath));
- report << "plugins_in_file=" << added << "\n";
- juce::PluginDescription instrument, effect;
- bool hasInstrument = false, hasEffect = false;
- for (const auto& type : host.getKnownPlugins().getTypes())
- {
- if (juce::File (type.fileOrIdentifier).getFileName() != juce::File (pluginPath).getFileName()
- || (only.isNotEmpty() && type.name != only))
- continue;
- report << " " << (type.isInstrument ? "instrument: " : "effect: ") << type.name << " (" << type.manufacturerName
- << ") in " << type.fileOrIdentifier << "\n";
- if (type.isInstrument && ! hasInstrument) { instrument = type; hasInstrument = true; }
- if (! type.isInstrument && ! hasEffect) { effect = type; hasEffect = true; }
- }
- auto song = lynx::Song::makeDefault();
- if (hasInstrument)
- {
- auto& c = song.channels[4]; // the "Synth" channel becomes the plugin
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin.id = instrument.createIdentifierString().toStdString();
- c.plugin.name = instrument.name.toStdString();
- c.volume = 1.0f;
- for (int i = 0; i < 4; ++i) // one chord per beat
- for (int key : { 60, 64, 67 })
- song.patterns[0].notes.push_back ({ (std::int64_t) i * lynx::ppq, lynx::ppq / 2, 4, key, 0.9f });
- song.patterns[0].sortNotes();
- }
- if (hasEffect)
- {
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::plugin;
- slot.plugin.id = effect.createIdentifierString().toStdString();
- slot.plugin.name = effect.name.toStdString();
- song.mixer[0].effects.push_back (slot);
- }
- const auto effectSlot = (int) song.mixer[0].effects.size() - 1; // (the default master may hold effects already)
- offline.setSong (song);
- // after a render: the rack (and its plugins) is built when the engine is prepared
- const auto peak = offline.renderOffline (3.0, 48000.0);
- const auto* loadedInstrument = dynamic_cast<lynx::PluginInstrument*> (offline.getChannelInstrument (4).get());
- const auto* loadedEffect = dynamic_cast<lynx::PluginEffect*> (offline.getEffect (0, effectSlot).get());
- report << "instrument_loaded=" << (loadedInstrument != nullptr ? "yes" : "no") << "\n"
- << "effect_loaded=" << (loadedEffect != nullptr ? "yes" : "no") << "\n";
- if (host.getLoadFailures().size() > 0) // why: the host's own message (license, missing file, load failure)
- report << "load_failures=" << host.getLoadFailures().joinIntoString (" | ") << "\n";
- report << "peak=" << peak << "\n";
- // plugins that crashed inside a call, were caught and switched off (round 111)
- report << "plugin_crashes=" << lynx::pluginCrashCount() << "\n";
- for (const auto& c : lynx::pluginCrashes())
- report << " crashed: " << c.plugin << " (" << lynx::crashguard::describe (c.code) << ")\n";
- offline.capturePluginStates();
- const auto stateSize = hasInstrument ? offline.getSong().channels[4].plugin.state.size() : (size_t) 0;
- report << "state_bytes_base64=" << (int) stateSize << "\n";
- ok = (hasInstrument || hasEffect) && (! hasInstrument || loadedInstrument != nullptr)
- && (! hasEffect || loadedEffect != nullptr) && peak > 0.001f && peak < 10.0f;
- }
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // Round 190gg (B4): --crashguardtest plugin report.txt thread | ui. "thread": the plugin's own thread faults in its 40th
- // block (Linux / macOS): that thread is parked, LYNX switches the plugin off (as the main window's timer does) and goes
- // on; the other inserts play; Reload brings it back. "ui": the calls the UI makes into a plugin, under the guard: a
- // preset load that crashes (the Plugin window's preset menu path) and making the editor (PluginWindows::open, the CLAP
- // test plugin's "editor-create": a display is needed, e.g. Xvfb); each switches the plugin off, LYNX goes on.
- void runCrashGuardThreadOrUiTest (const juce::String& pluginPath, const juce::String& reportPath, const juce::String& mode)
- {
- juce::String report;
- bool ok = true;
- const auto expect = [&] (const char* name, bool value) {
- report << name << "=" << (value ? 1 : 0) << "\n";
- ok = ok && value;
- };
- const auto setEnv = [] (const char* name, const char* value) {
- #if JUCE_WINDOWS
- _putenv_s (name, value);
- #else
- setenv (name, value, 1);
- #endif
- };
- const auto render = [] (lynx::AudioEngine& engine, double seconds, float* peak) {
- lynx::AudioEngine::RenderOptions o;
- o.seconds = seconds;
- o.sampleRate = 48000.0;
- o.pluginWarmUp = false;
- if (peak != nullptr)
- o.capture = [peak] (const float* l, const float* r, int n) {
- for (int k = 0; k < n; ++k)
- *peak = std::max (*peak, std::max (std::abs (l[k]), std::abs (r[k])));
- };
- return engine.renderOffline (o);
- };
- report << "mode=" << mode << "\nthread_guard=" << (lynx::crashguard::pluginThreadFaultsCaught() ? "on" : "off") << "\n";
- setEnv ("LYNX_TEST_CRASH", mode == "thread" ? "thread" : "");
- setEnv ("LYNX_TEST_CRASH_AFTER", "40");
- const auto tmp = juce::File::getSpecialLocation (juce::File::tempDirectory)
- .getChildFile ("lynx-crashguardtest-" + juce::String::toHexString (juce::Random::getSystemRandom().nextInt64()));
- tmp.createDirectory();
- {
- lynx::AudioEngine offline (false);
- auto& host = offline.getPluginHost();
- host.addPluginFile (juce::File (pluginPath));
- juce::PluginDescription effect;
- bool found = false;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (! found && ! type.isInstrument && juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName())
- {
- effect = type;
- found = true;
- }
- expect ("plugin_found", found);
- auto song = lynx::Song::makeDefault();
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::plugin;
- slot.plugin.id = effect.createIdentifierString().toStdString();
- slot.plugin.name = effect.name.toStdString();
- song.mixer[1].effects.push_back (slot);
- offline.setSong (song);
- const lynx::AudioEngine::HostedSlot where { -1, 1, 0 };
- render (offline, 0.05, nullptr);
- offline.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.85f; }, false);
- render (offline, 0.05, nullptr);
- auto* first = dynamic_cast<lynx::PluginEffect*> (offline.getEffect (1, 0).get());
- expect ("plugin_loaded", first != nullptr);
- const auto crashesBefore = lynx::pluginCrashCount();
- if (mode == "thread")
- {
- const auto faultsBefore = lynx::crashguard::pluginThreadFaultCount();
- float peak = 0.0f;
- render (offline, 3.0, &peak); // (the plugin starts its faulting thread in its 40th block)
- for (int i = 0; i < 200 && lynx::crashguard::pluginThreadFaultCount() == faultsBefore; ++i)
- juce::Thread::sleep (10);
- const auto faults = lynx::crashguard::pluginThreadFaults();
- expect ("thread_fault_parked", lynx::crashguard::pluginThreadFaultCount() == faultsBefore + 1 && ! faults.empty());
- if (! faults.empty())
- report << "thread_fault=" << faults.back().where << " (" << lynx::crashguard::describe (faults.back().code) << ")\n";
- expect ("not_yet_counted_as_a_call_crash", lynx::pluginCrashCount() == crashesBefore);
- // what the main window's timer does
- // (every instance of that module: the engine may hold more than the slot's, e.g. the offline render's)
- if (first != nullptr)
- report << "slot_file=" << first->getInstance().getPluginDescription().fileOrIdentifier << "\n";
- const auto switched = lynx::switchOffPluginsOfThreadFaults();
- report << "switched_off=" << switched << "\n";
- expect ("plugin_switched_off", switched >= 1 && first != nullptr && first->hasCrashed() && lynx::pluginCrashCount() == crashesBefore + switched);
- expect ("only_once", lynx::switchOffPluginsOfThreadFaults() == 0);
- const auto down = offline.downHostedPlugins();
- expect ("slot_down", down.size() == 1 && down[0] == where);
- float after = 0.0f;
- render (offline, 1.0, &after);
- report << "peak_after=" << after << "\n";
- expect ("audio_after_fault", after > 0.01f);
- offline.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.0f; }, false);
- float others = 0.0f;
- render (offline, 1.0, &others);
- expect ("other_inserts_play", others > 0.01f);
- offline.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.85f; }, false);
- const auto running = offline.reloadHostedPlugins (down);
- auto* again = dynamic_cast<lynx::PluginEffect*> (offline.getEffect (1, 0).get());
- float reloaded = 0.0f;
- render (offline, 1.0, &reloaded);
- expect ("reloaded_plays", running == 1 && again != nullptr && again != first && ! again->hasCrashed() && reloaded > 0.01f);
- }
- else
- {
- // a preset that crashes the plugin (the preset menu's load), saved first from the running plugin
- auto& instance = first->getInstance();
- const auto preset = tmp.getChildFile ("crash.lynxpreset");
- juce::String error;
- expect ("preset_saved", lynx::pluginpresetui::save (instance, preset, "crash", error) && preset.existsAsFile());
- setEnv ("LYNX_TEST_CRASH", "state");
- const auto loaded = lynx::pluginpresetui::load (instance, preset, error);
- setEnv ("LYNX_TEST_CRASH", "");
- report << "preset_error=" << error << "\n";
- expect ("preset_crash_caught", ! loaded && lynx::pluginCrashCount() == crashesBefore + 1 && first->hasCrashed());
- expect ("preset_plugin_down", offline.hostedPluginDown (where) && lynx::pluginInstanceDown (instance));
- expect ("not_called_again", ! lynx::callPluginFromUi (instance, "test", [] {}) && lynx::pluginCrashCount() == crashesBefore + 1);
- float after = 0.0f;
- render (offline, 1.0, &after);
- expect ("audio_after_preset_crash", after > 0.01f);
- // Reload; then its editor crashes as it is made (PluginWindows::open): no window, the plugin is down
- setEnv ("LYNX_TEST_CRASH", "editor-create");
- const auto running = offline.reloadHostedPlugins (offline.downHostedPlugins());
- auto held = offline.getEffect (1, 0);
- auto* again = dynamic_cast<lynx::PluginEffect*> (held.get());
- expect ("reloaded", running == 1 && again != nullptr && again != first && ! again->hasCrashed());
- if (again != nullptr)
- {
- lynx::PluginWindows::open (held, again->getInstance(), "crash test", {});
- expect ("editor_crash_caught", lynx::pluginCrashCount() == crashesBefore + 2 && again->hasCrashed());
- expect ("no_window", ! lynx::PluginWindows::isOpen (again->getInstance()));
- float editorAfter = 0.0f;
- render (offline, 1.0, &editorAfter);
- expect ("audio_after_editor_crash", editorAfter > 0.01f);
- }
- setEnv ("LYNX_TEST_CRASH", "");
- }
- }
- setEnv ("LYNX_TEST_CRASH", "");
- // LYNX's own faults (also on its own threads) stay crashes (child processes; the selftest runs the same)
- const auto own = faultReportSelfTest();
- report << "own_faults=" << own << "\n";
- ok = ok && ! own.startsWith ("ERROR");
- for (const auto& c : lynx::pluginCrashes())
- report << " crashed: " << c.plugin << " (" << lynx::crashguard::describe (c.code) << ")\n";
- tmp.deleteRecursively();
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX --crashguardtest plugin report.txt [process|memcpy] (round 190dt): see the dispatch in initialise().
- void runCrashGuardTest (const juce::String& pluginPath, const juce::String& reportPath, const juce::String& mode)
- {
- if (mode == "thread" || mode == "ui")
- {
- runCrashGuardThreadOrUiTest (pluginPath, reportPath, mode);
- return;
- }
- juce::String report;
- bool ok = true;
- const auto expect = [&] (const char* name, bool value) {
- report << name << "=" << (value ? 1 : 0) << "\n";
- ok = ok && value;
- };
- const auto setEnv = [] (const char* name, const char* value) {
- #if JUCE_WINDOWS
- _putenv_s (name, value);
- #else
- setenv (name, value, 1);
- #endif
- };
- // renders without the plugin warm-up (its silent blocks would count towards the crash)
- const auto render = [] (lynx::AudioEngine& engine, double seconds, const std::function<void (const float*, const float*, int)>& capture) {
- lynx::AudioEngine::RenderOptions o;
- o.seconds = seconds;
- o.sampleRate = 48000.0;
- o.pluginWarmUp = false;
- o.capture = capture;
- return engine.renderOffline (o);
- };
- const auto peakOf = [] (float& peak) {
- return [&peak] (const float* l, const float* r, int n) {
- for (int k = 0; k < n; ++k)
- peak = std::max (peak, std::max (std::abs (l[k]), std::abs (r[k])));
- };
- };
- report << "guard=" << (lynx::crashguard::pluginFaultsCaught() ? "on" : "off") << "\nmode=" << mode << "\n";
- setEnv ("LYNX_TEST_CRASH", mode == "memcpy" ? "memcpy" : "process");
- setEnv ("LYNX_TEST_CRASH_AFTER", "40");
- const auto tmp = juce::File::getSpecialLocation (juce::File::tempDirectory)
- .getChildFile ("lynx-crashguardtest-" + juce::String::toHexString (juce::Random::getSystemRandom().nextInt64()));
- tmp.createDirectory();
- std::optional<lynx::Song> saved;
- std::string savedState;
- {
- lynx::AudioEngine offline (false);
- auto& host = offline.getPluginHost();
- host.addPluginFile (juce::File (pluginPath));
- juce::PluginDescription effect;
- bool found = false;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (! found && ! type.isInstrument && juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName())
- {
- effect = type;
- found = true;
- }
- expect ("plugin_found", found);
- // the plugin on insert 1 (the kick's); the clap and the hat play on inserts 2 and 3
- auto song = lynx::Song::makeDefault();
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::plugin;
- slot.plugin.id = effect.createIdentifierString().toStdString();
- slot.plugin.name = effect.name.toStdString();
- song.mixer[1].effects.push_back (slot);
- offline.setSong (song);
- const lynx::AudioEngine::HostedSlot where { -1, 1, 0 };
- // the rack is published at the engine's rate and an offline render runs at its own (48 kHz) without publishing:
- // one edit after a first render puts the rack (and the plugin) at the render's rate, so later edits keep it
- render (offline, 0.05, {}); // (a few blocks, far from the 40th)
- offline.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.85f; }, false);
- render (offline, 0.05, {});
- auto* first = dynamic_cast<lynx::PluginEffect*> (offline.getEffect (1, 0).get());
- expect ("plugin_loaded", first != nullptr);
- offline.capturePluginStates();
- savedState = offline.getSong().mixer[1].effects[0].plugin.state;
- expect ("state_captured", ! savedState.empty());
- // the crash: 3 s, the plugin faults in its 40th block
- const auto crashesBefore = lynx::pluginCrashCount();
- juce::int64 position = 0, crashAt = -1;
- float peakAfter = 0.0f;
- const auto afterPeak = peakOf (peakAfter);
- const auto peak = render (offline, 3.0, [&] (const float* l, const float* r, int n) {
- if (crashAt < 0 && lynx::pluginCrashCount() != crashesBefore)
- crashAt = position;
- else if (crashAt >= 0)
- afterPeak (l, r, n);
- position += n;
- });
- report << "peak=" << peak << "\ncrash_at_sample=" << crashAt << "\npeak_after_crash=" << peakAfter << "\n";
- const auto crashes = lynx::pluginCrashes();
- expect ("crash_caught", lynx::pluginCrashCount() == crashesBefore + 1 && ! crashes.empty() && ! crashes.back().onLoad);
- if (! crashes.empty())
- report << "crash=" << crashes.back().plugin << " (" << lynx::crashguard::describe (crashes.back().code) << ")\n";
- expect ("slot_marked_crashed", first != nullptr && offline.getEffect (1, 0).get() == first && first->hasCrashed());
- const auto down = offline.downHostedPlugins();
- expect ("slot_down", down.size() == 1 && down[0] == where);
- expect ("audio_after_crash", crashAt >= 0 && peakAfter > 0.01f);
- // the other inserts: with the kick (through the crashed slot) silent, the clap and the hat still play
- offline.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.0f; }, false);
- float othersPeak = 0.0f;
- render (offline, 1.0, peakOf (othersPeak));
- report << "other_inserts_peak=" << othersPeak << "\n";
- expect ("other_inserts_play", othersPeak > 0.01f);
- expect ("nothing_reloads_by_itself", offline.hostedPluginDown (where) && offline.getEffect (1, 0).get() == first);
- offline.editSong ([] (lynx::Song& s) { s.channels[0].volume = 0.85f; }, false);
- // the project saves with the settings the plugin had before it crashed, and opens again
- offline.capturePluginStates();
- expect ("state_kept", offline.getSong().mixer[1].effects[0].plugin.state == savedState);
- const auto file = tmp.getChildFile ("crashed.lynx");
- juce::String error;
- expect ("project_saved", lynx::ProjectFile::save (offline.getSong(), file, error) && file.existsAsFile());
- saved = lynx::ProjectFile::load (file, error);
- expect ("project_reopens", saved.has_value() && saved->mixer.size() > 1 && saved->mixer[1].effects.size() == 1
- && saved->mixer[1].effects[0].plugin.state == savedState);
- // Reload (the prompt's button, round 190ao): a new instance; the module's block count is past 40 now
- const auto running = offline.reloadHostedPlugins (down);
- auto* again = dynamic_cast<lynx::PluginEffect*> (offline.getEffect (1, 0).get());
- expect ("reloaded", running == 1 && again != nullptr && again != first && ! again->hasCrashed());
- float reloadedPeak = 0.0f;
- render (offline, 1.0, peakOf (reloadedPeak));
- report << "reloaded_peak=" << reloadedPeak << "\n";
- expect ("reloaded_plays", reloadedPeak > 0.01f && lynx::pluginCrashCount() == crashesBefore + 1 && again != nullptr && ! again->hasCrashed());
- }
- // the saved project opens again with the plugin crashing on its saved settings: left out, the rest plays, the
- // settings stay in the project
- setEnv ("LYNX_TEST_CRASH", "state");
- if (saved.has_value())
- {
- lynx::AudioEngine reopened (false);
- reopened.getPluginHost().addPluginFile (juce::File (pluginPath));
- const auto before = lynx::pluginCrashCount();
- reopened.setSong (*saved);
- float reopenedPeak = 0.0f;
- render (reopened, 1.0, peakOf (reopenedPeak));
- const auto crashes = lynx::pluginCrashes();
- report << "reopened_peak=" << reopenedPeak << "\n";
- if (reopened.getPluginHost().getLoadFailures().size() > 0)
- report << "load_failures=" << reopened.getPluginHost().getLoadFailures().joinIntoString (" | ") << "\n";
- expect ("state_crash_caught", lynx::pluginCrashCount() == before + 1 && ! crashes.empty() && crashes.back().onLoad);
- expect ("state_crash_left_out", dynamic_cast<lynx::PluginEffect*> (reopened.getEffect (1, 0).get()) == nullptr);
- expect ("state_crash_project_plays", reopenedPeak > 0.01f);
- reopened.capturePluginStates();
- expect ("state_crash_settings_kept", reopened.getSong().mixer[1].effects.size() == 1
- && reopened.getSong().mixer[1].effects[0].plugin.state == savedState);
- }
- setEnv ("LYNX_TEST_CRASH", "");
- // LYNX's own faults inside a guarded call stay crashes (child processes; the selftest runs the same)
- const auto own = faultReportSelfTest();
- report << "own_faults=" << own << "\n";
- ok = ok && ! own.startsWith ("ERROR");
- report << "plugin_crashes=" << lynx::pluginCrashCount() << "\n";
- for (const auto& c : lynx::pluginCrashes())
- report << " crashed: " << c.plugin << " (" << lynx::crashguard::describe (c.code) << (c.onLoad ? ", loading its state" : "") << ")\n";
- tmp.deleteRecursively();
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --mpetest "LYNX Test MPE.clap" report.txt (tools/testplugin/lynx_test_mpe.c, issue #108): a hosted CLAP
- // instrument with the wrapper's MPE switch on gets each note on its own member channel, its fine pitch / Mod X /
- // Mod Y as tuning / brightness / pressure note expressions before the note on, and a sounding note's expression
- // on that note's channel alone. The plugin writes down what it received; no window, no audio device.
- // Round 190hy: see --mpeplaytest190hy. Note A (C4, 1 s): its pitch curve holds 0 for 0.5 s, rises an octave over
- // 0.25 s and holds it; then note B (G4, 0.5 s), no curve: it must not inherit A's bend. The frequencies come from the
- // rendered audio's zero crossings (a silent logging plugin: its log shows the expressions instead).
- void runMpePlayTest190hy (const juce::String& pluginPath, const juce::String& reportPath)
- {
- const auto log = juce::File (reportPath).getSiblingFile (juce::File (reportPath).getFileNameWithoutExtension() + "-plugin.txt");
- log.deleteFile();
- #if JUCE_WINDOWS
- _putenv_s ("LYNX_TEST_MPE_REPORT", log.getFullPathName().toRawUTF8());
- #else
- setenv ("LYNX_TEST_MPE_REPORT", log.getFullPathName().toRawUTF8(), 1);
- #endif
- juce::String report;
- auto ok = false;
- const auto wavFile = juce::File (reportPath).withFileExtension ("wav");
- constexpr double rate = 44100.0;
- {
- lynx::AudioEngine offline (false);
- auto& host = offline.getPluginHost();
- report << "plugins_in_file=" << host.addPluginFile (juce::File (pluginPath)) << "\n";
- const auto wanted = juce::File (pluginPath).hasFileExtension ("clap") ? "CLAP" : "VST3";
- std::optional<juce::PluginDescription> type;
- for (const auto& t : host.getKnownPlugins().getTypes())
- if (t.pluginFormatName == wanted && t.isInstrument && ! type)
- type = t;
- report << "format=" << wanted << " found=" << (type ? type->name : juce::String ("none")) << "\n";
- if (type)
- {
- lynx::Song s;
- s.mixer = lynx::Song::defaultMixer (2);
- s.bpm = 120.0;
- lynx::ChannelDef c;
- c.name = type->name.toStdString();
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin.id = type->createIdentifierString().toStdString();
- c.plugin.name = type->name.toStdString();
- c.plugin.mpe = true;
- c.mixerTrack = 1;
- s.channels.push_back (c);
- s.patterns.emplace_back();
- auto& p = s.patterns[0];
- lynx::Note a;
- a.channel = 0;
- a.key = 60;
- a.length = 2 * lynx::ppq;
- a.velocity = 0.8f;
- lynx::NoteCurves curves;
- curves.lane (lynx::NoteCurveLane::pitch) = { { 0.0f, 0.0f }, { (float) lynx::ppq, 0.0f }, { 1.5f * (float) lynx::ppq, 1200.0f },
- { 2.0f * (float) lynx::ppq, 1200.0f } };
- a.curves = curves;
- auto b = a;
- b.key = 67;
- b.start = 2 * lynx::ppq;
- b.length = lynx::ppq;
- b.curves.clear();
- p.notes = { a, b };
- p.lengthTicks = 16 * lynx::ppq; // (one pass: the notes play once in the 1.2 s rendered)
- offline.setSong (std::move (s));
- wavFile.deleteFile();
- juce::WavAudioFormat wav;
- std::unique_ptr<juce::AudioFormatWriter> writer (wav.createWriterFor (wavFile.createOutputStream().release(), rate, 2, 24, {}, 0));
- const auto peak = writer != nullptr ? offline.renderOffline (1.6, rate, writer.get()) : 0.0f;
- writer.reset();
- report << "peak=" << peak << "\n";
- ok = writer == nullptr && wavFile.existsAsFile();
- }
- } // (the plugin writes its log, if any, as it is destroyed)
- // the frequency of [from, to) seconds of the left channel from its rising zero crossings
- juce::AudioBuffer<float> audio;
- {
- juce::AudioFormatManager formats;
- formats.registerBasicFormats();
- if (std::unique_ptr<juce::AudioFormatReader> reader (formats.createReaderFor (wavFile)); reader != nullptr)
- {
- audio.setSize (1, (int) reader->lengthInSamples);
- reader->read (&audio, 0, (int) reader->lengthInSamples, 0, true, false);
- }
- }
- const auto frequency = [&audio] (double from, double to) {
- const auto* x = audio.getReadPointer (0);
- const auto n = audio.getNumSamples();
- long first = -1, last = -1;
- auto crossings = 0;
- for (auto i = juce::jmax (1, (int) (from * rate)); i < juce::jmin (n, (int) (to * rate)); ++i)
- if (x[i - 1] <= 0.0f && x[i] > 0.0f)
- {
- if (first < 0)
- first = i;
- else
- ++crossings, last = i;
- }
- return crossings > 0 ? crossings * rate / (double) (last - first) : 0.0;
- };
- if (audio.getNumSamples() > 0 && audio.getMagnitude (0, 0, audio.getNumSamples()) > 0.001f)
- {
- const auto before = frequency (0.1, 0.45), during = frequency (0.55, 0.7), after = frequency (0.8, 0.98), next = frequency (1.1, 1.45);
- report << "a_before_hz=" << before << " a_rising_hz=" << during << " a_after_hz=" << after << " b_hz=" << next << "\n";
- report << "a_after_over_before=" << (before > 0.0 ? after / before : 0.0) << " (an octave: 2)\n";
- report << "b_over_a_before=" << (before > 0.0 ? next / before : 0.0) << " (a fifth: 1.498)\n";
- }
- else
- report << "audio=silent\n";
- if (log.existsAsFile())
- report << "--- plugin log ---\n" << log.loadFileAsString();
- report << "result=" << (ok ? "RENDERED" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- void runMpeTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- const auto log = juce::File (reportPath).getSiblingFile (juce::File (reportPath).getFileNameWithoutExtension() + "-plugin.txt");
- log.deleteFile();
- #if JUCE_WINDOWS
- _putenv_s ("LYNX_TEST_MPE_REPORT", log.getFullPathName().toRawUTF8());
- #else
- setenv ("LYNX_TEST_MPE_REPORT", log.getFullPathName().toRawUTF8(), 1);
- #endif
- juce::String report;
- auto failures = 0;
- {
- lynx::AudioEngine engine (false);
- auto& host = engine.getPluginHost();
- report << "plugins_in_file=" << host.addPluginFile (juce::File (pluginPath)) << "\n";
- std::optional<juce::PluginDescription> clap;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (type.pluginFormatName == "CLAP" && juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName())
- clap = type;
- lynx::PluginRef ref;
- if (clap)
- {
- ref.id = clap->createIdentifierString().toStdString();
- ref.name = clap->name.toStdString();
- }
- ref.mpe = true;
- juce::String error;
- auto instrument = clap ? host.makeInstrument (ref, 48000.0, &error) : nullptr;
- report << "instrument_loaded=" << (instrument != nullptr ? "yes" : "no") << (error.isNotEmpty() ? " (" + error + ")" : juce::String()) << "\n";
- if (instrument != nullptr)
- {
- std::vector<float> l (256), r (256);
- auto block = [&] { instrument->render (l.data(), r.data(), 256, 1.0f, 1.0f); };
- block(); // (the zone's setup)
- instrument->setNextNoteFinePitch (30.0f); // +30 cents
- instrument->setNextNoteModulation (0.75f, 1.0f); // timbre 0.75, full pressure
- instrument->noteOn (60, 0.8f);
- instrument->noteOn (64, 0.5f); // a second note: its own channel, centre values
- block();
- instrument->noteExpression (60, (int) lynx::vfx::Prop::pitch, 200.0f, 0.0f);
- instrument->noteExpression (64, (int) lynx::vfx::Prop::modX, 0.25f, 0.0f);
- instrument->noteExpression (60, (int) lynx::vfx::Prop::modY, 0.75f, 0.0f);
- block();
- instrument->noteOff (60);
- instrument->noteOff (64);
- block();
- }
- else
- ++failures;
- } // (the plugin writes its log as it is destroyed)
- struct Line
- {
- juce::String kind;
- int a = 0, b = 0, c = 0, d = 0;
- };
- std::vector<Line> lines;
- for (const auto& text : juce::StringArray::fromLines (log.loadFileAsString()))
- {
- const auto t = juce::StringArray::fromTokens (text, " ", "");
- if (t.size() >= 3)
- lines.push_back ({ t[0], t[1].getIntValue(), t[2].getIntValue(), t.size() > 3 ? t[3].getIntValue() : 0, t.size() > 4 ? t[4].getIntValue() : 0 });
- }
- report << "plugin_events=" << (int) lines.size() << "\n";
- // the first line at or after `from` that matches (−1 = none); `value` within `tolerance` (thousandths)
- auto find = [&lines] (const juce::String& kind, int a, int b, int value, int tolerance, int from = 0) {
- for (auto i = (std::size_t) from; i < lines.size(); ++i)
- {
- const auto& x = lines[i];
- const auto v = kind == "expr" ? x.d : x.c;
- if (x.kind == kind && x.a == a && x.b == b && std::abs (v - value) <= tolerance)
- return (int) i;
- }
- return -1;
- };
- auto check = [&] (const char* what, bool ok) {
- report << what << "=" << (ok ? "ok" : "FAILED") << "\n";
- failures += ok ? 0 : 1;
- };
- // (CLAP expression ids: 2 tuning in semitones, 5 brightness, 6 pressure; channels 0-based: the first member = 1)
- const auto on60 = find ("on", 1, 60, 800, 5), on64 = find ("on", 2, 64, 500, 5);
- check ("zone_setup_sent", find ("midi", 176, 6, 15, 0) >= 0 && find ("midi", 177, 6, 48, 0) >= 0);
- check ("notes_on_their_own_channels", on60 >= 0 && on64 > on60);
- const auto tune = find ("expr", 2, 1, 300, 3), bright = find ("expr", 5, 1, 756, 4), press = find ("expr", 6, 1, 1000, 1);
- check ("expression_before_the_note_on", tune >= 0 && bright >= 0 && press >= 0 && tune < on60 && bright < on60 && press < on60);
- check ("second_note_starts_centred", find ("expr", 2, 2, 0, 1) >= 0 && find ("expr", 5, 2, 504, 4) >= 0 && find ("expr", 6, 2, 0, 1) >= 0);
- const auto later = std::max (on60, on64) + 1;
- check ("sounding_note_expression", later > 0 && find ("expr", 2, 1, 2000, 3, later) >= 0 && find ("expr", 5, 2, 252, 4, later) >= 0
- && find ("expr", 6, 1, 504, 4, later) >= 0);
- check ("other_note_untouched", later > 0 && find ("expr", 2, 2, 2000, 3, later) < 0 && find ("expr", 6, 2, 504, 4, later) < 0);
- check ("notes_off_on_their_channels", find ("off", 1, 60, 0, 100000) >= 0 && find ("off", 2, 64, 0, 100000) >= 0);
- auto expressionAsMidi = false; // (a CLAP-dialect plugin gets no raw bend / pressure / CC 74 on a member channel)
- for (const auto& x : lines)
- if (x.kind == "midi" && (x.a & 0x0f) != 0 && ((x.a & 0xf0) == 0xe0 || (x.a & 0xf0) == 0xd0 || ((x.a & 0xf0) == 0xb0 && x.b == 74)))
- expressionAsMidi = true;
- check ("no_duplicate_midi_expression", ! expressionAsMidi);
- report << "--- plugin log ---\n" << log.loadFileAsString() << "result=" << (failures == 0 ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (failures == 0 ? 0 : 1);
- quit();
- }
- // LYNX.exe --claprestarttest "LYNX Test Restart.clap" report.txt (tools/testplugin/lynx_test_restart.c, PR #29): a
- // CLAP effect on the Master that asks for a restart every 8 blocks while an export renders on a thread of its own
- // (the message thread is free to run the restarts, as with the Export window). The plugin aborts the process when
- // start / stop_processing run off the audio thread or activate / deactivate off the main thread (issue #46, as u-he
- // Presswerk does; an export at 44.1 kHz and prepare calls from the export's thread check the latter) and counts deactivations that
- // landed inside its process() call (must be none), the restarts must happen, and the delay compensation must end on
- // the latency the plugin reports after its last restart.
- void runClapRestartTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- struct Run
- {
- std::unique_ptr<lynx::AudioEngine> engine;
- juce::String report;
- int slot = -1;
- std::thread render;
- std::atomic<bool> done { false };
- double renderSeconds = 0.0;
- };
- auto run = std::make_shared<Run>();
- const auto counters = juce::File (reportPath).getSiblingFile (juce::File (reportPath).getFileNameWithoutExtension() + "-plugin.txt");
- counters.deleteFile();
- #if JUCE_WINDOWS
- _putenv_s ("LYNX_TEST_RESTART_REPORT", counters.getFullPathName().toRawUTF8());
- #else
- setenv ("LYNX_TEST_RESTART_REPORT", counters.getFullPathName().toRawUTF8(), 1);
- #endif
- const auto fail = [this, reportPath] (juce::String report) {
- report << "result=FAILED\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (1);
- quit();
- };
- run->engine = std::make_unique<lynx::AudioEngine> (false);
- auto& host = run->engine->getPluginHost();
- run->report << "plugins_in_file=" << host.addPluginFile (juce::File (pluginPath)) << "\n";
- std::optional<juce::PluginDescription> clap;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (type.pluginFormatName == "CLAP" && juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName())
- clap = type;
- if (! clap)
- {
- fail (run->report + "no CLAP plugin in the file\n");
- return;
- }
- auto song = lynx::Song::makeDefault();
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::plugin;
- slot.plugin.id = clap->createIdentifierString().toStdString();
- slot.plugin.name = clap->name.toStdString();
- slot.smartDisable = false; // (processed every block, as with music playing: the export itself is silent)
- song.mixer[0].effects = { slot }; // alone on the Master: the delay compensation is the plugin's latency
- run->slot = (int) song.mixer[0].effects.size() - 1;
- run->engine->setSong (song);
- run->engine->renderOffline (0.1, 48000.0); // builds the rack (and the plugin) on the message thread
- if (dynamic_cast<lynx::PluginEffect*> (run->engine->getEffect (0, run->slot).get()) == nullptr)
- {
- fail (run->report + "effect_loaded=no\n");
- return;
- }
- auto effect = std::dynamic_pointer_cast<lynx::PluginEffect> (run->engine->getEffect (0, run->slot));
- run->render = std::thread ([run, effect] () mutable {
- const auto start = juce::Time::getMillisecondCounterHiRes();
- run->engine->renderOffline (30.0, 48000.0);
- run->renderSeconds = (juce::Time::getMillisecondCounterHiRes() - start) * 0.001;
- // issue #46: an export at another rate / block size prepares the plugin from the export's thread; the
- // plugin aborts unless activate / deactivate reach the main thread
- auto& instance = effect->getInstance();
- instance.prepareToPlay (44100.0, 1024);
- instance.releaseResources();
- instance.prepareToPlay (48000.0, 512);
- run->engine->renderOffline (3.0, 44100.0); // (the engine rebuilds its rack at that rate)
- // The engine has replaced this instance (made for 48 kHz) by then, so this is its last reference: it is
- // deleted here, on the export's thread, and its deactivate / destroy go to the message thread, which this
- // waits for. That has to happen before `done`: once the message thread sees it, it blocks in join() until
- // this thread ends, and an instance deleted after that waited 10 s for it and then deactivated the plugin
- // right here, off the main thread (the plugin aborts: about 1 run in 40 under load, round 190au).
- effect.reset();
- run->done = true;
- });
- // after the render: a second for the restarts still queued and the engine's timer (the new PDC plan)
- auto finish = std::make_shared<std::function<void()>>();
- *finish = [this, run, counters, reportPath, fail, finish] {
- if (! run->done)
- {
- juce::Timer::callAfterDelay (50, *finish);
- return;
- }
- run->render.join();
- juce::Timer::callAfterDelay (1000, [this, run, counters, reportPath, fail] {
- auto report = run->report;
- int pluginLatency = -1;
- if (const auto effect = run->engine->getEffect (0, run->slot)) // (not held past the engine's reset)
- pluginLatency = effect->latencySamples();
- const auto pdc = run->engine->getLatencySamples();
- report << "render_seconds=" << juce::String (run->renderSeconds, 2) << "\n"
- << "plugin_latency=" << pluginLatency << "\npdc_total=" << pdc << "\n"
- << "plugin_crashes=" << lynx::pluginCrashCount() << "\n";
- run->engine.reset(); // destroys the plugin: it writes its counters
- // one line per plugin instance (the engine may have made more than one): none may have been
- // deactivated inside process(), and the one that rendered must have restarted
- int overlapped = 0, inactive = 0, requests = 0, activations = 0, lines = 0, wrongThread = 0, misordered = 0, unstopped = 0;
- bool otherRate = false;
- for (const auto& line : juce::StringArray::fromLines (counters.loadFileAsString()))
- {
- juce::StringPairArray values;
- for (const auto& token : juce::StringArray::fromTokens (line, " ", ""))
- if (token.contains ("="))
- values.set (token.upToFirstOccurrenceOf ("=", false, false), token.fromFirstOccurrenceOf ("=", false, false));
- if (values.size() == 0)
- continue;
- ++lines;
- report << "instance: " << line << "\n";
- overlapped += values["overlapped"].getIntValue();
- inactive += values["inactive_blocks"].getIntValue();
- // issue #46: activate / deactivate on the main thread, start / stop_processing on the audio thread
- // (the plugin aborts the process otherwise, as u-he's do), in order, every start stopped
- wrongThread += values["wrong_thread"].getIntValue();
- misordered += values["misordered"].getIntValue();
- unstopped += values["starts"].getIntValue() - values["stops"].getIntValue();
- otherRate = otherRate || values["last_rate"].getIntValue() == 44100;
- if (values["requests"].getIntValue() > requests)
- {
- requests = values["requests"].getIntValue();
- activations = values["activations"].getIntValue();
- }
- }
- report << "wrong_thread=" << wrongThread << "\nmisordered=" << misordered << "\nunstopped=" << unstopped
- << "\nactivated_at_44100=" << (otherRate ? "yes" : "no") << "\n";
- const auto ok = lines > 0 && requests > 0 && activations > requests / 2 && overlapped == 0 && inactive == 0
- && wrongThread == 0 && misordered == 0 && unstopped == 0 && otherRate
- && pluginLatency > 0 && pdc == pluginLatency && lynx::pluginCrashCount() == 0;
- if (! ok)
- {
- fail (report);
- return;
- }
- report << "result=OK\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (0);
- quit();
- });
- };
- juce::Timer::callAfterDelay (50, *finish);
- }
- // LYNX.exe --vst2test "LYNX Test Synth.dll" report.txt (tools/testplugin/lynx_test_vst2.c): LYNX's own VST2 host.
- // Scans the DLL, imports it the way an .flp holds it (Fruity Wrapper VST2 state with a chunk, REA_rodada89 §2),
- // renders with two saved gains (the level must follow the restored state) and checks the plugin saw the song tempo.
- void runVst2Test (const juce::String& pluginPath, const juce::String& reportPath)
- {
- juce::String report;
- bool ok = false;
- {
- lynx::AudioEngine offline (false);
- auto& host = offline.getPluginHost();
- report << "plugins_in_file=" << host.addPluginFile (juce::File (pluginPath)) << "\n";
- std::optional<juce::PluginDescription> vst2;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (type.pluginFormatName == "VST")
- vst2 = type;
- auto render = [&] (float gain, float& tempoSeen, int& adopted) {
- lynx::FlVst2State state;
- state.flags = 8;
- state.chunk = { 'L', 'X', 'V', '2', 0, 0, 0, 0 };
- std::memcpy (state.chunk.data() + 4, &gain, 4);
- auto song = lynx::Song::makeDefault();
- song.bpm = 137.0;
- auto& f = song.channels[4].plugin.foreign;
- f.format = lynx::ForeignPlugin::Format::vst2;
- f.vst2Id = (std::uint32_t) vst2->uniqueId;
- f.name = "Some other name"; // found by the VST2 ID
- f.state = lynx::writeFlVst2State (state);
- song.channels[4].volume = 1.0f;
- song.patterns[0].notes.clear();
- song.patterns[0].notes.push_back ({ 0, 4 * lynx::ppq, 4, 69, 1.0f });
- for (std::size_t c = 0; c < song.channels.size(); ++c)
- if (c != 4)
- song.channels[c].muted = true;
- adopted = host.adoptFlPlugins (song);
- offline.setSong (song);
- const auto peak = offline.renderOffline (1.0, 48000.0);
- offline.capturePluginStates();
- juce::MemoryBlock saved;
- saved.fromBase64Encoding (juce::String (offline.getSong().channels[4].plugin.state));
- lynx::FlVst2State back;
- tempoSeen = 0.0f;
- if (lynx::parseFlVst2State (std::vector<std::uint8_t> ((const std::uint8_t*) saved.getData(), (const std::uint8_t*) saved.getData() + saved.getSize()), back)
- && back.chunk.size() >= 12)
- std::memcpy (&tempoSeen, back.chunk.data() + 8, 4);
- return peak;
- };
- if (vst2)
- {
- report << "plugin=" << vst2->name << " id=" << vst2->uniqueId << " instrument=" << (int) vst2->isInstrument << "\n";
- float tempoA = 0, tempoB = 0;
- int adoptedA = 0, adoptedB = 0;
- const auto quiet = render (0.1f, tempoA, adoptedA);
- const auto loud = render (0.4f, tempoB, adoptedB);
- report << "adopted=" << adoptedA << "," << adoptedB << " peak_gain_0.1=" << quiet << " peak_gain_0.4=" << loud
- << " tempo_seen=" << tempoB * 1000.0f << "\n";
- ok = adoptedA == 1 && adoptedB == 1 && quiet > 0.01f && std::abs (loud / quiet - 4.0f) < 0.2f
- && std::abs (tempoB * 1000.0f - 137.0f) < 0.01f;
- }
- }
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX --vst3noteidtest "LYNX Test Synth.vst3" report.txt (round 190fg, cmake/LynxPatchJuce.cmake fix 26): the VST3
- // test synth (tools/testplugin/lynx_test_synth_vst3.cpp: voices kept by noteId, its log the ids it got) plays two
- // overlapping pairs of one key on one channel: FIFO (A 0-4, B 2-6 beats, key 60) and LIFO (C 8-14, D 10-12, key 64).
- // Each note off must carry its own note on's id (FL: each note ends its own voice, round 190ej): the inner note D's
- // end ends D. A second render with the tag hook off shows fix 14 alone (the oldest id: D's end carries C's id).
- void runVst3NoteIdTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- juce::String report;
- bool ok = false;
- const auto logBase = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-noteid-" + juce::String (juce::Time::currentTimeMillis()));
- // (read by each new instance)
- #if JUCE_WINDOWS
- _putenv_s ("LYNX_TEST_SYNTH_LOG", logBase.getFullPathName().toRawUTF8());
- #else
- setenv ("LYNX_TEST_SYNTH_LOG", logBase.getFullPathName().toRawUTF8(), 1);
- #endif
- struct E
- {
- bool on = false;
- int key = 0, id = -1;
- };
- // (the lines each render added: a running instance keeps its log file open, so the files stay until the end)
- std::map<juce::String, int> linesRead;
- const auto readLog = [&logBase, &linesRead] {
- std::vector<E> events;
- for (const auto& f : logBase.getParentDirectory().findChildFiles (juce::File::findFiles, false, logBase.getFileName() + ".*"))
- {
- juce::StringArray lines;
- f.readLines (lines);
- auto& done = linesRead[f.getFullPathName()];
- for (int i = done; i < lines.size(); ++i)
- {
- const auto p = juce::StringArray::fromTokens (lines[i], " ", {});
- if (p.size() >= 5 && p[0].startsWith ("E"))
- events.push_back ({ p[1] == "on", p[2].getIntValue(), p[4].getIntValue() });
- }
- done = lines.size() - (lines.isEmpty() || lines[lines.size() - 1].isNotEmpty() ? 0 : 1);
- }
- return events;
- };
- {
- lynx::AudioEngine offline (false);
- auto& host = offline.getPluginHost();
- report << "plugins_in_file=" << host.addPluginFile (juce::File (pluginPath)) << "\n";
- std::optional<juce::PluginDescription> vst3;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (type.pluginFormatName == "VST3" && type.isInstrument)
- vst3 = type;
- const auto render = [&] (bool tags) {
- auto song = lynx::Song::makeDefault();
- song.bpm = 120.0;
- auto& c = song.channels[0];
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin.id = vst3->createIdentifierString().toStdString();
- c.plugin.name = vst3->name.toStdString();
- for (std::size_t k = 1; k < song.channels.size(); ++k)
- song.channels[k].muted = true;
- auto& notes = song.patterns[0].notes;
- notes.clear();
- const auto beat = (std::int64_t) lynx::ppq;
- notes.push_back ({ 0, 4 * beat, 0, 60, 0.8f }); // A
- notes.push_back ({ 2 * beat, 4 * beat, 0, 60, 0.8f }); // B
- notes.push_back ({ 8 * beat, 6 * beat, 0, 64, 0.8f }); // C
- notes.push_back ({ 10 * beat, 2 * beat, 0, 64, 0.8f }); // D (inside C)
- song.patterns[0].sortNotes();
- song.patterns[0].lengthTicks = 16 * beat;
- offline.setSong (song);
- offline.dispatchPendingMessages();
- if (! tags)
- juce::lynxNoteTagHook = nullptr; // (fix 14 alone: the oldest sounding id; the next instance sets it again)
- offline.renderOffline (7.9, 48000.0); // (C ends at 7 s; the 8 s pattern does not loop yet)
- return readLog();
- };
- const auto check = [&report] (const char* name, const std::vector<E>& events, bool expectOwn) {
- // ons and offs of each key in the order the plugin got them
- std::map<int, std::vector<int>> ons, offs;
- for (const auto& e : events)
- (e.on ? ons : offs)[e.key].push_back (e.id);
- const auto& a = ons[60]; const auto& o60 = offs[60];
- const auto& c = ons[64]; const auto& o64 = offs[64];
- report << name << ": key 60 ons";
- for (auto id : a) report << " " << id;
- report << " offs";
- for (auto id : o60) report << " " << id;
- report << "; key 64 ons";
- for (auto id : c) report << " " << id;
- report << " offs";
- for (auto id : o64) report << " " << id;
- report << "\n";
- if (a.size() != 2 || o60.size() != 2 || c.size() != 2 || o64.size() != 2 || a[0] < 0 || c[0] < 0)
- return false;
- const auto fifo = o60[0] == a[0] && o60[1] == a[1]; // A ends first: A's id either way
- // LIFO: D (c[1]) ends first; its own id with the tags, C's (the oldest) without
- const auto lifo = expectOwn ? (o64[0] == c[1] && o64[1] == c[0]) : (o64[0] == c[0] && o64[1] == c[1]);
- return fifo && lifo;
- };
- if (vst3)
- {
- report << "plugin=" << vst3->name << "\n";
- const auto withTags = render (true);
- const auto okTags = check ("with_tags", withTags, true);
- const auto withoutTags = render (false);
- const auto okBefore = check ("fix14_only", withoutTags, false);
- report << "own_ids=" << (okTags ? "yes" : "NO") << " fix14_only_oldest=" << (okBefore ? "yes" : "NO") << "\n";
- ok = okTags && okBefore;
- }
- }
- if (ok) // (a failure leaves the logs for a look: their path is in the report)
- for (const auto& f : logBase.getParentDirectory().findChildFiles (juce::File::findFiles, false, logBase.getFileName() + ".*"))
- f.deleteFile();
- else
- report << "synth_logs=" << logBase.getFullPathName() << ".*\n";
- #if JUCE_WINDOWS
- _putenv_s ("LYNX_TEST_SYNTH_LOG", "");
- #else
- unsetenv ("LYNX_TEST_SYNTH_LOG");
- #endif
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // Round 181c: a wrapper MIDI option changed on a running plugin must act like the same option on a new one. For each
- // option: a control engine whose plugin is created with the option set (proves the test can see it), then an engine
- // whose plugin is already running when the option changes through editSong, as the wrapper page does it. What the
- // plugin received comes from the test plugin's own log. The running instance must also stay the same one.
- void runWrapperMidiTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- juce::String report;
- auto ok = true;
- const juce::File logFile (juce::SystemStats::getEnvironmentVariable ("LYNX_TEST_VST2_MIDILOG", {}));
- struct Event { juce::String instance; int status, data1, data2; };
- auto take = [&] {
- std::vector<Event> out;
- juce::StringArray lines;
- logFile.readLines (lines);
- for (const auto& line : lines)
- {
- const auto p = juce::StringArray::fromTokens (line, " ", {});
- if (p.size() == 4)
- out.push_back ({ p[0], p[1].getIntValue(), p[2].getIntValue(), p[3].getIntValue() });
- }
- logFile.deleteFile();
- return out;
- };
- auto count = [] (const std::vector<Event>& events, int status, int data1, int data2) {
- int n = 0;
- for (const auto& e : events)
- n += (e.status & 0xF0) == status && (data1 < 0 || e.data1 == data1) && (data2 < 0 || e.data2 == data2) ? 1 : 0;
- return n;
- };
- struct Option
- {
- const char* name;
- std::function<void (lynx::PluginRef&)> before, change;
- std::function<juce::String (const std::vector<Event>&)> seen;
- };
- const Option options[] = {
- { "Send note release velocity off", {}, [] (lynx::PluginRef& r) { r.releaseVelocity = false; },
- [&] (const std::vector<Event>& e) { return "offs_with_release_32=" + juce::String (count (e, 0x80, 69, 32)) + " offs_at_0=" + juce::String (count (e, 0x80, 69, 0)); } },
- { "Send pitch bend range on", {}, [] (lynx::PluginRef& r) { r.sendBendRange = true; },
- [&] (const std::vector<Event>& e) { return "rpn_range_12=" + juce::String (count (e, 0xB0, 6, 12)); } },
- { "Pitch bend range 24", [] (lynx::PluginRef& r) { r.sendBendRange = true; }, [] (lynx::PluginRef& r) { r.bendRange = 24; },
- [&] (const std::vector<Event>& e) { return "rpn_range_24=" + juce::String (count (e, 0xB0, 6, 24)); } },
- { "Send MOD X as polyphonic aftertouch on", {}, [] (lynx::PluginRef& r) { r.modXAftertouch = true; },
- [&] (const std::vector<Event>& e) { return "aftertouch=" + juce::String (count (e, 0xA0, 69, -1)); } },
- { "Send All Notes Off when playback stops off", {}, [] (lynx::PluginRef& r) { r.allNotesOffOnStop = false; },
- [&] (const std::vector<Event>& e) { return "cc123=" + juce::String (count (e, 0xB0, 123, -1)); } },
- };
- // each phase has its own engine: an engine keeps the running instance across setSong, so one engine would
- // carry the control's plugin into the "before" phase
- lynx::AudioEngine scanner (false);
- auto& host = scanner.getPluginHost();
- report << "plugins_in_file=" << host.addPluginFile (juce::File (pluginPath)) << "\n";
- std::optional<juce::PluginDescription> vst2;
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (type.pluginFormatName == "VST")
- vst2 = type;
- if (! vst2 || logFile.getFullPathName().isEmpty())
- ok = false;
- else
- for (const auto& option : options)
- {
- auto makeSong = [&] (bool changed) {
- auto song = lynx::Song::makeDefault();
- auto& channel = song.channels[0];
- channel.instrument = lynx::InstrumentKind::plugin;
- channel.plugin = {};
- channel.plugin.id = vst2->createIdentifierString().toStdString();
- channel.plugin.name = vst2->name.toStdString();
- if (option.before)
- option.before (channel.plugin);
- if (changed)
- option.change (channel.plugin);
- song.patterns[0].notes.clear();
- lynx::Note note;
- note.start = 0;
- note.length = lynx::ppq;
- note.channel = 0;
- note.key = 69;
- note.velocity = 1.0f;
- note.release = 0.25f; // 32 of 127
- note.modX = 0.75f;
- song.patterns[0].notes.push_back (note);
- for (std::size_t c = 1; c < song.channels.size(); ++c)
- song.channels[c].muted = true;
- return song;
- };
- // a block of the song, then a note held across "playback stopped", as the options act on either
- auto play = [&] (lynx::AudioEngine& engine) {
- logFile.deleteFile();
- engine.renderOffline (1.0, 48000.0);
- if (auto instrument = engine.getChannelInstrument (0))
- {
- instrument->noteOn (60, 1.0f);
- instrument->transportStopped();
- }
- engine.renderOffline (0.1, 48000.0);
- return take();
- };
- auto newEngine = [&] {
- auto engine = std::make_unique<lynx::AudioEngine> (false);
- engine->getPluginHost().addPluginFile (juce::File (pluginPath));
- return engine;
- };
- std::vector<Event> control;
- {
- auto engine = newEngine();
- engine->setSong (makeSong (true));
- control = play (*engine);
- }
- auto engine = newEngine();
- engine->setSong (makeSong (false));
- const auto before = play (*engine);
- const auto instrumentBefore = engine->getChannelInstrument (0).get();
- engine->capturePluginStates(); // as the wrapper page does
- engine->editSong ([&] (lynx::Song& song) { option.change (song.channels[0].plugin); });
- const auto after = play (*engine);
- const auto sameInstance = engine->getChannelInstrument (0).get() == instrumentBefore;
- // the counts differ between phases (how many blocks the note spans, how many instances the phase made):
- // what matters is whether each kind of event is there at all
- auto shape = [] (const juce::String& seen) {
- juce::String out;
- for (const auto& token : juce::StringArray::fromTokens (seen, " ", {}))
- out << token.upToFirstOccurrenceOf ("=", false, false) << (token.fromFirstOccurrenceOf ("=", false, false).getIntValue() > 0 ? "=yes " : "=no ");
- return out;
- };
- auto instances = [] (const std::vector<Event>& events) {
- std::set<juce::String> made;
- for (const auto& e : events)
- made.insert (e.instance);
- return (int) made.size();
- };
- const auto a = option.seen (control) + " instances=" + juce::String (instances (control)),
- b = option.seen (before) + " instances=" + juce::String (instances (before)),
- c = option.seen (after) + " instances=" + juce::String (instances (after));
- const auto visible = shape (option.seen (control)) != shape (option.seen (before));
- const auto works = shape (option.seen (after)) == shape (option.seen (control));
- report << option.name << ": control " << a << " | before " << b << " | after the change " << c << " | same_instance=" << (int) sameInstance
- << " | test_sees_the_option=" << (int) visible << " | " << (! visible ? "NOT PROVEN" : works ? "acts on the plugin" : "DEAD until re-created") << "\n";
- ok = ok && visible && works;
- }
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --wrappershot "LYNX Test Drums.dll" <folder> (round 188d): the wrapper's Processing tab drawn offscreen
- // (no window, no focus) for the FL | LYNX review: wrap-default.png (a fresh plugin), wrap-automap.png (Auto map
- // outputs, output 3 off: FL's shot b23), wrap-settings.png. Scale 1.5 (FL's shots are at 150 %).
- // (round 190oh, --wrappershot190oh: the steps run from a timer, so the editors' windows get their messages)
- struct WrapperShot190oh final : juce::Timer
- {
- std::function<bool()> step; // false: done
- void timerCallback() override
- {
- if (! step())
- stopTimer();
- }
- };
- std::unique_ptr<WrapperShot190oh> wrapperShot190oh;
- void runWrapperShot190oh (const juce::String& pluginPath, const juce::String& folderPath, bool openEditors)
- {
- struct State
- {
- juce::File folder;
- juce::String report;
- bool ok = true;
- std::shared_ptr<lynx::AudioEngine> engine;
- std::optional<juce::PluginDescription> type;
- int phase = 0, wait = 0;
- void expect (const char* name, bool value)
- {
- report << name << "=" << (value ? 1 : 0) << "\n";
- ok = ok && value;
- }
- static lynx::PluginRef* find (lynx::Song& s)
- {
- return s.mixer.size() < 2 || s.mixer[1].effects.empty() ? nullptr : &s.mixer[1].effects[0].plugin;
- }
- std::shared_ptr<lynx::PluginEffect> effect() { return std::dynamic_pointer_cast<lynx::PluginEffect> (engine->getEffect (1, 0)); }
- bool save (const juce::String& name, float scale)
- {
- auto fx = effect();
- if (fx == nullptr)
- return false;
- const auto image = lynx::wrapperSettingsSnapshot (*engine, &State::find, fx->getInstance(), false, 0, scale, 1, 0);
- auto file = folder.getChildFile (name);
- file.deleteFile();
- juce::FileOutputStream out (file);
- return out.openedOk() && juce::PNGImageFormat().writeImageToStream (image, out);
- }
- void open()
- {
- if (auto fx = effect())
- {
- lynx::PluginWindows::WrapperContext context;
- context.engine = engine.get();
- context.find = &State::find;
- context.track = 1;
- context.slot = 0;
- lynx::PluginWindows::open (fx, fx->getInstance(), type->name, context);
- }
- }
- // what the open editor was marked with and (Windows) the DPI awareness of its window and of the windows
- // inside it (the plugin's own)
- void describe (const char* tag)
- {
- auto fx = effect();
- if (fx == nullptr)
- return;
- auto& instance = fx->getInstance();
- auto* editor = instance.getActiveEditor();
- report << tag << ".editor=" << (editor != nullptr ? 1 : 0);
- if (editor != nullptr)
- report << " size=" << editor->getWidth() << "x" << editor->getHeight()
- << " unaware_mark=" << (int) (bool) editor->getProperties()["lynxDpiUnaware"]
- << " dims_mark=" << (int) (bool) editor->getProperties()["lynxScaleEditorDimensions"];
- report << " docked=" << (int) lynx::PluginWindows::isDocked (instance);
- int windows = 0;
- if (const auto unaware = lynx::platform::dpiUnawareWindowCount (lynx::PluginWindows::hostWindowHandle (instance), windows); unaware >= 0)
- {
- report << " windows=" << windows << " unaware_windows=" << unaware;
- expect ((juce::String (tag) + "_unaware_as_set").toRawUTF8(),
- juce::String (tag) == "default" ? unaware == 0 : (windows > 0 && unaware == windows));
- }
- report << "\n";
- lynx::PluginWindows::close (instance);
- }
- void change()
- {
- engine->editSong ([] (lynx::Song& s) {
- s.mixer[1].effects[0].plugin.dpiAware = false;
- s.mixer[1].effects[0].plugin.scaleEditorDimensions = true;
- });
- engine->renderOffline (0.05, 48000.0); // ("DPI aware" reloads the plugin)
- }
- };
- auto st = std::make_shared<State>();
- st->folder = juce::File (folderPath);
- st->folder.createDirectory();
- st->engine = std::make_shared<lynx::AudioEngine> (false);
- st->engine->getPluginHost().addPluginFile (juce::File (pluginPath));
- for (const auto& t : st->engine->getPluginHost().getKnownPlugins().getTypes())
- if (! st->type && (juce::File (t.fileOrIdentifier) == juce::File (pluginPath) || juce::File (pluginPath).isAChildOf (juce::File (t.fileOrIdentifier))
- || juce::File (t.fileOrIdentifier).isAChildOf (juce::File (pluginPath))))
- st->type = t;
- st->expect ("plugin_found", st->type.has_value());
- if (st->type)
- {
- st->report << "plugin=" << st->type->name << " (" << st->type->pluginFormatName << ")\n";
- auto song = lynx::Song::makeDefault();
- auto slot = lynx::makeEffectSlot (lynx::EffectKind::plugin);
- slot.plugin.id = st->type->createIdentifierString().toStdString();
- slot.plugin.name = st->type->name.toStdString();
- song.mixer[1].effects = { slot };
- st->engine->setSong (song);
- st->engine->renderOffline (0.05, 48000.0);
- const auto* ref = State::find (const_cast<lynx::Song&> (st->engine->getSong()));
- st->expect ("fl_defaults", ref != nullptr && ref->dpiAware && ! ref->scaleEditorDimensions);
- st->expect ("shot_default_100", st->save ("gui-default.png", 1.0f));
- st->expect ("shot_default_150", st->save ("gui-default@150.png", 1.5f));
- }
- auto finish = [this, st] {
- st->folder.getChildFile ("report.txt").replaceWithText (st->report + "result=" + (st->ok ? "OK" : "FAIL") + "\n");
- st->engine.reset();
- setApplicationReturnValue (st->ok ? 0 : 1);
- quit();
- };
- if (! st->type || ! openEditors)
- {
- if (st->type)
- {
- st->change();
- st->expect ("shot_changed_100", st->save ("gui-changed.png", 1.0f));
- st->expect ("shot_changed_150", st->save ("gui-changed@150.png", 1.5f));
- }
- finish();
- return;
- }
- // with --open: open the editor (default settings), look after 1 s, close; change; open again, look, close
- wrapperShot190oh = std::make_unique<WrapperShot190oh>();
- wrapperShot190oh->step = [st, finish] {
- if (st->wait-- > 0)
- return true;
- switch (st->phase++)
- {
- case 0: st->open(); st->wait = 10; return true;
- case 1: st->describe ("default"); st->wait = 3; return true;
- case 2:
- st->change();
- st->expect ("shot_changed_100", st->save ("gui-changed.png", 1.0f));
- st->expect ("shot_changed_150", st->save ("gui-changed@150.png", 1.5f));
- st->open();
- st->wait = 10;
- return true;
- case 3: st->describe ("changed"); st->wait = 3; return true;
- default: finish(); return false;
- }
- };
- wrapperShot190oh->startTimer (100);
- }
- void runWrapperShot (const juce::String& pluginPath, const juce::String& folderPath)
- {
- const juce::File folder (folderPath);
- folder.createDirectory();
- auto ok = false;
- lynx::AudioEngine engine (false);
- engine.getPluginHost().addPluginFile (juce::File (pluginPath));
- std::optional<juce::PluginDescription> vst2;
- for (const auto& type : engine.getPluginHost().getKnownPlugins().getTypes())
- if (type.pluginFormatName == "VST" && juce::File (type.fileOrIdentifier) == juce::File (pluginPath))
- vst2 = type; // (the profile may know other test plugins)
- if (vst2 && ! vst2->isInstrument)
- {
- // an effect (round 188d): on insert 1, with insert 2 routed there as a sidechain (FL's k65 / k78 shots):
- // wrap-fx-default.png, wrap-fx-automap.png (Auto map inputs and outputs)
- auto song = lynx::Song::makeDefault();
- if (song.mixer.size() < 4)
- song.mixer.resize (4);
- auto slot = lynx::makeEffectSlot (lynx::EffectKind::plugin);
- slot.plugin.id = vst2->createIdentifierString().toStdString();
- slot.plugin.name = vst2->name.toStdString();
- song.mixer[1].effects = { slot };
- lynx::mixerops::sidechainTo (song, 2, 1);
- engine.setSong (song);
- engine.renderOffline (0.05, 48000.0);
- if (auto fx = std::dynamic_pointer_cast<lynx::PluginEffect> (engine.getEffect (1, 0)))
- {
- auto find = [] (lynx::Song& s) -> lynx::PluginRef* {
- return s.mixer.size() < 2 || s.mixer[1].effects.empty() ? nullptr : &s.mixer[1].effects[0].plugin;
- };
- auto save = [&] (const char* name) {
- const auto image = lynx::wrapperSettingsSnapshot (engine, find, fx->getInstance(), false, 1, 1.5f, 1, 0);
- juce::FileOutputStream out (folder.getChildFile (name));
- out.setPosition (0);
- out.truncate();
- return out.openedOk() && juce::PNGImageFormat().writeImageToStream (image, out);
- };
- ok = save ("wrap-fx-default.png");
- engine.editSong ([] (lynx::Song& s) {
- lynx::autoMapOutputs (s.mixer[1].effects[0].plugin.inputs, 2);
- lynx::autoMapOutputs (s.mixer[1].effects[0].plugin.outputs, 2);
- s.mixer[1].effects[0].sidechain = lynx::mixerops::sidechainIndexSource (s, 1, 1);
- });
- ok = ok && save ("wrap-fx-automap.png") && engine.getSong().mixer[1].effects[0].sidechain == 2;
- }
- }
- else if (vst2)
- {
- auto song = lynx::Song::makeDefault();
- auto& channel = song.channels[0];
- channel.instrument = lynx::InstrumentKind::plugin;
- channel.plugin = {};
- channel.plugin.id = vst2->createIdentifierString().toStdString();
- channel.plugin.name = vst2->name.toStdString();
- channel.mixerTrack = 5;
- engine.setSong (song);
- engine.renderOffline (0.05, 48000.0); // (the plugin is hosted by then)
- if (auto instrument = std::dynamic_pointer_cast<lynx::PluginInstrument> (engine.getChannelInstrument (0)))
- {
- auto find = [] (lynx::Song& s) -> lynx::PluginRef* { return s.channels.empty() ? nullptr : &s.channels[0].plugin; };
- auto save = [&] (const char* name, int tab) {
- const auto image = lynx::wrapperSettingsSnapshot (engine, find, instrument->getInstance(), true, tab, 1.5f);
- juce::FileOutputStream out (folder.getChildFile (name));
- out.setPosition (0);
- out.truncate();
- return out.openedOk() && juce::PNGImageFormat().writeImageToStream (image, out);
- };
- ok = save ("wrap-default.png", 1) && save ("wrap-settings.png", 0);
- engine.editSong ([] (lynx::Song& s) {
- lynx::autoMapOutputs (s.channels[0].plugin.outputs, 8);
- s.channels[0].plugin.outputs.resize (8);
- s.channels[0].plugin.outputs[2].active = 0;
- s.channels[0].plugin.processInactive = false; // (as an LED click does, FL's b23)
- });
- ok = ok && save ("wrap-automap.png", 1);
- }
- }
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --multiouttest "LYNX Test Drums.dll" report.txt (round 188d, issue #114): a multi-output VST2
- // (tools/testplugin/lynx_test_drums_vst2.c: key 36 = output 1 at 110 Hz, key 37 = output 2 at 220 Hz) on a
- // channel routed to insert 1; the wrapper's Processing › Connections as FL plays them [EXEC fl188d]: every output
- // on the channel's insert by default, an offset to another insert, an inactive output silent, the channel's
- // volume on all of them. Measured on the master with insert 1 muted or not.
- void runMultiOutTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- juce::String report;
- auto ok = true;
- lynx::AudioEngine scanner (false);
- report << "plugins_in_file=" << scanner.getPluginHost().addPluginFile (juce::File (pluginPath)) << "\n";
- std::optional<juce::PluginDescription> vst2;
- for (const auto& type : scanner.getPluginHost().getKnownPlugins().getTypes())
- if (type.pluginFormatName == "VST" && juce::File (type.fileOrIdentifier) == juce::File (pluginPath))
- vst2 = type; // (the profile may know other test plugins)
- struct Case
- {
- const char* name;
- std::vector<lynx::PluginOutputRoute> routes;
- bool muteInsert1;
- float volume;
- bool kick, snare; // expected on the master
- };
- const Case cases[] = {
- { "defaults", {}, false, -1.0f, true, true },
- { "defaults, insert 1 muted", {}, true, -1.0f, false, false },
- { "auto map, insert 1 muted", { { 0, 1 }, { 1, 1 } }, true, -1.0f, false, true },
- { "auto map", { { 0, 1 }, { 1, 1 } }, false, -1.0f, true, true },
- { "output 2 inactive", { { 0, 1 }, { 1, 0 } }, false, -1.0f, true, false },
- { "output 1 inactive", { { 0, 0 } }, false, -1.0f, false, true },
- { "auto map, channel volume 0", { { 0, 1 }, { 1, 1 } }, false, 0.0f, false, false },
- { "output 2 inactive, Process inactive inputs and outputs on", { { 0, 1 }, { 1, 0 } }, false, -1.0f, true, true },
- };
- auto tone = [] (const std::vector<float>& x, double hz) {
- // Goertzel magnitude over the buffer (normalised to a sine's amplitude)
- const auto w = 2.0 * juce::MathConstants<double>::pi * hz / 48000.0;
- double s1 = 0.0, s2 = 0.0;
- for (const auto v : x)
- {
- const auto s0 = v + 2.0 * std::cos (w) * s1 - s2;
- s2 = s1;
- s1 = s0;
- }
- return std::sqrt (s1 * s1 + s2 * s2 - 2.0 * std::cos (w) * s1 * s2) * 2.0 / (double) std::max<std::size_t> (1, x.size());
- };
- if (! vst2)
- ok = false;
- else
- for (const auto& c : cases)
- {
- lynx::AudioEngine engine (false);
- engine.getPluginHost().addPluginFile (juce::File (pluginPath));
- auto song = lynx::Song::makeDefault();
- auto& channel = song.channels[0];
- channel.instrument = lynx::InstrumentKind::plugin;
- channel.plugin = {};
- channel.plugin.id = vst2->createIdentifierString().toStdString();
- channel.plugin.name = vst2->name.toStdString();
- channel.plugin.outputs = c.routes;
- // (FL's "Process inactive inputs and outputs" plays an inactive output: off but for the case named so)
- channel.plugin.processInactive = juce::String (c.name).contains ("Process inactive");
- channel.mixerTrack = 1;
- if (c.volume >= 0.0f)
- channel.volume = c.volume;
- for (std::size_t k = 1; k < song.channels.size(); ++k)
- song.channels[k].muted = true;
- if (song.mixer.size() < 4)
- song.mixer.resize (4);
- song.mixer[1].muted = c.muteInsert1;
- song.patterns[0].notes.clear();
- for (const auto key : { 36, 37 })
- {
- lynx::Note note;
- note.start = 0;
- note.length = lynx::ppq;
- note.channel = 0;
- note.key = key;
- note.velocity = 1.0f;
- song.patterns[0].notes.push_back (note);
- }
- engine.setSong (song);
- std::vector<float> master;
- lynx::AudioEngine::RenderOptions options;
- options.seconds = 0.25;
- options.sampleRate = 48000.0;
- options.capture = [&master] (const float* l, const float*, int n) { master.insert (master.end(), l, l + n); };
- engine.renderOffline (options);
- const auto kick = tone (master, 110.0), snare = tone (master, 220.0);
- const auto pass = (kick > 0.01) == c.kick && (snare > 0.01) == c.snare;
- report << c.name << ": kick_110Hz=" << juce::String (kick, 4) << " snare_220Hz=" << juce::String (snare, 4) << " expected kick="
- << (int) c.kick << " snare=" << (int) c.snare << (pass ? " OK" : " FAILED") << "\n";
- ok = ok && pass;
- if (auto instrument = std::dynamic_pointer_cast<lynx::PluginInstrument> (engine.getChannelInstrument (0)))
- if (&c == &cases[0])
- {
- report << "outputs=" << (int) instrument->outputs().size();
- for (const auto& o : instrument->outputs())
- report << " [" << o.name << " ch" << o.channel << "x" << o.channels << "]";
- report << "\n";
- ok = ok && instrument->outputs().size() == 8 && instrument->outputs()[1].name == "Snare";
- }
- }
- // round 189j: "LYNX Test SC.dll" next to it (tools/testplugin/lynx_test_sc_vst2.c) as an effect on insert 1
- const auto sc = juce::File (pluginPath).getSiblingFile ("LYNX Test SC.dll");
- if (sc.existsAsFile())
- ok = runEffectConnectionsTest (sc, report) && ok;
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // Round 189j: a hosted effect's Processing › Connections against FL 2026's own renders of the same projects
- // [EXEC fxconn189j: FL /R renders of LYNX's .flp exports, docs/analise/REA_rodada189j.md]. Insert 1: a 440 Hz
- // sampler and "LYNX Test SC" (output 1 = input 1, output 2 = input 2); inserts 2 (1000 Hz) and 3 (1500 Hz) routed
- // to insert 1 at level 0 only; insert 4 a 2500 Hz reference on the Master; insert 1 routed to the Master and at
- // level 0 to inserts 5 (panned left) and 6 (right). Each tone's level per side, in dB from the reference's, must be
- // FL's within 0.5 dB (absent: 50 dB under it).
- bool runEffectConnectionsTest (const juce::File& scFile, juce::String& report)
- {
- lynx::AudioEngine scanner (false);
- scanner.getPluginHost().addPluginFile (scFile);
- std::optional<juce::PluginDescription> sc;
- for (const auto& type : scanner.getPluginHost().getKnownPlugins().getTypes())
- if (type.pluginFormatName == "VST" && juce::File (type.fileOrIdentifier) == scFile)
- sc = type;
- report << "effect_plugin=" << (sc ? sc->name : juce::String ("not found")) << "\n";
- if (! sc)
- return false;
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-fxconn189j");
- dir.createDirectory();
- const double tones[] = { 440.0, 1000.0, 1500.0, 2500.0 };
- for (const auto hz : tones)
- {
- const auto wav = dir.getChildFile ("sine" + juce::String ((int) hz) + ".wav");
- if (wav.existsAsFile())
- continue;
- juce::AudioBuffer<float> sine (1, 44100 * 3);
- for (int i = 0; i < sine.getNumSamples(); ++i)
- sine.setSample (0, i, 0.25f * (float) std::sin (2.0 * juce::MathConstants<double>::pi * hz * i / 44100.0));
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 44100.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (sine, 0, sine.getNumSamples());
- }
- }
- using Route = lynx::PluginOutputRoute;
- constexpr float none = -999.0f;
- struct Case
- {
- const char* name;
- std::vector<Route> inputs, outputs;
- int tweak; // 1 no Master route, 2 insert 1 fader at 0.4, 3 Process inactive off, 4 Master route level 0, 5 route
- // to 7 too, 6 insert 2 fader at 0.4, 7 insert 2 muted, 8 insert 2 panned left
- float level[3][2]; // 440 / 1000 / 1500 Hz, left / right: dB from the reference, FL's
- };
- const Route d { 0, 1 };
- const Case cases[] = {
- { "e00 FL defaults", { d, d }, {}, 0, { { 6.1f, 6.1f }, { none, none }, { none, none } } },
- { "e01 input 1 at 1", { { 1, 1 } }, {}, 0, { { 0, 0 }, { 0, 0 }, { none, none } } },
- { "e02 input 1 at 2", { { 2, 1 } }, {}, 0, { { 0, 0 }, { none, none }, { 0, 0 } } },
- { "e03 input 2 at 1", { d, { 1, 1 } }, {}, 0, { { 0, 0 }, { 0, 0 }, { none, none } } },
- { "e04 output 2 at 1 (Master)", { d, { 1, 1 } }, { d, { 1, 1 } }, 0, { { 0, 0 }, { 0, 0 }, { none, none } } },
- { "e05 output 2 at 2 (insert 5)", { d, { 1, 1 } }, { d, { 2, 1 } }, 0, { { 0, 0 }, { 3.0f, none }, { none, none } } },
- { "e06 output 1 at 1", {}, { { 1, 1 } }, 0, { { 6.1f, 6.1f }, { none, none }, { none, none } } },
- { "e07 output 2 at 5 (past the list)", { d, { 1, 1 } }, { d, { 5, 1 } }, 0, { { 0, 0 }, { none, 3.0f }, { none, none } } },
- { "e08 inputs 1 and 2 at 1", { { 1, 1 }, { 1, 1 } }, {}, 0, { { none, none }, { 6.1f, 6.1f }, { none, none } } },
- { "e09 output 2 inactive", { d, { 1, 1 } }, { d, { 0, 0 } }, 0, { { 0, 0 }, { 0, 0 }, { none, none } } },
- { "e10 input 1 at 5 (past the list)", { { 5, 1 } }, {}, 0, { { 6.1f, 6.1f }, { none, none }, { none, none } } },
- { "e11 output 2 at 3 (insert 6)", { d, { 1, 1 } }, { d, { 3, 1 } }, 0, { { 0, 0 }, { none, 3.0f }, { none, none } } },
- { "e13 no Master route, output 2 at 1", { d, { 1, 1 } }, { d, { 1, 1 } }, 1, { { none, none }, { 3.0f, none }, { none, none } } },
- { "e14 insert 1 fader 0.4, output 2 at 1", { d, { 1, 1 } }, { d, { 1, 1 } }, 2, { { -12.7f, -12.7f }, { 0, 0 }, { none, none } } },
- { "e15 input 2 inactive", { d, { 1, 0 } }, { d, d }, 3, { { 0, 0 }, { none, none }, { none, none } } },
- { "e16 output 2 inactive", { d, { 1, 1 } }, { d, { 0, 0 } }, 3, { { 0, 0 }, { none, none }, { none, none } } },
- { "e18 route to 7 too, output 2 at 3", { d, { 1, 1 } }, { d, { 3, 1 } }, 5, { { 0, 0 }, { none, 3.0f }, { none, none } } },
- { "e19 Master route at 0, output 2 at 1", { d, { 1, 1 } }, { d, { 1, 1 } }, 4, { { none, none }, { 0, 0 }, { none, none } } },
- { "e22 input 1 at 1 inactive", { { 1, 0 } }, {}, 3, { { 0, 0 }, { none, none }, { none, none } } },
- { "e23 output 2 at -1, insert 1 fader 0.4", { d, { 1, 1 } }, { d, { -1, 1 } }, 2, { { -12.7f, -12.7f }, { 0, 0 }, { none, none } } },
- { "e24 input 1 at 1, insert 2 fader 0.4", { { 1, 1 } }, {}, 6, { { 0, 0 }, { -12.7f, -12.7f }, { none, none } } },
- { "e25 input 1 at 1, insert 2 muted", { { 1, 1 } }, {}, 7, { { 0, 0 }, { none, none }, { none, none } } },
- { "e26 input 1 at 1, insert 2 panned left", { { 1, 1 } }, {}, 8, { { 0, 0 }, { 3.0f, none }, { none, none } } },
- };
- auto goertzel = [] (const std::vector<float>& x, double hz) {
- const auto w = 2.0 * juce::MathConstants<double>::pi * hz / 44100.0;
- double s1 = 0.0, s2 = 0.0;
- for (const auto v : x)
- {
- const auto s0 = v + 2.0 * std::cos (w) * s1 - s2;
- s2 = s1;
- s1 = s0;
- }
- const auto a = std::sqrt (juce::jmax (0.0, s1 * s1 + s2 * s2 - 2.0 * std::cos (w) * s1 * s2)) * 2.0 / (double) std::max<std::size_t> (1, x.size());
- return a > 1e-7 ? 20.0 * std::log10 (a) : -140.0;
- };
- auto ok = true;
- for (const auto& c : cases)
- {
- lynx::AudioEngine engine (false);
- engine.getPluginHost().addPluginFile (scFile);
- auto song = lynx::Song::makeDefault();
- song.bpm = 120.0;
- song.channels.clear();
- song.automations.clear();
- for (auto& p : song.patterns)
- p.notes.clear();
- for (int k = 0; k < 4; ++k)
- {
- lynx::ChannelDef ch;
- ch.name = "S" + std::to_string ((int) tones[k]);
- ch.instrument = lynx::InstrumentKind::sampler;
- ch.samplePath = dir.getChildFile ("sine" + juce::String ((int) tones[k]) + ".wav").getFullPathName().toStdString();
- ch.mixerTrack = k + 1;
- song.channels.push_back (ch);
- lynx::Note note;
- note.start = 0;
- note.length = 8 * lynx::ppq;
- note.channel = k;
- note.key = 60;
- note.velocity = 0.78f;
- song.patterns[0].notes.push_back (note);
- }
- if (song.mixer.size() < 10)
- song.mixer.resize (10);
- for (auto& t : song.mixer)
- {
- t.effects.clear();
- t.sends.clear();
- t.toMaster = true;
- }
- lynx::EffectSlot fx;
- fx.kind = lynx::EffectKind::plugin;
- fx.plugin.id = sc->createIdentifierString().toStdString();
- fx.plugin.name = sc->name.toStdString();
- fx.plugin.inputs = c.inputs;
- fx.plugin.outputs = c.outputs;
- fx.plugin.processInactive = c.tweak != 3;
- auto& one = song.mixer[1];
- one.effects.push_back (fx);
- one.sends = { { 5, 0.0f }, { 6, 0.0f } };
- for (const int t : { 2, 3 })
- {
- song.mixer[(std::size_t) t].toMaster = false;
- song.mixer[(std::size_t) t].sends = { { 1, 0.0f } };
- }
- song.mixer[5].pan = -1.0f;
- song.mixer[6].pan = 1.0f;
- one.toMaster = c.tweak != 1;
- if (c.tweak == 2)
- one.volume = 0.4f;
- if (c.tweak == 4)
- one.masterLevel = 0.0f;
- if (c.tweak == 6)
- song.mixer[2].volume = 0.4f;
- song.mixer[2].muted = c.tweak == 7;
- song.mixer[2].pan = c.tweak == 8 ? -1.0f : 0.0f;
- if (c.tweak == 5)
- {
- one.sends = { { 7, 0.0f }, { 5, 0.0f }, { 6, 0.0f } };
- song.mixer[7].pan = 0.5f;
- }
- // (input 2's index sets the slot's side input source, as the Connections page and the import do)
- if (c.inputs.size() > 1 && c.inputs[1].offset > 0)
- one.effects[0].sidechain = lynx::mixerops::sidechainIndexSource (song, 1, c.inputs[1].offset);
- engine.setSong (song);
- std::vector<float> left, right;
- lynx::AudioEngine::RenderOptions options;
- options.seconds = 1.2;
- options.sampleRate = 44100.0;
- options.capture = [&] (const float* l, const float* r, int n) {
- left.insert (left.end(), l, l + n);
- right.insert (right.end(), r, r + n);
- };
- engine.renderOffline (options);
- const auto from = (std::size_t) 22050, to = (std::size_t) 44100;
- if (right.size() < to)
- {
- report << c.name << ": rendered " << (int) right.size() << " samples FAILED\n";
- ok = false;
- continue;
- }
- const std::vector<float> l (left.begin() + (std::ptrdiff_t) from, left.begin() + (std::ptrdiff_t) to);
- const std::vector<float> r (right.begin() + (std::ptrdiff_t) from, right.begin() + (std::ptrdiff_t) to);
- const auto ref = 0.5 * (goertzel (l, 2500.0) + goertzel (r, 2500.0));
- auto pass = ref > -60.0;
- report << c.name << ": ref=" << juce::String (ref, 1);
- for (int k = 0; k < 3; ++k)
- for (int side = 0; side < 2; ++side)
- {
- const auto got = goertzel (side == 0 ? l : r, tones[k]) - ref;
- const auto want = c.level[k][side];
- const auto good = want == none ? got < -50.0 : std::abs (got - want) < 0.5;
- pass = pass && good;
- report << " " << (int) tones[k] << (side == 0 ? "L" : "R") << "=" << (got < -50.0 ? juce::String ("-") : juce::String (got, 1))
- << (good ? "" : "(FL " + (want == none ? juce::String ("-") : juce::String (want, 1)) + ")");
- }
- report << (pass ? " OK" : " FAILED") << "\n";
- ok = ok && pass;
- }
- return ok;
- }
- // LYNX.exe --wrappertest plugin.vst3 report.txt: builds a VST3 state the way FL's Fruity
- // Wrapper stores it (REA_rodada5 §3.2), runs it through the import (adoptFlPlugins) and checks
- // that the plugin comes back with the changed parameter.
- void runWrapperTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- juce::String report;
- bool ok = false;
- {
- lynx::AudioEngine offline (false);
- auto& host = offline.getPluginHost();
- host.addPluginFile (juce::File (pluginPath));
- const juce::PluginDescription* vst3 = nullptr;
- const auto types = host.getKnownPlugins().getTypes(); // copy: the pointer below points into it
- for (const auto& type : types)
- if (type.pluginFormatName == "VST3" && type.isInstrument)
- vst3 = &type;
- if (vst3 != nullptr)
- {
- juce::String error;
- auto plugin = host.getFormats().createPluginInstance (*vst3, 48000.0, 512, error);
- auto* parameter = plugin != nullptr && ! plugin->getParameters().isEmpty() ? plugin->getParameters()[0] : nullptr;
- if (parameter != nullptr)
- {
- const auto target = parameter->getValue() > 0.5f ? 0.13f : 0.87f;
- parameter->setValueNotifyingHost (target);
- juce::MemoryBlock juceState;
- plugin->getStateInformation (juceState);
- report << "parameter=" << parameter->getName (64) << " target=" << target << "\n";
- // JUCE state -> FL container: u32 1 + records 1 (flags), 3 (component), 2 (controller)
- std::vector<std::uint8_t> flState;
- auto put32 = [&] (std::uint32_t v) { for (int b = 0; b < 4; ++b) flState.push_back ((std::uint8_t) (v >> (8 * b))); };
- auto record = [&] (std::uint32_t id, const juce::MemoryBlock& data) {
- put32 (id);
- put32 ((std::uint32_t) data.getSize());
- put32 (0);
- flState.insert (flState.end(), (const std::uint8_t*) data.getData(), (const std::uint8_t*) data.getData() + data.getSize());
- };
- put32 (1);
- record (1, juce::MemoryBlock (64, true));
- // record 4 (REA_rodada22 §2.3): slots 0/1 hold the ParamIDs of parameters 2 and 0, so FL's
- // automations k = 0, 1, 2 mean positions 2, 0 and 1 (the first parameter without a slot)
- juce::MemoryBlock slots;
- const auto paramId = [&] (int i) {
- const auto* hosted = dynamic_cast<const juce::HostedAudioProcessorParameter*> (plugin->getParameters()[i]);
- return hosted != nullptr ? (std::uint32_t) hosted->getParameterID().getLargeIntValue() : 0u;
- };
- const bool reorder = plugin->getParameters().size() >= 3;
- if (reorder)
- {
- for (auto v : { 2u, paramId (2), paramId (0) })
- slots.append (&v, 4);
- report << "slot_param_ids=" << (juce::int64) paramId (2) << "," << (juce::int64) paramId (0) << "\n";
- }
- if (auto xml = juce::AudioProcessor::getXmlFromBinary (juceState.getData(), (int) juceState.getSize()))
- for (auto [tag, id] : { std::pair { "IComponent", 3u }, { "IEditController", 2u } })
- if (auto* child = xml->getChildByName (tag))
- {
- juce::MemoryBlock data;
- data.fromBase64Encoding (child->getAllSubText());
- record (id, data);
- report << tag << "_bytes=" << (int) data.getSize() << "\n";
- }
- if (reorder)
- record (4, slots);
- plugin.reset();
- auto song = lynx::Song::makeDefault();
- auto& f = song.channels[4].plugin.foreign;
- f.format = lynx::ForeignPlugin::Format::vst3;
- f.name = vst3->name.toStdString(); // no class ID: find it by name (fallback)
- f.state = flState;
- {
- std::vector<std::uint8_t> comp, ctrl;
- report << "split=" << (int) lynx::splitFlVst3State (flState, comp, ctrl) << " component=" << (int) comp.size()
- << " saved_slots=" << (int) lynx::flVst3ParamSlots (flState).size() << "\n";
- }
- for (int k = 0; k < 3; ++k)
- {
- lynx::Automation a;
- a.target = { lynx::AutomationTargetKind::channelParam, 4, 0, k };
- song.automations.push_back (a);
- }
- const auto adopted = host.adoptFlPlugins (song);
- report << "adopted=" << adopted << "\n";
- juce::String mapped;
- for (const auto& a : song.automations)
- if (a.target.kind == lynx::AutomationTargetKind::channelParam && a.target.index == 4)
- mapped << (mapped.isEmpty() ? "" : ",") << a.target.param;
- report << "slot_positions=" << mapped << "\n";
- const auto slotsOk = ! reorder || mapped == "2,0,1";
- offline.setSong (song);
- if (auto* loaded = dynamic_cast<lynx::PluginInstrument*> (offline.getChannelInstrument (4).get()))
- {
- const auto value = loaded->getInstance().getParameters()[0]->getValue();
- report << "restored_value=" << value << "\n";
- ok = adopted == 1 && std::abs (value - target) < 0.02f && slotsOk;
- }
- }
- }
- }
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- void runDemoSongs (const juce::String& folderPath)
- {
- const juce::File folder (folderPath);
- folder.createDirectory();
- bool ok = true;
- for (int d = 1; d < lynx::demos::count; ++d)
- {
- juce::String error;
- ok = lynx::ProjectFile::save (lynx::demos::make (d), folder.getChildFile (lynx::demos::fileName (d)), error) && ok;
- }
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // --perfgen (round perfgate190id): each synthetic project of the performance gate written as <folder>/<name>.lynx, its
- // audio as 16-bit WAVs in <folder>/<name>/ (written once: the same code makes the same audio). The report gives, per
- // project, the .lynx size, the time to write it (ProjectFile::save, which reads it back) and to read it
- // (ProjectFile::load), the medians of 5, and a hash of its text.
- void runPerfGen (const juce::String& folderPath, const juce::String& reportPath, const juce::String& only)
- {
- const juce::File folder (folderPath);
- folder.createDirectory();
- const auto wanted = juce::StringArray::fromTokens (only, ",", "");
- juce::String report;
- bool ok = true;
- auto median = [] (std::vector<double> v) {
- std::sort (v.begin(), v.end());
- return v[v.size() / 2];
- };
- for (const auto& name : lynx::perfprojects::names())
- {
- if (! wanted.isEmpty() && ! wanted.contains (juce::String (name)))
- continue;
- lynx::Song song;
- lynx::perfprojects::Samples samples;
- const auto audioFolder = folder.getChildFile (juce::String (name));
- lynx::perfprojects::make (name, song, samples, audioFolder.getFullPathName().toStdString());
- for (const auto& [path, data] : samples)
- {
- const juce::File wav { juce::String (path) };
- if (wav.existsAsFile())
- continue;
- wav.getParentDirectory().createDirectory();
- const auto frames = (int) data->frames();
- juce::AudioBuffer<float> audio (2, frames);
- audio.copyFrom (0, 0, data->leftData(), frames);
- audio.copyFrom (1, 0, data->rightData(), frames);
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = out != nullptr ? format.createWriterFor (out.get(), data->sampleRate, 2, 16, {}, 0) : nullptr)
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- ok = writer->writeFromAudioSampleBuffer (audio, 0, frames) && ok;
- }
- else
- ok = false;
- }
- const auto file = folder.getChildFile (juce::String (name) + ".lynx");
- std::vector<double> saveMs, loadMs;
- juce::String error;
- bool loadedOk = true;
- for (int rep = 0; rep < 5; ++rep)
- {
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- ok = lynx::ProjectFile::save (song, file, error) && ok;
- const auto t1 = juce::Time::getMillisecondCounterHiRes();
- const auto loaded = lynx::ProjectFile::load (file, error);
- const auto t2 = juce::Time::getMillisecondCounterHiRes();
- loadedOk = loadedOk && loaded.has_value() && loaded->channels.size() == song.channels.size()
- && loaded->playlist.size() == song.playlist.size() && loaded->automations.size() == song.automations.size();
- saveMs.push_back (t1 - t0);
- loadMs.push_back (t2 - t1);
- }
- ok = ok && loadedOk;
- const auto text = file.loadFileAsString();
- std::uint64_t h = 1469598103934665603ull;
- for (auto* c = text.toRawUTF8(); *c != 0; ++c)
- h = (h ^ (std::uint8_t) *c) * 1099511628211ull;
- report << name << ": channels=" << (int) song.channels.size() << " inserts=" << (int) song.mixer.size() - 1
- << " clips=" << (int) song.playlist.size() << " automations=" << (int) song.automations.size()
- << " wavs=" << (int) samples.size() << " lynx_kb=" << juce::String ((double) file.getSize() / 1024.0, 1)
- << " save_ms=" << juce::String (median (saveMs), 2) << " load_ms=" << juce::String (median (loadMs), 2)
- << " roundtrip=" << (loadedOk ? "OK" : "FAILED") << " text_hash=" << juce::String::toHexString ((juce::int64) h)
- << (error.isNotEmpty() ? " error=" + error : juce::String()) << "\n";
- }
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- if (reportPath.isNotEmpty())
- juce::File (reportPath).replaceWithText (report);
- else
- std::fputs (report.toRawUTF8(), stdout);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- void runShowcase (const juce::String& outputPath, int currentPattern)
- {
- const auto song = lynx::makeShowcaseSong (currentPattern);
- juce::String error;
- const auto ok = lynx::ProjectFile::save (song, juce::File (outputPath), error);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --sandboxtest plugin.vst3 report.txt: opens the instrument in a separate process, plays a
- // note, changes a parameter, checks the state (back in an in-process plugin) and makes the child hang
- // to check that LYNX keeps going (silence, without waiting longer than the timeout).
- // --sandboxtest: plays an instrument (a note) or an effect (a 440 Hz tone through it); render() adds into l / r
- struct TestVoice
- {
- explicit TestVoice (std::unique_ptr<juce::AudioPluginInstance> p)
- {
- if (p->acceptsMidi() && p->getTotalNumInputChannels() == 0)
- instrument = std::make_unique<lynx::PluginInstrument> (std::move (p), 512);
- else
- effect = std::move (p);
- }
- void noteOn()
- {
- if (instrument != nullptr)
- instrument->noteOn (60, 0.9f);
- }
- void render (float* l, float* r, int n, float gainLeft, float gainRight)
- {
- if (instrument != nullptr)
- {
- instrument->render (l, r, n, gainLeft, gainRight);
- return;
- }
- const auto channels = juce::jmax (2, effect->getTotalNumInputChannels(), effect->getTotalNumOutputChannels());
- juce::AudioBuffer<float> block (channels, 512);
- juce::MidiBuffer midi;
- for (int done = 0; done < n; done += 512)
- {
- const auto k = juce::jmin (512, n - done);
- block.setSize (channels, k, false, false, true);
- for (int i = 0; i < k; ++i)
- {
- const auto v = 0.25f * (float) std::sin (phase);
- phase += 2.0 * juce::MathConstants<double>::pi * 440.0 / 48000.0;
- for (int c = 0; c < channels; ++c)
- block.setSample (c, i, v);
- }
- effect->processBlock (block, midi);
- for (int i = 0; i < k; ++i)
- {
- l[done + i] += gainLeft * block.getSample (0, i);
- r[done + i] += gainRight * block.getSample (1, i);
- }
- }
- }
- void release()
- {
- instrument.reset();
- effect.reset();
- }
- std::unique_ptr<lynx::PluginInstrument> instrument;
- std::unique_ptr<juce::AudioPluginInstance> effect;
- double phase = 0.0;
- };
- void runSandboxTest (const juce::String& pluginPath, const juce::String& reportPath)
- {
- juce::String report;
- bool ok = false;
- lynx::setPluginSandboxAlerts (false);
- const juce::File log (reportPath + ".log");
- auto step = [&] (const char* what) { log.appendText (juce::String (what) + "\n"); };
- log.deleteFile();
- {
- lynx::PluginHost host (false);
- host.addPluginFile (juce::File (pluginPath));
- const auto types = host.getKnownPlugins().getTypes(); // getTypes() returns a copy
- // the file's instrument, else its first effect (round 161: effects too, e.g. a Windows effect through yabridge)
- const juce::PluginDescription* instrument = nullptr;
- for (const auto& type : types)
- if (type.isInstrument)
- instrument = &type;
- for (const auto& type : types)
- if (instrument == nullptr && ! type.isInstrument)
- instrument = &type;
- step ("host");
- juce::String error;
- auto remote = instrument != nullptr ? lynx::createSandboxedPlugin (*instrument, 48000.0, 512, {}, error) : nullptr;
- report << "opened=" << (remote != nullptr ? 1 : 0) << " error=" << error << "\n";
- step ("created");
- if (remote != nullptr)
- {
- auto& proxy = *remote;
- TestVoice voice (std::move (remote));
- std::vector<float> l (48000), r (48000);
- auto peakOf = [&] {
- float peak = 0.0f;
- for (std::size_t k = 0; k < l.size(); ++k)
- peak = std::max ({ peak, std::abs (l[k]), std::abs (r[k]) });
- return peak;
- };
- const auto start = juce::Time::getMillisecondCounterHiRes();
- voice.noteOn();
- voice.render (l.data(), r.data(), 48000, 1.0f, 1.0f);
- const auto renderMs = juce::Time::getMillisecondCounterHiRes() - start;
- const auto peak = peakOf();
- step ("played");
- if (juce::JUCEApplication::getCommandLineParameters().contains ("--expect-crash"))
- {
- // a plugin that crashes while playing (round 161 test plugin): LYNX notices, mutes it and keeps running
- const auto dead = lynx::isSandboxedPluginDead (proxy);
- std::fill (l.begin(), l.end(), 0.0f);
- std::fill (r.begin(), r.end(), 0.0f);
- voice.render (l.data(), r.data(), 4096, 1.0f, 1.0f);
- report << "peak=" << peak << " render_1s_ms=" << renderMs << " dead=" << (dead ? 1 : 0) << " peak_after=" << peakOf() << "\n";
- ok = dead && peak > 1e-4f && renderMs < 2000.0 && peakOf() == 0.0f;
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- return;
- }
- report << "plugin=" << proxy.getName() << (instrument->isInstrument ? " (instrument)" : " (effect)") << " parameters="
- << proxy.getParameters().size() << " peak=" << peak << " render_1s_ms=" << renderMs << "\n";
- if (juce::JUCEApplication::getCommandLineParameters().contains ("--editor") && proxy.hasEditor())
- {
- // the plugin's own window, opened by the child process (4 s on screen); the child must stay responsive
- std::unique_ptr<juce::AudioProcessorEditor> editor (proxy.createEditorIfNeeded());
- juce::Thread::sleep (4000);
- juce::MemoryBlock state;
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- proxy.getStateInformation (state);
- report << "editor_shown=1 state_with_editor_ms=" << (juce::Time::getMillisecondCounterHiRes() - t0) << " dead=" << (lynx::isSandboxedPluginDead (proxy) ? 1 : 0) << "\n";
- editor.reset();
- }
- // parameter -> state -> in-process plugin
- bool stateOk = false;
- if (! proxy.getParameters().isEmpty())
- {
- auto* p = proxy.getParameters()[0];
- const auto target = p->getValue() > 0.5f ? 0.13f : 0.87f;
- p->setValue (target);
- std::fill (l.begin(), l.end(), 0.0f);
- voice.render (l.data(), r.data(), 512, 1.0f, 1.0f); // carries the change to the child
- juce::MemoryBlock state;
- proxy.getStateInformation (state);
- if (auto local = host.getFormats().createPluginInstance (*instrument, 48000.0, 512, error))
- {
- local->setStateInformation (state.getData(), (int) state.getSize());
- const auto back = local->getParameters()[0]->getValue();
- // the same steps without the sandbox: some plugins quantise the value or keep it out of their state
- auto control = target;
- if (auto a = host.getFormats().createPluginInstance (*instrument, 48000.0, 512, error))
- {
- a->enableAllBuses();
- a->prepareToPlay (48000.0, 512);
- a->getParameters()[0]->setValue (target);
- juce::AudioBuffer<float> block (juce::jmax (2, a->getTotalNumInputChannels(), a->getTotalNumOutputChannels()), 512);
- block.clear();
- juce::MidiBuffer none;
- a->processBlock (block, none);
- juce::MemoryBlock direct;
- a->getStateInformation (direct);
- if (auto b = host.getFormats().createPluginInstance (*instrument, 48000.0, 512, error))
- {
- b->setStateInformation (direct.getData(), (int) direct.getSize());
- control = b->getParameters()[0]->getValue();
- }
- a->releaseResources();
- }
- report << "state_bytes=" << (int) state.getSize() << " target=" << target << " in_process=" << back << " in_process_control=" << control << "\n";
- stateOk = std::abs (back - control) < 0.02f;
- }
- }
- step ("state");
- // hung child: the block returns in ~0.5 s, muted, and the plugin is marked dead
- lynx::hangSandboxedPluginForTest (proxy);
- juce::Thread::sleep (200);
- std::fill (l.begin(), l.end(), 1.0f);
- std::fill (r.begin(), r.end(), 1.0f);
- const auto hangStart = juce::Time::getMillisecondCounterHiRes();
- voice.render (l.data(), r.data(), 4096, 0.0f, 0.0f);
- std::fill (l.begin(), l.end(), 0.0f);
- std::fill (r.begin(), r.end(), 0.0f);
- voice.render (l.data(), r.data(), 4096, 1.0f, 1.0f);
- const auto hangMs = juce::Time::getMillisecondCounterHiRes() - hangStart;
- const auto dead = lynx::isSandboxedPluginDead (proxy);
- const auto hangPeak = peakOf();
- report << "hung_ms=" << hangMs << " dead=" << (dead ? 1 : 0) << " peak_after=" << hangPeak << "\n";
- // crashed child (round 161): a second instance aborts; LYNX notices, mutes it and keeps running
- bool crashOk = false;
- if (auto second = lynx::createSandboxedPlugin (*instrument, 48000.0, 512, {}, error))
- {
- auto& proxy2 = *second;
- TestVoice voice2 (std::move (second));
- voice2.noteOn();
- voice2.render (l.data(), r.data(), 512, 1.0f, 1.0f);
- lynx::crashSandboxedPluginForTest (proxy2);
- const auto crashStart = juce::Time::getMillisecondCounterHiRes();
- while (! lynx::isSandboxedPluginDead (proxy2) && juce::Time::getMillisecondCounterHiRes() - crashStart < 5000.0)
- {
- voice2.render (l.data(), r.data(), 512, 1.0f, 1.0f);
- juce::Thread::sleep (5);
- }
- const auto crashMs = juce::Time::getMillisecondCounterHiRes() - crashStart;
- std::fill (l.begin(), l.end(), 0.0f);
- std::fill (r.begin(), r.end(), 0.0f);
- voice2.render (l.data(), r.data(), 4096, 1.0f, 1.0f);
- const auto crashDead = lynx::isSandboxedPluginDead (proxy2);
- report << "crash_ms=" << crashMs << " crash_dead=" << (crashDead ? 1 : 0) << " crash_peak_after=" << peakOf() << "\n";
- crashOk = crashDead && crashMs < 3000.0;
- // issue #159: freeing the crashed plugin doesn't wait on its pipe (JUCE waited up to 10 s there for
- // the gone child, on the message thread when the rack freed it); its teardown ends on its own
- const auto freeStart = juce::Time::getMillisecondCounterHiRes();
- voice2.release();
- const auto freeMs = juce::Time::getMillisecondCounterHiRes() - freeStart;
- const auto endedAll = lynx::finishSandboxTeardowns (15000);
- report << "crashed_free_ms=" << freeMs << " teardown_done=" << (endedAll ? 1 : 0) << "\n";
- crashOk = crashOk && freeMs < 250.0 && endedAll;
- }
- step ("crash");
- ok = peak > 1e-4f && stateOk && dead && hangMs < 1500.0 && hangPeak == 0.0f && crashOk;
- }
- }
- report << "result=" << (ok ? "OK" : "FAILED") << "\n";
- juce::File (reportPath).replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // --timertest (round 174f): a view's polling timer follows the view and its parents, and survives a minimised window
- void runTimerTest (const juce::File& report)
- {
- struct Ticks final : juce::Timer
- {
- void timerCallback() override {}
- } timer;
- juce::Component top, parent, view;
- parent.addChildComponent (view);
- top.addChildComponent (parent);
- top.setSize (320, 200);
- lynx::ui::TimerWhileShowing watch (view, timer, 30);
- juce::String text;
- auto failures = 0;
- auto expect = [&] (const char* step, bool running) {
- const auto ok = timer.isTimerRunning() == running;
- failures += ok ? 0 : 1;
- text << step << ": timer " << (timer.isTimerRunning() ? "running" : "stopped") << (ok ? "" : " FAIL") << "\n";
- };
- expect ("never shown", false);
- view.setVisible (true);
- parent.setVisible (true);
- expect ("view and parent visible, not on the desktop", false);
- top.addToDesktop (juce::ComponentPeer::windowHasTitleBar);
- top.setVisible (true);
- expect ("window shown", true);
- parent.setVisible (false);
- expect ("parent hidden", false);
- parent.setVisible (true);
- expect ("parent shown", true);
- view.setVisible (false);
- expect ("view hidden", false);
- top.getPeer()->setMinimised (true);
- view.setVisible (true);
- expect ("view shown while minimised", true);
- top.getPeer()->setMinimised (false);
- expect ("window restored", true);
- top.setVisible (false);
- expect ("window hidden", false);
- top.setVisible (true);
- expect ("window shown again", true);
- top.removeFromDesktop();
- text << "failures: " << failures << "\nresult=" << (failures == 0 ? "OK" : "FAIL") << "\n";
- report.replaceWithText (text);
- setApplicationReturnValue (failures == 0 ? 0 : 1);
- quit();
- }
- // --cachetest (round 174f): PlaylistComponent::cacheSelfTest on the project, the Playlist off screen at 1466 x 930
- void runCacheTest (const juce::File& project, const juce::File& report)
- {
- engine = std::make_unique<lynx::AudioEngine>();
- juce::String error;
- auto ok = false;
- // (round 190nq: a Live set, FL Studio Mobile project or DAWproject takes the same import, issue #193's set)
- if (project.hasFileExtension ("flp;als;flm;dawproject"))
- ok = engine->importFlpFile (project, error);
- else if (auto song = lynx::ProjectFile::load (project, error))
- {
- engine->setSong (std::move (*song));
- ok = true;
- }
- juce::String text = "project: " + project.getFullPathName() + "\n";
- if (ok)
- {
- text << "video tracks: " << (int) engine->getSong().videoTracks.size() << "\n";
- auto playlist = std::make_unique<lynx::PlaylistComponent> (*engine);
- playlist->setBounds (0, 0, 1466, 930);
- playlist->setVisible (true);
- text << playlist->cacheSelfTest ([] { lynx::ui::WaveformCache::getInstance()->waitUntilIdle (60000); }, report.getParentDirectory());
- }
- else
- text << "result=ERROR " << error << "\n";
- report.replaceWithText (text);
- setApplicationReturnValue (ok && text.contains ("result=OK") ? 0 : 1);
- quit();
- }
- // --picturetest (round 190bm): ui/PictureCheck.h on the Playlist and the Mixer, at a window's usual size, at a 4K
- // screen's, and wider than a GPU bitmap can be (16384 px)
- void runPictureTest (const juce::File& report, const juce::File& project)
- {
- engine = std::make_unique<lynx::AudioEngine>();
- juce::String error, text;
- if (project != juce::File())
- {
- auto ok = false;
- if (project.hasFileExtension ("flp"))
- ok = engine->importFlpFile (project, error);
- else if (auto song = lynx::ProjectFile::load (project, error))
- {
- engine->setSong (std::move (*song));
- ok = true;
- }
- text << "project: " << project.getFullPathName() << (ok ? "" : " (not loaded: " + error + ")") << "\n";
- }
- #if JUCE_WINDOWS
- text << "native image: " << juce::NativeImageType().create (juce::Image::RGB, 8, 8, true)->createType()->getTypeID()
- << " (software = " << juce::SoftwareImageType().getTypeID() << ")\n";
- #endif
- auto failures = 0;
- struct Size
- {
- int width, height;
- std::vector<float> scales;
- };
- const auto folder = report.getParentDirectory();
- for (const auto& size : { Size { 1466, 930, { 1.0f, 1.5f, 2.0f, 3.0f } }, Size { 3840, 2040, { 1.0f, 2.0f } }, Size { 17000, 700, { 1.0f } } })
- {
- const auto label = [&size] (const char* name) { return juce::String (name) + " " + juce::String (size.width) + " x " + juce::String (size.height); };
- {
- auto playlist = std::make_unique<lynx::PlaylistComponent> (*engine);
- playlist->setBounds (0, 0, size.width, size.height);
- playlist->setVisible (true);
- {
- juce::Image warm (juce::Image::RGB, 64, 64, true); // (one paint asks for the waveforms, then they are waited for)
- juce::Graphics g (warm);
- playlist->paintEntireComponent (g, true);
- }
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (60000);
- text << lynx::ui::picturecheck::run (*playlist, label ("Playlist"), size.scales, failures, folder);
- }
- {
- auto mixer = std::make_unique<lynx::MixerComponent> (*engine);
- mixer->setBounds (0, 0, size.width, juce::jmin (size.height, 700));
- mixer->setVisible (true);
- text << lynx::ui::picturecheck::run (*mixer, label ("Mixer"), size.scales, failures, folder);
- }
- }
- text << "failures: " << failures << "\nresult=" << (failures == 0 ? "OK" : "FAIL") << "\n";
- report.replaceWithText (text);
- setApplicationReturnValue (failures == 0 ? 0 : 1);
- quit();
- }
- // --uiperf (round 161): opens the project in the normal window, plays it, and drives the heavy UI cases of round 151
- // through the window's own event path — the default layout, the Mixer maximised (meters while playing, then
- // scrolled), the Playlist maximised (scroll down, scroll sideways, zoom in and out) and the Channel rack scrolled.
- // Every frame is painted right after its event (ComponentPeer::performAnyPendingRepaintsNow) and timed; the report
- // has, per case, the time to show it and the frames' mean / p95 / max, how many took longer than 16 ms, and the
- // process CPU. The same on every OS, so Linux (X11, XWayland) and Windows numbers can be put side by side.
- void runUiPerf (const juce::File& project, const juce::File& report)
- {
- if (const auto profile = juce::SystemStats::getEnvironmentVariable ("LYNX_PROFILE_MAIN", {}); profile.isNotEmpty())
- lynx::crashguard::startMainProfiler (profile.toStdString()); // (stopped in shutdown)
- startupOptions = lynx::StartupOptions::load();
- engine = std::make_unique<lynx::AudioEngine>();
- lynx::videoview::install (*engine); // (Fruity Video Player channels: their sound tracks)
- crashEngine = engine.get();
- createMainWindow();
- mainWindow->reveal();
- // LYNX_UIPERF_SIZE=WxH, LYNX_UIPERF_SCALE=<percent> (round 179a): a large window, a HiDPI desktop's scale
- if (const auto scale = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_SCALE", {}).getIntValue(); scale > 0)
- juce::Desktop::getInstance().setGlobalScaleFactor ((float) scale / 100.0f);
- if (const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_SIZE", {}), "x", ""); size.size() == 2)
- mainWindow->setBounds (0, 0, size[0].getIntValue(), size[1].getIntValue());
- juce::String error;
- auto ok = false;
- const auto loadStart = juce::Time::getMillisecondCounterHiRes();
- if (project.hasFileExtension ("flp;als;flm;band;blx")) // (round 190gr: a Live set, its Session clips in the grid)
- ok = engine->importFlpFile (project, error);
- else if (auto song = lynx::ProjectFile::load (project, error))
- {
- engine->setSong (std::move (*song));
- ok = true;
- }
- const auto loadMs = juce::Time::getMillisecondCounterHiRes() - loadStart;
- if (! ok)
- {
- report.replaceWithText ("project: " + project.getFullPathName() + "\nresult=ERROR " + error + "\n");
- setApplicationReturnValue (1);
- quit();
- return;
- }
- // LYNX_UIPERF_STANDIN=1 (round 190qe): no audio device here (Xvfb under WSL): the self-tests' stand-in device plays the
- // song, so the "playing" steps move (the playhead of UX-A10's check above all)
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_STANDIN", {}) == "1" && engine->getDeviceManager().getCurrentAudioDevice() == nullptr)
- if (const auto e = engine->openStandInDevice (48000.0, 512); e.isNotEmpty())
- std::fprintf (stderr, "uiperf: stand-in device: %s\n", e.toRawUTF8());
- // LYNX_UIPERF_MUTE=1: the Master fader down (the meters of the inserts still move): a run on a desktop someone uses
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_MUTE", {}) == "1")
- engine->editSong ([] (lynx::Song& s) { if (! s.mixer.empty()) s.mixer[0].volume = 0.0f; }, false);
- struct Step
- {
- juce::String name;
- std::function<void()> setup;
- std::function<void (int)> action; // per frame; none: the step watches the window for `frames` ms
- int frames;
- std::function<juce::String()> finish = {}; // round 173f: after the step, its own lines for the report
- };
- struct UiPerf final : juce::Timer
- {
- LynxApplication& app;
- juce::File report;
- juce::String text;
- std::vector<Step> steps;
- std::size_t step = 0;
- int frame = -1;
- std::vector<double> times, rendered; // whole frames (event + paint + blit, when this timer paints) / the window's paints
- std::vector<double> frames; // round 173f: the time of every frame the window painted (ui/FrameProbe.h)
- double paintedPixels = 0.0; // round 190ge: the dirty area of those frames, summed (overdraw / repaint storms)
- double setupMs = 0.0, wallStart = 0.0;
- double cpuStart = 0.0; // process CPU seconds (std::clock is wall time on Windows)
- bool threadsWanted = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_THREADS", {}) == "1";
- std::vector<lynx::ThreadCpu> threadsStart;
- double messageCpuStart = 0.0; // the message thread's CPU seconds
- // round 190jx: LYNX_UIPERF_PEER_PID=<pid> (Linux): another process's CPU over each step too (the X server, which
- // draws the overlay's marks there)
- int peerPid = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_PEER_PID", "0").getIntValue();
- double peerCpuStart = 0.0;
- static double peerCpuSeconds (int pid)
- {
- if (pid <= 0)
- return 0.0;
- const auto stat = juce::File ("/proc/" + juce::String (pid) + "/stat").loadFileAsString();
- const auto fields = juce::StringArray::fromTokens (stat.fromLastOccurrenceOf (")", false, false), " ", "");
- // (after the name: state is field 0, utime 11, stime 12, in clock ticks)
- return fields.size() > 12 ? (fields[11].getDoubleValue() + fields[12].getDoubleValue()) / 100.0 : 0.0;
- }
- int presentsStart = 0; // round 190jy: Direct2D presents of every LYNX window (Windows)
- double audioLoadSum = 0.0; // the device's CPU use (AudioDeviceManager::getCpuUsage), summed per tick
- int audioLoadTicks = 0;
- // round 190kb: exact CPU cycles, the worker pool's waiting, the callbacks' deadlines, the Direct2D presents
- std::uint64_t cyclesStart = 0;
- lynx::WorkerPool::Stats poolStart;
- lynx::RtStats::Snapshot rtStart; // (presentsStart: 190jy's, above)
- std::map<std::string, std::pair<long long, long long>> tickersStart; // round 190kr
- int coveredStart = 0;
- // round 190os: LYNX_UIPERF_STALLS=<folder>, each step's wall-clock thread samples and frame times there
- // (crashguard::startStallSampler; perf190os/s/stalls.py)
- juce::String stallsFolder = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_STALLS", {});
- UiPerf (LynxApplication& a, juce::File r) : app (a), report (std::move (r))
- {
- lynx::WorkerPool::nameCurrentThread ("LYNX message thread"); // (round 190kb: the threads' lines)
- }
- juce::ComponentPeer* peer() const { return app.mainWindow != nullptr ? app.mainWindow->getPeer() : nullptr; }
- double paintNow() const
- {
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- if (auto* p = peer())
- p->performAnyPendingRepaintsNow();
- return juce::Time::getMillisecondCounterHiRes() - t0;
- }
- void timerCallback() override
- {
- if (step >= steps.size())
- {
- stopTimer();
- finish();
- return;
- }
- auto& s = steps[step];
- if (frame < 0)
- {
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- if (s.setup)
- s.setup();
- paintNow();
- setupMs = juce::Time::getMillisecondCounterHiRes() - t0;
- times.clear();
- rendered.clear();
- frames.clear();
- paintedPixels = 0.0;
- wallStart = juce::Time::getMillisecondCounterHiRes();
- cpuStart = lynx::processCpuSeconds();
- messageCpuStart = lynx::threadCpuSeconds();
- peerCpuStart = peerCpuSeconds (peerPid);
- // round 190os: LYNX_UIPERF_UIPRIO="<priority>[,m]" — the UI's helper threads (Direct2D's swap chain
- // waiters, the vblank and timer threads; with ",m" the message thread too) at that Windows thread
- // priority, for the stall A/B
- if (const auto prio = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_UIPRIO", {}); prio.isNotEmpty())
- text << " (UI threads at priority " << prio.getIntValue() << ": "
- << lynx::setThreadPriorities ({ "swap chain", "VBlank", "Timer" }, prio.endsWith (",m"), prio.getIntValue()) << " set)\n";
- // LYNX_UIPERF_DRVPRIO=<priority>: the graphics driver's own threads in this process (NVIDIA, AMD, Intel)
- if (const auto prio = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_DRVPRIO", {}); prio.isNotEmpty())
- text << " (driver threads at priority " << prio.getIntValue() << ": "
- << lynx::setThreadPriorities ({ "module:nvwgf2um", "module:amdxx", "module:atidxx", "module:igd10", "module:igd12" }, false, prio.getIntValue()) << " set)\n";
- if (stallsFolder.isNotEmpty())
- lynx::crashguard::startStallSampler ({ "swap chain", "VBlank", "Timer" }, 2000, &app.engine->getOverloadGuard().stateTag());
- presentsStart = uiPerfPresents();
- if (threadsWanted) // round 190ih: LYNX_UIPERF_THREADS=1, the CPU of every thread over the step
- threadsStart = lynx::threadCpuList();
- lynx::grossBeatPaintStats (true);
- cyclesStart = lynx::processCpuCycles();
- tickersStart = lynx::ui::FrameTicker::perOwner();
- coveredStart = lynx::nativechild::coveredSkips().load();
- if (const auto* pool = app.engine->getWorkerPool())
- poolStart = pool->stats();
- rtStart = app.engine->getRtStats().snapshot();
- audioLoadSum = 0.0;
- audioLoadTicks = 0;
- frame = 0;
- return;
- }
- audioLoadSum += app.engine->getDeviceManager().getCpuUsage();
- ++audioLoadTicks;
- if (s.action)
- s.action (frame);
- if (const auto ms = paintNow(); ms > 0.25) // (nothing to paint: not a frame)
- times.push_back (ms);
- ++frame;
- if (s.action ? frame < s.frames : juce::Time::getMillisecondCounterHiRes() - wallStart < (double) s.frames)
- return;
- const auto wall = juce::Time::getMillisecondCounterHiRes() - wallStart;
- const auto cpu = 1000.0 * (lynx::processCpuSeconds() - cpuStart);
- const auto messageCpu = 1000.0 * (lynx::threadCpuSeconds() - messageCpuStart);
- text << s.name << ": show " << juce::String (setupMs, 1) << " ms\n"
- << " painted frames: " << stats (rendered) << "\n"
- << " timed here (event + paint + blit): " << stats (times)
- << "\n window frames (probe): " << lynx::ui::FrameStats::of (frames, wall).describe()
- << ", painted " << juce::String (wall > 0.0 ? paintedPixels / wall / 1000.0 : 0.0, 2) << " Mpx/s"
- << "\n CPU " << juce::String (wall > 0.0 ? 100.0 * cpu / wall : 0.0, 0) << "% (process, " << juce::String (wall / 1000.0, 1) << " s), message thread "
- << juce::String (wall > 0.0 ? 100.0 * messageCpu / wall : 0.0, 1) << "%, audio device "
- << juce::String (audioLoadTicks > 0 ? 100.0 * audioLoadSum / audioLoadTicks : 0.0, 1) << "%\n";
- if (peerPid > 0 && wall > 0.0)
- text << " peer process " << peerPid << " CPU " << juce::String (100.0 * 1000.0 * (peerCpuSeconds (peerPid) - peerCpuStart) / wall, 1) << "%\n";
- // round 190jy: every LYNX window's Direct2D presents (the main window's and each native child's) and how
- // the docked LYNX editors were drawn
- {
- int native = 0, inMain = 0, hidden = 0;
- for (auto* w : lynx::dockedEditorWindows())
- if (w != nullptr)
- (! w->isVisible() ? hidden : lynx::isEditorInMainWindow (*w) ? inMain : native) += 1;
- text << " presents " << juce::String (wall > 0.0 ? 1000.0 * (uiPerfPresents() - presentsStart) / wall : 0.0, 1)
- << "/s; docked editors: " << native << " own windows, " << inMain << " in the main window, " << hidden << " hidden\n";
- }
- const auto cycleRate = lynx::cpuCyclesPerSecond();
- if (cycleRate > 0.0 && wall > 0.0)
- text << " CPU cycles " << juce::String (100.0 * (double) (lynx::processCpuCycles() - cyclesStart) / cycleRate / (wall / 1000.0), 1)
- << "% (process, exact); presents " << juce::String (1000.0 * (uiPerfPresents() - presentsStart) / wall, 1) << "/s\n";
- if (const auto* pool = app.engine->getWorkerPool(); pool != nullptr && wall > 0.0)
- {
- // round 190kb: per second of the step (time in ms/s = tenths of a percent of one core)
- const auto p = pool->stats();
- const auto& a = poolStart;
- const auto perS = [wall] (std::uint64_t v) { return juce::String (1000.0 * (double) v / wall, 0); };
- const auto msS = [wall] (std::uint64_t ns) { return juce::String ((double) ns / 1.0e6 * 1000.0 / wall, 2); };
- text << " pool: rounds " << perS (p.rounds - a.rounds) << "/s; workers work " << msS (p.workNs - a.workNs)
- << " ms/s, spin " << msS (p.spinNs - a.spinNs) << " ms/s (" << perS (p.spins - a.spins) << "/s: found "
- << perS (p.spinFound - a.spinFound) << ", parked " << perS (p.spinParked - a.spinParked) << ", timed out "
- << perS (p.spinTimedOut - a.spinTimedOut) << "), sleeps " << perS (p.sleeps - a.sleeps) << "/s (early "
- << perS (p.earlyWakes - a.earlyWakes) << "); waits " << msS (p.waitNs - a.waitNs) << " ms/s (" << perS (p.waits - a.waits)
- << "/s, yields " << perS (p.waitYields - a.waitYields) << ", sleeps " << perS (p.waitSleeps - a.waitSleeps) << " = " << msS (p.waitSleepNs - a.waitSleepNs) << " ms/s"
- << "); caller wait " << msS (p.callerWaitNs - a.callerWaitNs) << " ms/s (sleeps " << perS (p.callerSleeps - a.callerSleeps) << "/s)\n";
- }
- {
- const auto r = app.engine->getRtStats().snapshot();
- text << " callbacks " << juce::String ((juce::int64) (r.callbacks - rtStart.callbacks)) << ", over the deadline "
- << juce::String ((juce::int64) (r.overBudget - rtStart.overBudget)) << ", 80-100 % " << juce::String ((juce::int64) (r.nearBudget - rtStart.nearBudget))
- << ", late " << juce::String ((juce::int64) (r.lateCalls - rtStart.lateCalls)) << "\n";
- // round 190ok (P24): Settings › Audio › "Safe overloads" (core/OverloadGuard.h), since the start
- const auto& guard = app.engine->getOverloadGuard();
- text << " safe overloads " << (guard.isEnabled() ? "on" : "off") << ": engaged " << (juce::int64) guard.timesEngaged()
- << " times" << (guard.engaged() ? " (now)" : "") << ", yielded " << juce::String (guard.yieldedMs(), 0) << " ms"
- // round 190px: the render-ahead thread's catch-up paced while the UI starved
- << ", render-ahead paced " << (juce::int64) guard.timesPaced() << " times (" << juce::String (guard.pacedMs(), 0) << " ms)";
- // round 190os: the last release in this step — why, and how long after the callbacks kept their
- // deadline again
- if (const auto at = guard.lastReleaseAtMs(); at >= wallStart && guard.lastReleaseReason() != lynx::OverloadGuard::notReleased)
- {
- const char* why[] { "", "the transport stopped", "the load dropped", "a probe passed" };
- text << "; let go " << juce::String (at - wallStart, 0) << " ms into the step (" << why[juce::jlimit (0, 3, guard.lastReleaseReason())]
- << ", " << juce::String (guard.lastReleaseLagMs(), 0) << " ms after the callbacks kept their deadline)";
- }
- text << "\n";
- }
- if (threadsWanted && wall > 0.0)
- {
- // (round 190kb: and each thread's exact cycles in brackets, as % of one core; sorted by them where known)
- std::vector<std::pair<double, juce::String>> rows;
- for (const auto& t : lynx::threadCpuList())
- {
- auto before = 0.0;
- std::uint64_t cyclesBefore = 0;
- for (const auto& b : threadsStart)
- if (b.id == t.id)
- before = b.seconds, cyclesBefore = b.cycles;
- const auto used = t.seconds - before;
- const auto exact = cycleRate > 0.0 ? 100.0 * (double) (t.cycles - cyclesBefore) / cycleRate / (wall / 1000.0) : -1.0;
- if (used > 0.0005 || exact > 0.05)
- rows.push_back ({ exact >= 0.0 ? exact : 100.0 * 1000.0 * used / wall,
- juce::String (t.id) + " " + (t.name.empty() ? juce::String ("(unnamed)") : juce::String (t.name)) + " "
- + juce::String (100.0 * 1000.0 * used / wall, 1) + "%" + (exact >= 0.0 ? " [" + juce::String (exact, 1) + "%]" : juce::String()) });
- }
- std::sort (rows.begin(), rows.end(), [] (const auto& a, const auto& b) { return a.first > b.first; });
- text << " threads:";
- for (std::size_t k = 0; k < rows.size() && k < 16; ++k)
- text << " " << rows[k].second << ";";
- text << "\n";
- }
- if (const auto gb = lynx::grossBeatPaintStats (false); gb.isNotEmpty())
- text << " " << gb << "\n";
- // round 190kr: LYNX_UIPERF_TICKERS=1, the live views' frame steps per second (run / moved) and the steps
- // left out because the view's docked panel was covered
- if (lynx::ui::FrameTicker::perOwnerWanted() && wall > 0.0)
- {
- text << " tickers:";
- for (const auto& [name, counts] : lynx::ui::FrameTicker::perOwner())
- {
- const auto before = tickersStart.count (name) != 0 ? tickersStart.at (name) : std::pair<long long, long long> {};
- if (counts.first != before.first)
- text << " " << juce::String (name).fromLastOccurrenceOf ("::", false, false).retainCharacters ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_")
- << " " << juce::String (1000.0 * (double) (counts.first - before.first) / wall, 0) << "/" << juce::String (1000.0 * (double) (counts.second - before.second) / wall, 0);
- }
- text << "; covered skips " << juce::String (1000.0 * (double) (lynx::nativechild::coveredSkips().load() - coveredStart) / wall, 0) << "/s\n";
- }
- if (stallsFolder.isNotEmpty())
- {
- juce::File (stallsFolder).createDirectory();
- lynx::crashguard::stopStallSampler (juce::File (stallsFolder).getChildFile ("stall-" + juce::String ((int) step) + ".txt").getFullPathName().toStdString());
- juce::String list;
- for (const auto t : frames)
- list << juce::String (t, 3) << "\n";
- juce::File (stallsFolder).getChildFile ("frames-" + juce::String ((int) step) + ".txt").replaceWithText (list);
- text << " stall samples: " << stallsFolder << " (step " << (int) step << ")\n";
- }
- if (s.finish)
- text << s.finish();
- juce::File (report).replaceWithText (text);
- ++step;
- frame = -1;
- }
- static juce::String stats (std::vector<double> sorted)
- {
- std::sort (sorted.begin(), sorted.end());
- const auto at = [&sorted] (double q) { return sorted.empty() ? 0.0 : sorted[(std::size_t) juce::jlimit (0, (int) sorted.size() - 1, (int) (q * (double) sorted.size()))]; };
- double sum = 0.0;
- int over = 0;
- for (auto t : sorted)
- {
- sum += t;
- over += t > 16.0 ? 1 : 0;
- }
- return juce::String ((int) sorted.size()) + ", mean " + juce::String (sorted.empty() ? 0.0 : sum / (double) sorted.size(), 1)
- + " ms, p95 " + juce::String (at (0.95), 1) + " ms, max " + juce::String (sorted.empty() ? 0.0 : sorted.back(), 1)
- + " ms, >16 ms " + juce::String (over);
- }
- void finish()
- {
- // the cost of asking where the mouse is (X11: a round trip to the display server)
- const auto q0 = juce::Time::getMillisecondCounterHiRes();
- for (int i = 0; i < 100; ++i)
- juce::ignoreUnused (juce::Desktop::getInstance().getMainMouseSource().getScreenPosition());
- text << "mouse position query: " << juce::String ((juce::Time::getMillisecondCounterHiRes() - q0) / 100.0, 3) << " ms\n";
- app.mainWindow->onFrame = nullptr;
- app.mainWindow->watchFrames ({});
- app.engine->stop();
- text << "result=OK\n";
- report.replaceWithText (text);
- app.setApplicationReturnValue (0);
- app.quit();
- }
- };
- auto* ui = &mainWindow->getContent();
- auto wheelAt = [this] (juce::Component& target, float dx, float dy, juce::ModifierKeys mods) {
- auto* peer = mainWindow->getPeer();
- if (peer == nullptr || ! target.isShowing())
- return;
- juce::ModifierKeys::currentModifiers = mods;
- const auto local = peer->globalToLocal (target.localPointToGlobal (target.getLocalBounds().getCentre()).toFloat());
- juce::MouseWheelDetails wheel { dx, dy, false, false, false };
- peer->handleMouseWheel (juce::MouseInputSource::InputSourceType::mouse, local, juce::Time::currentTimeMillis(), wheel);
- juce::ModifierKeys::currentModifiers = {};
- };
- auto run = std::make_unique<UiPerf> (*this, report);
- mainWindow->onFrame = [r = run.get()] (double ms) { if (r->frame >= 0) r->rendered.push_back (ms); };
- // round 173f: every frame the window paints; a fader drag's moves count as shown when a frame covers the fader
- auto drag = std::make_shared<UiPerfDrag>();
- mainWindow->watchFrames ([r = run.get(), drag] (double now, juce::Rectangle<int> area) {
- if (r->frame >= 0)
- {
- r->frames.push_back (now);
- r->paintedPixels += (double) area.getWidth() * (double) area.getHeight();
- }
- drag->framePainted (now, area);
- });
- run->text << "project: " << project.getFullPathName() << "\n"
- << "LYNX " << getApplicationVersion() << ", " << juce::SystemStats::getOperatingSystemName() << ", "
- << juce::SystemStats::getCpuModel() << ", window " << mainWindow->getWidth() << "x" << mainWindow->getHeight()
- << ", scale " << juce::String (juce::Desktop::getInstance().getDisplays().getPrimaryDisplay() != nullptr
- ? juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->scale : 1.0, 2)
- << ", audio device " << (engine->getDeviceManager().getCurrentAudioDevice() != nullptr ? engine->getDeviceManager().getCurrentAudioDevice()->getName() : juce::String ("none")) << "\n"
- << "load " << juce::String (loadMs / 1000.0, 2) << " s\n";
- const auto none = juce::ModifierKeys();
- // discussion #10 (round 173f): the reporter's screen — the Channel Rack and the Mixer open, the pattern playing —
- // watched as it is, then insert 3's fader dragged up and down with the mouse (125 moves a second through the
- // window's own mouse path, the frames painted as the window paints them)
- const auto dragTrack = engine->getSong().mixer.size() > 3 ? 3 : 1;
- run->steps.push_back ({ "rack + mixer, pattern playing", [this, ui] {
- ui->showPanelsForSnapshot ({ lynx::workspace::Panel::channelRack, lynx::workspace::Panel::mixer });
- engine->getTransport().songMode = false;
- engine->rewind();
- engine->play();
- }, {}, 4000 });
- run->steps.push_back ({ "fader drag by mouse, rack + mixer, pattern playing", [this, ui, drag, dragTrack] {
- auto& strips = ui->getMixerForSnapshot().getStripsForSnapshot();
- const auto rail = strips.faderRailForSnapshot (dragTrack);
- drag->start (*mainWindow, strips, rail, engine.get(), dragTrack);
- }, {}, 3000, [drag] { return drag->stop(); } });
- run->steps.push_back ({ "song stopped during the drag", {}, {}, 500, [drag] { return drag->release(); } });
- run->steps.push_back ({ "after the drag (released)", {}, {}, 600, [drag] { return drag->released(); } });
- run->steps.push_back ({ "desktop, playing", [this, ui] { ui->showDesktopForSnapshot (false); engine->rewind(); engine->play(); }, {}, 3000 });
- run->steps.push_back ({ "mixer maximised, playing", [ui] { ui->selectTabForSnapshot (3); }, {}, 3000 });
- // round 177a: only the meters move, so the strips' picture must stay valid, also with a folded group's tab and VCA
- // strips on screen (their levels are drawn over the picture, like the inserts' meters)
- run->steps.push_back ({ "mixer meters over the picture, playing", [this, ui] {
- ui->selectTabForSnapshot (3);
- engine->getTransport().songMode = false;
- engine->rewind();
- engine->play();
- ui->getMixerForSnapshot().getStripsForSnapshot().cacheCountersForPerf();
- }, {}, 6000, [this, ui, report] {
- const auto [spoiled, refills] = ui->getMixerForSnapshot().getStripsForSnapshot().cacheCountersForPerf();
- if (juce::FileOutputStream out (report.withFileExtension ("png")); out.openedOk())
- {
- out.setPosition (0);
- out.truncate();
- juce::PNGImageFormat().writeImageToStream (mainWindow->createComponentSnapshot (mainWindow->getLocalBounds()), out);
- }
- return juce::String (" mixer picture: spoiled ") + juce::String (spoiled) + " times, drawn again " + juce::String (refills) + " times\n";
- } });
- // (round 190my: the wheel goes to a strip's blank body near the Mixer's centre — since 293333ae6's Current strip the
- // centre itself can be a control, which the wheel would turn instead of scrolling; trace 190my: the strips then
- // move from x -56 to -325 in a 1113 px view. Strips that fit their view can't scroll: the step uses Extra large
- // then, e.g. at a wide window.)
- auto scrollLayout = std::make_shared<std::optional<lynx::mixerlayout::Layout>>();
- auto scrollTrace = std::make_shared<juce::String>();
- run->steps.push_back ({ "mixer scroll",
- [ui, scrollLayout, scrollTrace] {
- scrollTrace->clear();
- auto& strips = ui->getMixerForSnapshot().getStripsForSnapshot();
- const auto* holder = strips.getParentComponent();
- if (holder != nullptr && strips.getWidth() <= holder->getWidth() + 200)
- {
- *scrollLayout = lynx::MixerStrips::layout;
- strips.setLayout (lynx::mixerlayout::Layout::extraLarge);
- }
- },
- [this, ui, scrollTrace] (int f) {
- auto& mixer = ui->getMixerForSnapshot();
- auto& strips = mixer.getStripsForSnapshot();
- auto* peer = mainWindow->getPeer();
- if (peer == nullptr || ! strips.isShowing())
- return;
- const auto centre = strips.getLocalPoint (&mixer, mixer.getLocalBounds().getCentre());
- const auto at = strips.wheelScrollPointForPerf (centre, strips.getParentComponent() != nullptr
- ? strips.getLocalArea (strips.getParentComponent(), strips.getParentComponent()->getLocalBounds())
- : strips.getLocalBounds());
- const auto local = peer->globalToLocal (strips.localPointToGlobal (at).toFloat());
- juce::ModifierKeys::currentModifiers = {};
- juce::MouseWheelDetails wheel { 0.0f, f < 30 ? -0.25f : 0.25f, false, false, false };
- peer->handleMouseWheel (juce::MouseInputSource::InputSourceType::mouse, local, juce::Time::currentTimeMillis(), wheel);
- if (f == 0 || f == 29)
- {
- auto* under = peer->getComponent().getComponentAt (local.roundToInt());
- const auto* holder = strips.getParentComponent();
- *scrollTrace << " mixer scroll frame " << f << ": wheel at " << at.toString() << " (strips), under it "
- << (under == &strips ? juce::String ("the strips") : under != nullptr ? juce::String (typeid (*under).name()) : juce::String ("nothing"))
- << ", view " << (holder != nullptr ? holder->getBounds().toString() : juce::String()) << ", strips at x " << strips.getX() << "\n";
- }
- }, 60,
- [ui, scrollLayout, scrollTrace] {
- auto& strips = ui->getMixerForSnapshot().getStripsForSnapshot();
- const auto width = strips.getWidth();
- juce::String used = scrollLayout->has_value() ? "Extra large (the strips fit the view in their layout)" : "the project's layout";
- if (scrollLayout->has_value())
- strips.setLayout (**scrollLayout);
- scrollLayout->reset();
- return juce::String (" mixer scroll: strips ") + juce::String (width) + " px, " + used + "\n" + *scrollTrace;
- } });
- // a fader dragged while the song plays (round 171c, discussion #10): 4 mouse moves per frame on insert 1's fader,
- // through the old path (a whole snapshot per move) and through editLevels
- auto faderMove = [this] (bool levels, int f) {
- for (int k = 0; k < 4; ++k)
- {
- const auto v = 0.5f + 0.3f * std::sin ((float) (f * 4 + k) * 0.05f);
- const auto edit = [v] (lynx::Song& s) { if (s.mixer.size() > 1) s.mixer[1].volume = v; };
- if (levels)
- engine->editLevels (edit, false); // (no undo step: in a real drag only the press saves one)
- else
- engine->editSong (edit, false);
- }
- };
- run->steps.push_back ({ "mixer fader drag, playing, rebuild per move (before 171c)", {}, [faderMove] (int f) { faderMove (false, f); }, 60 });
- run->steps.push_back ({ "mixer fader drag, playing, live levels (171c)", {}, [faderMove, this] (int f) { faderMove (true, f); if (f == 59) engine->flushLevels(); }, 60 });
- // F8's Plugin picker (round 171c): opening it (the "show" time = building it + its first paint), its pictures
- // loading while it stays open, pointing at the tiles, then closing it
- run->steps.push_back ({ "plugin picker open (F8)", [ui] { ui->togglePluginPickerForSnapshot(); }, {}, 2500 });
- run->steps.push_back ({ "plugin picker, pointing at tiles", {}, [ui] (int f) {
- // (round 175b: the picker is its own window)
- if (auto* picker = ui->pluginPickerForSnapshot(); picker != nullptr && picker->getPeer() != nullptr)
- {
- const auto p = picker->localPointToGlobal (juce::Point<int> (60 + (f * 37) % juce::jmax (1, picker->getWidth() - 120),
- 90 + (f * 53) % juce::jmax (1, picker->getHeight() - 200)));
- const auto local = picker->getPeer()->globalToLocal (p.toFloat());
- picker->getPeer()->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, local, {}, 0.0f, 0.0f,
- juce::Time::currentTimeMillis());
- }
- }, 60 });
- run->steps.push_back ({ "plugin picker close", [ui] { ui->togglePluginPickerForSnapshot(); }, {}, 300 });
- run->steps.push_back ({ "playlist maximised, playing", [ui] { ui->selectTabForSnapshot (2); }, {}, 3000 });
- run->steps.push_back ({ "playlist scroll down/up", [this] { engine->stop(); },
- [wheelAt, ui, none] (int f) { wheelAt (ui->getPlaylistForSnapshot(), 0.0f, f < 40 ? -0.15f : 0.15f, none); }, 80 });
- run->steps.push_back ({ "playlist scroll sideways", {},
- [wheelAt, ui, none] (int f) { wheelAt (ui->getPlaylistForSnapshot(), f < 40 ? -0.15f : 0.15f, 0.0f, none); }, 80 });
- // round 174f: Ctrl+wheel zoom, a notch every third frame (~20 a second), three in then three out, as dupmon drives it
- run->steps.push_back ({ "playlist zoom (Ctrl+wheel)", {},
- [wheelAt, ui] (int f) {
- if (f % 3 == 0)
- wheelAt (ui->getPlaylistForSnapshot(), 0.0f, (f / 9) % 2 == 0 ? 0.15f : -0.15f, juce::ModifierKeys (juce::ModifierKeys::ctrlModifier));
- }, 120 });
- run->steps.push_back ({ "playlist after the zoom (settles)", {}, {}, 500 });
- // round 190qe (TOP-NEXT R1): "edgescroll" — a clip held 20 px past the Playlist's right edge for 2 s: the view runs on
- // the view's frames at FL's speed (Pattern layout: ≈ 223 px/s), so the window's frames a second are the display's rate
- // (compare "playlist maximised, playing"); the move is undone after. "UX-A10" — the overview strip's window dragged
- // sideways for 5 s while the song plays: the playhead drawn must move every frame (no stall, then jump, as FL's)
- {
- struct FeelPerf
- {
- double startScroll = 0.0, startMs = 0.0, ppt = 1.0;
- juce::Point<int> press, held;
- std::vector<double> playheads;
- int stalls = 0, longestStall = 0, run = 0;
- };
- auto feel = std::make_shared<FeelPerf>();
- auto inject = [this] (juce::Component& target, juce::Point<int> p, bool down) {
- auto* peer = mainWindow->getPeer();
- if (peer == nullptr)
- return;
- const auto mods = down ? juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier) : juce::ModifierKeys();
- juce::ModifierKeys::currentModifiers = mods;
- const auto local = peer->globalToLocal (target.localPointToGlobal (p).toFloat());
- peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, local, mods, juce::MouseInputSource::defaultPressure,
- juce::MouseInputSource::defaultOrientation, juce::Time::currentTimeMillis());
- };
- run->steps.push_back ({ "playlist edgescroll: a clip held 20 px past the right edge (2 s)", [this, ui, feel, inject] {
- engine->stop();
- ui->selectTabForSnapshot (2);
- auto& pl = ui->getPlaylistForSnapshot();
- const auto grid = pl.gridAreaForSnapshot();
- // the first clip at least 24 px wide fully in view
- const auto& list = engine->getSong().playlist;
- for (int i = 0; i < (int) list.size(); ++i)
- if (const auto b = pl.clipBoundsForSnapshot (i); b.getWidth() >= 24 && grid.contains (b) && b.getHeight() >= 12)
- {
- feel->press = { b.getX() + 12, b.getBottom() - 4 };
- break;
- }
- feel->held = { grid.getRight() - 1 + 20, feel->press.y };
- feel->startScroll = pl.viewNowForTests().scroll;
- feel->ppt = pl.viewNowForTests().pixelsPerUnit;
- inject (pl, feel->press, false);
- inject (pl, feel->press, true);
- inject (pl, { (feel->press.x + feel->held.x) / 2, feel->press.y }, true);
- inject (pl, feel->held, true);
- feel->startMs = juce::Time::getMillisecondCounterHiRes();
- }, {}, 2000, [this, ui, feel, inject] {
- auto& pl = ui->getPlaylistForSnapshot();
- const auto ms = juce::Time::getMillisecondCounterHiRes() - feel->startMs;
- const auto moved = (pl.viewNowForTests().scroll - feel->startScroll) * feel->ppt;
- inject (pl, feel->held, false);
- juce::ModifierKeys::currentModifiers = {};
- engine->undo();
- return " edge scroll: " + juce::String (moved, 0) + " px in " + juce::String (ms / 1000.0, 2) + " s = "
- + juce::String (ms > 0.0 ? 1000.0 * moved / ms : 0.0, 0) + " px/s (FL's law 20 px out: 223 px/s; press at "
- + feel->press.toString() + ")\n";
- } });
- run->steps.push_back ({ "playlist overview drag while playing (UX-A10, 5 s)", [this, ui, feel, inject] {
- ui->selectTabForSnapshot (2);
- auto& pl = ui->getPlaylistForSnapshot();
- pl.setViewForSnapshot (64.0, 0, 0);
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- auto& strip = pl.overviewForSnapshot();
- const auto w = strip.windowAreaForSnapshot();
- feel->press = pl.getLocalPoint (&strip, juce::Point<int> ((int) w.getCentreX(), (int) w.getCentreY()));
- feel->playheads.clear();
- feel->stalls = feel->longestStall = feel->run = 0;
- inject (pl, feel->press, false);
- inject (pl, feel->press, true);
- },
- [ui, feel, inject] (int f) {
- auto& pl = ui->getPlaylistForSnapshot();
- // 2 px a frame to the right for 2.5 s, then back
- const auto dx = f < 150 ? 2 * f : 2 * (300 - f);
- inject (pl, feel->press.translated (dx, 0), true);
- const auto now = pl.playheadTickForSnapshot();
- if (! feel->playheads.empty() && now == feel->playheads.back())
- {
- feel->longestStall = juce::jmax (feel->longestStall, ++feel->run);
- ++feel->stalls;
- }
- else
- feel->run = 0;
- feel->playheads.push_back (now);
- }, 300, [this, ui, feel, inject] {
- auto& pl = ui->getPlaylistForSnapshot();
- inject (pl, feel->press, false);
- juce::ModifierKeys::currentModifiers = {};
- engine->stop();
- const auto ok = feel->longestStall < 2;
- return " UX-A10: " + juce::String ((int) feel->playheads.size()) + " frames, the playhead stood still on "
- + juce::String (feel->stalls) + " (longest run " + juce::String (feel->longestStall) + " frames) "
- + (ok ? "OK" : "STALLS") + "\n";
- } });
- }
- run->steps.push_back ({ "whole window repainted", {}, [this] (int) { mainWindow->repaint(); }, 40 });
- run->steps.push_back ({ "channel rack scroll", [ui] { ui->selectTabForSnapshot (0); },
- [wheelAt, ui, none] (int f) { wheelAt (ui->getRackViewportForSnapshot(), 0.0f, f < 30 ? -0.25f : 0.25f, none); }, 60 });
- // round 190ge: the other main views while the pattern plays, then every view with the transport stopped and
- // nothing moving (an idle view should paint nothing: its frames and painted area are the repaint storms), then
- // the Clip-launch grid playing
- auto playPattern = [this] {
- engine->getTransport().songMode = false;
- engine->rewind();
- engine->play();
- };
- run->steps.push_back ({ "piano roll maximised, pattern playing", [ui, playPattern] { ui->selectTabForSnapshot (1); playPattern(); }, {}, 3000 });
- // round 190jx: the moving playheads alone, for the overlay's A/B (LYNX_UIPERF_ONLY="overlay A/B", LYNX_OVERLAY=0|1):
- // the Playlist with the song playing and the Piano roll with the pattern playing, LYNX_UIPERF_PLAY_MS each (10 s)
- {
- const auto playMs = juce::jmax (1000, juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_PLAY_MS", "10000").getIntValue());
- run->steps.push_back ({ "overlay A/B: playlist maximised, song playing", [this, ui] {
- ui->selectTabForSnapshot (2);
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- }, {}, playMs });
- // round 190ok (P24): LYNX_UIPERF_RECOVERY=1 — the song stopped after it, 3 s: the safe-overload guard lets go
- // and the callbacks keep their deadline again (the report's "safe overloads" line: no "(now)")
- // (round 190os: and when the guard let go after the stop was asked)
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_RECOVERY", "0") == "1")
- {
- auto stopAt = std::make_shared<double> (0.0);
- run->steps.push_back ({ "overlay A/B: playlist maximised, stopped after the song (recovery)", [this, stopAt] {
- *stopAt = juce::Time::getMillisecondCounterHiRes();
- engine->stop();
- }, {}, 3000, [this, stopAt] {
- const auto& guard = engine->getOverloadGuard();
- const auto at = guard.lastReleaseAtMs();
- return at >= *stopAt && guard.lastReleaseReason() != lynx::OverloadGuard::notReleased
- ? " safe overloads let go " + juce::String (at - *stopAt, 1) + " ms after the stop\n"
- : juce::String (" safe overloads: not let go after the stop\n");
- } });
- }
- // round 190os: LYNX_UIPERF_LOAD_ENDS=<ms> — the song played again, and that many ms in every note and every
- // playlist clip removed while the transport keeps running: the notes stop, the tails die out and the overload ends while playing.
- // The report's "safe overloads" line says when the guard let go after the callbacks kept their deadline.
- if (const auto endsMs = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_LOAD_ENDS", "0").getIntValue(); endsMs > 0)
- {
- auto emptiedAt = std::make_shared<double> (0.0);
- run->steps.push_back ({ "overlay A/B: playlist maximised, the load ends while playing", [this, ui, endsMs, emptiedAt] {
- ui->selectTabForSnapshot (2);
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- juce::Timer::callAfterDelay (endsMs, [this, emptiedAt] {
- *emptiedAt = juce::Time::getMillisecondCounterHiRes();
- engine->editSong ([] (lynx::Song& song) {
- for (auto& pattern : song.patterns)
- pattern.notes.clear();
- song.playlist.clear(); // (its audio and automation clips too)
- }, false);
- });
- }, {}, endsMs + 4000, [this, emptiedAt] {
- const auto& guard = engine->getOverloadGuard();
- const auto at = guard.lastReleaseAtMs();
- const auto playing = engine->getTransport().playing.load();
- engine->stop();
- return " notes removed (still playing: " + juce::String (playing ? "yes" : "no") + "); safe overloads "
- + (at >= *emptiedAt && *emptiedAt > 0.0 ? "let go " + juce::String (at - *emptiedAt, 0) + " ms after it, "
- + juce::String (guard.lastReleaseLagMs(), 0) + " ms after the callbacks kept their deadline\n"
- : juce::String ("not let go after it\n"));
- } });
- }
- run->steps.push_back ({ "overlay A/B: piano roll maximised, pattern playing", [ui, playPattern] { ui->selectTabForSnapshot (1); playPattern(); }, {}, playMs,
- [this] { engine->stop(); return juce::String(); } });
- }
- run->steps.push_back ({ "channel rack maximised, pattern playing", [ui, playPattern] { ui->selectTabForSnapshot (0); playPattern(); }, {}, 3000 });
- const char* idleViews[] { "channel rack", "piano roll", "playlist", "mixer" };
- for (int view = 0; view < 4; ++view)
- run->steps.push_back ({ juce::String ("idle: ") + idleViews[view] + ", stopped", [this, ui, view] { engine->stop(); ui->selectTabForSnapshot (view); }, {}, 3000 });
- run->steps.push_back ({ "idle: desktop, stopped", [this, ui] { engine->stop(); ui->showDesktopForSnapshot (false); }, {}, 3000 });
- // round 190im (R1, DE-124): the automation editor window open over the Playlist, stopped and then playing (its
- // timer only while it plays, its playhead columns only); closed after
- {
- int automation = -1;
- for (const auto& c : engine->getSong().playlist)
- if (c.kind == lynx::ClipKind::automation && c.automation >= 0 && automation < 0)
- automation = c.automation;
- if (automation >= 0)
- {
- run->steps.push_back ({ "automation editor open, stopped", [this, ui, automation] {
- engine->stop();
- ui->selectTabForSnapshot (2);
- lynx::openAutomationEditor (*engine, automation);
- }, {}, 3000 });
- run->steps.push_back ({ "automation editor open, song playing", [this] {
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- }, {}, 3000, [this] {
- engine->stop();
- auto& desktop = juce::Desktop::getInstance();
- for (int i = desktop.getNumComponents(); --i >= 0;)
- if (auto* w = dynamic_cast<juce::DocumentWindow*> (desktop.getComponent (i)); w != nullptr && w->getName().startsWith ("Automation - "))
- w->closeButtonPressed();
- return juce::String();
- } });
- }
- }
- run->steps.push_back ({ "clip grid, song playing", [this, ui] {
- ui->selectTabForSnapshot (2);
- ui->setClipLaunchWorkflow (true);
- ui->setClipGridView (lynx::PlaylistArea::GridView::grid);
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- }, {}, 3000 });
- // round 190gr: the grid's clips launched (every scene that has clips, one after the other: the playing cells'
- // progress bars move, the launches blink until their grid point)
- run->steps.push_back ({ "clip grid, clips launched", [this] {
- engine->getTransport().songMode = true;
- if (const auto& grid = engine->getSong().clipGrid)
- for (int scene = 0; scene < juce::jmin (8, (int) grid->scenes.size()); ++scene)
- engine->launcherCommand ({ lynx::launcher::Command::Type::launchScene, 0, scene });
- }, {}, 3000, [this] {
- int playing = 0;
- if (const auto* state = engine->launcherState())
- for (const auto& t : state->tracks)
- playing += t.playing.load() >= 0 ? 1 : 0;
- engine->launcherCommand ({ lynx::launcher::Command::Type::stopAll });
- return " tracks playing a clip: " + juce::String (playing) + "\n";
- } });
- run->steps.push_back ({ "idle: clip grid, stopped", [this] { engine->stop(); }, {}, 3000, [ui] { ui->setClipLaunchWorkflow (false); return juce::String(); } });
- // round 190jn: the Clip-launch layout's Arrangement (Live's look: 19 px lanes, colour blocks, dark waveforms) playing,
- // then idle
- run->steps.push_back ({ "clip arrangement, song playing", [this, ui] {
- ui->selectTabForSnapshot (2);
- ui->setClipLaunchWorkflow (true);
- ui->setClipGridView (lynx::PlaylistArea::GridView::song);
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- }, {}, 3000 });
- run->steps.push_back ({ "idle: clip arrangement, stopped", [this] { engine->stop(); }, {}, 3000, [ui] {
- ui->setClipGridView (lynx::PlaylistArea::GridView::grid);
- ui->setClipLaunchWorkflow (false);
- return juce::String();
- } });
- // round 190ih: the plugin windows with live parts — Gross Beat (its locator), the Formula Controller (its monitor),
- // the Envelope Controller (its meters and key line) — idle with the song stopped, then Gross Beat while it plays
- // (CPU and frames; the windows are their own, so the main window's painted area stays the main window's)
- run->steps.push_back ({ "idle: Gross Beat + Formula + Envelope controller windows, stopped", [this] {
- engine->stop();
- auto& song = engine->getSong();
- int gbTrack = -1, gbSlot = -1;
- for (int t = 0; t < (int) song.mixer.size() && gbTrack < 0; ++t)
- for (int k = 0; k < (int) song.mixer[(std::size_t) t].effects.size(); ++k)
- if (song.mixer[(std::size_t) t].effects[(std::size_t) k].kind == lynx::EffectKind::grossBeat)
- {
- gbTrack = t;
- gbSlot = k;
- break;
- }
- const auto last = (int) song.mixer.size() - 1;
- const auto formulaSlot = last >= 1 ? (int) song.mixer[(std::size_t) last].effects.size() : -1;
- engine->editSong ([last] (lynx::Song& s) {
- if (last >= 1 && s.mixer[(std::size_t) last].effects.size() < (std::size_t) lynx::maxEffectSlots)
- s.mixer[(std::size_t) last].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::formulaController));
- lynx::ChannelDef env;
- env.name = "Envelope Controller";
- env.instrument = lynx::InstrumentKind::controller;
- env.controllerState = lynx::writeEnvelopeController (lynx::defaultEnvelopeController());
- s.channels.push_back (env);
- }, false);
- engine->dispatchPendingMessages();
- // LYNX_UIPERF_WINDOWS: which of them (G Gross Beat, F Formula, E Envelope Controller; default all)
- const auto which = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_WINDOWS", "GFE");
- if (gbTrack >= 0 && which.containsChar ('G'))
- lynx::NativeEffectWindows::open (*engine, gbTrack, gbSlot);
- if (formulaSlot >= 0 && which.containsChar ('F'))
- lynx::FormulaControllerWindows::open (*engine, last, formulaSlot);
- if (which.containsChar ('E'))
- lynx::openChannelSettings (*engine, (int) engine->getSong().channels.size() - 1);
- }, {}, 3000 });
- // round 190ih: LYNX_UIPERF_GBAB=n — n cycles over Gross Beat's live-display variants, playing, 2.5 s each, in one
- // process (other load hits every variant alike): the names carry the LYNX_GB_DIAG mask
- if (const auto cycles = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_GBAB", "0").getIntValue(); cycles > 0)
- {
- run->steps.push_back ({ "Gross Beat A/B start", [this] {
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- }, {}, 1500 });
- // (off, the default, 30 / s, off, 10 / s; LYNX_UIPERF_GBAB_MASKS="1,2,0" picks others, e.g. round 190iy's
- // locator on the GPU overlay (0) against the repaint path (2))
- std::vector<int> masks { 1, 0, 30 << 8, 1, 10 << 8 };
- if (const auto list = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_GBAB_MASKS", {}); list.isNotEmpty())
- {
- masks.clear();
- for (const auto& m : juce::StringArray::fromTokens (list, ",", {}))
- masks.push_back (m.trim().getIntValue());
- }
- for (int c = 0; c < cycles; ++c)
- for (const int mask : masks)
- run->steps.push_back ({ "Gross Beat A/B mask " + juce::String (mask) + " cycle " + juce::String (c + 1),
- [this, mask] {
- lynx::setGrossBeatDiagnostics (mask);
- if (! engine->getTransport().playing.load()) // (the song ended: again)
- {
- engine->rewind();
- engine->play();
- }
- }, {}, 2500 });
- }
- // round 190jy (queue item 44): LYNX_UIPERF_DOCKAB=n — the docked LYNX editors with live displays, playing, each set
- // hidden / a native child window / drawn by the main window, n cycles of 2.5 s steps in one process.
- // LYNX_UIPERF_DOCKAB_SETS (default "G,L,M,GLM"): G Gross Beat, L Fruity Limiter, M Maximus (both on the master).
- if (const auto cycles = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_DOCKAB", "0").getIntValue(); cycles > 0)
- {
- auto sets = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_DOCKAB_SETS", "G,L,M,GLM"), ",", {});
- auto shown = std::make_shared<std::vector<juce::Component::SafePointer<juce::DocumentWindow>>>();
- auto keepPlaying = [this] {
- engine->getTransport().songMode = true;
- if (! engine->getTransport().playing.load()) // (the song ended: again)
- {
- engine->rewind();
- engine->play();
- }
- };
- for (const auto& set : sets)
- {
- const auto name = set.trim();
- run->steps.push_back ({ "dock A/B " + name + " open", [this, name, shown, keepPlaying] {
- lynx::NativeEffectWindows::closeAll();
- for (auto* w : lynx::dockedEditorWindows()) // (a channel's settings window of the set before)
- if (w != nullptr)
- w->closeButtonPressed();
- shown->clear();
- auto& song = engine->getSong();
- auto openKind = [this] (lynx::EffectKind kind) {
- auto& so = engine->getSong();
- for (int t = 0; t < (int) so.mixer.size(); ++t)
- for (int k = 0; k < (int) so.mixer[(std::size_t) t].effects.size(); ++k)
- if (so.mixer[(std::size_t) t].effects[(std::size_t) k].kind == kind)
- {
- lynx::NativeEffectWindows::open (*engine, t, k);
- return;
- }
- // (not in the project: on the master, after its effects)
- if (so.mixer.empty() || so.mixer[0].effects.size() >= (std::size_t) lynx::maxEffectSlots)
- return;
- const auto slot = (int) so.mixer[0].effects.size();
- engine->editSong ([kind] (lynx::Song& s2) { s2.mixer[0].effects.push_back (lynx::makeEffectSlot (kind)); }, false);
- engine->dispatchPendingMessages();
- lynx::NativeEffectWindows::open (*engine, 0, slot);
- };
- juce::ignoreUnused (song);
- if (name.containsChar ('G'))
- openKind (lynx::EffectKind::grossBeat);
- if (name.containsChar ('L'))
- openKind (lynx::EffectKind::fruityLimiter);
- if (name.containsChar ('M'))
- openKind (lynx::EffectKind::maximus);
- // S: a Slicex channel (a 2 s tone in 4 regions) that plays the notes of the project's busiest
- // channel, its settings window open (its deck's play line moves while it sounds)
- if (name.containsChar ('S'))
- {
- const auto wav = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-uiperf-slicex.wav");
- {
- juce::AudioBuffer<float> tone (2, 96000);
- for (int i = 0; i < tone.getNumSamples(); ++i)
- tone.setSample (0, i, 0.3f * (float) std::sin (juce::MathConstants<double>::twoPi * (200.0 + 200.0 * (i / 24000)) * i / 48000.0));
- tone.copyFrom (1, 0, tone, 0, 0, tone.getNumSamples());
- wav.deleteFile();
- if (auto out = std::unique_ptr<juce::OutputStream> (wav.createOutputStream()))
- if (auto writer = std::unique_ptr<juce::AudioFormatWriter> (juce::WavAudioFormat().createWriterFor (out.get(), 48000.0, 2, 16, {}, 0)))
- {
- out.release();
- writer->writeFromAudioSampleBuffer (tone, 0, tone.getNumSamples());
- }
- }
- int busiest = -1;
- {
- std::map<int, int> count;
- for (const auto& pat : engine->getSong().patterns)
- for (const auto& n : pat.notes)
- ++count[n.channel];
- int best = 0;
- for (const auto& [ch, n] : count)
- if (n > best)
- best = n, busiest = ch;
- }
- const auto index = (int) engine->getSong().channels.size();
- engine->editSong ([&wav, busiest, index] (lynx::Song& s2) {
- lynx::ChannelDef ch;
- ch.name = "Slicex (uiperf)";
- ch.instrument = lynx::InstrumentKind::slicex;
- ch.samplePath = wav.getFullPathName().toStdString();
- auto state = lynx::slicex::fresh();
- lynx::slicex::setDeckFile (state, 0, ch.samplePath, 4);
- lynx::slicex::setDeckBeats (state, 0, 0.0, 4.0);
- ch.pluginState = lynx::slicex::write (state);
- s2.channels.push_back (ch);
- for (auto& pat : s2.patterns)
- {
- std::vector<lynx::Note> copies;
- for (const auto& n : pat.notes)
- if (n.channel == busiest)
- {
- auto c = n;
- c.channel = index;
- c.key = 60 + (int) (copies.size() % 4); // (the four slices in turn)
- copies.push_back (c);
- }
- pat.notes.insert (pat.notes.end(), copies.begin(), copies.end());
- pat.sortNotes();
- }
- }, false);
- engine->dispatchPendingMessages();
- lynx::openChannelSettings (*engine, index);
- }
- for (auto* w : lynx::dockedEditorWindows())
- shown->emplace_back (w);
- keepPlaying();
- }, {}, 1500 });
- static const char* variantNames[] = { "hidden", "own window", "main window" };
- for (int c = 0; c < cycles; ++c)
- for (int v = 0; v < 3; ++v)
- run->steps.push_back ({ "dock A/B " + name + " " + variantNames[v] + " cycle " + juce::String (c + 1), [v, shown, keepPlaying] {
- if (v > 0)
- lynx::moveDockedEditors (v == 2);
- for (auto& w : *shown)
- if (w != nullptr && w->isVisible() != (v > 0))
- w->setVisible (v > 0);
- keepPlaying();
- }, {}, 2500 });
- }
- run->steps.push_back ({ "dock A/B close", [this, shown] {
- engine->stop();
- shown->clear();
- lynx::NativeEffectWindows::closeAll();
- for (auto* w : lynx::dockedEditorWindows())
- if (w != nullptr)
- w->closeButtonPressed();
- }, {}, 500 });
- }
- // round 190jy: LYNX_UIPERF_DOCKCHECK=1 — the checks of a docked editor drawn by the main window (ui/DockPaintCheck.h),
- // on screen in this main window; LYNX_UIPERF_DOCKCHECK_SHOTS=<folder> keeps the two on-screen pictures compared
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_DOCKCHECK", {}) == "1")
- {
- auto check = std::make_shared<std::unique_ptr<lynx::dockpaint::Check>>();
- auto lines = std::make_shared<juce::String>();
- for (int i = 0; i < lynx::dockpaint::Check::count(); ++i)
- run->steps.push_back ({ "dock check " + juce::String (i), [this, ui, check, lines, i] {
- if (*check == nullptr)
- *check = std::make_unique<lynx::dockpaint::Check> (*engine, *ui, *mainWindow,
- juce::File (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_DOCKCHECK_SHOTS", {})));
- *lines = (*check)->step (i);
- }, {}, 700, [lines] { return *lines; } });
- }
- run->steps.push_back ({ "Gross Beat window, song playing", [this] {
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- }, {}, 3000, [this] {
- engine->stop();
- lynx::NativeEffectWindows::closeAll();
- lynx::FormulaControllerWindows::closeAll();
- return juce::String();
- } });
- // round 190kb: LYNX_UIPERF_SPINAB=n — the worker pool's waiting policies (WorkerPool::Tuning) A/B inside one
- // process while the song plays with live editor windows: per set (LYNX_UIPERF_SPINAB_SETS, default "G,GLM": G
- // Gross Beat, L Fruity Limiter, M Maximus; on the master when the project has none), n cycles over every
- // variant (LYNX_UIPERF_SPINAB_VARIANTS="name:spec;…", spec as LYNX_POOL) with the windows hidden and shown,
- // 2.5 s steps, the order turning every cycle. Run with LYNX_UIPERF_THREADS=1 for the threads' lines.
- if (const auto cycles = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_SPINAB", "0").getIntValue(); cycles > 0)
- {
- auto sets = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_SPINAB_SETS", "G,GLM"), ",", {});
- struct Variant
- {
- juce::String name, spec;
- };
- std::vector<Variant> variants;
- for (const auto& v : juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable (
- "LYNX_UIPERF_SPINAB_VARIANTS", "old:spin=60,adaptive=0,wait=0;new:spin=60,adaptive=1,dry=4,wait=1,waitspin=30"),
- ";", {}))
- if (v.containsChar (':'))
- variants.push_back ({ v.upToFirstOccurrenceOf (":", false, false).trim(), v.fromFirstOccurrenceOf (":", false, false).trim() });
- auto shown = std::make_shared<std::vector<juce::Component::SafePointer<juce::Component>>>();
- // every step plays the same part of the song (LYNX_UIPERF_SPINAB_AT: a fraction of the song, default 0.4): the
- // audio work differs from part to part far more than between the variants (a first run without this put the
- // variants of one cycle in different parts and read the parts)
- auto at = std::make_shared<double> (0.0);
- const auto atFraction = juce::jlimit (0.0, 0.95, juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_SPINAB_AT", "0.4").getDoubleValue());
- auto keepPlaying = [this, at] {
- engine->getTransport().songMode = true;
- engine->seek (*at);
- if (! engine->getTransport().playing.load())
- engine->play();
- };
- for (const auto& set : sets)
- {
- const auto name = set.trim();
- run->steps.push_back ({ "spin A/B " + name + " open", [this, name, shown, keepPlaying, at, atFraction] {
- *at = atFraction * engine->getTransport().songEnd.load();
- lynx::NativeEffectWindows::closeAll();
- shown->clear();
- std::vector<juce::Component*> before;
- auto& desktop = juce::Desktop::getInstance();
- for (int i = 0; i < desktop.getNumComponents(); ++i)
- before.push_back (desktop.getComponent (i));
- auto openKind = [this] (lynx::EffectKind kind) {
- auto& so = engine->getSong();
- for (int t = 0; t < (int) so.mixer.size(); ++t)
- for (int k = 0; k < (int) so.mixer[(std::size_t) t].effects.size(); ++k)
- if (so.mixer[(std::size_t) t].effects[(std::size_t) k].kind == kind)
- {
- lynx::NativeEffectWindows::open (*engine, t, k);
- return;
- }
- // (not in the project: on the master, after its effects)
- if (so.mixer.empty() || so.mixer[0].effects.size() >= (std::size_t) lynx::maxEffectSlots)
- return;
- const auto slot = (int) so.mixer[0].effects.size();
- engine->editSong ([kind] (lynx::Song& s2) { s2.mixer[0].effects.push_back (lynx::makeEffectSlot (kind)); }, false);
- engine->dispatchPendingMessages();
- lynx::NativeEffectWindows::open (*engine, 0, slot);
- };
- if (name.containsChar ('G'))
- openKind (lynx::EffectKind::grossBeat);
- if (name.containsChar ('L'))
- openKind (lynx::EffectKind::fruityLimiter);
- if (name.containsChar ('M'))
- openKind (lynx::EffectKind::maximus);
- for (int i = 0; i < desktop.getNumComponents(); ++i)
- if (auto* c = desktop.getComponent (i); std::find (before.begin(), before.end(), c) == before.end())
- shown->emplace_back (c);
- keepPlaying();
- }, {}, 1500, [shown, at] { return " windows of the set: " + juce::String ((int) shown->size()) + ", every step from tick " + juce::String (*at, 0) + "\n"; } });
- for (int c = 0; c < cycles; ++c)
- for (int k = 0; k < (int) variants.size() * 2; ++k)
- {
- // (the variants in turn, starting one further each cycle; hidden / shown swapped every cycle)
- const auto& v = variants[(std::size_t) ((k / 2 + c) % (int) variants.size())];
- const auto visible = ((k % 2) == 1) != ((c % 2) == 1);
- run->steps.push_back ({ "spin A/B " + name + " " + v.name + (visible ? " shown" : " hidden") + " cycle " + juce::String (c + 1),
- [spec = v.spec, visible, shown, keepPlaying] {
- lynx::WorkerPool::tuning().apply (spec.toRawUTF8());
- for (auto& w : *shown)
- if (w != nullptr && w->isVisible() != visible)
- w->setVisible (visible);
- keepPlaying();
- }, {}, 2500 });
- }
- }
- run->steps.push_back ({ "spin A/B close", [this, shown] {
- engine->stop();
- shown->clear();
- lynx::NativeEffectWindows::closeAll();
- lynx::WorkerPool::tuning().apply (juce::SystemStats::getEnvironmentVariable ("LYNX_POOL", "").toRawUTF8());
- }, {}, 500 });
- }
- // round 190iv: the Simple layout (its toolbar) idle and while the song plays
- run->steps.push_back ({ "idle: simple layout, stopped", [this, ui] {
- engine->stop();
- ui->setLayoutStyle (lynx::layoutstyle::Style::simple, false);
- }, {}, 3000 });
- run->steps.push_back ({ "simple layout, song playing", [this] {
- engine->getTransport().songMode = true;
- engine->rewind();
- engine->play();
- }, {}, 3000, [this, ui] {
- engine->stop();
- ui->setLayoutStyle (lynx::layoutstyle::Style::pattern, false);
- return juce::String();
- } });
- // LYNX_UIPERF_ONLY=text: only the steps whose name has that text
- if (const auto only = juce::SystemStats::getEnvironmentVariable ("LYNX_UIPERF_ONLY", {}); only.isNotEmpty())
- run->steps.erase (std::remove_if (run->steps.begin(), run->steps.end(), [&only] (const auto& s) { return ! juce::String (s.name).contains (only); }), run->steps.end());
- // let the window draw the project first
- perf = std::move (run);
- juce::Timer::callAfterDelay (1500, [this] { if (perf != nullptr) perf->startTimer (16); });
- }
- // --rtstress: opens the project in the normal window with the saved audio device, plays it from the start for
- // `seconds` and writes the real-time statistics (deadline misses, late device calls, load histogram, heaviest units)
- // --rtstress --backuptest N (round 177d): while the project plays, a device's MIDI clock (10/s) and active sensing
- // (3/s) arrive, and the project counts as changed. N > 0 also forces a backup every N seconds on top of the timed ones.
- // The report tells how many backups were written, when, and what the MIDI counters did.
- struct BackupTest final : juce::Timer
- {
- lynx::AudioEngine* engine = nullptr;
- lynx::MainComponent* ui = nullptr;
- double everyMs = 0.0, startMs = 0.0, lastForcedMs = 0.0, longestCallMs = 0.0;
- int ticks = 0, forced = 0;
- std::uint64_t seenOver = 0, seenNear = 0;
- juce::String misses; // each callback over (or near) its deadline: how long after the last forced backup
- void timerCallback() override
- {
- engine->injectMidiInput (juce::MidiMessage (0xf8));
- if (++ticks % 3 == 0)
- engine->injectMidiInput (juce::MidiMessage (0xfe));
- const auto now = juce::Time::getMillisecondCounterHiRes();
- const auto s = engine->getRtStats().snapshot();
- if (s.overBudget != seenOver || s.nearBudget != seenNear)
- {
- misses << " +" << juce::String ((now - lastForcedMs) / 1000.0, 1) << " s after the last forced backup (or the start): over +"
- << (juce::int64) (s.overBudget - seenOver) << ", near +" << (juce::int64) (s.nearBudget - seenNear) << "\n";
- seenOver = s.overBudget;
- seenNear = s.nearBudget;
- }
- if (everyMs > 0.0 && now - lastForcedMs >= everyMs)
- {
- lastForcedMs = now;
- ++forced;
- ui->backupNowForTest();
- longestCallMs = juce::jmax (longestCallMs, juce::Time::getMillisecondCounterHiRes() - now);
- }
- }
- };
- std::unique_ptr<BackupTest> backupTest;
- void startBackupTest()
- {
- const auto& cli = juce::JUCEApplication::getCommandLineParameterArray();
- const auto at = cli.indexOf ("--backuptest");
- auto* ui = mainWindow != nullptr ? dynamic_cast<lynx::MainComponent*> (mainWindow->getContentComponent()) : nullptr;
- if (at < 0 || ui == nullptr)
- return;
- backupTest = std::make_unique<BackupTest>();
- backupTest->engine = engine.get();
- backupTest->ui = ui;
- backupTest->everyMs = cli[at + 1].getDoubleValue() * 1000.0;
- backupTest->startMs = backupTest->lastForcedMs = juce::Time::getMillisecondCounterHiRes();
- // (the project counts as changed, so a backup has something to write; the Master's fader is down, so a long run
- // makes no sound: everything else is processed as usual)
- engine->editSong ([] (lynx::Song& s) {
- if (! s.mixer.empty())
- s.mixer[0].volume = 0.0f;
- });
- backupTest->startTimer (100);
- }
- juce::String finishBackupTest()
- {
- if (backupTest == nullptr)
- return {};
- backupTest->stopTimer();
- juce::String text;
- const auto played = engine->getMidiPlayed();
- text << " backup test: MIDI light count " << (int) engine->getMidiActivity() << ", played count " << (int) played << " (clock and active sensing only)\n";
- text << " backup test: " << backupTest->forced << " forced, longest forced call on the message thread "
- << juce::String (backupTest->longestCallMs, 1) << " ms\n";
- if (backupTest->misses.isNotEmpty())
- text << " backup test: callbacks over or near the deadline (seen within 100 ms):\n" << backupTest->misses;
- auto files = lynx::autosaveFolder().findChildFiles (juce::File::findFiles, false, "*.lynx");
- text << " backup test: " << files.size() << " file(s) in the backup folder:\n";
- for (const auto& f : files)
- text << " " << juce::String ((f.getLastModificationTime().toMilliseconds() - juce::Time::getCurrentTime().toMilliseconds()) / 1000) << " s before the end: "
- << f.getFileName() << " (" << f.getSize() << " bytes)\n";
- engine->injectMidiInput (juce::MidiMessage::noteOn (1, 60, (juce::uint8) 1));
- engine->injectMidiInput (juce::MidiMessage::noteOff (1, 60));
- text << " backup test: after a played note, played count " << (int) engine->getMidiPlayed() << "\n";
- backupTest.reset();
- return text;
- }
- void runRealtimeStress (const juce::File& project, const juce::File& report, double seconds, int bufferSize,
- const juce::String& deviceType, const juce::String& deviceName, const juce::String& recordTo = {})
- {
- startupOptions = lynx::StartupOptions::load();
- engine = std::make_unique<lynx::AudioEngine>();
- lynx::videoview::install (*engine); // (Fruity Video Player channels: their sound tracks)
- crashEngine = engine.get();
- // the user's saved device stays as it was: this run's choices are undone before quitting
- savedDeviceState = engine->getDeviceManager().createStateXml();
- auto& devices = engine->getDeviceManager();
- const auto driverFile = addDriverFileDeviceType();
- const auto type = deviceType.isEmpty() && driverFile ? juce::String (lynx::dllAsioTypeName) : deviceType;
- if (type.isNotEmpty() && devices.getCurrentAudioDeviceType() != type)
- devices.setCurrentAudioDeviceType (type, true);
- if (bufferSize > 0 || deviceName.isNotEmpty())
- {
- auto setup = devices.getAudioDeviceSetup();
- if (bufferSize > 0)
- setup.bufferSize = bufferSize;
- if (deviceName.isNotEmpty())
- setup.outputDeviceName = deviceName;
- const auto error = devices.setAudioDeviceSetup (setup, true);
- if (error.isNotEmpty())
- report.replaceWithText ("device error: " + error + "\n");
- }
- createMainWindow();
- if (! juce::JUCEApplication::getCommandLineParameters().contains ("--no-window")) // --no-window: is it the UI?
- mainWindow->reveal();
- juce::String error;
- auto ok = false;
- const auto loadStart = juce::Time::getMillisecondCounterHiRes();
- if (project.hasFileExtension ("flp"))
- ok = engine->importFlpFile (project, error);
- else if (auto song = lynx::ProjectFile::load (project, error))
- {
- engine->setSong (std::move (*song));
- ok = true;
- }
- const auto loadMs = juce::Time::getMillisecondCounterHiRes() - loadStart;
- if (! ok)
- {
- report.replaceWithText ("project: " + project.getFullPathName() + "\nresult=ERROR " + error + "\n");
- restoreSavedDeviceState();
- setApplicationReturnValue (1);
- quit();
- return;
- }
- if (recordTo.isNotEmpty())
- engine->setAudioRecordingArmed (true); // opens the input of the driver
- // let the window draw the project, then play from the start with fresh statistics
- juce::Timer::callAfterDelay (1500, [this, project, report, seconds, loadMs, recordTo] {
- if (engine == nullptr)
- return;
- engine->stop();
- engine->rewind();
- engine->getRtStats().reset();
- engine->takeUiPulse();
- if (recordTo.isNotEmpty())
- engine->setRecording (true);
- // --log folder: the audio logger records what the Master plays during the run (realtime vs export checks)
- const auto& cli = juce::JUCEApplication::getCommandLineParameterArray();
- if (const auto at = cli.indexOf ("--log"); at >= 0 && at + 1 < cli.size())
- engine->getAudioLogger().start (juce::File (cli[at + 1].unquoted()), engine->getDeviceManager().getCurrentAudioDevice() != nullptr
- ? engine->getDeviceManager().getCurrentAudioDevice()->getCurrentSampleRate() : 44100.0);
- engine->play();
- startBackupTest();
- juce::Timer::callAfterDelay ((int) (seconds * 1000.0), [this, project, report, seconds, loadMs, recordTo] {
- if (engine == nullptr)
- return;
- const auto backupReport = finishBackupTest();
- engine->stop();
- juce::String recording;
- if (engine->getAudioLogger().isLogging())
- {
- recording << " logged: " << engine->getAudioLogger().currentFile().getFullPathName() << "\n";
- engine->getAudioLogger().stop();
- }
- if (recordTo.isNotEmpty())
- recording = finishStressTake (juce::File (recordTo), seconds);
- const auto& cli = juce::JUCEApplication::getCommandLineParameterArray();
- const auto s = engine->getRtStats().snapshot();
- juce::String text;
- text << "project: " << project.getFullPathName() << "\n"
- << "LYNX " << getApplicationVersion() << ", " << juce::SystemStats::getOperatingSystemName() << ", "
- << juce::SystemStats::getNumCpus() << " logical CPUs (" << juce::SystemStats::getNumPhysicalCpus() << " cores), "
- << juce::SystemStats::getCpuModel() << "\n"
- << "load " << juce::String (loadMs / 1000.0, 1) << " s, played " << juce::String (seconds, 0) << " s\n"
- << engine->describeRealtime();
- const auto pulse = engine->takeUiPulse();
- text << " UI: the 30 Hz engine timer ran " << pulse.calls << " times (" << juce::String (pulse.calls / seconds, 1)
- << "/s), longest gap " << juce::String (pulse.maxGapMs, 0) << " ms" << (mainWindow == nullptr || ! mainWindow->isVisible() ? " (window hidden)" : "") << "\n";
- text << " load histogram (share of the deadline: callbacks):";
- for (std::size_t b = 0; b < s.histogram.size(); ++b)
- if (s.histogram[b] > 0)
- text << " " << (int) (b * 10) << (b + 1 == s.histogram.size() ? juce::String ("+") : "-" + juce::String ((int) (b * 10 + 10))) << "%:" << (juce::int64) s.histogram[b];
- text << "\n";
- text << recording << backupReport;
- // --settingsshot file.png (round 161): Options > Audio settings of this run's device, as a picture
- if (const auto at = cli.indexOf ("--settingsshot"); at >= 0 && at + 1 < cli.size())
- {
- auto page = lynx::makeSettingsPanel (*engine, lynx::SettingsPage::audio);
- juce::Image image (juce::Image::ARGB, page->getWidth(), page->getHeight(), true);
- {
- juce::Graphics g (image);
- g.fillAll (lynx::theme::panel);
- page->paintEntireComponent (g, false);
- }
- const juce::File shot (cli[at + 1].unquoted());
- shot.deleteFile();
- if (auto out = shot.createOutputStream())
- juce::PNGImageFormat().writeImageToStream (image, *out);
- }
- text << "result=" << (s.callbacks == 0 ? "ERROR no audio callbacks" : s.overBudget == 0 && s.lateCalls == 0 ? "OK" : "GLITCHES") << "\n";
- report.replaceWithText (text);
- restoreSavedDeviceState();
- setApplicationReturnValue (s.callbacks == 0 ? 1 : 0);
- quit();
- });
- });
- }
- // --bendrectest (round 167a): see the command line above
- void runBendRecordTest (const juce::File& report, bool songMode)
- {
- engine = std::make_unique<lynx::AudioEngine>();
- auto text = std::make_shared<juce::String>();
- auto step = [report, text] (const juce::String& line) { *text << line << "\n"; report.replaceWithText (*text); };
- auto finish = [this] (int code) {
- setApplicationReturnValue (code);
- quit();
- };
- auto* device = engine->getDeviceManager().getCurrentAudioDevice();
- if (device == nullptr)
- {
- step ("result=ERROR no audio device");
- finish (1);
- return;
- }
- step ("device=" + device->getTypeName() + " | " + device->getName() + " | mode " + (songMode ? "song" : "pattern"));
- auto song = lynx::Song::makeDefault();
- song.bpm = 120.0;
- song.mode = songMode ? lynx::PlayMode::song : lynx::PlayMode::pattern;
- engine->setSong (std::move (song));
- auto o = engine->getRecordOptions();
- o.mode = lynx::RecordMode::overdub;
- o.recordNotes = true;
- o.recordAutomation = true;
- o.countInBars = 0;
- o.waitForInput = false;
- o.quantiseAutomation = false;
- o.punchLoopRegion = false;
- o.preRollBars = o.postRollBars = 0;
- engine->setRecordOptions (o);
- engine->stop();
- engine->rewind();
- engine->setRecording (true);
- engine->startPlayback();
- // 2 s of wheel at ~100 messages a second: 0 → +1 (0.5 s), +1 → −1 (1 s), −1 → 0 (0.5 s)
- auto sent = std::make_shared<std::vector<std::pair<double, float>>>();
- auto t0 = std::make_shared<double> (juce::Time::getMillisecondCounterHiRes());
- engine->injectMidiInput (juce::MidiMessage::noteOn (1, 60, (juce::uint8) 100));
- auto tick = std::make_shared<std::function<void()>>();
- *tick = [this, sent, t0, tick, step, finish, songMode] {
- if (engine == nullptr)
- return;
- const auto ms = juce::Time::getMillisecondCounterHiRes() - *t0;
- if (ms < 2000.0)
- {
- const auto x = ms / 1000.0;
- const auto v = (float) (x < 0.5 ? x * 2.0 : x < 1.5 ? 1.0 - (x - 0.5) * 2.0 : -1.0 + (x - 1.5) * 2.0);
- const auto wheel = juce::jlimit (0, 16383, 8192 + juce::roundToInt (v * 8191.0f));
- engine->injectMidiInput (juce::MidiMessage::pitchWheel (1, wheel));
- sent->push_back ({ ms, (float) (wheel - 8192) / 8192.0f });
- juce::Timer::callAfterDelay (10, *tick);
- return;
- }
- engine->injectMidiInput (juce::MidiMessage::pitchWheel (1, 8192));
- engine->injectMidiInput (juce::MidiMessage::noteOff (1, 60));
- juce::Timer::callAfterDelay (400, [this, sent, step, finish, songMode] {
- if (engine == nullptr)
- return;
- engine->stop();
- juce::Timer::callAfterDelay (600, [this, sent, step, finish, songMode] {
- if (engine == nullptr)
- return;
- engine->setRecording (false);
- const auto& s = engine->getSong();
- // the channel's pitch bend (MIDI channel 1), recorded as a lane or a clip
- std::vector<std::pair<std::int64_t, float>> got;
- juce::String where = "nothing";
- for (const auto& a : s.automations)
- if (a.target.kind == lynx::AutomationTargetKind::channelParam && lynx::midictl::isPitchBend (a.target.param))
- {
- where = "automation clip \"" + juce::String (a.name) + "\"";
- for (const auto& pt : a.points)
- got.push_back ({ pt.tick, pt.value });
- }
- for (const auto& p : s.patterns)
- for (const auto& lane : p.events)
- if (lane.target.kind == lynx::AutomationTargetKind::channelParam && lynx::midictl::isPitchBend (lane.target.param))
- {
- where = "pattern \"" + juce::String (p.name) + "\" event lane";
- for (const auto& e : lane.events)
- got.push_back ({ e.tick, e.value });
- }
- int notes = 0;
- for (const auto& p : s.patterns)
- notes += (int) p.notes.size();
- float lo = 1.0f, hi = 0.0f;
- for (const auto& [t, v] : got)
- lo = std::min (lo, v), hi = std::max (hi, v);
- // ticks: in order, spread over the ~2 s sweep (8 beats of 96 ticks at 120 bpm ≈ 4 beats)
- const auto span = got.empty() ? 0 : got.back().first - got.front().first;
- const auto sorted = std::is_sorted (got.begin(), got.end(), [] (const auto& a, const auto& b) { return a.first < b.first; });
- step ("sent=" + juce::String ((int) sent->size()) + " wheel messages over 2 s");
- step ("recorded=" + juce::String ((int) got.size()) + " points in " + where + ", value " + juce::String (lo, 3) + " .. "
- + juce::String (hi, 3) + " (0.5 = centre), ticks " + juce::String (span) + " apart, " + (sorted ? "in order" : "OUT OF ORDER")
- + ", notes " + juce::String (notes));
- if (! got.empty())
- step ("last=" + juce::String (got.back().second, 3));
- // song mode: a clip over the take, ending back at the centre. Pattern mode: the take loops the 1-bar pattern
- // (4.6 beats of take), so the lane spans the bar and the last wheel message (the centre) lands inside it
- const auto centred = std::any_of (got.begin(), got.end(), [] (const auto& p) { return std::abs (p.second - 0.5f) < 0.02f; });
- const auto ok = got.size() >= 20 && hi > 0.97f && lo < 0.03f && sorted && notes >= 1
- && (songMode ? span > lynx::ppq * 3 && span < lynx::ppq * 6 && std::abs (got.back().second - 0.5f) < 0.02f
- : span > lynx::ppq * 2 && span <= lynx::ppq * 4 && centred);
- step (ok ? "result=OK" : "result=FAILED");
- finish (ok ? 0 : 1);
- });
- });
- };
- juce::Timer::callAfterDelay (300, *tick);
- }
- // --countinrectest (round 170d): see the command line above.
- void runCountInRecordTest (const juce::File& report)
- {
- engine = std::make_unique<lynx::AudioEngine>();
- engine->getDeviceManager().closeAudioDevice(); // the engine's callback is driven by hand below
- struct StandIn final : juce::AudioIODevice
- {
- StandIn() : juce::AudioIODevice ("countin", "test") {}
- juce::StringArray getOutputChannelNames() override { return { "L", "R" }; }
- juce::StringArray getInputChannelNames() override { return {}; }
- juce::Array<double> getAvailableSampleRates() override { return { 48000.0 }; }
- juce::Array<int> getAvailableBufferSizes() override { return { 512 }; }
- int getDefaultBufferSize() override { return 512; }
- juce::String open (const juce::BigInteger&, const juce::BigInteger&, double, int) override { return {}; }
- void close() override {}
- bool isOpen() override { return true; }
- void start (juce::AudioIODeviceCallback*) override {}
- void stop() override {}
- bool isPlaying() override { return true; }
- juce::String getLastError() override { return {}; }
- int getCurrentBufferSizeSamples() override { return 512; }
- double getCurrentSampleRate() override { return 48000.0; }
- int getCurrentBitDepth() override { return 32; }
- juce::BigInteger getActiveOutputChannels() const override
- {
- juce::BigInteger b;
- b.setRange (0, 2, true);
- return b;
- }
- juce::BigInteger getActiveInputChannels() const override { return {}; }
- int getOutputLatencyInSamples() override { return 256; }
- int getInputLatencyInSamples() override { return 0; }
- };
- auto device = std::make_shared<StandIn>();
- auto text = std::make_shared<juce::String>();
- auto step = [report, text] (const juce::String& line) { *text << line << "\n"; report.replaceWithText (*text); };
- auto finish = [this] (int code) {
- setApplicationReturnValue (code);
- quit();
- };
- constexpr std::int64_t bar = 4 * lynx::ppq; // 120 BPM, 4/4
- lynx::Song song; // (as --cliplooptest: one synth channel on insert 1, an empty pattern)
- song.bpm = 120.0;
- song.mixer = lynx::Song::defaultMixer (2);
- song.channels.resize (1);
- song.channels[0].mixerTrack = 1;
- song.patterns.emplace_back();
- song.mode = lynx::PlayMode::song;
- song.currentPattern = 0;
- engine->setSong (song);
- engine->getTransport().metronome.store (true);
- auto o = engine->getRecordOptions();
- o.mode = lynx::RecordMode::overdub;
- o.countInBars = 1;
- o.catchWindow = lynx::ppq / 4;
- o.compensateOutput = true;
- o.recordNotes = true;
- o.recordAudio = false;
- o.recordAutomation = false;
- o.waitForInput = false;
- o.quantise = 0;
- o.placeSongClip = true;
- o.recordingMarkers = false;
- o.punchLoopRegion = false;
- o.preRollBars = o.postRollBars = 0;
- engine->setRecordOptions (o);
- engine->deviceCallback().audioDeviceAboutToStart (device.get());
- step ("stand-in device: 48 kHz, blocks of 512, output latency 256 samples; Song mode, 120 BPM, take from bar 3, count-in 1 bar");
- // an event heard at output sample `heard` (counted from the first block after Play), sent as MIDI input
- struct Event
- {
- std::int64_t heard;
- juce::MidiMessage message;
- };
- struct Pass
- {
- std::vector<float> out;
- std::vector<Event> events;
- std::int64_t playingAt = -1; // the first sample of the block the song started in
- int block = 0, blocks = 0;
- std::function<void()> done;
- };
- constexpr int n = 512;
- constexpr double rate = 48000.0;
- // one pass: the take recorded from bar 3, `blocks` blocks driven by hand, 8 at a time between the engine's timer
- // ticks (the take is committed there); then stopped and its results left to the timer
- auto runPass = std::make_shared<std::function<void (std::shared_ptr<Pass>)>>();
- *runPass = [this] (std::shared_ptr<Pass> pass) {
- auto& cb = engine->deviceCallback();
- std::vector<float> l (n), r (n);
- float* outs[] = { l.data(), r.data() };
- juce::AudioIODeviceCallbackContext context;
- if (pass->block == 0)
- {
- engine->stop();
- engine->seek ((double) (2 * bar));
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, n, context); // (the seek, stopped)
- engine->setRecording (true);
- engine->startPlayback(); // the count-in starts
- }
- for (int k = 0; k < 8 && pass->block < pass->blocks; ++k, ++pass->block)
- {
- // the events heard in this block: stamped the way the engine's clock maps time to heard samples
- const auto blockStart = (std::int64_t) pass->block * n;
- const auto clock = engine->liveClock();
- const auto compMs = 1000.0 * (n + 256) / rate;
- for (auto& e : pass->events)
- if (e.heard >= blockStart && e.heard < blockStart + n)
- {
- auto m = e.message;
- m.setTimeStamp ((clock.timeMs + compMs + (double) (e.heard - blockStart) * 1000.0 / rate) * 0.001);
- engine->injectMidiInput (m);
- }
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, n, context);
- pass->out.insert (pass->out.end(), l.begin(), l.end());
- if (pass->playingAt < 0 && engine->getTransport().playing.load())
- pass->playingAt = blockStart;
- }
- };
- // (the recursion through the message loop; written out so each step lets the engine's timer run)
- auto drive = std::make_shared<std::function<void (std::shared_ptr<Pass>)>>();
- // (round 190rf: the step holds itself weakly, the timer's call strongly: a strong self-capture never freed the passes'
- // takes, ~4 MB, LeakSanitizer in the sanitizer sweep)
- *drive = [this, runPass, weakDrive = std::weak_ptr (drive), device] (std::shared_ptr<Pass> pass) { // (the stand-in lives while the passes run)
- if (engine == nullptr)
- return;
- (*runPass) (pass);
- if (pass->block < pass->blocks)
- {
- if (auto self = weakDrive.lock())
- juce::Timer::callAfterDelay (40, [pass, self] { (*self) (pass); });
- return;
- }
- engine->stop();
- juce::Timer::callAfterDelay (300, [this, pass] {
- if (engine == nullptr)
- return;
- engine->setRecording (false);
- juce::Timer::callAfterDelay (200, [pass] { pass->done(); });
- });
- };
- auto onsets = [] (const std::vector<float>& out) {
- std::vector<std::int64_t> at;
- std::int64_t last = -100000;
- for (std::size_t i = 0; i < out.size(); ++i)
- if (std::abs (out[i]) > 0.02f && (std::int64_t) i - last > 4000)
- {
- at.push_back ((std::int64_t) i);
- last = (std::int64_t) i;
- }
- else if (std::abs (out[i]) > 0.02f)
- last = (std::int64_t) i;
- return at;
- };
- // the graph is (re)built on the message thread: start once it has settled
- juce::Timer::callAfterDelay (1500, [this, step, finish, drive, onsets] {
- if (engine == nullptr)
- return;
- auto first = std::make_shared<Pass>();
- first->blocks = (int) (rate * 18.0 / n); // count-in + 8 bars
- first->done = [this, weakFirst = std::weak_ptr (first), step, finish, drive, onsets] { // (round 190rf: not itself)
- const auto first = weakFirst.lock();
- if (first == nullptr)
- return;
- const auto clicks = onsets (first->out);
- juce::String list;
- for (std::size_t i = 0; i < std::min<std::size_t> (clicks.size(), 8); ++i)
- list << clicks[i] << " ";
- step ("pass 1: clicks heard at samples " + list + "…, the song started in the block at " + juce::String (first->playingAt));
- // the bar-3 downbeat: the click at the block the song started in
- std::int64_t down = -1;
- for (auto c : clicks)
- if (std::abs (c - first->playingAt) < n)
- down = c;
- if (down < 0 || engine->getSong().patterns[0].notes.size() != 0)
- {
- step ("result=FAILED no downbeat click found (or notes recorded without input)");
- finish (1);
- return;
- }
- const auto ms = [down] (double t) { return down + (std::int64_t) std::llround (t * rate / 1000.0); };
- auto second = std::make_shared<Pass>();
- second->blocks = first->blocks;
- auto add = [&second] (std::int64_t at, int key, bool on) {
- second->events.push_back ({ at, on ? juce::MidiMessage::noteOn (1, key, (juce::uint8) 100) : juce::MidiMessage::noteOff (1, key) });
- };
- for (int key : { 60, 64, 67 }) // the chord, 15 ms early, held half a second
- {
- add (ms (-15.0), key, true);
- add (ms (500.0), key, false);
- }
- add (ms (-1500.0), 62, true); // beat 2 of the count-in bar (bar 2)
- add (ms (-1250.0), 62, false);
- add (ms (503.0), 77, true); // 3 ms after beat 2
- add (ms (603.0), 77, false);
- for (int b = 1; b <= 6; ++b) // a note a bar ("it stopped after two bars")
- {
- add (ms (b * 2000.0), 70 + b, true);
- add (ms (b * 2000.0 + 250.0), 70 + b, false);
- }
- second->done = [this, step, finish] {
- const auto& s = engine->getSong();
- const auto& p = s.patterns[0];
- const lynx::Clip* clip = nullptr;
- for (const auto& c : s.playlist)
- if (c.kind == lynx::ClipKind::pattern && c.pattern == 0)
- clip = &c;
- const auto origin = clip != nullptr ? clip->start - clip->offset : -1;
- step ("pass 2: " + juce::String ((int) p.notes.size()) + " notes recorded, clip at " + juce::String (clip != nullptr ? clip->start : -1));
- auto ok = clip != nullptr && origin == bar && p.notes.size() == 11;
- // where each one was heard (song ticks): 0.5 ms = ~1 tick
- const std::vector<std::pair<int, double>> want = { { 60, 2.0 * bar }, { 64, 2.0 * bar }, { 67, 2.0 * bar },
- { 62, 2.0 * bar - 3 * lynx::ppq }, { 77, 2.0 * bar + lynx::ppq + 3.0 * 1.92 },
- { 71, 3.0 * bar }, { 72, 4.0 * bar }, { 73, 5.0 * bar },
- { 74, 6.0 * bar }, { 75, 7.0 * bar }, { 76, 8.0 * bar } };
- for (const auto& [key, tick] : want)
- {
- const lynx::Note* found = nullptr;
- for (const auto& note : p.notes)
- if (note.key == key)
- found = ¬e;
- const auto at = found != nullptr ? (double) (origin + found->start) : -1.0;
- const auto good = found != nullptr && std::abs (at - tick) <= 2.0;
- ok = ok && good;
- step ("key " + juce::String (key) + ": heard at tick " + juce::String (tick, 2) + ", recorded at " + juce::String (at, 0)
- + (good ? " ok" : " WRONG"));
- }
- const auto* chord = [&p] () -> const lynx::Note* {
- for (const auto& note : p.notes)
- if (note.key == 60)
- return ¬e;
- return nullptr;
- }();
- if (chord != nullptr)
- step ("chord length " + juce::String (chord->length) + " ticks (caught 15 ms early, released 500 ms after bar 3: 960)");
- step (ok ? "result=OK" : "result=FAILED");
- finish (ok ? 0 : 1);
- };
- (*drive) (second);
- };
- (*drive) (first);
- });
- }
- // --cliplooptest (round 167q): see the command line above.
- // --slicexedittest (round 190aj): see the command line above
- void runDirectWaveEditTest (const juce::String& project, const juce::File& script, const juce::File& report, const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray lines;
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1280, 720);
- if (project == "new")
- {
- if (auto c = lynx::natives::makeChannel (lynx::InstrumentKind::directwave, {}))
- offline.editSong ([c] (lynx::Song& s) { s.channels.push_back (*c); });
- }
- else
- ui.openFile (juce::File (project));
- offline.dispatchPendingMessages();
- int channel = -1;
- for (int c = 0; c < (int) offline.getSong().channels.size() && channel < 0; ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::directwave)
- channel = c;
- if (channel < 0)
- lines.add ("no DirectWave channel in " + project);
- else
- {
- auto panel = lynx::makeChannelSettingsPanel (offline, channel);
- juce::Component frame;
- frame.setSize (panel->getWidth(), panel->getHeight());
- frame.setOpaque (true);
- frame.addAndMakeVisible (*panel);
- panel->setTopLeftPosition (0, 0);
- offline.dispatchPendingMessages();
- juce::StringArray commands;
- script.readLines (commands);
- for (const auto& raw : commands)
- {
- const auto command = raw.trim();
- if (command.isEmpty() || command.startsWith ("#"))
- {
- lines.add (command);
- continue;
- }
- if (command.startsWith ("shot "))
- {
- frame.setSize (panel->getWidth(), panel->getHeight());
- // (round 190jd: at the shot scale, --shot-scale / LYNX_SHOT_SCALE, with its suffix; scale 1 = the same pixels)
- const auto image = lynx::shot::paint (frame, lynx::theme::panel);
- const auto file = lynx::shot::file (juce::File (prefix + command.fromFirstOccurrenceOf (" ", false, false).trim() + ".png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (image, *out);
- lines.add (command + " -> " + file.getFileName());
- continue;
- }
- if (command.startsWith ("savestate "))
- {
- const auto& st = offline.getSong().channels[(std::size_t) channel].pluginState;
- juce::File (command.fromFirstOccurrenceOf (" ", false, false).trim()).replaceWithData (st.data(), st.size());
- lines.add (command + " -> " + juce::String ((int) st.size()) + " bytes");
- continue;
- }
- const auto result = lynx::directWaveEditorTest (*panel, command);
- offline.dispatchPendingMessages();
- lines.add (command + " -> " + result);
- }
- }
- }
- report.replaceWithText (lines.joinIntoString ("\n") + "\nresult=DONE\n");
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- quit();
- }
- void runSlicexEditTest (const juce::File& project, const juce::File& script, const juce::File& report, const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray lines;
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1280, 720);
- ui.openFile (project);
- offline.dispatchPendingMessages();
- int channel = -1;
- for (int c = 0; c < (int) offline.getSong().channels.size() && channel < 0; ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::slicex)
- channel = c;
- if (channel < 0)
- lines.add ("no Slicex channel in " + project.getFullPathName());
- else
- {
- auto panel = lynx::makeChannelSettingsPanel (offline, channel);
- juce::Component frame;
- frame.setSize (panel->getWidth(), panel->getHeight());
- frame.setOpaque (true);
- frame.addAndMakeVisible (*panel);
- panel->setTopLeftPosition (0, 0);
- offline.dispatchPendingMessages();
- juce::StringArray commands;
- script.readLines (commands);
- for (const auto& raw : commands)
- {
- const auto command = raw.trim();
- if (command.isEmpty() || command.startsWith ("#"))
- {
- lines.add (command);
- continue;
- }
- if (command.startsWith ("shot "))
- {
- frame.setSize (panel->getWidth(), panel->getHeight()); // (round 190hg: the display modes resize the editor)
- // (round 190jd: at the shot scale, --shot-scale / LYNX_SHOT_SCALE, with its suffix; scale 1 = the same pixels)
- const auto image = lynx::shot::paint (frame, lynx::theme::panel);
- const auto file = lynx::shot::file (juce::File (prefix + command.fromFirstOccurrenceOf (" ", false, false).trim() + ".png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (image, *out);
- lines.add (command + " -> " + file.getFileName());
- continue;
- }
- if (command.startsWith ("menushot ")) // round 190jd: the deck's Snap menu as a picture
- {
- const auto file = prefix + command.fromFirstOccurrenceOf (" ", false, false).trim() + ".png";
- saveMenus (juce::StringArray { "Slicex deck: Snap" }, std::vector<juce::PopupMenu> { lynx::slicexSnapMenuForSnapshot (*panel) }, file);
- lines.add (command + " -> " + juce::File (file).getFileName());
- continue;
- }
- const auto result = lynx::slicexEditorTest (*panel, command);
- offline.dispatchPendingMessages();
- lines.add (command + " -> " + result);
- }
- }
- }
- report.replaceWithText (lines.joinIntoString ("\n") + "\nresult=DONE\n");
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- quit();
- }
- // --slicexkeytest (round 190ac): see the command line above
- void runSlicexKeyTest (const juce::File& report)
- {
- engine = std::make_unique<lynx::AudioEngine>();
- engine->getDeviceManager().closeAudioDevice(); // the engine's callback is driven by hand below
- struct StandIn final : juce::AudioIODevice
- {
- StandIn() : juce::AudioIODevice ("slicexkey", "test") {}
- juce::StringArray getOutputChannelNames() override { return { "L", "R" }; }
- juce::StringArray getInputChannelNames() override { return {}; }
- juce::Array<double> getAvailableSampleRates() override { return { 48000.0 }; }
- juce::Array<int> getAvailableBufferSizes() override { return { 512 }; }
- int getDefaultBufferSize() override { return 512; }
- juce::String open (const juce::BigInteger&, const juce::BigInteger&, double, int) override { return {}; }
- void close() override {}
- bool isOpen() override { return true; }
- void start (juce::AudioIODeviceCallback*) override {}
- void stop() override {}
- bool isPlaying() override { return true; }
- juce::String getLastError() override { return {}; }
- int getCurrentBufferSizeSamples() override { return 512; }
- double getCurrentSampleRate() override { return 48000.0; }
- int getCurrentBitDepth() override { return 32; }
- juce::BigInteger getActiveOutputChannels() const override
- {
- juce::BigInteger b;
- b.setRange (0, 2, true);
- return b;
- }
- juce::BigInteger getActiveInputChannels() const override { return {}; }
- int getOutputLatencyInSamples() override { return 0; }
- int getInputLatencyInSamples() override { return 0; }
- };
- auto device = std::make_shared<StandIn>();
- auto text = std::make_shared<juce::String>();
- auto step = [report, text] (const juce::String& line) { *text << line << "\n"; report.replaceWithText (*text); };
- // the deck's sample: 1 s at 48 kHz, four regions (cue points) of 0.25 s, each a steady tone of its own (200 Hz
- // × region number), so the region a key played can be read from the output
- constexpr int rate = 48000, regionFrames = rate / 4;
- const auto wavFile = report.getSiblingFile ("slicexkey-deck.wav");
- {
- juce::MemoryOutputStream w;
- auto chunk = [&w] (const char* id, const juce::MemoryBlock& body) {
- w.write (id, 4);
- w.writeInt ((int) body.getSize());
- w.write (body.getData(), body.getSize());
- };
- juce::MemoryOutputStream fmt, data, cue;
- fmt.writeShort (1);
- fmt.writeShort (1);
- fmt.writeInt (rate);
- fmt.writeInt (rate * 2);
- fmt.writeShort (2);
- fmt.writeShort (16);
- for (int i = 0; i < 4 * regionFrames; ++i)
- data.writeShort ((short) std::lround (12000.0 * std::sin (juce::MathConstants<double>::twoPi * 200.0 * (double) (i / regionFrames + 1) * (double) i / rate)));
- cue.writeInt (4);
- for (int k = 0; k < 4; ++k)
- {
- cue.writeInt (k + 1);
- cue.writeInt (k * regionFrames);
- cue.write ("data", 4);
- cue.writeInt (0);
- cue.writeInt (0);
- cue.writeInt (k * regionFrames);
- }
- juce::MemoryOutputStream riff;
- riff.write ("WAVE", 4);
- w.reset();
- chunk ("fmt ", fmt.getMemoryBlock());
- chunk ("data", data.getMemoryBlock());
- chunk ("cue ", cue.getMemoryBlock());
- riff.write (w.getData(), w.getDataSize());
- juce::MemoryOutputStream file;
- file.write ("RIFF", 4);
- file.writeInt ((int) riff.getDataSize());
- file.write (riff.getData(), riff.getDataSize());
- wavFile.replaceWithData (file.getData(), file.getDataSize());
- }
- lynx::Song song;
- song.bpm = 120.0;
- song.mixer = lynx::Song::defaultMixer (2);
- song.channels.resize (1);
- auto& channel = song.channels[0];
- channel.instrument = lynx::InstrumentKind::slicex;
- channel.mixerTrack = 1;
- channel.samplePath = wavFile.getFullPathName().toStdString();
- {
- auto state = lynx::slicex::fresh();
- lynx::slicex::setDeckFile (state, 0, channel.samplePath, 4);
- lynx::slicex::setDeckBeats (state, 0, 0.0, 2.0);
- channel.pluginState = lynx::slicex::write (state);
- }
- song.patterns.emplace_back();
- engine->setSong (song);
- auto& callback = engine->deviceCallback();
- callback.audioDeviceAboutToStart (device.get());
- step ("song=one Slicex channel, deck A = 4 regions of 0.25 s (200 / 400 / 600 / 800 Hz), 48 kHz, blocks of 512; keys as the editor's keyboard sends them");
- juce::Timer::callAfterDelay (2000, [this, device, step] {
- if (engine == nullptr)
- return;
- auto& cb = engine->deviceCallback();
- auto pump = [&cb] (int blocks) {
- std::vector<float> l (512), r (512), out;
- float* outs[] = { l.data(), r.data() };
- juce::AudioIODeviceCallbackContext context;
- for (int k = 0; k < blocks; ++k)
- {
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
- out.insert (out.end(), l.begin(), l.end());
- }
- return out;
- };
- auto rms = [] (const std::vector<float>& x, int from, int count) {
- double sum = 0.0;
- for (int i = from; i < from + count && i < (int) x.size(); ++i)
- sum += (double) x[(std::size_t) i] * x[(std::size_t) i];
- return std::sqrt (sum / juce::jmax (1, count));
- };
- // the tone's frequency from its rising zero crossings over a stretch
- auto hertz = [] (const std::vector<float>& x, int from, int count) {
- int crossings = 0, first = -1, last = -1;
- for (int i = from + 1; i < from + count && i < (int) x.size(); ++i)
- if (x[(std::size_t) i - 1] < 0.0f && x[(std::size_t) i] >= 0.0f)
- {
- first = first < 0 ? i : first;
- last = i;
- ++crossings;
- }
- return crossings > 1 ? 48000.0 * (double) (crossings - 1) / (double) (last - first) : 0.0;
- };
- bool ok = true;
- auto check = [&ok, step] (bool good, const juce::String& what) {
- ok = ok && good;
- step ((good ? "ok " : "FAIL ") + what);
- };
- const auto idle = pump (20);
- engine->getMeters().takePeak (1, 0);
- check (rms (idle, 0, (int) idle.size()) < 1.0e-6, "idle: rms " + juce::String (rms (idle, 0, (int) idle.size()), 9));
- // 4 regions map to keys 60…63 (FL's automatic map); the editor's click: velocity 100 / 128
- engine->sendLiveNote (0, 60, 0.78125f, true);
- const auto first = pump (16); // 8192 frames = 171 ms, inside region 1 (250 ms)
- const auto meter = engine->getMeters().takePeak (1, 0);
- check (rms (first, 1024, 6000) > 0.01, "key 60 down: rms " + juce::String (rms (first, 1024, 6000), 6) + ", " + juce::String (hertz (first, 1024, 6000), 1) + " Hz");
- check (std::abs (hertz (first, 1024, 6000) - 200.0) < 4.0, "key 60 plays region 1 (200 Hz)");
- check (meter > 0.01f, "mixer track 1 meter peak " + juce::String (meter, 6));
- engine->sendLiveNote (0, 60, 0.0f, false);
- const auto tail = pump (60);
- check (rms (tail, (int) tail.size() - 4096, 4096) < 1.0e-5, "key 60 up: the end is silent, rms " + juce::String (rms (tail, (int) tail.size() - 4096, 4096), 9));
- engine->sendLiveNote (0, 62, 0.78125f, true);
- const auto third = pump (16);
- check (rms (third, 1024, 6000) > 0.01 && std::abs (hertz (third, 1024, 6000) - 600.0) < 8.0,
- "key 62 plays region 3 (600 Hz): rms " + juce::String (rms (third, 1024, 6000), 6) + ", " + juce::String (hertz (third, 1024, 6000), 1) + " Hz");
- engine->sendLiveNote (0, 62, 0.0f, false);
- engine->sendLiveNote (0, 72, 0.78125f, true); // a key without a region
- const auto none = pump (60);
- check (rms (none, (int) none.size() - 4096, 4096) < 1.0e-5, "key 72 (no region): silent, rms " + juce::String (rms (none, (int) none.size() - 4096, 4096), 9));
- engine->sendLiveNote (0, 72, 0.0f, false);
- step (ok ? "result=OK" : "result=FAILED");
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- });
- }
- // --renderaheadtest (round 190gq): see the command line above
- void runRenderAheadTest (const juce::File& report, const juce::StringArray& projects, int block, double seconds)
- {
- struct StandIn final : juce::AudioIODevice
- {
- explicit StandIn (int b) : juce::AudioIODevice ("renderahead", "test"), block (b) {}
- const int block;
- juce::StringArray getOutputChannelNames() override { return { "L", "R" }; }
- juce::StringArray getInputChannelNames() override { return {}; }
- juce::Array<double> getAvailableSampleRates() override { return { 48000.0 }; }
- juce::Array<int> getAvailableBufferSizes() override { return { block }; }
- int getDefaultBufferSize() override { return block; }
- juce::String open (const juce::BigInteger&, const juce::BigInteger&, double, int) override { return {}; }
- void close() override {}
- bool isOpen() override { return true; }
- void start (juce::AudioIODeviceCallback*) override {}
- void stop() override {}
- bool isPlaying() override { return true; }
- juce::String getLastError() override { return {}; }
- int getCurrentBufferSizeSamples() override { return block; }
- double getCurrentSampleRate() override { return 48000.0; }
- int getCurrentBitDepth() override { return 32; }
- juce::BigInteger getActiveOutputChannels() const override
- {
- juce::BigInteger b;
- b.setRange (0, 2, true);
- return b;
- }
- juce::BigInteger getActiveInputChannels() const override { return {}; }
- int getOutputLatencyInSamples() override { return 0; }
- int getInputLatencyInSamples() override { return 0; }
- };
- struct Scenario
- {
- juce::String name;
- juce::File file; // a project, or none: the showcase song
- int mode = 0; // 0 Song mode from the start, 1 a loop region, 2 Pattern mode
- };
- auto scenarios = std::make_shared<std::vector<Scenario>>();
- scenarios->push_back ({ "showcase, Song mode", {}, 0 });
- scenarios->push_back ({ "showcase, a loop region wrapping mid-block", {}, 1 });
- scenarios->push_back ({ "showcase, Pattern mode", {}, 2 });
- for (const auto& p : projects)
- scenarios->push_back ({ juce::File (p).getFileName(), juce::File (p), 0 });
- auto text = std::make_shared<juce::String>();
- auto step = [report, text] (const juce::String& line) { *text << line << "\n"; report.replaceWithText (*text); };
- step ("render-ahead test: blocks of " + juce::String (block) + " at 48 kHz, " + juce::String (seconds, 1) + " s per run");
- auto outputs = std::make_shared<std::vector<std::vector<float>>>();
- auto ok = std::make_shared<bool> (true);
- auto run = std::make_shared<std::function<void (std::size_t, int)>>();
- // (round 190rf, LeakSanitizer: the step holds itself weakly, what is pending holds it: a strong self-capture kept the
- // last engine's outputs for good)
- *run = [this, scenarios, step, outputs, ok, weakRun = std::weak_ptr (run), block, seconds, report] (std::size_t index, int pass) {
- const auto run = weakRun.lock();
- if (run == nullptr)
- return;
- if (index >= scenarios->size())
- {
- lynx::renderAheadOption().store (true);
- step (juce::String ("result=") + (*ok ? "OK" : "FAIL"));
- setApplicationReturnValue (*ok ? 0 : 1);
- engine.reset();
- quit();
- return;
- }
- const auto& sc = (*scenarios)[index];
- lynx::renderAheadOption().store (pass == 1);
- engine = std::make_unique<lynx::AudioEngine>();
- engine->getDeviceManager().closeAudioDevice(); // the engine's callback is driven by hand below
- engine->setRenderAheadAlways (true); // (the showcase song is light: the app would leave it real-time)
- juce::String error;
- auto loaded = true;
- if (sc.file == juce::File())
- {
- auto song = lynx::makeShowcaseSong (0);
- if (sc.mode == 1)
- {
- song.loopStart = 4 * lynx::ppq * song.beatsPerBar + 37; // (not on a block boundary)
- song.loopEnd = 6 * lynx::ppq * song.beatsPerBar + 211;
- song.loopOff = false;
- }
- if (sc.mode == 2)
- song.mode = lynx::PlayMode::pattern;
- engine->setSong (std::move (song));
- }
- else if (sc.file.hasFileExtension ("flp"))
- loaded = engine->importFlpFile (sc.file, error);
- else if (auto song = lynx::ProjectFile::load (sc.file, error))
- engine->setSong (std::move (*song));
- else
- loaded = false;
- if (! loaded)
- {
- step ("FAIL " + sc.name + ": " + error);
- *ok = false;
- (*run) (index + 1, 0);
- return;
- }
- auto device = std::make_shared<StandIn> (block);
- engine->deviceCallback().audioDeviceAboutToStart (device.get());
- // the graph is (re)built on the message thread: the run starts once it has settled
- juce::Timer::callAfterDelay (1500, [this, scenarios, step, outputs, ok, run, block, seconds, index, pass, device] {
- if (engine == nullptr)
- return;
- const auto& sc = (*scenarios)[index];
- auto& cb = engine->deviceCallback();
- std::vector<float> l ((std::size_t) block), r ((std::size_t) block), out;
- float* outs[] = { l.data(), r.data() };
- juce::AudioIODeviceCallbackContext context;
- engine->stop();
- engine->seek (0.0);
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, block, context); // (the seek, stopped)
- engine->play();
- const auto blocks = (int) (seconds * 48000.0 / block);
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int k = 0; k < blocks; ++k)
- {
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, block, context);
- out.insert (out.end(), l.begin(), l.end());
- out.insert (out.end(), r.begin(), r.end());
- // (about the device's pace at the start of each second, so the render-ahead thread gets ahead)
- if (k % (48000 / block) < 48000 / block / 2)
- std::this_thread::sleep_for (std::chrono::microseconds ((int) (block * 1.0e6 / 48000.0 * 0.6)));
- }
- const auto ms = juce::Time::getMillisecondCounterHiRes() - t0;
- engine->stop();
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, block, context);
- const auto* st = engine->renderAheadStats();
- auto n = [] (const std::atomic<std::uint64_t>& v) { return (juce::int64) v.load(); };
- juce::String line = sc.name + (pass == 1 ? ", render ahead on: " : ", render ahead off: ") + juce::String (ms / 1000.0, 1) + " s";
- if (st != nullptr && pass == 1)
- line << "; blocks " << n (st->blocks) << ", from the ring " << n (st->fromRing) << ", waited " << n (st->waited) << ", in the callback "
- << n (st->inline_) << ", dropped " << n (st->flushes) << ", drained " << n (st->drains) << ", started " << n (st->engagements)
- << ", boundary mismatches " << n (st->splitMismatches) << "; ahead " << st->aheadChannels.load() << " channels / "
- << st->aheadTracks.load() << " inserts, boundary " << st->boundary.load() << ", window " << st->window.load();
- step (" " + line);
- if (pass == 0)
- {
- outputs->assign (1, std::move (out));
- (*run) (index, 1);
- return;
- }
- const auto& off = outputs->front();
- std::size_t first = off.size() == out.size() ? off.size() : 0;
- for (std::size_t s = 0; s < std::min (off.size(), out.size()); ++s)
- if (std::memcmp (&off[s], &out[s], sizeof (float)) != 0)
- {
- first = s;
- break;
- }
- const auto same = off.size() == out.size() && first == off.size();
- const auto clean = st != nullptr && st->flushes.load() == 0 && st->splitMismatches.load() == 0 && st->engagements.load() >= 1
- && st->fromRing.load() > st->blocks.load() / 4;
- *ok = *ok && same && clean;
- step (juce::String (same && clean ? "ok " : "FAIL ") + sc.name + ": " + (same ? "bit-identical" : "differs from sample " + juce::String ((juce::int64) first / 2 % block) + " of block " + juce::String ((juce::int64) first / 2 / block))
- + (clean ? "" : ", render-ahead counters off (see above)"));
- (*run) (index + 1, 0);
- });
- };
- (*run) (0, 0);
- }
- void runClipLoopTest (const juce::File& report, const juce::File& wavFile)
- {
- engine = std::make_unique<lynx::AudioEngine>();
- engine->getDeviceManager().closeAudioDevice(); // the engine's callback is driven by hand below
- struct StandIn final : juce::AudioIODevice
- {
- StandIn() : juce::AudioIODevice ("cliploop", "test") {}
- juce::StringArray getOutputChannelNames() override { return { "L", "R" }; }
- juce::StringArray getInputChannelNames() override { return {}; }
- juce::Array<double> getAvailableSampleRates() override { return { 48000.0 }; }
- juce::Array<int> getAvailableBufferSizes() override { return { 512 }; }
- int getDefaultBufferSize() override { return 512; }
- juce::String open (const juce::BigInteger&, const juce::BigInteger&, double, int) override { return {}; }
- void close() override {}
- bool isOpen() override { return true; }
- void start (juce::AudioIODeviceCallback*) override {}
- void stop() override {}
- bool isPlaying() override { return true; }
- juce::String getLastError() override { return {}; }
- int getCurrentBufferSizeSamples() override { return 512; }
- double getCurrentSampleRate() override { return 48000.0; }
- int getCurrentBitDepth() override { return 32; }
- juce::BigInteger getActiveOutputChannels() const override
- {
- juce::BigInteger b;
- b.setRange (0, 2, true);
- return b;
- }
- juce::BigInteger getActiveInputChannels() const override { return {}; }
- int getOutputLatencyInSamples() override { return 0; }
- int getInputLatencyInSamples() override { return 0; }
- };
- auto device = std::make_shared<StandIn>();
- auto text = std::make_shared<juce::String>();
- auto step = [report, text] (const juce::String& line) { *text << line << "\n"; report.replaceWithText (*text); };
- constexpr int bar = 96000, beat = bar / 4; // 120 BPM, 48 kHz
- const auto ppq = (double) lynx::ppq;
- lynx::Song song;
- song.bpm = 120.0;
- song.mixer = lynx::Song::defaultMixer (2);
- song.channels.resize (1); // the synth of a new channel: deterministic
- song.channels[0].mixerTrack = 1;
- auto& pattern = song.patterns.emplace_back(); // 1 bar: C5 on beat 0, C6 on beat 2
- for (auto [b, key] : { std::pair { 0, 60 }, std::pair { 2, 72 } })
- {
- lynx::Note n;
- n.start = b * lynx::ppq;
- n.length = lynx::ppq / 4;
- n.key = key;
- pattern.notes.push_back (n);
- }
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 16 * lynx::ppq; // stretched to 4 bars
- song.playlist.push_back (clip);
- song.mode = lynx::PlayMode::song;
- {
- // the Windows GUI check's project: the same song with a 1-bar clip, to stretch with the mouse
- auto gui = song;
- gui.playlist[0].length = 4 * lynx::ppq;
- juce::String error;
- lynx::ProjectFile::save (gui, report.getSiblingFile ("cliploop-gui.lynx"), error);
- }
- engine->setSong (song);
- auto& callback = engine->deviceCallback();
- callback.audioDeviceAboutToStart (device.get());
- step ("song=1-bar synth pattern, clip stretched to 4 bars, 120 BPM, 48 kHz, blocks of 512");
- // the graph is (re)built on the message thread: the scenarios run once it has settled
- juce::Timer::callAfterDelay (1500, [this, device, step, wavFile, ppq] {
- if (engine == nullptr)
- return;
- auto& cb = engine->deviceCallback();
- // plays `samples` from tick `from` through the device callback; `between` runs after each block (block index)
- auto play = [this, &cb] (double from, int samples, const std::function<void (int)>& between = {}) {
- engine->stop();
- engine->seek (from);
- std::vector<float> l (512), r (512), out;
- float* outs[] = { l.data(), r.data() };
- juce::AudioIODeviceCallbackContext context;
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context); // (the seek, stopped)
- engine->play();
- for (int k = 0; (int) out.size() < samples; ++k)
- {
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
- out.insert (out.end(), l.begin(), l.end());
- if (between)
- between (k);
- }
- engine->stop();
- for (int k = 0; k < 400; ++k) // the tails of the scenario die out
- cb.audioDeviceIOCallbackWithContext (nullptr, 0, outs, 2, 512, context);
- out.resize ((std::size_t) samples);
- return out;
- };
- auto rms = [] (const std::vector<float>& x, int from, int count) {
- double sum = 0.0;
- for (int i = from; i < from + count && i < (int) x.size(); ++i)
- sum += (double) x[(std::size_t) i] * x[(std::size_t) i];
- return std::sqrt (sum / juce::jmax (1, count));
- };
- auto diff = [] (const std::vector<float>& a, int aFrom, const std::vector<float>& b, int bFrom, int count) {
- double m = 0.0;
- for (int i = 0; i < count && aFrom + i < (int) a.size() && bFrom + i < (int) b.size(); ++i)
- m = juce::jmax (m, (double) std::abs (a[(std::size_t) (aFrom + i)] - b[(std::size_t) (bFrom + i)]));
- return m;
- };
- auto num = [] (double v) { return juce::String (v, 6); };
- bool ok = true;
- auto check = [&ok, step] (bool good, const juce::String& what) {
- ok = ok && good;
- step ((good ? "ok " : "FAIL ") + what);
- };
- lynx::setStretchedClipsLoop (true);
- const auto a = play (0.0, 4 * bar);
- const auto bar1 = rms (a, 0, bar);
- check (bar1 > 0.01, "play from the start: bar 1 RMS " + num (bar1));
- for (int k = 1; k < 4; ++k)
- {
- const auto rk = rms (a, k * bar, bar), d = diff (a, k * bar, a, 0, bar);
- check (std::abs (rk / bar1 - 1.0) < 1.0e-3 && d < 1.0e-4,
- "bar " + juce::String (k + 1) + " RMS " + num (rk) + " (x" + num (rk / bar1) + " of bar 1), max |bar - bar 1| " + juce::String (d, 9));
- }
- {
- const auto x = play (10 * ppq, bar + bar / 2);
- const auto d = juce::jmax (diff (x, 0, a, 2 * beat, bar / 2), diff (x, bar / 2, a, 0, bar));
- check (rms (x, 0, bar / 2) > 0.01 && d < 1.0e-4,
- "start inside a repeat (bar 3, beat 3): RMS " + num (rms (x, 0, (int) x.size())) + ", max diff vs bar 1 " + juce::String (d, 9));
- }
- {
- // a seek while playing, after 6.99 beats, to bar 4 beat 3 (a ruler click)
- const auto jumpBlock = 7 * beat / 512 - 1;
- const auto x = play (0.0, 2 * bar, [this, jumpBlock, ppq] (int k) {
- if (k == jumpBlock)
- engine->seek (14 * ppq);
- });
- // (the best of 0-2 samples late: anything but 0 fails)
- const auto at = (jumpBlock + 1) * 512;
- int lag = 0;
- auto d = 1.0e9;
- for (int l = 0; l <= 2; ++l)
- if (const auto dl = diff (x, at + l, a, 2 * beat, beat - 2); dl < d)
- d = dl, lag = l;
- d = lag == 0 ? d : 1.0;
- const auto ratio = rms (x, at, beat) / rms (a, 2 * beat, beat);
- check (std::abs (ratio - 1.0) < 1.0e-3 && d < 1.0e-4,
- "jump mid-clip to bar 4 beat 3: RMS " + num (rms (x, at, beat)) + " (x" + num (ratio) + " of bar 1 beat 3), max diff "
- + juce::String (d, 9) + " (" + juce::String (lag) + " sample(s) late)");
- }
- {
- engine->editSong ([ppq] (lynx::Song& s) {
- s.loopStart = (std::int64_t) (4 * ppq);
- s.loopEnd = (std::int64_t) (12 * ppq);
- }, false);
- const auto x = play (0.0, 7 * bar);
- double d = 0.0;
- juce::String lags;
- for (int k = 1; k < 7; ++k) // (the best of 0-2 samples late after a wrap, as after a jump)
- {
- auto best = 1.0e9;
- int lag = 0;
- for (int l = 0; l <= 2; ++l)
- if (const auto dl = diff (x, k * bar + l, a, 0, bar - 2); dl < best)
- best = dl, lag = l;
- d = juce::jmax (d, lag == 0 ? best : 1.0); // a sample gained at a wrap fails (round 167q loopwrap)
- lags << (k > 1 ? "," : "") << lag;
- }
- const auto r = rms (x, bar, 6 * bar);
- check (std::abs (r / bar1 - 1.0) < 1.0e-3 && d < 1.0e-4,
- "loop region bars 2-3, played 3 times: RMS " + num (r) + " (x" + num (r / bar1) + "), max diff of each bar vs bar 1 " + juce::String (d, 9)
- + " (samples late, bars 2-7: " + lags + ")");
- engine->editSong ([] (lynx::Song& s) { s.loopStart = s.loopEnd = 0; }, false);
- }
- {
- // 100 wraps of a 1-bar loop region (bar 2): every pass on its sample, none gained (round 167q loopwrap: each
- // wrap used to play one sample more)
- engine->editSong ([ppq] (lynx::Song& s) {
- s.loopStart = (std::int64_t) (4 * ppq);
- s.loopEnd = (std::int64_t) (8 * ppq);
- }, false);
- const auto x = play (0.0, 101 * bar);
- double d = 0.0;
- int worst = 0;
- for (int k = 1; k <= 100; ++k)
- if (const auto dk = diff (x, k * bar, a, 0, bar); dk > d)
- d = dk, worst = k + 1;
- check (d < 1.0e-4, "loop region bar 2, 100 wraps: max diff of every pass vs bar 1 " + juce::String (d, 9)
- + (d < 1.0e-4 ? juce::String() : " (worst: bar " + juce::String (worst) + ")"));
- engine->editSong ([] (lynx::Song& s) { s.loopStart = s.loopEnd = 0; }, false);
- }
- lynx::setStretchedClipsLoop (false);
- {
- const auto x = play (0.0, 4 * bar);
- const auto r = juce::jmax (rms (x, bar, bar), juce::jmax (rms (x, 2 * bar, bar), rms (x, 3 * bar, bar)));
- check (diff (x, 0, a, 0, bar) < 1.0e-4 && r < 1.0e-5, "option off (FL): bar 1 the same, bars 2-4 RMS at most " + juce::String (r, 9));
- }
- lynx::setStretchedClipsLoop (true);
- cb.audioDeviceStopped();
- // the export: a WAV of the 4 bars, read back from the file
- if (wavFile != juce::File())
- {
- for (const auto loops : { true, false })
- {
- lynx::setStretchedClipsLoop (loops);
- const auto file = loops ? wavFile : wavFile.getSiblingFile (wavFile.getFileNameWithoutExtension() + "-off.wav");
- file.deleteFile();
- {
- juce::WavAudioFormat wav;
- std::unique_ptr<juce::AudioFormatWriter> writer (wav.createWriterFor (file.createOutputStream().release(), 48000.0, 2, 32, {}, 0));
- engine->stop();
- engine->seek (0.0);
- lynx::AudioEngine::RenderOptions o;
- o.seconds = 8.0;
- o.sampleRate = 48000.0;
- o.output = writer.get();
- engine->renderOffline (o);
- }
- juce::WavAudioFormat wav;
- std::unique_ptr<juce::AudioFormatReader> reader (wav.createReaderFor (file.createInputStream().release(), true));
- std::vector<float> x;
- if (reader != nullptr)
- {
- juce::AudioBuffer<float> buffer (2, (int) reader->lengthInSamples);
- reader->read (&buffer, 0, (int) reader->lengthInSamples, 0, true, true);
- x.assign (buffer.getReadPointer (0), buffer.getReadPointer (0) + buffer.getNumSamples());
- }
- const auto b1 = rms (x, 0, bar);
- juce::String line = juce::String (loops ? "export" : "export, option off") + " (" + file.getFileName() + ", " + juce::String ((int) x.size()) + " samples): bar 1 RMS " + num (b1);
- bool good = x.size() >= (std::size_t) 4 * bar && b1 > 0.01;
- for (int k = 1; k < 4; ++k)
- {
- const auto rk = rms (x, k * bar, bar);
- line << ", bar " << (k + 1) << " " << num (rk);
- good = good && (loops ? std::abs (rk / b1 - 1.0) < 1.0e-3 && diff (x, k * bar, x, 0, bar) < 1.0e-4 : rk < 1.0e-5);
- }
- if (loops)
- line << ", max |bar - bar 1| " << juce::String (juce::jmax (diff (x, bar, x, 0, bar), juce::jmax (diff (x, 2 * bar, x, 0, bar), diff (x, 3 * bar, x, 0, bar))), 9);
- check (good, line);
- }
- lynx::setStretchedClipsLoop (true);
- }
- step (ok ? "result=OK" : "result=FAILED");
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- });
- }
- // --rectest (round 163): see the command line above. Writes report lines step by step (a driver that ends the
- // process leaves what was done).
- void runRecordTest (const juce::File& report, double seconds, const juce::String& deviceType, const juce::String& deviceName,
- const juce::String& inputName, int mode, int pdcSamples, int bufferSize)
- {
- engine = std::make_unique<lynx::AudioEngine>();
- lynx::videoview::install (*engine); // (Fruity Video Player channels: their sound tracks)
- savedDeviceState = engine->getDeviceManager().createStateXml();
- auto text = std::make_shared<juce::String>();
- auto step = [report, text] (const juce::String& line) { *text << line << "\n"; report.replaceWithText (*text); };
- auto finish = [this, step] (int code) {
- restoreSavedDeviceState();
- setApplicationReturnValue (code);
- quit();
- };
- auto& devices = engine->getDeviceManager();
- if (deviceType.isNotEmpty() && devices.getCurrentAudioDeviceType() != deviceType)
- devices.setCurrentAudioDeviceType (deviceType, true);
- {
- auto setup = devices.getAudioDeviceSetup();
- if (deviceName.isNotEmpty())
- setup.outputDeviceName = deviceName;
- if (bufferSize > 0)
- setup.bufferSize = bufferSize;
- if (const auto error = devices.setAudioDeviceSetup (setup, true); error.isNotEmpty())
- step ("device_error=" + error);
- }
- if (const auto r = engine->openAudioInput (inputName.isNotEmpty() ? inputName : deviceName); r.issue != lynx::AudioEngine::InputIssue::none)
- step ("input_error=" + juce::String ((int) r.issue) + " " + r.detail);
- // takes go next to the report, not into the user's recordings folder
- engine->setRecordingTarget (report.getSiblingFile (report.getFileNameWithoutExtension() + "-takes"), {});
- auto* device = devices.getCurrentAudioDevice();
- if (device == nullptr || engine->getInputChannelNames().empty())
- {
- step ("result=ERROR no device / no input");
- finish (1);
- return;
- }
- const auto rate = device->getCurrentSampleRate();
- step ("device=" + device->getTypeName() + " | " + device->getName() + " | " + juce::String (rate) + " Hz | block " + juce::String (device->getCurrentBufferSizeSamples())
- + " | driver latency in " + juce::String (device->getInputLatencyInSamples()) + " out " + juce::String (device->getOutputLatencyInSamples()));
- // a click (the ping's pulse) on every beat at 120 bpm: beat k at sample k * rate / 2
- const auto beats = (int) std::ceil (seconds * 2.0) + 8;
- const auto clickFile = report.getSiblingFile (report.getFileNameWithoutExtension() + "-clicks.wav");
- {
- lynx::takes::WavTakeWriter w;
- w.open (clickFile.getFullPathName().toStdString(), rate, 1, lynx::takes::SampleFormat::float32);
- const auto total = (juce::int64) std::llround ((double) beats * rate / 2.0);
- std::vector<float> block (4096);
- for (juce::int64 at = 0; at < total; at += (juce::int64) block.size())
- {
- std::fill (block.begin(), block.end(), 0.0f);
- for (int k = 0; k < (int) block.size(); ++k)
- {
- const auto f = at + k;
- const auto beat = (juce::int64) std::floor ((double) f / (rate / 2.0));
- const auto rel = f - (juce::int64) std::llround ((double) beat * rate / 2.0);
- static constexpr float shape[] { 0.25f, 0.75f, 1.0f, 0.75f, 0.25f };
- if (rel >= 0 && rel < 5)
- block[(std::size_t) k] = 0.5f * shape[rel];
- }
- const float* d[] { block.data() };
- w.write (d, (int) std::min<juce::int64> ((juce::int64) block.size(), total - at));
- }
- w.close();
- }
- lynx::Song song = lynx::Song::makeDefault();
- song.bpm = 120.0;
- song.mode = lynx::PlayMode::song;
- song.playlist.clear();
- lynx::ChannelDef c;
- c.name = "Clicks";
- c.instrument = lynx::InstrumentKind::audioClip;
- c.samplePath = clickFile.getFullPathName().toStdString();
- c.mixerTrack = 0;
- c.volume = 1.0f;
- song.channels.push_back (c);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = (int) song.channels.size() - 1;
- clip.track = 0;
- clip.start = 0;
- clip.length = (std::int64_t) beats * lynx::ppq;
- song.playlist.push_back (clip);
- if (mode == 1) // loop recording, bars 2-4
- {
- song.loopStart = 4 * lynx::ppq;
- song.loopEnd = 16 * lynx::ppq;
- }
- else if (mode == 2) // punch in/out, bars 3-4
- {
- song.loopStart = 8 * lynx::ppq;
- song.loopEnd = 16 * lynx::ppq;
- }
- if (song.mixer.size() > 1)
- {
- song.mixer[1].name = "Loop In";
- song.mixer[1].monitor = lynx::InputMonitor::off; // (the loopback must not hear itself)
- }
- engine->setSong (std::move (song));
- engine->setInsertInput (1, 0, false);
- juce::ignoreUnused (pdcSamples);
- // 1) the ping
- if (const auto error = engine->startLatencyPing(); error.isNotEmpty())
- step ("ping_error=" + error);
- juce::Timer::callAfterDelay (3500, [this, step, finish, seconds, rate, report, mode] {
- if (engine == nullptr)
- return;
- if (engine->isPinging())
- engine->cancelLatencyPing();
- const auto r = engine->finishLatencyPing();
- step ("ping=" + juce::String (r.ok ? "ok" : "FAILED " + juce::String (r.problem)) + " samples " + juce::String (r.samples) + " spread " + juce::String (r.spread)
- + " found " + juce::String (r.found) + "/" + juce::String (r.sent) + " peak " + juce::String (juce::Decibels::gainToDecibels (r.peak, -150.0f), 1) + " dB");
- const auto l = engine->currentLatency();
- step ("compensation=" + juce::String (l.total()) + " (round trip " + juce::String (l.roundTrip()) + ", manual " + juce::String (l.manual) + ", pdc " + juce::String (l.pdc) + ")");
- // 2) record
- engine->setInsertArmed (1, true);
- auto o = engine->getRecordOptions();
- o.recordAudio = true;
- o.countInBars = 0;
- o.waitForInput = false;
- o.punchLoopRegion = mode == 2;
- o.preRollBars = mode == 2 ? 1 : 0;
- o.postRollBars = mode == 2 ? 1 : 0;
- // (round 177c: LYNX_RECTEST_BLEND_OFF=1: Blend off; LYNX_RECTEST_LAST_PASS=1: "only the last pass plays")
- o.mode = juce::SystemStats::getEnvironmentVariable ("LYNX_RECTEST_BLEND_OFF", {}) == "1" ? lynx::RecordMode::replace
- : lynx::RecordMode::overdub;
- o.lastLoopPassPlays = juce::SystemStats::getEnvironmentVariable ("LYNX_RECTEST_LAST_PASS", {}) == "1";
- engine->setRecordOptions (o);
- engine->stop();
- engine->rewind();
- engine->setRecording (true);
- juce::Timer::callAfterDelay (300, [this, step, finish, seconds, rate, report, mode] {
- if (engine == nullptr)
- return;
- engine->startPlayback(); // (as the Play button: pre-roll / punch)
- juce::Timer::callAfterDelay ((int) (seconds * 1000.0), [this, step, finish, seconds, rate, report, mode] {
- if (engine == nullptr)
- return;
- if (mode == 2)
- step (juce::String ("stopped_by_post_roll=") + (engine->getTransport().playing.load() ? "no" : "yes"));
- engine->stop();
- juce::Timer::callAfterDelay (500, [this, step, finish, seconds, rate, report, mode] {
- if (engine == nullptr)
- return;
- engine->setRecording (false);
- const auto& s = engine->getSong();
- const auto tps = 120.0 * lynx::ppq / (60.0 * rate);
- int take = -1;
- for (int ch = 0; ch < (int) s.channels.size(); ++ch)
- if (s.channels[(std::size_t) ch].instrument == lynx::InstrumentKind::audioClip && s.channels[(std::size_t) ch].name != "Clicks")
- take = ch;
- if (take < 0)
- {
- step ("result=ERROR no take (" + engine->getLastRecordingError() + ")");
- finish (1);
- return;
- }
- std::vector<std::vector<float>> audio;
- double takeRate = 0.0;
- const auto& path = s.channels[(std::size_t) take].samplePath;
- lynx::takes::readWav (path, audio, &takeRate);
- const auto frames = audio.empty() ? (juce::int64) 0 : (juce::int64) audio[0].size();
- step ("take=" + juce::String::fromUTF8 (path.c_str()) + " frames " + juce::String (frames) + " (" + juce::String ((double) frames / rate, 3)
- + " s of " + juce::String (seconds, 1) + " s played) lost " + juce::String (engine->getLostRecordingFrames()));
- // the clicks in the file (peaks above -12 dBFS, one per 1/8 s at most)
- std::vector<juce::int64> peaks;
- if (! audio.empty())
- for (juce::int64 f = 1; f + 1 < frames; ++f)
- {
- const auto x = std::abs (audio[0][(std::size_t) f]);
- if (x > 0.25f && x >= std::abs (audio[0][(std::size_t) f - 1]) && x > std::abs (audio[0][(std::size_t) f + 1])
- && (peaks.empty() || f - peaks.back() > (juce::int64) (rate / 8)))
- peaks.push_back (f);
- }
- // every clip of the take: each click inside it against the nearest beat
- int clips = 0, checked = 0, muted = 0;
- double worst = 0.0, sum = 0.0;
- for (const auto& c : s.playlist)
- {
- if (c.kind != lynx::ClipKind::audio || c.channel != take)
- continue;
- ++clips;
- muted += c.muted ? 1 : 0;
- const auto skip = ((double) c.offset + (double) c.offsetFraction) / tps; // file samples before the clip start
- for (const auto f : peaks)
- {
- const auto intoClip = (double) f - skip;
- if (intoClip < 0.0 || intoClip * tps >= (double) c.length)
- continue;
- const auto songTick = (double) c.start + intoClip * tps - 2.0 * tps; // (the pulse's peak is its 3rd sample)
- const auto beat = std::round (songTick / lynx::ppq) * lynx::ppq;
- const auto error = (songTick - beat) / tps;
- worst = std::max (worst, std::abs (error));
- sum += error;
- ++checked;
- }
- step ("clip track " + juce::String (c.track) + " start " + juce::String ((juce::int64) c.start) + " length " + juce::String ((juce::int64) c.length)
- + " offset " + juce::String ((juce::int64) c.offset) + juce::String (c.offsetFraction >= 0.0f ? "+" : "") + juce::String (c.offsetFraction, 4)
- + (c.muted ? " (muted lane)" : ""));
- }
- step ("clicks_in_file=" + juce::String ((int) peaks.size()) + " checked=" + juce::String (checked) + " clips=" + juce::String (clips)
- + " muted_lanes=" + juce::String (muted));
- step ("placement_error_samples=max " + juce::String (worst, 3) + " mean " + juce::String (checked > 0 ? sum / checked : 0.0, 3));
- auto ok = checked > 0 && worst <= 1.0 && engine->getLostRecordingFrames() == 0;
- if (mode == 2) // one clip, exactly the punch range, its 8 beats
- {
- const auto& sp = engine->getSong();
- bool exact = false;
- for (const auto& c : sp.playlist)
- if (c.kind == lynx::ClipKind::audio && c.channel == take)
- exact = c.start == sp.loopStart && c.start + c.length == sp.loopEnd;
- step (juce::String ("punch_clip_matches_range=") + (exact ? "yes" : "no"));
- ok = ok && clips == 1 && exact && checked == 8;
- }
- report.getSiblingFile (report.getFileNameWithoutExtension() + "-project.lynx").replaceWithText (lynx::ProjectFile::toJson (engine->getSong()));
- step (juce::String ("result=") + (ok ? "OK" : "FAILED"));
- finish (ok ? 0 : 1);
- });
- });
- });
- });
- }
- // --hwinserttest (round 164d): see the command line above.
- void runHwInsertTest (const juce::File& report, double seconds, const juce::String& deviceType, const juce::String& deviceName,
- const juce::String& inputName, int bufferSize, bool inPatcher = false, juce::File bounceFile = {})
- {
- engine = std::make_unique<lynx::AudioEngine>();
- lynx::videoview::install (*engine); // (Fruity Video Player channels: their sound tracks)
- savedDeviceState = engine->getDeviceManager().createStateXml();
- auto text = std::make_shared<juce::String>();
- auto step = [report, text] (const juce::String& line) { *text << line << "\n"; report.replaceWithText (*text); };
- auto finish = [this] (int code) {
- if (engine != nullptr)
- engine->getMeters().capture.setSource (lynx::AudioCapture::off);
- restoreSavedDeviceState();
- setApplicationReturnValue (code);
- quit();
- };
- auto& devices = engine->getDeviceManager();
- if (deviceType.isNotEmpty() && devices.getCurrentAudioDeviceType() != deviceType)
- devices.setCurrentAudioDeviceType (deviceType, true);
- {
- auto setup = devices.getAudioDeviceSetup();
- if (deviceName.isNotEmpty())
- setup.outputDeviceName = deviceName;
- if (bufferSize > 0)
- setup.bufferSize = bufferSize;
- if (const auto error = devices.setAudioDeviceSetup (setup, true); error.isNotEmpty())
- step ("device_error=" + error);
- }
- if (const auto r = engine->openAudioInput (inputName.isNotEmpty() ? inputName : deviceName); r.issue != lynx::AudioEngine::InputIssue::none)
- step ("input_error=" + juce::String ((int) r.issue) + " " + r.detail);
- auto* device = devices.getCurrentAudioDevice();
- if (device == nullptr || engine->getInputChannelNames().empty())
- {
- step ("result=ERROR no device / no input");
- finish (1);
- return;
- }
- const auto rate = device->getCurrentSampleRate();
- step ("device=" + device->getTypeName() + " | " + device->getName() + " | " + juce::String (rate) + " Hz | block " + juce::String (device->getCurrentBufferSizeSamples()));
- // the click track: the ping's pulse on every beat at 120 bpm
- const auto beats = (int) std::ceil (seconds * 2.0) + 8;
- const auto clickFile = report.getSiblingFile (report.getFileNameWithoutExtension() + "-clicks.wav");
- {
- lynx::takes::WavTakeWriter w;
- w.open (clickFile.getFullPathName().toStdString(), rate, 1, lynx::takes::SampleFormat::float32);
- const auto total = (juce::int64) std::llround ((double) beats * rate / 2.0);
- std::vector<float> block (4096);
- for (juce::int64 at = 0; at < total; at += (juce::int64) block.size())
- {
- std::fill (block.begin(), block.end(), 0.0f);
- for (int k = 0; k < (int) block.size(); ++k)
- {
- const auto f = at + k;
- const auto beat = (juce::int64) std::floor ((double) f / (rate / 2.0));
- const auto rel = f - (juce::int64) std::llround ((double) beat * rate / 2.0);
- static constexpr float shape[] { 0.25f, 0.75f, 1.0f, 0.75f, 0.25f };
- if (rel >= 0 && rel < 5)
- block[(std::size_t) k] = 0.5f * shape[rel];
- }
- const float* d[] { block.data() };
- w.write (d, (int) std::min<juce::int64> ((juce::int64) block.size(), total - at));
- }
- w.close();
- }
- lynx::Song song = lynx::Song::makeDefault();
- song.bpm = 120.0;
- song.mode = lynx::PlayMode::song;
- song.playlist.clear();
- song.channels.clear();
- for (int k = 0; k < 2; ++k)
- {
- lynx::ChannelDef c;
- c.name = k == 0 ? "Wet" : "Dry";
- c.instrument = lynx::InstrumentKind::audioClip;
- c.samplePath = clickFile.getFullPathName().toStdString();
- c.mixerTrack = k + 1;
- c.volume = 1.0f;
- song.channels.push_back (c);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = k;
- clip.track = k;
- clip.start = 0;
- clip.length = (std::int64_t) beats * lynx::ppq;
- song.playlist.push_back (clip);
- }
- song.mixer[0].outputChannel = lynx::outputNone; // (the cable carries the send only)
- for (auto& fx : song.mixer[0].effects) // (no Master effects: the default limiter's PDC would hide nothing, but keep it plain)
- fx.enabled = false;
- song.mixer[1].pan = -1.0f;
- song.mixer[2].pan = 1.0f;
- auto hw = lynx::makeEffectSlot (lynx::EffectKind::hardwareInsert);
- hw.params[lynx::hwinsert::output] = lynx::hwinsert::channelValue (0);
- hw.params[lynx::hwinsert::input] = lynx::hwinsert::channelValue (0);
- hw.params[lynx::hwinsert::inputStereo] = 1.0f;
- song.mixer[1].effects.clear();
- lynx::AudioEngine::HardwareInsertRef ref { false, 1, 0, {} };
- if (inPatcher) // (round 165c) From LYNX -> Hardware Insert -> To LYNX
- {
- auto slot = lynx::makeEffectSlot (lynx::EffectKind::patcher);
- lynx::PatchNode node;
- node.effect = hw;
- slot.patcher.nodes = { node };
- lynx::PatchWire in, out;
- in.from = lynx::patchFromHost;
- in.to = 0;
- out.from = 0;
- out.to = lynx::patchToHost;
- slot.patcher.wires = { in, out };
- song.mixer[1].effects.push_back (slot);
- ref.nodes = { 0 };
- }
- else
- song.mixer[1].effects.push_back (hw);
- engine->setSong (std::move (song));
- step (juce::String ("insert=") + (inPatcher ? "inside a Patcher on Insert 1" : "Insert 1 slot 1"));
- const auto meter = [this, ref] (int output) {
- const auto fx = engine->runningHardwareInsert (ref);
- return fx != nullptr ? fx->controlOutput (output) : 0.0f;
- };
- // 1) the insert's ping (as its Ping button: a momentary value flipped)
- juce::Timer::callAfterDelay (500, [this, report, step, finish, seconds, rate, meter, ref, inPatcher, bounceFile] {
- if (engine == nullptr)
- return;
- engine->pingHardwareInserts ({ ref });
- juce::Timer::callAfterDelay (3500, [this, report, step, finish, seconds, rate, meter, ref, inPatcher, bounceFile] {
- if (engine == nullptr)
- return;
- // (round 165c) the engine makes a ping's result the slot's round trip with the device setup it belongs to; the
- // new round trip rebuilds the insert (its latency), so the result is read from the slot
- const auto* slot = lynx::AudioEngine::locateHardwareInsert (const_cast<lynx::Song&> (engine->getSong()), ref);
- const auto samples = slot != nullptr ? lynx::hwinsert::roundTripOf (slot->params[lynx::hwinsert::roundTrip]) : 0;
- const auto setup = slot != nullptr ? lynx::hwinsert::measuredSetup (*slot) : std::string();
- const auto state = meter (lynx::hwinsert::pingState);
- const auto ok = samples > 0 && setup == engine->currentSetupKey();
- step ("ping_round_trip=" + juce::String (samples) + " measured_setup=" + juce::String (setup) + (ok ? " (ok)" : " (FAILED)")
- + " live_ping_state=" + juce::String (state, 3) + " status_flags=" + juce::String (juce::roundToInt (meter (lynx::hwinsert::status) * 16.0f)));
- if (! ok)
- {
- step ("result=FAILED ping");
- finish (1);
- return;
- }
- // a stale setup is noticed: another setup key on the slot gives the notice, the real one none
- step ("stale_now=" + juce::String ((int) engine->staleHardwareInserts().size()));
- // 2) play, capturing the Master
- juce::Timer::callAfterDelay (500, [this, report, step, finish, seconds, rate, samples, ref, inPatcher, bounceFile] {
- if (engine == nullptr)
- return;
- step ("pdc_total=" + juce::String (engine->getLatencySamples()) + " (expected " + juce::String (samples) + ")");
- // saved in the project: the slot comes back the same (routing, round trip), and its latency with it — also an
- // odd round trip (12345 samples: the project keeps it to the sample)
- if (! inPatcher)
- {
- auto odd = engine->getSong();
- odd.mixer[1].effects[0].params[lynx::hwinsert::roundTrip] = lynx::hwinsert::roundTripValue (12345);
- juce::String error;
- auto same = true;
- for (const auto* song : { &engine->getSong(), (const lynx::Song*) &odd })
- {
- const auto file = report.getSiblingFile (report.getFileNameWithoutExtension() + (song == &odd ? "-odd.lynx" : ".lynx"));
- const auto saved = lynx::ProjectFile::save (*song, file, error);
- const auto loaded = saved ? lynx::ProjectFile::load (file, error) : std::nullopt;
- same = same && loaded && loaded->mixer.size() > 1 && ! loaded->mixer[1].effects.empty()
- && loaded->mixer[1].effects[0].kind == lynx::EffectKind::hardwareInsert
- && loaded->mixer[1].effects[0].params == song->mixer[1].effects[0].params
- && lynx::makeEffect (loaded->mixer[1].effects[0])->latencySamples() == (song == &odd ? 12345 : samples);
- }
- const auto file = report.getSiblingFile (report.getFileNameWithoutExtension() + ".lynx");
- step (juce::String ("project_round_trip=") + (same ? "same" : "DIFFERENT " + error) + " (" + file.getFileName() + ")");
- if (! same)
- {
- step ("result=FAILED project");
- finish (1);
- return;
- }
- }
- auto left = std::make_shared<std::vector<float>>(), right = std::make_shared<std::vector<float>>();
- engine->stop();
- engine->rewind();
- engine->getMeters().capture.setSource (0);
- engine->play();
- auto pulls = std::make_shared<int> ((int) (seconds * 5.0));
- auto pull = std::make_shared<std::function<void()>>();
- *pull = [this, report, step, finish, seconds, rate, samples, left, right, pulls, pull, ref, inPatcher, bounceFile] {
- if (engine == nullptr)
- return;
- engine->getMeters().capture.pull (*left, *right);
- if (*pulls == 10) // the insert's editor while it plays (next to the report)
- for (const auto scale : { 1.0f, 1.5f })
- {
- auto editor = inPatcher ? lynx::makeNodeEffectEditor (
- *engine, [ref] (lynx::Song& s) { return lynx::AudioEngine::locateHardwareInsert (s, ref); },
- [this, ref] { return engine->runningHardwareInsert (ref); }, "Insert 1 (Patcher)", scale)
- : lynx::makeNativeEffectEditor (*engine, 1, 0, scale, 0);
- juce::Image image (juce::Image::ARGB, editor->getWidth(), editor->getHeight(), true);
- {
- juce::Graphics g (image);
- g.fillAll (lynx::theme::panel);
- editor->paintEntireComponent (g, false);
- }
- const auto file = report.getSiblingFile (report.getFileNameWithoutExtension() + (scale > 1.0f ? "-editor150.png" : "-editor.png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- if (--*pulls > 0)
- {
- juce::Timer::callAfterDelay (200, *pull);
- return;
- }
- engine->stop();
- const auto dropped = engine->getMeters().capture.droppedFrames();
- engine->getMeters().capture.setSource (lynx::AudioCapture::off);
- // the clicks of each side (peaks above -12 dBFS, one per 1/8 s at most)
- auto peaksOf = [rate] (const std::vector<float>& x) {
- std::vector<juce::int64> peaks;
- for (std::size_t f = 1; f + 1 < x.size(); ++f)
- if (std::abs (x[f]) > 0.25f && std::abs (x[f]) >= std::abs (x[f - 1]) && std::abs (x[f]) > std::abs (x[f + 1])
- && (peaks.empty() || (juce::int64) f - peaks.back() > (juce::int64) (rate / 8)))
- peaks.push_back ((juce::int64) f);
- return peaks;
- };
- const auto wet = peaksOf (*left), dry = peaksOf (*right);
- int pairs = 0;
- juce::int64 worst = 0;
- double gainSum = 0.0, residual = 0.0, energy = 0.0;
- for (const auto w : wet)
- {
- auto best = std::min_element (dry.begin(), dry.end(), [w] (juce::int64 a, juce::int64 b) { return std::abs (a - w) < std::abs (b - w); });
- if (best == dry.end() || std::abs (*best - w) > (juce::int64) (rate / 8))
- continue;
- ++pairs;
- worst = std::max (worst, std::abs (*best - w));
- gainSum += (*left)[(std::size_t) w] / (*right)[(std::size_t) *best];
- }
- const auto gain = pairs > 0 ? gainSum / pairs : 1.0;
- // dry clicks with no wet click beside them (a dropout of the cable / device), listed
- juce::String unmatched;
- for (const auto d : dry)
- if (std::none_of (wet.begin(), wet.end(), [d, rate] (juce::int64 w) { return std::abs (w - d) <= (juce::int64) (rate / 8); }))
- unmatched << " " << (juce::int64) d << " (" << juce::String ((*left)[(std::size_t) d], 3) << ")";
- if (unmatched.isNotEmpty())
- step ("dry_clicks_without_wet=" + unmatched);
- // the null test: left − gain · right around each click (both sides aligned → only the cable's colour remains)
- for (const auto w : wet)
- for (juce::int64 f = std::max<juce::int64> (0, w - 16); f < std::min<juce::int64> ((juce::int64) left->size(), w + 16); ++f)
- {
- const auto d = (double) (*left)[(std::size_t) f] - gain * (double) (*right)[(std::size_t) f];
- residual += d * d;
- energy += (double) (*left)[(std::size_t) f] * (*left)[(std::size_t) f];
- }
- const auto nullDb = energy > 0.0 ? 10.0 * std::log10 (std::max (1e-30, residual / energy)) : 0.0;
- step ("captured=" + juce::String ((int) left->size()) + " frames dropped=" + juce::String (dropped) + " wet_clicks=" + juce::String ((int) wet.size())
- + " dry_clicks=" + juce::String ((int) dry.size()) + " pairs=" + juce::String (pairs));
- step ("alignment_error_samples=max " + juce::String ((int) worst) + " cable_gain=" + juce::String (gain, 4) + " null_residual_db=" + juce::String (nullDb, 1));
- auto* dev = engine->getDeviceManager().getCurrentAudioDevice();
- const auto xruns = dev != nullptr ? dev->getXRunCount() : -1;
- step ("device_xruns=" + juce::String (xruns) + " (a dropout loses what was on the cable then: its clicks are excused)");
- const auto excused = xruns > 0 ? 2 * xruns : 0;
- const auto ok = pairs >= (int) (seconds * 2.0) - 2 - excused && worst == 0 && dropped == 0 && engine->getLatencySamples() == samples;
- step (juce::String ("result=") + (ok ? "OK" : "FAILED"));
- // (round 165c) then the re-ping notice after a buffer size change
- auto then = [this, ref, step, finish] (int code) {
- if (code != 0)
- finish (code);
- else
- runRepingCheck (ref, step, finish);
- };
- if (! ok)
- {
- finish (1);
- return;
- }
- if (bounceFile == juce::File())
- then (0);
- else
- runBounceCheck (bounceFile, step, then);
- };
- juce::Timer::callAfterDelay (200, *pull);
- });
- });
- });
- }
- // --hwinserttest --bounce (round 165c): Export › "Render through the hardware in real time" of the test song next to
- // the offline export of the same song. Through the loopback cable (gain 1) the return is the send delayed by the
- // pinged round trip, so the real-time file must equal the offline one (which passes the dry signal at that delay)
- // to float rounding, with the wet clicks (left) on the dry clicks' samples (right).
- // --hwinserttest (round 165c): the buffer size changes (another round trip on the device): the engine notices the
- // insert measured for the old setup (the app's "Ping now?" prompt), "Ping now" measures it again for the new one
- void runRepingCheck (lynx::AudioEngine::HardwareInsertRef ref, std::function<void (const juce::String&)> step, std::function<void (int)> finish)
- {
- auto& devices = engine->getDeviceManager();
- auto setup = devices.getAudioDeviceSetup();
- const auto before = setup.bufferSize;
- setup.bufferSize = before == 512 ? 256 : 512;
- if (const auto error = devices.setAudioDeviceSetup (setup, true); error.isNotEmpty())
- step ("reping_device_error=" + error);
- engine->takeHardwareInsertNotice(); // (whatever was pending before the change)
- juce::Timer::callAfterDelay (1500, [this, ref, step, finish, before] {
- if (engine == nullptr)
- return;
- auto* device = engine->getDeviceManager().getCurrentAudioDevice();
- const auto block = device != nullptr ? device->getCurrentBufferSizeSamples() : 0;
- const auto notice = engine->takeHardwareInsertNotice();
- step ("reping_buffer=" + juce::String (before) + "->" + juce::String (block) + " notice=" + juce::String ((int) notice.size())
- + " stale=" + juce::String ((int) engine->staleHardwareInserts().size()));
- if (notice.size() != 1 || ! (notice[0] == ref))
- {
- step ("result_reping=FAILED (no notice)");
- finish (1);
- return;
- }
- engine->pingHardwareInserts (notice); // ("Ping now")
- juce::Timer::callAfterDelay (3500, [this, ref, step, finish, block] {
- if (engine == nullptr)
- return;
- const auto* slot = lynx::AudioEngine::locateHardwareInsert (const_cast<lynx::Song&> (engine->getSong()), ref);
- const auto samples = slot != nullptr ? lynx::hwinsert::roundTripOf (slot->params[lynx::hwinsert::roundTrip]) : 0;
- const auto stale = (int) engine->staleHardwareInserts().size();
- step ("reping_round_trip=" + juce::String (samples) + " pdc_total=" + juce::String (engine->getLatencySamples()) + " stale=" + juce::String (stale));
- const auto ok = stale == 0 && samples > 0 && engine->getLatencySamples() == samples;
- step (juce::String ("result_reping=") + (ok ? "OK" : "FAILED") + " (device block " + juce::String (block) + ")");
- finish (ok ? 0 : 1);
- });
- });
- }
- void runBounceCheck (const juce::File& bounceFile, std::function<void (const juce::String&)> step, std::function<void (int)> finish)
- {
- // the Export window as the user sees it with the real-time option ticked (next to the report)
- lynx::showExportDialog (*engine, bounceFile.getParentDirectory(), "bounce", 0);
- for (int k = 0; k < juce::TopLevelWindow::getNumTopLevelWindows(); ++k)
- if (auto* w = juce::TopLevelWindow::getTopLevelWindow (k))
- {
- std::function<juce::ToggleButton* (juce::Component&)> find = [&find] (juce::Component& c) -> juce::ToggleButton* {
- if (auto* t = dynamic_cast<juce::ToggleButton*> (&c); t != nullptr && t->getButtonText() == lynx::tr ("Render through the hardware in real time"))
- return t;
- for (auto* child : c.getChildren())
- if (auto* t = find (*child))
- return t;
- return nullptr;
- };
- if (auto* toggle = find (*w))
- {
- step (juce::String ("export_option_visible=") + (toggle->isVisible() ? "yes" : "NO"));
- toggle->setToggleState (true, juce::sendNotificationSync); // (calls its onClick, as a click)
- auto* c = dynamic_cast<juce::DocumentWindow*> (w) != nullptr ? static_cast<juce::DocumentWindow*> (w)->getContentComponent() : w;
- if (c != nullptr)
- {
- const auto file = bounceFile.getSiblingFile (bounceFile.getFileNameWithoutExtension() + "-export.png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat png;
- if (out.openedOk())
- png.writeImageToStream (c->createComponentSnapshot (c->getLocalBounds()), out);
- }
- delete w;
- break;
- }
- }
- lynx::exportopts::Options o;
- o.format = lynx::exportopts::Format::wav;
- o.wavBits = 32;
- o.dither = lynx::exportopts::DitherMode::none;
- o.tail = lynx::exportopts::TailMode::cut;
- o.range = lynx::exportopts::Range::song;
- o.trimPdc = true;
- o.hqAllPlugins = false;
- o.pluginWarmUp = false;
- const auto offlineFile = bounceFile.getSiblingFile (bounceFile.getFileNameWithoutExtension() + "-offline.wav");
- auto realtimeJob = std::make_shared<lynx::ExportJob> (*engine, o, bounceFile);
- o.sampleRate = engine->getTransport().sampleRate.load();
- auto offlineJob = std::make_shared<lynx::ExportJob> (engine->getSong(), o, offlineFile);
- struct Shared
- {
- std::atomic<int> done { 0 };
- bool okRealtime = false, okOffline = false;
- juce::String errorRealtime, errorOffline;
- double lastProgress = 0.0;
- double started = juce::Time::getMillisecondCounterHiRes();
- };
- auto shared = std::make_shared<Shared>();
- // (the jobs stay owned by the message thread's poll below: they are destroyed there)
- juce::Thread::launch ([rt = realtimeJob.get(), off = offlineJob.get(), shared] {
- shared->okRealtime = rt->run ([shared] (double p) { shared->lastProgress = p; return true; }, shared->errorRealtime);
- shared->okOffline = off->run ({}, shared->errorOffline);
- shared->done.store (1);
- });
- auto poll = std::make_shared<std::function<void()>>();
- *poll = [this, poll, shared, realtimeJob, offlineJob, bounceFile, offlineFile, step, finish] {
- if (shared->done.load() == 0)
- {
- juce::Timer::callAfterDelay (100, *poll);
- return;
- }
- const auto seconds = (juce::Time::getMillisecondCounterHiRes() - shared->started) / 1000.0;
- step ("bounce_realtime=" + juce::String (shared->okRealtime ? "ok" : "FAILED " + shared->errorRealtime) + " offline="
- + juce::String (shared->okOffline ? "ok" : "FAILED " + shared->errorOffline) + " took=" + juce::String (seconds, 1) + " s (music "
- + juce::String (realtimeJob->getMusicSeconds(), 1) + " s)" + (realtimeJob->getNotice().isNotEmpty() ? " notice=" + realtimeJob->getNotice() : juce::String()));
- juce::AudioFormatManager formats;
- formats.registerBasicFormats();
- std::unique_ptr<juce::AudioFormatReader> a (formats.createReaderFor (bounceFile)), b (formats.createReaderFor (offlineFile));
- if (! shared->okRealtime || ! shared->okOffline || a == nullptr || b == nullptr)
- {
- step ("result=FAILED bounce");
- finish (1);
- return;
- }
- const auto frames = (int) std::min (a->lengthInSamples, b->lengthInSamples);
- juce::AudioBuffer<float> x (2, frames), y (2, frames);
- a->read (&x, 0, frames, 0, true, true);
- b->read (&y, 0, frames, 0, true, true);
- double residual = 0.0, energy = 0.0, wetDry = 0.0;
- for (int ch = 0; ch < 2; ++ch)
- for (int i = 0; i < frames; ++i)
- {
- const double d = x.getSample (ch, i) - y.getSample (ch, i);
- residual += d * d;
- energy += (double) y.getSample (ch, i) * y.getSample (ch, i);
- }
- for (int i = 0; i < frames; ++i) // the wet side against the dry side of the real-time file
- wetDry += std::pow ((double) x.getSample (0, i) - x.getSample (1, i), 2.0);
- const auto db = [energy] (double r) { return energy > 0.0 ? 10.0 * std::log10 (std::max (1e-30, r / energy)) : 0.0; };
- step ("bounce_frames=" + juce::String ((juce::int64) a->lengthInSamples) + " offline_frames=" + juce::String ((juce::int64) b->lengthInSamples)
- + " rate=" + juce::String (a->sampleRate) + " bounce_vs_offline_db=" + juce::String (db (residual), 1)
- + " wet_vs_dry_db=" + juce::String (db (2.0 * wetDry), 1) + " peak=" + juce::String (realtimeJob->getPeak(), 3));
- const auto ok = std::abs (a->lengthInSamples - b->lengthInSamples) <= 1 && db (residual) < -100.0 && realtimeJob->getPeak() > 0.1f;
- step (juce::String ("result_bounce=") + (ok ? "OK" : "FAILED"));
- finish (ok ? 0 : 1);
- };
- juce::Timer::callAfterDelay (100, *poll);
- }
- // --rtstress --record: stops recording (the take becomes a clip of the song, as in the app), moves the take's WAV to
- // `target` and describes it: length against the time played, channels, peak, the latencies the driver reported.
- juce::String finishStressTake (const juce::File& target, double seconds)
- {
- juce::String text;
- auto* device = engine->getDeviceManager().getCurrentAudioDevice();
- text << " recording: input " << (device != nullptr ? device->getActiveInputChannels().countNumberOfSetBits() : 0) << " channel(s)";
- if (device != nullptr)
- text << ", input latency " << device->getInputLatencyInSamples() << " + output latency " << device->getOutputLatencyInSamples() << " samples";
- engine->setRecording (false); // closes the take: a clip of the song
- juce::File take;
- for (const auto& c : engine->getSong().channels)
- if (c.instrument == lynx::InstrumentKind::audioClip)
- take = juce::File (juce::String::fromUTF8 (c.samplePath.c_str()));
- if (! take.existsAsFile())
- return text + "\n recording: no take (" + engine->getLastRecordingError() + ")\n";
- target.deleteFile();
- if (! take.moveFileTo (target))
- take.copyFileTo (target);
- juce::AudioFormatManager formats;
- formats.registerBasicFormats();
- if (std::unique_ptr<juce::AudioFormatReader> reader (formats.createReaderFor (target)); reader != nullptr)
- {
- juce::AudioBuffer<float> audio ((int) reader->numChannels, (int) reader->lengthInSamples);
- reader->read (&audio, 0, (int) reader->lengthInSamples, 0, true, true);
- const auto peak = audio.getMagnitude (0, audio.getNumSamples());
- const auto length = (double) reader->lengthInSamples / reader->sampleRate;
- text << "\n recording: take " << juce::String (length, 3) << " s of " << juce::String (seconds, 0) << " s played, "
- << (int) reader->numChannels << " ch @ " << (int) reader->sampleRate << " Hz, peak "
- << juce::String (juce::Decibels::gainToDecibels (peak, -150.0f), 1) << " dBFS -> " << target.getFullPathName() << "\n";
- }
- else
- text << "\n recording: take unreadable (" << target.getFullPathName() << ")\n";
- return text;
- }
- // LYNX.exe --render project.(flp|lynx) output.wav [seconds]
- // Exports the current pattern to 24-bit WAV (for an imported .flp, the one with the most notes).
- void runRender (const juce::String& inputPath, const juce::String& outputPath, double seconds)
- {
- lynx::AudioEngine offline (false);
- const juce::File input (inputPath);
- juce::String error, report;
- bool ok = false;
- if (input.hasFileExtension ("flp;als;flm;songtmpl;band;blx;mod;xm;s3m;it")) // (round 190ic: a GarageBand .band folder too; 190nw: a module)
- ok = offline.importFlpFile (input, error);
- else if (auto song = lynx::ProjectFile::load (input, error))
- {
- offline.setSong (std::move (*song));
- ok = true;
- }
- int samplers = 0, samplersLoaded = 0;
- if (ok)
- {
- for (const auto& c : offline.getSong().channels)
- if (c.instrument == lynx::InstrumentKind::sampler || c.instrument == lynx::InstrumentKind::audioClip)
- {
- ++samplers;
- samplersLoaded += offline.getSampleLibrary().load (juce::String::fromUTF8 (c.samplePath.c_str())) != nullptr;
- }
- const juce::File output (outputPath);
- output.deleteFile();
- juce::WavAudioFormat wav;
- std::unique_ptr<juce::AudioFormatWriter> writer (
- wav.createWriterFor (output.createOutputStream().release(), 44100.0, 2, 24, {}, 0));
- if (writer == nullptr)
- {
- ok = false;
- error = lynx::utf8 ("could not create ") + outputPath;
- }
- else
- {
- const auto peak = offline.renderOffline (seconds > 0.0 ? seconds : 10.0, 44100.0, writer.get());
- report << "peak=" << peak << "\n";
- ok = peak > 0.001f;
- }
- }
- report << "samples=" << samplersLoaded << "/" << samplers << "\n"
- << "result=" << (ok ? "OK" : "ERROR " + error) << "\n";
- juce::File (outputPath + ".txt").replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --export-flp project.(lynx|flp|als) output.(flp|zip) [--substitute] (round 171e): File › Export › FL Studio
- // project without the window (option A unless --substitute; the renders next to a .flp in "<name> audio"); the
- // report goes to output.txt
- void runAlsExport (const juce::String& inputPath, const juce::String& folderPath, bool live11, bool reference)
- {
- juce::String error;
- juce::StringArray notes;
- juce::File als;
- {
- lynx::AudioEngine loader (false);
- const juce::File input (inputPath);
- bool ok = false;
- // --scan: the targeted plugin scan an open runs first (child processes), so the set's plugins load
- if (juce::JUCEApplication::getCommandLineParameterArray().contains ("--scan") && input.hasFileExtension ("flp;als;flm;songtmpl"))
- {
- juce::MemoryBlock data;
- if (input.loadFileAsData (data))
- {
- const std::vector<std::uint8_t> bytes (static_cast<const std::uint8_t*> (data.getData()),
- static_cast<const std::uint8_t*> (data.getData()) + data.getSize());
- try
- {
- const auto uses = input.hasFileExtension ("als") ? lynx::alsForeignPlugins (bytes)
- : lynx::flpForeignPlugins (flp::parseProject ({ bytes.data(), bytes.size() }));
- loader.getPluginHost().scanFiles (loader.getPluginHost().filesToScanFor (uses), {});
- }
- catch (const std::exception&)
- {
- }
- }
- }
- if (input.hasFileExtension ("flp;als;flm;songtmpl;band;blx;mod;xm;s3m;it"))
- ok = loader.importFlpFile (input, error);
- else if (auto song = lynx::ProjectFile::load (input, error))
- {
- loader.setSong (std::move (*song));
- ok = true;
- }
- if (ok)
- {
- loader.capturePluginStates();
- const juce::File folder (folderPath);
- folder.createDirectory();
- als = lynx::writeAlsProject (loader.getSong(), &loader.getPluginHost(), live11 ? lynx::AlsVersion::live11 : lynx::AlsVersion::live12, ! reference, folder,
- input.getFileNameWithoutExtension(), notes, error);
- }
- }
- juce::String report;
- report << (als != juce::File() ? "ok " + als.getFullPathName() : "error=" + error) << "\n" << notes.joinIntoString ("\n") << "\n";
- juce::File (folderPath).getChildFile ("export-als.txt").replaceWithText (report);
- setApplicationReturnValue (als != juce::File() ? 0 : 1);
- quit();
- }
- // --versionsshot <prefix> (round 190ap): everything the round adds, offscreen (no window on the desktop):
- // -versions.png / -versions-unsaved.png the Versions panel (a project with versions, backups and labels; a new one)
- // -menu-file.png / -menu-file-pluginsoff.png the File menu, and as it is while the plugins are off
- // -pluginsoff-window.png / -pluginsoff-mixer.png a project opened without its third-party plugins (the tags)
- // -pluginsoff-panel.png / -pluginsoff-panel-one.png the list, all off, then after "Switch on" for one
- // -export-default.png / -export.png the Export window as it opens, and with the additions in use
- bool runLinkShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto shoot = [&prefix] (juce::Component& c, const char* name) {
- savePng (c.createComponentSnapshot (c.getLocalBounds()), prefix + "-" + name + ".png");
- };
- using lynx::AutomationTarget;
- using lynx::AutomationTargetKind;
- using lynx::MidiLink;
- lynx::AudioEngine engine (false);
- const AutomationTarget volume { AutomationTargetKind::channelVolume, 0 }, pan { AutomationTargetKind::channelPan, 0 },
- insert { AutomationTargetKind::mixerVolume, 1 };
- // ---- the window as it opens on a control with no link (FL's defaults)
- {
- auto panel = lynx::makeRemoteControlPanel (engine, { volume }, false);
- shoot (*panel, "remote-default");
- check ("default_state", lynx::remoteControlPanelState (*panel).startsWith ("-1|1|-1|Input|"), lynx::remoteControlPanelState (*panel));
- // Auto detect: the controller that sends next fills the fields
- engine.injectControllerForTest (74, 2, 100, 5);
- lynx::remoteControlPanelPoll (*panel);
- check ("auto_detect", lynx::remoteControlPanelState (*panel).startsWith ("5|3|74|"), lynx::remoteControlPanelState (*panel));
- // a formula preset, smoothing; Accept writes the link
- lynx::remoteControlPanelSetController (*panel, -1, 1, 7);
- lynx::remoteControlPanelSetFormula (*panel, "Tension(Input,10)");
- lynx::remoteControlPanelSetSmoothing (*panel, true, 469);
- shoot (*panel, "remote-formula-smoothing");
- lynx::remoteControlPanelPress (*panel, 2);
- const auto& links = engine.getSong().midiLinks;
- check ("accept_writes_link", links.size() == 1 && links[0].cc == 7 && links[0].channel == 0 && links[0].port == -1
- && links[0].formula == "Tension(Input,10)" && links[0].smooth && links[0].target == volume);
- }
- // ---- a broken formula: the message, the red text
- {
- auto panel = lynx::makeRemoteControlPanel (engine, { volume }, false);
- lynx::remoteControlPanelSetFormula (*panel, "Min(Input*2,");
- shoot (*panel, "remote-formula-error");
- check ("formula_error_shown", ! lynx::remoteControlPanelState (*panel).contains ("Compiled ok."), lynx::remoteControlPanelState (*panel));
- }
- // ---- the engine: formula, port, conflicts, omni
- {
- engine.editSong ([&] (lynx::Song& s) {
- s.midiLinks.clear();
- MidiLink inverted { 20, 0, volume };
- inverted.formula = "1-Input";
- MidiLink ported { 21, 0, pan };
- ported.port = 3;
- s.midiLinks = { inverted, ported };
- });
- engine.injectControllerForTest (20, 0, 127);
- check ("formula_inverts", std::abs (engine.currentTargetValue (volume)) < 0.01f, juce::String (engine.currentTargetValue (volume)));
- engine.injectControllerForTest (20, 0, 0);
- check ("formula_inverts_back", std::abs (engine.currentTargetValue (volume) - 1.0f) < 0.01f, juce::String (engine.currentTargetValue (volume)));
- const auto panBefore = engine.currentTargetValue (pan);
- engine.injectControllerForTest (21, 0, 127); // no port: not this link's device
- check ("port_must_match", std::abs (engine.currentTargetValue (pan) - panBefore) < 0.001f);
- engine.injectControllerForTest (21, 0, 127, 3);
- check ("port_matches", std::abs (engine.currentTargetValue (pan) - 1.0f) < 0.01f, juce::String (engine.currentTargetValue (pan)));
- // the window on a control whose controller another control uses: Remove conflicts in red; Accept removes it
- auto panel = lynx::makeRemoteControlPanel (engine, { insert }, false);
- lynx::remoteControlPanelSetController (*panel, -1, 1, 20);
- shoot (*panel, "remote-conflict");
- check ("conflict_counted", lynx::remoteControlPanelState (*panel).contains ("|1|"), lynx::remoteControlPanelState (*panel));
- lynx::remoteControlPanelPress (*panel, 2);
- const auto& links = engine.getSong().midiLinks;
- check ("conflict_removed", links.size() == 2
- && std::none_of (links.begin(), links.end(), [&] (const MidiLink& l) { return l.target == volume; })
- && std::any_of (links.begin(), links.end(), [&] (const MidiLink& l) { return l.target == insert && l.cc == 20; }));
- engine.undo();
- check ("accept_is_one_undo_step", engine.getSong().midiLinks.size() == 2 && engine.getSong().midiLinks[0].target == volume);
- }
- // ---- an existing link opened again: "Link 1" / "New link"
- {
- auto panel = lynx::makeRemoteControlPanel (engine, { volume }, false);
- shoot (*panel, "remote-existing-link");
- check ("existing_link_loaded", lynx::remoteControlPanelState (*panel).startsWith ("-1|1|20|1-Input|"), lynx::remoteControlPanelState (*panel));
- // Reset, then Accept: a link without a controller is removed
- lynx::remoteControlPanelPress (*panel, 0);
- check ("reset_state", lynx::remoteControlPanelState (*panel).startsWith ("-1|1|-1|Input|"), lynx::remoteControlPanelState (*panel));
- lynx::remoteControlPanelPress (*panel, 2);
- const auto& links = engine.getSong().midiLinks;
- check ("reset_accept_unlinks", std::none_of (links.begin(), links.end(), [&] (const MidiLink& l) { return l.target == volume; }));
- }
- // ---- several controls ("Link to controllers..."): Accept and Skip step through them
- {
- auto panel = lynx::makeRemoteControlPanel (engine, { volume, pan, insert }, false, [] {});
- shoot (*panel, "remote-multilink");
- const auto parameter = [&panel] { return juce::StringArray::fromTokens (lynx::remoteControlPanelState (*panel), "|", "")[6]; };
- const auto first = parameter();
- check ("multilink_caption_and_skip", first.startsWith ("1/3") && first.contains (lynx::tr ("Channel volume"))
- && lynx::remoteControlPanelState (*panel).contains ("S|omni"),
- lynx::remoteControlPanelState (*panel));
- lynx::remoteControlPanelSetController (*panel, -1, 1, 30);
- lynx::remoteControlPanelPress (*panel, 2); // Accept: volume linked, on to pan
- const auto second = parameter();
- lynx::remoteControlPanelPress (*panel, 1); // Skip: pan untouched, on to the insert
- const auto third = parameter();
- const auto beforeLast = lynx::remoteControlPanelFinished (*panel);
- lynx::remoteControlPanelPress (*panel, 1); // Skip on the last one: done
- const auto closed = ! beforeLast && lynx::remoteControlPanelFinished (*panel);
- const auto& links = engine.getSong().midiLinks;
- check ("multilink_steps", first != second && second != third && closed
- && std::any_of (links.begin(), links.end(), [&] (const MidiLink& l) { return l.target == volume && l.cc == 30; }),
- first + " > " + second + " > " + third);
- }
- // ---- Global link settings
- {
- auto panel = lynx::makeRemoteControlPanel (engine, { volume }, true);
- shoot (*panel, "global-default");
- lynx::remoteControlPanelSetController (*panel, 2, 1, 11);
- lynx::remoteControlPanelSetFormula (*panel, "Input*0.5");
- lynx::remoteControlPanelPress (*panel, 2);
- const auto global = engine.globalLinkOf (volume);
- check ("global_link_written", global && global->cc == 11 && global->port == 2 && global->formula == "Input*0.5");
- const auto text = engine.getMidiPrefs().toText();
- const auto back = lynx::prefs::MidiPrefs::fromText (text);
- check ("global_link_settings_round_trip", back.globalLinks == engine.getMidiPrefs().globalLinks && text.find ("linkset=2|0|469|Input*0.5") != std::string::npos);
- auto again = lynx::makeRemoteControlPanel (engine, { volume }, true);
- shoot (*again, "global-existing-link");
- engine.setGlobalLink (volume, std::nullopt);
- check ("global_link_removed", ! engine.globalLinkOf (volume));
- }
- // ---- the project file: links with settings come back; a project of an older version loads the same
- {
- lynx::Song song = engine.getSong();
- MidiLink plain { 7, -1, volume };
- MidiLink rich { 74, 2, pan };
- rich.port = 4;
- rich.formula = "Min(Input*1.1,0.5)+Max(Input*1.1,0.6)-0.6";
- rich.smooth = true;
- rich.smoothing = -300;
- rich.omni = true;
- song.midiLinks = { plain, rich };
- juce::String error;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, error);
- check ("project_round_trip", back && back->midiLinks == song.midiLinks, error);
- // without settings the file holds only the list older versions wrote
- song.midiLinks = { plain };
- const auto plainJson = lynx::ProjectFile::toJson (song);
- check ("plain_links_write_the_old_form", ! plainJson.contains ("midiLinkSettings") && plainJson.contains ("midiLinks"));
- const auto plainBack = lynx::ProjectFile::fromJson (plainJson, error);
- check ("old_project_loads_the_same", plainBack && plainBack->midiLinks.size() == 1 && plainBack->midiLinks[0] == plain
- && ! plainBack->midiLinks[0].hasSettings());
- // what an older version does with a new file: it reads "midiLinks" alone, so the links stay (plain)
- auto parsed = juce::JSON::parse (json);
- if (auto* o = parsed.getDynamicObject())
- o->removeProperty ("midiLinkSettings");
- const auto stripped = lynx::ProjectFile::fromJson (juce::JSON::toString (parsed), error);
- check ("older_version_keeps_the_links", stripped && stripped->midiLinks.size() == 2 && stripped->midiLinks[1].cc == 74
- && ! stripped->midiLinks[1].hasSettings());
- }
- // ---- round 190cs: FL's live answers (live check 190cq) and the note / button link modes
- {
- const auto state = [] (juce::Component& p) { return lynx::remoteControlPanelState (p); };
- engine.editSong ([] (lynx::Song& s) { s.midiLinks.clear(); });
- // the layout FL shows: no assignment list without a link, no Skip outside Multilink, no internal
- // controller group without a controller in the project; the parameter caption in FL's words
- auto fresh = lynx::makeRemoteControlPanel (engine, { volume }, false);
- shoot (*fresh, "cs-remote-default");
- check ("cs_layout_without_link", state (*fresh).contains ("|" + lynx::tr ("Channel volume") + "|") && state (*fresh).contains ("|shown=POC|"), state (*fresh));
- // Omni: enabled on a mixer track's volume (FL: "Insert 1 - Volume"), greyed on the tempo
- auto onInsert = lynx::makeRemoteControlPanel (engine, { insert }, false);
- auto onTempo = lynx::makeRemoteControlPanel (engine, { AutomationTarget { AutomationTargetKind::tempo, 0 } }, false);
- shoot (*onInsert, "cs-remote-omni-insert");
- check ("cs_omni_mixer_track", state (*onInsert).contains ("|omni=on|") && state (*onTempo).contains ("|omni=off|"),
- state (*onInsert) + " / " + state (*onTempo));
- // the formula compiles on Enter only; FL's messages and colours
- lynx::remoteControlPanelSetFormula (*fresh, "1-Input^2", false);
- check ("cs_no_compile_while_typing", state (*fresh).contains ("|" + lynx::tr ("(default 1:1 mapping)") + "|"), state (*fresh));
- lynx::remoteControlPanelSetFormula (*fresh, "-Input^2");
- shoot (*fresh, "cs-remote-compiled");
- check ("cs_compiled_on_enter", state (*fresh).contains ("|" + lynx::tr ("Compiled ok.") + "|"), state (*fresh));
- const std::pair<const char*, const char*> errors[] { { "Input*", "Syntax error: function or operand" },
- { "foo(Input)", "Invalid identifier: foo" },
- { "Sin(Input", "Unequal brackets" },
- { "Input 2", "input two space limited" } };
- for (const auto& [text, expected] : errors)
- {
- lynx::remoteControlPanelSetFormula (*fresh, text);
- check ("cs_fl_error_text", state (*fresh).contains (expected), state (*fresh));
- }
- lynx::remoteControlPanelSetFormula (*fresh, "foo(Input)");
- shoot (*fresh, "cs-remote-error");
- // Accept with that formula: the link is made, the formula is not kept (FL reopens it as "Input")
- lynx::remoteControlPanelSetController (*fresh, -1, 1, 7);
- lynx::remoteControlPanelPress (*fresh, 2);
- check ("cs_bad_formula_accept_is_input", engine.getSong().midiLinks.size() == 1 && engine.getSong().midiLinks[0].cc == 7
- && engine.getSong().midiLinks[0].formula.empty());
- auto reopened = lynx::makeRemoteControlPanel (engine, { volume }, false);
- shoot (*reopened, "cs-remote-reopened");
- check ("cs_reopened_shows_input_and_link_list", state (*reopened).startsWith ("-1|1|7|Input|" + lynx::tr ("(default 1:1 mapping)") + "|")
- && state (*reopened).contains ("|shown=PAOC|"),
- state (*reopened));
- // the internal controller group appears with a controller in the project, with "Record automation"
- engine.editSong ([] (lynx::Song& s) {
- lynx::EffectSlot peak;
- peak.kind = lynx::EffectKind::peakController;
- s.mixer[0].effects.push_back (peak);
- });
- auto withController = lynx::makeRemoteControlPanel (engine, { volume }, false);
- lynx::remoteControlPanelSetInternal (*withController, 1, true);
- shoot (*withController, "cs-remote-internal");
- check ("cs_internal_group_shown", state (*withController).contains ("|shown=PAIOC|") && state (*withController).startsWith ("-1|1|-1|"),
- state (*withController));
- lynx::remoteControlPanelPress (*withController, 2);
- const auto& autos = engine.getSong().automations;
- check ("cs_record_automation_kept", std::any_of (autos.begin(), autos.end(), [&] (const lynx::Automation& a) {
- return a.isLive() && a.target == volume && a.recordLive;
- }));
- engine.editSong ([] (lynx::Song& s) {
- s.mixer[0].effects.pop_back();
- s.automations.clear();
- s.midiLinks.clear();
- });
- // the global window: no parameter list, Omni, Remove conflicts or Skip; Mode is there
- auto globalPanel = lynx::makeRemoteControlPanel (engine, { volume }, true);
- shoot (*globalPanel, "cs-global-default");
- check ("cs_global_layout", state (*globalPanel).contains ("|shown=|"), state (*globalPanel));
- // a key link in each Mode: note 60 = FL's controller number 256 + 60
- const auto key = lynx::linkNoteBase + 60;
- auto modePanel = lynx::makeRemoteControlPanel (engine, { volume }, false);
- lynx::remoteControlPanelSetController (*modePanel, -1, 1, key);
- lynx::remoteControlPanelSetMode (*modePanel, 2);
- shoot (*modePanel, "cs-remote-note-latch");
- lynx::remoteControlPanelPress (*modePanel, 2);
- check ("cs_note_link_written", engine.getSong().midiLinks.size() == 1 && engine.getSong().midiLinks[0].cc == key
- && engine.getSong().midiLinks[0].mode == 2);
- const auto play = [&engine, key, volume] (int velocity) {
- engine.injectControllerForTest (key, 0, velocity);
- return engine.currentTargetValue (volume);
- };
- const auto setMode = [&engine] (int mode) {
- engine.editSong ([mode] (lynx::Song& s) { s.midiLinks[0].mode = mode; });
- engine.editSong ([] (lynx::Song& s) { s.setTargetValue ({ AutomationTargetKind::channelVolume, 0 }, 0.25f); });
- };
- setMode (2); // Latch: press switches, release does nothing
- const auto l1 = play (100), l1off = play (0), l2 = play (90), l2off = play (0);
- check ("cs_mode_latch", std::abs (l1 - 1.0f) < 1e-4f && std::abs (l1off - 1.0f) < 1e-4f && l2 < 1e-4f && l2off < 1e-4f,
- juce::String (l1) + " " + juce::String (l1off) + " " + juce::String (l2) + " " + juce::String (l2off));
- setMode (1); // Hold: the velocity while held, back to 0 on release
- const auto h1 = play (100), h1off = play (0);
- check ("cs_mode_hold", std::abs (h1 - 100.0f / 127.0f) < 1e-4f && h1off < 1e-4f, juce::String (h1) + " " + juce::String (h1off));
- setMode (0); // Default: as Hold for a key
- const auto d1 = play (64), d1off = play (0);
- check ("cs_mode_default", std::abs (d1 - 64.0f / 127.0f) < 1e-4f && d1off < 1e-4f, juce::String (d1) + " " + juce::String (d1off));
- setMode (3); // Inc: each press adds 1/128
- const auto i1 = play (100), i1off = play (0), i2 = play (20);
- check ("cs_mode_inc", std::abs (i1 - (0.25f + 1.0f / 128.0f)) < 1e-4f && std::abs (i1off - i1) < 1e-6f
- && std::abs (i2 - (0.25f + 2.0f / 128.0f)) < 1e-4f,
- juce::String (i1) + " " + juce::String (i2));
- setMode (4); // Stay: the velocity, kept after the release
- const auto s1 = play (100), s1off = play (0);
- check ("cs_mode_stay", std::abs (s1 - 100.0f / 127.0f) < 1e-4f && std::abs (s1off - s1) < 1e-6f, juce::String (s1) + " " + juce::String (s1off));
- // the project file keeps the key link and its mode; an older reader skips it
- lynx::Song song = engine.getSong();
- song.midiLinks[0].mode = 2;
- MidiLink cc7 { 7, 0, pan };
- cc7.mode = 4;
- song.midiLinks.insert (song.midiLinks.begin(), cc7);
- juce::String error;
- const auto json = lynx::ProjectFile::toJson (song);
- const auto back = lynx::ProjectFile::fromJson (json, error);
- check ("cs_note_link_round_trip", back && back->midiLinks == song.midiLinks && json.contains ("midiNoteLinks"), error);
- auto parsed = juce::JSON::parse (json);
- if (auto* o = parsed.getDynamicObject())
- {
- o->removeProperty ("midiNoteLinks");
- o->removeProperty ("midiLinkSettings");
- }
- const auto older = lynx::ProjectFile::fromJson (juce::JSON::toString (parsed), error);
- check ("cs_older_reader_keeps_cc_links_only", older && older->midiLinks.size() == 1 && older->midiLinks[0].cc == 7);
- // "Record automation" of an internal-controller link, saved only when on
- lynx::Automation live;
- live.target = volume;
- live.source.track = 0;
- live.recordLive = true;
- song.automations = { live };
- const auto withLive = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- live.recordLive = false;
- song.automations = { live };
- check ("cs_record_automation_round_trip", withLive && withLive->automations.size() == 1 && withLive->automations[0].recordLive
- && ! lynx::ProjectFile::toJson (song).contains ("recordLive"));
- engine.editSong ([] (lynx::Song& s) { s.midiLinks.clear(); });
- }
- // ---- menus: the control menu, the formula presets, the controller list, the Multilink items
- {
- juce::PopupMenu control;
- lynx::addAutomationItem (control, engine, volume, true);
- engine.setMultilink (true);
- engine.noteTweaked (volume);
- engine.noteTweaked (pan);
- juce::PopupMenu multilink;
- lynx::addMultilinkControlsItems (multilink, engine);
- check ("multilink_queue", engine.multilinkTargets().size() == 2);
- engine.setMultilink (false);
- saveMenus (juce::StringArray { "Control menu", "Formula presets", "Multilink" },
- std::vector<juce::PopupMenu> { control, lynx::remoteControlFormulaMenu ([] (const juce::String&) {}), multilink },
- prefix + "-menus.png");
- saveMenus (juce::StringArray { "Ctrl menu" }, std::vector<juce::PopupMenu> { lynx::remoteControlControllerMenu ([] (int) {}) },
- prefix + "-ctrl-menu.png");
- // the Mode list as its box pops it up (round 190cs)
- juce::PopupMenu modes;
- for (const char* m : { "Default", "Hold", "Latch", "Inc", "Stay" })
- modes.addItem (lynx::tr (m), true, juce::String (m) == "Default", [] {});
- saveMenus (juce::StringArray { "Mode" }, std::vector<juce::PopupMenu> { modes }, prefix + "-mode-menu.png");
- }
- // ---- Settings > MIDI: the input's Port box, the link list with a link's settings
- {
- engine.editSong ([&] (lynx::Song& s) {
- MidiLink l { 74, 2, pan };
- l.port = 4;
- l.formula = "1-Input";
- l.smooth = true;
- s.midiLinks = { MidiLink { 7, 0, volume }, l };
- });
- auto page = lynx::makeMidiPage (engine, {}, false);
- page->setSize (760, 900);
- shoot (*page, "settings-midi");
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- // A stand-in hosted plugin for the shot route: three parameters, its state = their values
- struct FlCtlShotPlugin final : juce::AudioPluginInstance
- {
- FlCtlShotPlugin()
- {
- for (const char* n : { "Cutoff", "Resonance", "Drive" })
- addHostedParameter (std::make_unique<juce::AudioParameterFloat> (juce::ParameterID (n, 1), n, 0.0f, 1.0f, 0.5f));
- }
- const juce::String getName() const override { return "Shot plugin"; }
- void prepareToPlay (double, int) override {}
- void releaseResources() override {}
- void processBlock (juce::AudioBuffer<float>&, juce::MidiBuffer&) override {}
- double getTailLengthSeconds() const override { return 0.0; }
- bool acceptsMidi() const override { return false; }
- bool producesMidi() const override { return false; }
- juce::AudioProcessorEditor* createEditor() override { return nullptr; }
- bool hasEditor() const override { return false; }
- int getNumPrograms() override { return 1; }
- int getCurrentProgram() override { return 0; }
- void setCurrentProgram (int) override {}
- const juce::String getProgramName (int) override { return {}; }
- void changeProgramName (int, const juce::String&) override {}
- void getStateInformation (juce::MemoryBlock& b) override
- {
- for (auto* p : getParameters())
- {
- const float v = static_cast<juce::AudioParameterFloat*> (p)->get();
- b.append (&v, sizeof (float));
- }
- }
- void setStateInformation (const void* data, int size) override
- {
- const auto& list = getParameters();
- for (int i = 0; i < list.size() && (i + 1) * (int) sizeof (float) <= size; ++i)
- *static_cast<juce::AudioParameterFloat*> (list[i]) = static_cast<const float*> (data)[i];
- }
- void fillInPluginDescription (juce::PluginDescription& d) const override
- {
- d.name = getName();
- d.pluginFormatName = "Shot";
- d.fileOrIdentifier = "shot";
- }
- };
- static juce::File writeShotSample (const juce::File& file, double hz)
- {
- juce::AudioBuffer<float> buffer (1, 22050);
- for (int i = 0; i < buffer.getNumSamples(); ++i)
- buffer.setSample (0, i, (float) (std::sin (juce::MathConstants<double>::twoPi * hz * i / 44100.0) * std::exp (-i / 6000.0)));
- file.deleteFile();
- juce::WavAudioFormat wav;
- if (auto out = std::unique_ptr<juce::AudioFormatWriter> (wav.createWriterFor (file.createOutputStream().release(), 44100.0, 1, 16, {}, 0)))
- out->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- return file;
- }
- static bool clickMenuItem (const juce::PopupMenu& menu, const juce::String& text)
- {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().text == text && it.getItem().isEnabled && it.getItem().action != nullptr)
- {
- it.getItem().action();
- return true;
- }
- return false;
- }
- // --samplerpageshot <prefix> (round 190dh): FL's Sampler page offscreen — the page as FL's shot (dock188a) shows it,
- // the legacy effects, a small window, a zoomed waveform — and its laws turned as a user would; prefix-checks.txt
- bool runSamplerPageShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto shoot = [&prefix] (juce::Component& c, const char* name) {
- savePng (c.createComponentSnapshot (c.getLocalBounds()), prefix + "-" + name + ".png");
- };
- lynx::AudioEngine engine (false);
- const auto folder = juce::File (prefix).getParentDirectory().getChildFile ("sampler-samples");
- folder.createDirectory();
- // an 808-like kick, 1 s (FL's shot: "Basic 808 Kick.wav")
- const auto kick = folder.getChildFile ("Basic 808 Kick.wav");
- {
- juce::AudioBuffer<float> buffer (1, 44100);
- double phase = 0.0;
- for (int i = 0; i < buffer.getNumSamples(); ++i)
- {
- const auto t = i / 44100.0;
- phase += juce::MathConstants<double>::twoPi * (48.0 + 90.0 * std::exp (-t * 30.0)) / 44100.0;
- buffer.setSample (0, i, (float) (0.9 * std::sin (phase) * std::exp (-t * 3.2)));
- }
- kick.deleteFile();
- juce::WavAudioFormat wav;
- if (auto out = std::unique_ptr<juce::AudioFormatWriter> (wav.createWriterFor (kick.createOutputStream().release(), 44100.0, 1, 16, {}, 0)))
- out->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- engine.editSong ([&] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- lynx::audioclips::loadSampleInto (s.channels[0], kick.getFullPathName().toStdString(), "808 Kick");
- // FL's shot: Resample and Load regions on, Use loop points on, declicking "Out only (no bleeding)"
- s.channels[0].sampler.resampleOnLoad = true;
- });
- const auto sampler = [&engine] { return engine.getSong().channels[0].sampler; };
- auto frame = lynx::makeChannelFrame (engine, 0, 0);
- frame->setSize (frame->getWidth() > 0 ? frame->getWidth() : 700, frame->getHeight() > 0 ? frame->getHeight() : 720);
- frame->createComponentSnapshot (frame->getLocalBounds()); // (starts the waveform's analysis)
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- shoot (*frame, "sampler-page");
- report.add ("page size " + juce::String (frame->getWidth()) + "x" + juce::String (frame->getHeight()));
- // ---- the laws, turned on the page
- auto& f = *frame;
- lynx::samplerPageTurn (f, "pingPong", 1.0);
- check ("ping_pong", sampler().precompute.pingPong);
- lynx::samplerPageTurn (f, "pingPong", 0.0);
- lynx::samplerPageTurn (f, "loopStart", 5000.0);
- check ("loop_start", sampler().loopStart == 5000 && sampler().loopEnd == 5001, juce::String (sampler().loopStart) + "/" + juce::String (sampler().loopEnd));
- lynx::samplerPageTurn (f, "loopEnd", 15000.0);
- check ("loop_end", sampler().loopStart == 5000 && sampler().loopEnd == 15000);
- lynx::samplerPageTurn (f, "loopStart", 20000.0, true); // Shift: the loop moves
- check ("loop_shift_moves", sampler().loopStart == 20000 && sampler().loopEnd == 30000, juce::String (sampler().loopStart) + "/" + juce::String (sampler().loopEnd));
- check ("keep_on_disk_greyed_with_loop", lynx::samplerPageQuery (f, "keepOnDisk") == "0");
- lynx::samplerPageTurn (f, "useLoops", 0.0);
- check ("keep_on_disk_back", lynx::samplerPageQuery (f, "keepOnDisk") == "1" && ! sampler().useLoopPoints);
- check ("not_cut_yet", ! lynx::channelCutsItself (engine.getSong().channels[0]));
- lynx::samplerPageTurn (f, "useLoops", 1.0);
- check ("use_loops_cuts_itself", sampler().useLoopPoints && lynx::channelCutsItself (engine.getSong().channels[0]));
- engine.editSong ([] (lynx::Song& s) {
- lynx::setChannelCutsItself (s.channels[0], 0, false);
- s.channels[0].sampler.useLoopPoints = false;
- });
- lynx::samplerPageTurn (f, "crossfade", 300.0); // (Use loop points off: the crossfade switches it on)
- check ("crossfade_switches_loops_on", sampler().precompute.crossfade == 300 && sampler().useLoopPoints);
- lynx::samplerPageTurn (f, "crossfade", 0.0);
- lynx::samplerPageTurn (f, "pitch", 300.0); // (Resample: FL switches to Auto)
- check ("pitch_resample_to_auto", sampler().keepPitch && sampler().flStretchMode == 5 && sampler().flStretchPitch == 300
- && lynx::samplerPageQuery (f, "mode") == lynx::tr ("General"),
- lynx::samplerPageQuery (f, "mode") + " " + juce::String (sampler().pitch));
- lynx::samplerPageTurn (f, "pitch", 0.0);
- lynx::samplerPageTurn (f, "mode", 1.0); // Resample
- check ("mode_resample", ! sampler().keepPitch && std::abs (sampler().pitch) < 1.0e-4f);
- lynx::samplerPageTurn (f, "time", 4.0);
- lynx::samplerPageTurn (f, "mul", 10000.0);
- check ("time_mul", std::abs (sampler().stretchBeats - 8.0f) < 1.0e-3f && sampler().stretchMul == 10000, juce::String (sampler().stretchBeats));
- lynx::samplerPageTurn (f, "mul", 0.0);
- lynx::samplerPageTurn (f, "time", 0.0);
- lynx::samplerPageTurn (f, "length", 0.5);
- lynx::samplerPageTurn (f, "smpStart", 0.5);
- check ("smp_start_keeps_length", std::abs (sampler().regionStart - 0.5f) < 1.0e-3f && std::abs (sampler().regionEnd - 0.75f) < 1.0e-3f,
- juce::String (sampler().regionStart) + "-" + juce::String (sampler().regionEnd));
- lynx::samplerPageTurn (f, "smpStart", 0.0);
- lynx::samplerPageTurn (f, "length", 1.0);
- lynx::samplerPageTurn (f, "declick", 4.0);
- check ("declick_mode", sampler().declickMode == 4);
- lynx::samplerPageTurn (f, "declick", 0.0);
- // ---- the .lynx keeps what the page set
- {
- lynx::samplerPageTurn (f, "mul", -5000.0);
- lynx::samplerPageTurn (f, "keepOnDisk", 1.0);
- juce::String error;
- const auto json = lynx::ProjectFile::toJson (engine.getSong(), false);
- const auto back = lynx::ProjectFile::fromJson (json, error);
- check ("lynx_round_trip", back.has_value() && back->channels[0].sampler == engine.getSong().channels[0].sampler, error);
- lynx::samplerPageTurn (f, "mul", 0.0);
- lynx::samplerPageTurn (f, "keepOnDisk", 0.0);
- }
- // ---- shots: FL's state again (loop points from the file: none), the legacy panel, a zoom, a small window
- engine.editSong ([] (lynx::Song& s) {
- auto& ch = s.channels[0];
- ch.sampler.loopStart = ch.sampler.loopEnd = -1;
- ch.sampler.useLoopPoints = true;
- ch.sampler.precompute = {};
- });
- lynx::samplerPageTurn (f, "show", 0.0); // (no control: the page shows the channel again)
- frame->createComponentSnapshot (frame->getLocalBounds());
- shoot (*frame, "sampler-page-fl-state");
- lynx::samplerPageTurn (f, "legacy", 1.0);
- check ("legacy_panel", lynx::samplerPageQuery (f, "legacy") == "1");
- shoot (*frame, "sampler-page-legacy");
- lynx::samplerPageTurn (f, "legacy", 0.0);
- lynx::samplerPageTurn (f, "zoom", 0.25);
- check ("zoom_scroll", lynx::samplerPageQuery (f, "scroll") == "0.250", lynx::samplerPageQuery (f, "scroll"));
- shoot (*frame, "sampler-page-zoom");
- lynx::samplerPageTurn (f, "zoom", 1.0);
- frame->setSize (520, 470);
- frame->createComponentSnapshot (frame->getLocalBounds());
- shoot (*frame, "sampler-page-small");
- report.add (juce::String ("result=") + (allOk ? "OK" : "FAIL"));
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\n");
- return allOk;
- }
- bool runFlCtlShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto shoot = [&prefix] (juce::Component& c, const char* name) {
- savePng (c.createComponentSnapshot (c.getLocalBounds()), prefix + "-" + name + ".png");
- };
- using lynx::AutomationTarget;
- using lynx::AutomationTargetKind;
- lynx::AudioEngine engine (false);
- engine.editSong ([] (lynx::Song& s) {
- if (s.channels.size() < 3)
- s.channels.resize (3);
- if (s.patterns.empty())
- s.patterns.resize (1);
- s.currentPattern = 0;
- });
- const AutomationTarget volume { AutomationTargetKind::channelVolume, 0 }, pan { AutomationTargetKind::channelPan, 0 };
- // ---- FL's multilink menu: on with two queued controls, off with the last tweaked parameters
- {
- engine.setMultilink (true);
- engine.noteTweaked (volume);
- engine.noteTweaked (pan);
- auto on = lynx::multilinkButtonMenu (engine);
- juce::PopupMenu::MenuItemIterator first (on);
- first.next();
- check ("ml_caption_on", first.getItem().isSectionHeader && first.getItem().text == lynx::tr ("{0} parameters selected", { "2" }), first.getItem().text);
- // Init pattern: the values at the pattern's start; ends multilink
- const auto v0 = engine.currentTargetValue (volume);
- lynx::runMultilinkAction (engine, lynx::mlmenu::Action::initPattern, engine.multilinkTargets(), 0);
- const auto& lanes = engine.getSong().patterns[0].events;
- check ("ml_init_pattern", lanes.size() == 2 && ! lanes[0].events.empty() && lanes[0].events[0].tick == 0
- && std::abs (lanes[0].events[0].value - v0) < 1.0e-6f && ! engine.isMultilinkOn());
- // Randomize keeps multilink on; Humanize moves at most an eighth
- engine.setMultilink (true);
- engine.noteTweaked (volume);
- engine.noteTweaked (pan);
- lynx::runMultilinkAction (engine, lynx::mlmenu::Action::randomize, engine.multilinkTargets(), 1234);
- check ("ml_randomize_keeps_queue", engine.isMultilinkOn() && engine.multilinkTargets().size() == 2);
- const auto before = engine.currentTargetValue (volume);
- lynx::runMultilinkAction (engine, lynx::mlmenu::Action::humanize, engine.multilinkTargets(), 99);
- check ("ml_humanize_small", std::abs (engine.currentTargetValue (volume) - before) <= 0.1251f && engine.isMultilinkOn(),
- juce::String (before) + " -> " + juce::String (engine.currentTargetValue (volume)));
- lynx::runMultilinkAction (engine, lynx::mlmenu::Action::initSong, engine.multilinkTargets(), 0);
- check ("ml_init_song", engine.getSong().findInitialValue (volume) >= 0 && ! engine.isMultilinkOn());
- // off: the last two tweaked parameters, no Cancel
- auto off = lynx::multilinkButtonMenu (engine);
- bool hasCancel = false;
- for (juce::PopupMenu::MenuItemIterator it (off); it.next();)
- hasCancel = hasCancel || it.getItem().text == lynx::tr ("Cancel");
- juce::PopupMenu::MenuItemIterator offFirst (off);
- offFirst.next();
- check ("ml_off_caption", offFirst.getItem().text == lynx::tr ("Last 2 tweaked parameters") && ! hasCancel, offFirst.getItem().text);
- // LYNX's own one-step items stay, after FL's items below a line (greyed while multilink is off)
- juce::String last;
- bool lineBefore = false, prevLine = false;
- for (juce::PopupMenu::MenuItemIterator it (on); it.next();)
- {
- if (it.getItem().text == lynx::tr ("Link to controller"))
- lineBefore = prevLine;
- prevLine = it.getItem().isSeparator;
- last = it.getItem().text;
- }
- check ("ml_lynx_items_after_fl", lineBefore && last == lynx::tr ("Override global links"), last);
- saveMenus (juce::StringArray { "Multilink on (2 queued)", "Multilink off" }, std::vector<juce::PopupMenu> { on, off },
- prefix + "-multilink-menu.png");
- }
- // ---- the plugin menu's spare state and Parameters > Link all parameters...
- {
- FlCtlShotPlugin plugin;
- juce::PopupMenu menu;
- lynx::addPluginWrapperItems (menu, engine, plugin, { AutomationTargetKind::channelParam, 1, 0, 0 });
- saveMenus (juce::StringArray { "Plugin menu: spare state and parameters" }, std::vector<juce::PopupMenu> { menu }, prefix + "-plugin-menu.png");
- const auto targets = lynx::allPluginParameterTargets (plugin, { AutomationTargetKind::channelParam, 1, 0, 0 });
- check ("link_all_parameters", targets.size() == 3 && targets[2].param == 2 && targets[2].index == 1);
- auto* cutoff = static_cast<juce::AudioParameterFloat*> (plugin.getParameters()[0]);
- *cutoff = 0.2f;
- check ("spare_store", clickMenuItem (menu, lynx::tr ("Store in spare state")));
- *cutoff = 0.9f;
- juce::PopupMenu again;
- lynx::addPluginWrapperItems (again, engine, plugin, { AutomationTargetKind::channelParam, 1, 0, 0 });
- check ("spare_flip", clickMenuItem (again, lynx::tr ("Flip with spare state")) && std::abs (cutoff->get() - 0.2f) < 1.0e-6f, juce::String (cutoff->get()));
- check ("spare_flip_back", clickMenuItem (again, lynx::tr ("Flip with spare state")) && std::abs (cutoff->get() - 0.9f) < 1.0e-6f, juce::String (cutoff->get()));
- lynx::sparestate::shared().forget (&plugin);
- }
- // ---- the sampler's File row: Load (history menu, wheel), Locate, Remove
- {
- const auto folder = juce::File (prefix).getParentDirectory().getChildFile ("flctl-samples");
- folder.createDirectory();
- const auto a = writeShotSample (folder.getChildFile ("Kick 1.wav"), 60.0), b = writeShotSample (folder.getChildFile ("Snare 2.wav"), 200.0),
- c = writeShotSample (folder.getChildFile ("Hat 3.wav"), 900.0);
- lynx::samplehistory::list().clear();
- engine.editSong ([&] (lynx::Song& s) {
- for (const auto& f : { c, b, a }) // (each load goes into the history, newest first)
- lynx::audioclips::loadSampleInto (s.channels[1], f.getFullPathName().toStdString(), f.getFileNameWithoutExtension().toStdString());
- });
- check ("history_order", lynx::samplehistory::list().size() == 3 && lynx::samplehistory::list().front() == a.getFullPathName().toStdString());
- juce::File located;
- lynx::locateInBrowserHandler() = [&located] (const juce::File& f) { located = f; };
- auto frame = lynx::makeChannelFrame (engine, 1, 0);
- frame->setSize (frame->getWidth() > 0 ? frame->getWidth() : 600, frame->getHeight() > 0 ? frame->getHeight() : 820);
- frame->createComponentSnapshot (frame->getLocalBounds()); // (starts the waveform's analysis)
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- shoot (*frame, "sampler-file-row");
- const auto history = lynx::samplerHistoryMenu (*frame);
- check ("history_menu", history.has_value() && history->getNumItems() == 4); // (caption + three samples)
- if (history)
- saveMenus (juce::StringArray { "Load: Sample history" }, std::vector<juce::PopupMenu> { *history }, prefix + "-sample-history.png");
- lynx::samplerFileRowPress (*frame, 0); // wheel down: the next (older) sample
- check ("wheel_down", engine.getSong().channels[1].samplePath == b.getFullPathName().toStdString(), juce::String (engine.getSong().channels[1].samplePath));
- lynx::samplerFileRowPress (*frame, 1); // wheel up: back
- check ("wheel_up", engine.getSong().channels[1].samplePath == a.getFullPathName().toStdString());
- lynx::samplerFileRowPress (*frame, 2);
- check ("locate", located == a, located.getFullPathName());
- lynx::samplerFileRowPress (*frame, 3);
- check ("remove", engine.getSong().channels[1].samplePath.empty());
- engine.undo();
- check ("remove_undo", engine.getSong().channels[1].samplePath == a.getFullPathName().toStdString());
- lynx::locateInBrowserHandler() = nullptr;
- }
- // ---- a sampler running FL's voice: FL's Envelope / instrument page with the tensions, the predelay and presets
- {
- engine.editSong ([] (lynx::Song& s) {
- auto& ch = s.channels[2];
- ch.instrument = lynx::InstrumentKind::sampler;
- ch.name = "FL sampler";
- const auto snap = lynx::flvp::defaultSnapshot();
- ch.sampler.flChannel.assign (90, 0);
- std::memcpy (ch.sampler.flChannel.data(), snap.data(), 85 * 4);
- std::memcpy (&ch.sampler.flChannel[85], snap.data() + 0x15c, 4);
- std::memcpy (&ch.sampler.flChannel[86], snap.data() + 0x160, 4);
- std::memcpy (&ch.sampler.flChannel[87], snap.data() + 0x168, 4);
- ch.sampler.flChannel[88] = 96;
- ch.sampler.flChannel[89] = 0;
- auto& vol = ch.sampler.flChannel; // the volume envelope on, bent
- vol[17 + 1] = -1;
- vol[17 + 2] = 4000; // predelay
- vol[17 + 14] = -70; // attack tension
- vol[17 + 15] = 60; // decay tension
- vol[17 + 16] = -40; // release tension
- });
- auto frame = lynx::makeChannelFrame (engine, 2, 1);
- frame->setSize (frame->getWidth() > 0 ? frame->getWidth() : 600, frame->getHeight() > 0 ? frame->getHeight() : 560);
- shoot (*frame, "sampler-fl-envelope");
- check ("fl_page_shown", lynx::flVoicePresetsMenu (*frame).has_value());
- lynx::flVoicePresetFolder().deleteRecursively();
- check ("preset_save", lynx::flVoiceSavePreset (*frame, "Bent volume")
- && lynx::flVoicePresetFolder().getChildFile ("Bent volume.CHENV").getSize() == 68);
- if (const auto menu = lynx::flVoicePresetsMenu (*frame))
- saveMenus (juce::StringArray { "Channel envelope presets" }, std::vector<juce::PopupMenu> { *menu }, prefix + "-envelope-presets.png");
- // the preset into the pitch target: its record becomes the saved one
- lynx::showFlVoiceTarget (*frame, lynx::flvoice::pitch);
- const auto loaded = lynx::flVoiceLoadPreset (*frame, lynx::flVoicePresetFolder().getChildFile ("Bent volume.CHENV"));
- const auto& fl = engine.getSong().channels[2].sampler.flChannel;
- check ("preset_load", loaded && fl.size() == 90 && fl[68 + 2] == 4000 && fl[68 + 14] == -70 && fl[68 + 16] == -40 && fl[88] == 96);
- engine.undo();
- check ("preset_load_undo", engine.getSong().channels[2].sampler.flChannel[68 + 14] != -70);
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- // --flplshot (round 190dx): see the dispatch above
- bool runHdrShot190ft (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto list = [] (const std::vector<int>& v) {
- juce::StringArray out;
- for (auto i : v)
- out.add (juce::String (i));
- return out.joinIntoString (",");
- };
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- {
- auto song = lynx::Song::makeDefault();
- song.playlist.clear();
- for (int t = 0; t < 6; ++t)
- {
- if ((int) song.playlistTracks.size() <= t)
- song.playlistTracks.resize ((std::size_t) t + 1);
- song.playlistTracks[(std::size_t) t].name = juce::String ("Track " + juce::String (t + 1)).toStdString();
- for (int k = 0; k < 2; ++k)
- {
- lynx::Clip c;
- c.kind = lynx::ClipKind::pattern;
- c.pattern = 0;
- c.track = t;
- c.start = (std::int64_t) (k * 4 + t % 3) * lynx::ppq;
- c.length = 2 * lynx::ppq;
- song.playlist.push_back (c);
- }
- }
- if (song.mixer.size() < 4)
- song.mixer.resize (4);
- song.playlistTracks[2].mode = lynx::PlaylistTrackMode::audio; // an audio track linked to mixer track 3
- song.playlistTracks[2].mixerTrack = 3;
- song.playlistTracks[2].name = "Vox";
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- engine.dispatchPendingMessages();
- auto& pl = ui.getPlaylistForSnapshot();
- pl.setSize (juce::jmax (pl.getWidth(), 900), juce::jmax (pl.getHeight(), 600));
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const auto now = juce::Time::getCurrentTime();
- const juce::ModifierKeys left (juce::ModifierKeys::leftButtonModifier);
- const int ctrl = juce::ModifierKeys::commandModifier; // (FL's Ctrl: Cmd on a Mac)
- const int shift = juce::ModifierKeys::shiftModifier;
- const int alt = juce::ModifierKeys::altModifier;
- const auto event = [&] (juce::Component& c, juce::Point<int> p, juce::ModifierKeys mods, juce::Point<int> down, int clicks, bool dragged) {
- return juce::MouseEvent (source, p.toFloat(), mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &c, &c, now, down.toFloat(), now, clicks, dragged);
- };
- // a press (and release) at p with the modifiers; `to`: a drag there before the release
- const auto press = [&] (juce::Component& c, juce::Point<int> p, juce::ModifierKeys mods, std::optional<juce::Point<int>> to = {}, int clicks = 1) {
- const auto down = mods.withFlags (juce::ModifierKeys::leftButtonModifier);
- c.mouseMove (event (c, p, mods, p, 1, false));
- c.mouseDown (event (c, p, down, p, clicks, false));
- if (to)
- c.mouseDrag (event (c, *to, down, p, clicks, true));
- c.mouseUp (event (c, to ? *to : p, mods, p, clicks, to.has_value()));
- };
- const auto headerPoint = [&] (int track) { const auto r = pl.trackRowForSnapshot (track); return juce::Point<int> (40, r.getY() + juce::jmin (10, r.getHeight() / 3)); };
- const auto bandPoint = [&] (int track) { const auto r = pl.trackRowForSnapshot (track); return juce::Point<int> (40, r.getBottom() - 2); };
- const auto clipsOn = [&] (const std::vector<int>& tracks) {
- std::vector<int> out;
- const auto& song = engine.getSong();
- for (int i = 0; i < (int) song.playlist.size(); ++i)
- if (std::find (tracks.begin(), tracks.end(), song.playlist[(std::size_t) i].track) != tracks.end())
- out.push_back (i);
- return out;
- };
- const auto sortedClips = [&] { auto v = pl.getSelectedClips(); std::sort (v.begin(), v.end()); return v; };
- const auto headerShot = [&] (const juce::String& name, int rows) {
- const auto bottom = pl.trackRowForSnapshot (rows).getY();
- savePng (pl.createComponentSnapshot ({ 0, 0, juce::jmin (pl.getWidth(), 760), juce::jmin (pl.getHeight(), bottom + 12) }), prefix + name);
- };
- // ---- 1. selection (AUTracksPanelMouseDown / FUN_012e83e0)
- press (pl, headerPoint (1), {});
- check ("click_selects_alone", pl.selectedTracksForSnapshot() == std::vector<int> { 1 }, list (pl.selectedTracksForSnapshot()));
- pl.selectClipsForSnapshot ({});
- // LYNX extra (issue #163): Ctrl+click adds / removes one track, its clips follow
- press (pl, headerPoint (3), ctrl);
- check ("ctrl_click_adds_lynx", pl.selectedTracksForSnapshot() == std::vector<int> { 1, 3 } && sortedClips() == clipsOn ({ 3 }),
- list (pl.selectedTracksForSnapshot()) + " clips " + list (sortedClips()));
- press (pl, headerPoint (5), ctrl);
- press (pl, headerPoint (1), ctrl);
- check ("ctrl_click_removes_lynx", pl.selectedTracksForSnapshot() == std::vector<int> { 3, 5 } && sortedClips() == clipsOn ({ 3, 5 }),
- list (pl.selectedTracksForSnapshot()) + " clips " + list (sortedClips()));
- // FL's own toggle: Ctrl+Shift+click (its clips are added)
- press (pl, headerPoint (1), ctrl | shift);
- check ("ctrl_shift_click_adds", pl.selectedTracksForSnapshot() == std::vector<int> { 1, 3, 5 }, list (pl.selectedTracksForSnapshot()));
- check ("ctrl_shift_click_adds_clips", sortedClips() == clipsOn ({ 1, 3, 5 }), list (sortedClips()));
- press (pl, headerPoint (3), ctrl | shift);
- check ("ctrl_shift_click_removes", pl.selectedTracksForSnapshot() == std::vector<int> { 1, 5 }, list (pl.selectedTracksForSnapshot()));
- press (pl, headerPoint (3), ctrl | shift);
- check ("ctrl_shift_click_adds_again", pl.selectedTracksForSnapshot() == std::vector<int> { 1, 3, 5 }, list (pl.selectedTracksForSnapshot()));
- pl.selectClipsForSnapshot ({});
- headerShot ("-ctrl-multiselect.png", 6);
- press (pl, headerPoint (0), ctrl, headerPoint (2));
- check ("ctrl_drag_range_with_clips", pl.selectedTracksForSnapshot() == std::vector<int> { 0, 1, 2 } && sortedClips() == clipsOn ({ 0, 1, 2 }),
- list (pl.selectedTracksForSnapshot()) + " clips " + list (sortedClips()));
- press (pl, headerPoint (1), shift); // LYNX's own Shift+click range (from the last clicked track, 0)
- check ("lynx_shift_range_kept", pl.selectedTracksForSnapshot() == std::vector<int> { 0, 1 }, list (pl.selectedTracksForSnapshot()));
- {
- int linked = -1;
- auto old = pl.onLinkedMixerTrack;
- pl.onLinkedMixerTrack = [&linked] (int insert) { linked = insert; };
- press (pl, headerPoint (2), {});
- check ("audio_track_click_links_mixer_track", linked == 3, juce::String (linked));
- pl.onLinkedMixerTrack = old;
- }
- // ---- 2. the resize band (FUN_00ea93a0, AUTracksPanelMouseMove)
- const auto heightOf = [&] (int t) { return pl.trackRowForSnapshot (t).getHeight(); };
- const auto& tracks = [&]() -> const std::vector<lynx::PlaylistTrack>& { return engine.getSong().playlistTracks; };
- press (pl, headerPoint (4), {}); // (track 4 alone selected)
- {
- const auto start = bandPoint (4);
- press (pl, start, {}, start + juce::Point<int> (0, 41));
- check ("drag_resizes", tracks()[4].height == 88 && heightOf (4) == 88, juce::String (tracks()[4].height) + " / " + juce::String (heightOf (4))); // (190gw: from FL's 48 px row)
- headerShot ("-resized.png", 6);
- const auto again = bandPoint (4);
- press (pl, again, {}, again + juce::Point<int> (0, -100)); // (above the row's top, but less than 32 px)
- check ("drag_stops_at_16", heightOf (4) == 16, juce::String (heightOf (4)));
- press (pl, bandPoint (4), alt);
- check ("alt_click_resets", tracks()[4].height == 0 && tracks()[4].lockedHeight == -1 && heightOf (4) == 48, juce::String (heightOf (4)));
- press (pl, bandPoint (4), {}, {}, 2); // the second press of a double click
- check ("double_click_locks_small", tracks()[4].lockedHeight == 1 && heightOf (4) == 16, juce::String (tracks()[4].lockedHeight));
- press (pl, bandPoint (4), {});
- check ("click_on_locked_band_unlocks", tracks()[4].lockedHeight == -1 && heightOf (4) == 48, juce::String (tracks()[4].lockedHeight));
- const auto top = pl.trackRowForSnapshot (4).getY();
- const auto b = bandPoint (4);
- press (pl, b, {}, juce::Point<int> (b.x, top - 40));
- check ("drag_past_the_top_groups", tracks()[4].grouped && tracks()[4].height == 0, juce::String ((int) tracks()[4].grouped));
- const auto b2 = bandPoint (4);
- press (pl, b2, {}, juce::Point<int> (b2.x, pl.trackRowForSnapshot (4).getY() - 40));
- check ("again_ungroups", ! tracks()[4].grouped, juce::String ((int) tracks()[4].grouped));
- }
- {
- // every selected track: the same height, from the first one's top to the mouse
- press (pl, headerPoint (1), {});
- press (pl, headerPoint (2), ctrl | shift);
- press (pl, headerPoint (3), ctrl | shift);
- const auto top = pl.trackRowForSnapshot (1).getY();
- const auto b = bandPoint (2);
- press (pl, b, {}, juce::Point<int> (b.x, top + 2 * 50));
- check ("selected_tracks_share_the_height", tracks()[1].height == 50 && tracks()[2].height == 50 && tracks()[3].height == 50,
- juce::String (tracks()[1].height) + "," + juce::String (tracks()[2].height) + "," + juce::String (tracks()[3].height));
- headerShot ("-selected-resized.png", 6);
- }
- // ---- 3. saved: .lynx round trip and the .flp size factor
- {
- engine.editSong ([] (lynx::Song& s) { s.playlistTracks[5].height = 300; s.playlistTracks[0].lockedHeight = 60; });
- const auto json = lynx::ProjectFile::toJson (engine.getSong());
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (json, error);
- check ("lynx_round_trip", back && back->playlistTracks.size() > 5 && back->playlistTracks[5].height == 300 && back->playlistTracks[1].height == 50
- && back->playlistTracks[0].lockedHeight == 60, error);
- lynx::flpexport::Options options;
- lynx::flpexport::Report flpReport;
- const auto project = flp::parseProject (lynx::flpexport::exportFlp (engine.getSong(), options, flpReport));
- float size5 = -1.0f, size1 = -1.0f;
- for (const auto& arrangement : project.arrangements)
- for (const auto& t : arrangement.tracks)
- {
- if (t.index == 5) size5 = t.heightScale;
- if (t.index == 1) size1 = t.heightScale;
- }
- check ("flp_size_factor", std::abs (size5 - lynx::polish::flSizeForHeight (300, 48)) < 1.0e-4f && std::abs (size1 - lynx::polish::flSizeForHeight (50, 48)) < 1.0e-4f,
- juce::String (size5) + " " + juce::String (size1));
- }
- // ---- 4. the mixer strips (round 170b's FL rules): Ctrl+click alone, Ctrl+Shift+click adds / removes
- {
- ui.selectTabForSnapshot (3);
- engine.editSong ([] (lynx::Song& s) { if (s.mixer.size() < 9) s.mixer.resize (9); });
- engine.dispatchPendingMessages();
- auto& mixer = ui.getMixerForSnapshot();
- mixer.setSize (1400, 640);
- auto& strips = mixer.getStripsForSnapshot();
- strips.setSize (juce::jmax (strips.getWidth(), 1300), juce::jmax (strips.getHeight(), 560));
- const auto at = [&] (int t) { return juce::Point<int> (strips.stripLeft (t) + 8, strips.getHeight() / 2 + 40); };
- press (strips, at (2), {});
- check ("mixer_click_alone", strips.getSelection() == std::vector<int> { 2 }, list (strips.getSelection()));
- // LYNX extra (issue #163): Ctrl+click adds / removes one insert
- press (strips, at (4), ctrl);
- press (strips, at (6), ctrl);
- check ("mixer_ctrl_click_adds_lynx", strips.getSelection() == std::vector<int> { 2, 4, 6 }, list (strips.getSelection()));
- press (strips, at (4), ctrl);
- check ("mixer_ctrl_click_removes_lynx", strips.getSelection() == std::vector<int> { 2, 6 }, list (strips.getSelection()));
- // FL: Ctrl+Shift+click adds / removes too
- press (strips, at (5), ctrl | shift);
- check ("mixer_ctrl_shift_click_adds", strips.getSelection() == std::vector<int> { 2, 5, 6 }, list (strips.getSelection()));
- savePng (mixer.createComponentSnapshot ({ 0, 0, juce::jmin (mixer.getWidth(), 900), mixer.getHeight() }), prefix + "-mixer-ctrl-multiselect.png");
- // FL: Ctrl+drag across the strips = the range from the press, alone
- press (strips, at (3), ctrl, at (4));
- check ("mixer_ctrl_drag_range", strips.getSelection() == std::vector<int> { 3, 4 }, list (strips.getSelection()));
- }
- // ---- 5. round 190gw (live check 190gu B1): FL's default row, the left lock strip, the right selection strip
- {
- ui.selectTabForSnapshot (2);
- auto song = lynx::Song::makeDefault();
- song.playlist.clear();
- song.playlistTracks.assign (6, {});
- for (int t = 0; t < 6; ++t)
- song.playlistTracks[(std::size_t) t].name = juce::String ("Track " + juce::String (t + 1)).toStdString();
- engine.setSong (std::move (song));
- engine.dispatchPendingMessages();
- pl.setSize (juce::jmax (pl.getWidth(), 900), juce::jmax (pl.getHeight(), 600));
- check ("gw_default_row_48", heightOf (0) == 48 && heightOf (5) == 48, juce::String (heightOf (0)));
- const auto rowMid = [&] (int t) { const auto r = pl.trackRowForSnapshot (t); return r.getY() + r.getHeight() / 2 - 4; };
- const auto stripX = pl.headerWidthForSnapshot() - 4;
- // the left strip (x < 10): the row flips to the smallest size and back; nothing selects
- press (pl, { 2, rowMid (2) }, {});
- check ("gw_left_strip_smallest", heightOf (2) == 16 && tracks()[2].lockedHeight == 1, juce::String (heightOf (2)));
- press (pl, { 2, rowMid (2) }, {});
- check ("gw_left_strip_back", heightOf (2) == 48 && tracks()[2].lockedHeight == -1, juce::String (heightOf (2)));
- // the right strip: click = alone, Shift+click toggles, right-click toggles with no menu
- press (pl, { stripX, rowMid (0) }, {});
- check ("gw_strip_click_alone", pl.selectedTracksForSnapshot() == std::vector<int> { 0 }, list (pl.selectedTracksForSnapshot()));
- press (pl, { stripX, rowMid (1) }, shift);
- check ("gw_strip_shift_click_adds", pl.selectedTracksForSnapshot() == std::vector<int> { 0, 1 }, list (pl.selectedTracksForSnapshot()));
- headerShot ("-gw-strip-two-selected.png", 6);
- press (pl, { stripX, rowMid (0) }, shift);
- check ("gw_strip_shift_click_removes", pl.selectedTracksForSnapshot() == std::vector<int> { 1 }, list (pl.selectedTracksForSnapshot()));
- {
- const juce::Point<int> p { stripX, rowMid (4) };
- const juce::ModifierKeys right (juce::ModifierKeys::rightButtonModifier);
- pl.mouseDown (event (pl, p, right, p, 1, false));
- pl.mouseUp (event (pl, p, {}, p, 1, false));
- }
- check ("gw_strip_right_click_adds", pl.selectedTracksForSnapshot() == std::vector<int> { 1, 4 }, list (pl.selectedTracksForSnapshot()));
- // a drag down the strip: the tracks crossed join (FUN_012e8740)
- press (pl, { stripX, rowMid (0) }, {}, juce::Point<int> (stripX, rowMid (4)));
- check ("gw_strip_drag_range", pl.selectedTracksForSnapshot() == std::vector<int> { 0, 1, 2, 3, 4 }, list (pl.selectedTracksForSnapshot()));
- headerShot ("-gw-strip-range.png", 6);
- // a double click: the track alone <-> every track
- press (pl, { stripX, rowMid (2) }, {});
- press (pl, { stripX, rowMid (2) }, {}, {}, 2);
- check ("gw_strip_double_click_all", (int) pl.selectedTracksForSnapshot().size() == pl.numTracksForSnapshot(), list (pl.selectedTracksForSnapshot()));
- press (pl, { stripX, rowMid (1) }, {});
- // .lynx: the new default row is saved; a project from before (no key) keeps LYNX's old 38 px row
- juce::String error;
- const auto json = lynx::ProjectFile::toJson (engine.getSong());
- const auto back = lynx::ProjectFile::fromJson (json, error);
- check ("gw_lynx_row_saved", back && back->playlistRowHeight == 48, error);
- auto parsed = juce::JSON::parse (json);
- if (auto* o = parsed.getDynamicObject())
- o->removeProperty ("playlistRowHeight");
- const auto old = lynx::ProjectFile::fromJson (juce::JSON::toString (parsed), error);
- check ("gw_old_lynx_keeps_38", old && old->playlistRowHeight == 38, error);
- engine.setSong (*old);
- engine.dispatchPendingMessages();
- check ("gw_old_lynx_rows_38", heightOf (0) == 38, juce::String (heightOf (0)));
- // an automation clip with two target links (Crossfade with) comes back with its links and formulas
- auto linked = lynx::Song::makeDefault();
- linked.channels.resize (2);
- lynx::Automation a;
- a.links = { { { lynx::AutomationTargetKind::channelAdjust, 0, 0, lynx::leveladjust::volume }, lynx::clipops::crossfadeOutFormula },
- { { lynx::AutomationTargetKind::channelAdjust, 1, 0, lynx::leveladjust::volume }, lynx::clipops::crossfadeInFormula } };
- a.target = a.links[0].target;
- a.points = { { 0, 1.0f, 0.0f }, { 384, 0.0f, 0.0f } };
- linked.automations.push_back (a);
- const auto linkedBack = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (linked), error);
- check ("gw_lynx_links_round_trip", linkedBack && linkedBack->automations.size() == linked.automations.size()
- && linkedBack->automations.back().links == a.links && linkedBack->automations.back().target == a.target, error);
- // Sampler › Open in new Fruity Slicer / Slicex channel: named after the sample, " #n" when taken
- const auto wav = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190gw").getChildFile ("Basic 808 Clap.wav");
- wav.getParentDirectory().createDirectory();
- {
- juce::AudioBuffer<float> b (1, 4410);
- for (int i = 0; i < b.getNumSamples(); ++i)
- b.setSample (0, i, 0.5f * std::sin ((float) i * 0.2f) * (1.0f - (float) i / (float) b.getNumSamples()));
- wav.deleteFile();
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream());
- if (auto* w = format.createWriterFor (out.get(), 44100.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (b, 0, b.getNumSamples());
- }
- }
- engine.editSong ([] (lynx::Song& s) {
- s.channels.resize (1);
- s.channels[0] = {};
- s.channels[0].name = "Basic 808 Clap";
- });
- engine.dispatchPendingMessages();
- if (lynx::openInNewChannelHandler())
- {
- lynx::openInNewChannelHandler() (wav, lynx::InstrumentKind::fruityslicer);
- lynx::openInNewChannelHandler() (wav, lynx::InstrumentKind::slicex);
- }
- engine.dispatchPendingMessages();
- const auto& ch = engine.getSong().channels;
- check ("gw_open_in_new_named_after_sample", ch.size() >= 3 && ch[1].name == "Basic 808 Clap #2" && ch[2].name == "Basic 808 Clap #3"
- && ch[1].instrument == lynx::InstrumentKind::fruityslicer && ch[2].instrument == lynx::InstrumentKind::slicex,
- ch.size() >= 3 ? juce::String::fromUTF8 (ch[1].name.c_str()) + " | " + juce::String::fromUTF8 (ch[2].name.c_str()) : juce::String ((int) ch.size()));
- wav.getParentDirectory().deleteRecursively();
- // the mixer's two boxes (live check 190gu B4): "Insert multiple..." asks "Number of tracks to add" (1),
- // "Add multiple..." "Enter the number of mixer tracks to add" (10)
- for (const auto adding : { false, true })
- {
- auto box = lynx::MixerStrips::makeInsertMultipleBox (adding);
- const auto text = box->getTextEditorContents ("count");
- check (adding ? "gw_add_multiple_box" : "gw_insert_multiple_box", text == (adding ? "10" : "1"), text);
- if (box->getWidth() > 0 && box->getHeight() > 0)
- savePng (box->createComponentSnapshot (box->getLocalBounds()), prefix + (adding ? "-gw-add-multiple-box.png" : "-gw-insert-multiple-box.png"));
- }
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- #include "FoldersShot190jf.inc" // round 190jf (slice B17)
- // --userfixshot190ib (round 190ib): see the dispatch above
- bool runUserFixShot190ib (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- engine.dispatchPendingMessages();
- // ---- #182: a real JUCE popup menu inside a host component, keys sent to its window as the keyboard would
- juce::Component host;
- host.setSize (560, 900);
- const auto typeInto = [&host] (const juce::String& text) {
- auto* menuWindow = host.getNumChildComponents() > 0 ? host.getChildComponent (host.getNumChildComponents() - 1) : nullptr;
- for (auto c : text)
- if (menuWindow != nullptr)
- menuWindow->keyPressed (juce::KeyPress ((int) juce::CharacterFunctions::toLowerCase (c), 0, c));
- return menuWindow != nullptr;
- };
- const auto shotMenu = [&host, &prefix] (const juce::String& name) {
- savePng (host.createComponentSnapshot (host.getLocalBounds()), prefix + name);
- };
- {
- auto& pl = ui.getPlaylistForSnapshot();
- pl.editMenu().showMenuAsync (juce::PopupMenu::Options().withParentComponent (&host).withTargetScreenArea ({ 8, 8, 1, 1 }));
- check ("menu_shown", host.getNumChildComponents() > 0, juce::String (host.getNumChildComponents()));
- shotMenu ("-menu-0.png");
- typeInto ("d");
- shotMenu ("-menu-d.png"); // the first item starting with D
- typeInto ("d");
- shotMenu ("-menu-dd.png"); // D again: the next one
- juce::Time::waitForMillisecondCounter (juce::Time::getMillisecondCounter() + 1100); // (a pause: a new prefix)
- typeInto ("drop a");
- shotMenu ("-menu-drop-a.png"); // "Drop audio on track headers"
- juce::PopupMenu::dismissAllActiveMenus();
- }
- {
- auto& pr = ui.getPianoRollForSnapshot();
- pr.moreMenuForSnapshot().showMenuAsync (juce::PopupMenu::Options().withParentComponent (&host).withTargetScreenArea ({ 8, 8, 1, 1 }));
- juce::Time::waitForMillisecondCounter (juce::Time::getMillisecondCounter() + 1100);
- typeInto ("preview");
- shotMenu ("-pianoroll-preview.png"); // #183's item, reached by typing its name
- juce::PopupMenu::dismissAllActiveMenus();
- check ("preview_while_playing_off_by_default", ! lynx::PianoRollComponent::previewWhilePlaying);
- }
- // ---- #181: Ctrl+, (Cmd+, on macOS) through the main window's key handling opens Settings, again closes it
- const auto ctrlComma = juce::KeyPress (',', juce::ModifierKeys::commandModifier, ',');
- check ("settings_closed_first", lynx::shownSettingsPage() < 0);
- ui.keyPressed (ctrlComma);
- check ("ctrl_comma_opens_settings", lynx::shownSettingsPage() == (int) lynx::SettingsPage::general, juce::String (lynx::shownSettingsPage()));
- ui.keyPressed (ctrlComma);
- check ("ctrl_comma_again_closes_it", lynx::shownSettingsPage() < 0, juce::String (lynx::shownSettingsPage()));
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- // --issuesshot190ht (round 190ht): see the dispatch above
- bool runIssuesShot190ht (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- using namespace lynx;
- AudioEngine engine (false);
- MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- const auto bar = (std::int64_t) 4 * ppq;
- {
- // Kick (1 bar), Bass (2 bars, a long note across its second bar), Lead (1 bar), Pad (1 bar): blocks in rows
- auto song = Song::makeDefault();
- song.playlist.clear();
- song.patterns.clear();
- const auto pattern = [&song] (const char* name, std::uint32_t colour, int channel, std::int64_t length) {
- auto& p = song.patterns.emplace_back();
- p.name = name;
- p.colour = colour;
- for (int step : { 0, 4, 8, 12 })
- p.toggleStep (channel, step);
- p.lengthTicks = length;
- return (int) song.patterns.size() - 1;
- };
- pattern ("Kick", 0xFFD85A3C, 0, bar);
- const auto bass = pattern ("Bass", 0xFF3C8DD8, 1, 0);
- Note longNote;
- longNote.channel = 1;
- longNote.start = 6 * ppq;
- longNote.length = 2 * ppq;
- song.patterns[(std::size_t) bass].notes.push_back (longNote);
- song.patterns[(std::size_t) bass].sortNotes();
- pattern ("Lead", 0xFF8A5CD8, 2, bar);
- pattern ("Pad", 0xFF5CB85C, 3, bar);
- song.patternBlocksOn = true;
- for (int b = 0; b < 8; ++b)
- patternblocks::place (song, 0, b * bar);
- patternblocks::place (song, 1, 0);
- patternblocks::place (song, 1, 4 * bar);
- for (int b = 2; b < 6; ++b)
- patternblocks::place (song, 2, b * bar);
- patternblocks::place (song, 3, 0);
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- engine.dispatchPendingMessages();
- auto& pl = ui.getPlaylistForSnapshot();
- pl.setSize (juce::jmax (pl.getWidth(), 1000), juce::jmax (pl.getHeight(), 640));
- pl.setViewForSnapshot (90.0, 0, 0); // (bar 1 at the left edge)
- pl.setBlocksHeight (6 + 5 * 18 + 6);
- engine.dispatchPendingMessages();
- const auto& song = [&]() -> const Song& { return engine.getSong(); };
- auto* blocks = pl.getBlocksViewForSnapshot();
- check ("blocks_view", blocks != nullptr && blocks->isVisible());
- if (blocks == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=FAIL\n");
- return false;
- }
- const auto shotBlocks = [&] (const juce::String& name) {
- engine.dispatchPendingMessages();
- const auto area = blocks->getBoundsInParent().withWidth (juce::jmin (pl.getWidth(), 900)).expanded (0, 2).getIntersection (pl.getLocalBounds());
- savePng (pl.createComponentSnapshot (area), prefix + name);
- };
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const juce::ModifierKeys left (juce::ModifierKeys::leftButtonModifier), right (juce::ModifierKeys::rightButtonModifier);
- juce::Point<float> pressedAt;
- const auto bEvent = [&] (int row, std::int64_t tick, juce::ModifierKeys mods, int clicks = 1) {
- const auto at = blocks->pointForSnapshot (row, tick).toFloat();
- const auto now = juce::Time::getCurrentTime();
- return juce::MouseEvent (source, at, mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, blocks, blocks, now, pressedAt, now, clicks, at != pressedAt);
- };
- const auto bPress = [&] (int row, std::int64_t tick, juce::ModifierKeys mods) {
- pressedAt = blocks->pointForSnapshot (row, tick).toFloat();
- blocks->mouseDown (bEvent (row, tick, mods));
- };
- const auto bDrag = [&] (int row, std::int64_t tick, juce::ModifierKeys mods) { blocks->mouseDrag (bEvent (row, tick, mods)); };
- const auto bRelease = [&] (int row, std::int64_t tick, juce::ModifierKeys mods = {}) {
- blocks->mouseUp (bEvent (row, tick, mods));
- engine.dispatchPendingMessages();
- };
- const auto blockOf = [&] (int row, std::int64_t start) -> const PatternBlock* {
- const auto i = patternblocks::indexOf (song(), { row, start });
- return i < 0 ? nullptr : &song().blocks[(std::size_t) i];
- };
- const auto mutedAt = [&] (int row, std::int64_t start) { const auto* x = blockOf (row, start); return x != nullptr && x->muted; };
- const auto playingAt = [&] (int row, std::int64_t start) { const auto* x = blockOf (row, start); return x != nullptr && ! x->muted; };
- const auto mutedCount = [&] {
- int n = 0;
- for (const auto& b : song().blocks)
- n += b.muted ? 1 : 0;
- return n;
- };
- shotBlocks ("-blocks-before.png");
- // ---- #127 Mute: a click mutes the block, a drag down across rows mutes the blocks it crosses (any row)
- pl.setToolForSnapshot (EditTool::mute);
- bPress (0, 2 * bar + 40, left);
- bRelease (0, 2 * bar + 40);
- check ("mute_click", blockOf (0, 2 * bar) != nullptr && mutedAt (0, 2 * bar) && mutedCount() == 1);
- bPress (0, 4 * bar + 40, left);
- bDrag (1, 4 * bar + 60, left);
- bDrag (2, 4 * bar + 80, left);
- bRelease (2, 4 * bar + 80);
- check ("mute_drag_across_rows", mutedAt (0, 4 * bar) && blockOf (1, 4 * bar) != nullptr && mutedAt (1, 4 * bar)
- && mutedAt (2, 4 * bar) && playingAt (3, 0) && mutedCount() == 4,
- juce::String (mutedCount()));
- shotBlocks ("-blocks-mute.png");
- // a sweep that starts on a muted block unmutes
- bPress (0, 2 * bar + 40, left);
- bDrag (0, 3 * bar + 40, left);
- bRelease (0, 3 * bar + 40);
- check ("mute_sweep_from_muted_unmutes", playingAt (0, 2 * bar) && playingAt (0, 3 * bar) && mutedCount() == 3,
- juce::String (mutedCount()));
- // the right button erases, as with every tool but Select / Slice / Zoom
- bPress (3, 40, right);
- bRelease (3, 40);
- check ("mute_right_click_erases", blockOf (3, 0) == nullptr);
- engine.undo();
- engine.dispatchPendingMessages();
- check ("undo_erase", blockOf (3, 0) != nullptr);
- // the muted blocks play nothing: their clips in the playback copy are muted
- {
- auto copy = song();
- patternblocks::expandSong (copy);
- int mutedClips = 0;
- for (const auto& c : copy.playlist)
- mutedClips += c.muted ? 1 : 0;
- check ("muted_blocks_play_muted_clips", mutedClips == 3, juce::String (mutedClips));
- juce::String error;
- const auto back = ProjectFile::fromJson (ProjectFile::toJson (song()), error);
- check ("muted_blocks_saved", back && back->blocks == song().blocks, error);
- }
- // ---- #127 Select: a box over rows 0-2, bars 5-6 selects every block it meets; Pencil moves them together
- pl.setToolForSnapshot (EditTool::lasso);
- bPress (0, 4 * bar + 40, left);
- bDrag (2, 5 * bar + 40, left);
- shotBlocks ("-blocks-select-box.png");
- bRelease (2, 5 * bar + 40);
- const auto selection = blocks->selectionForSnapshot();
- check ("select_box_any_row", selection.size() == 5 && patternblocks::contains (selection, { 0, 4 * bar }) && patternblocks::contains (selection, { 1, 4 * bar })
- && patternblocks::contains (selection, { 2, 5 * bar }),
- juce::String ((int) selection.size()));
- pl.setToolForSnapshot (EditTool::pencil);
- // (Kick's bars 7 and 8 are in the way of a 2-bar move: move the group by 1 bar after clearing them)
- engine.editSong ([bar] (Song& s) { patternblocks::eraseRange (s, 0, 6 * bar, 8 * bar); });
- engine.dispatchPendingMessages();
- bPress (1, 4 * bar + 40, left);
- bDrag (1, 6 * bar + 40, left);
- bRelease (1, 6 * bar + 40);
- check ("pencil_moves_the_selection", blockOf (1, 6 * bar) != nullptr && blockOf (0, 6 * bar) != nullptr && blockOf (0, 7 * bar) != nullptr
- && blockOf (2, 6 * bar) != nullptr && blockOf (2, 7 * bar) != nullptr && blockOf (1, 4 * bar) == nullptr
- && blocks->selectionForSnapshot().size() == 5);
- shotBlocks ("-blocks-select-moved.png");
- // a press on a block outside the selection moves that block alone and drops the selection
- bPress (3, 40, left);
- bDrag (3, bar + 40, left);
- bRelease (3, bar + 40);
- check ("pencil_unselected_block_alone", blockOf (3, bar) != nullptr && blockOf (0, 6 * bar) != nullptr && blocks->selectionForSnapshot().empty());
- // the right button selects too (FL 10: either button)
- pl.setToolForSnapshot (EditTool::lasso);
- bPress (3, bar + 40, right);
- bRelease (3, bar + 40);
- check ("select_click_right_button", blocks->selectionForSnapshot().size() == 1 && blockOf (3, bar) != nullptr);
- // ---- #127 Slice: a click on Bass's first block at bar 2 beat 4 cuts the pattern; a new pattern takes the rest
- pl.setToolForSnapshot (EditTool::knife);
- const auto patternsBefore = song().patterns.size();
- const juce::ModifierKeys freeLeft (juce::ModifierKeys::leftButtonModifier | juce::ModifierKeys::altModifier); // (Alt: no snap)
- bPress (1, bar + 3 * ppq, freeLeft);
- bDrag (2, bar + 3 * ppq, freeLeft); // (a vertical drag: the row under the mouse when released is cut)
- bRelease (1, bar + 3 * ppq);
- check ("slice_adds_a_pattern", song().patterns.size() == patternsBefore + 1 && song().patterns[2].name == "Bass #2",
- juce::String ((int) song().patterns.size()));
- check ("slice_trims_the_long_note", song().patterns[1].notes.back().start == 6 * ppq && song().patterns[1].notes.back().length >= ppq
- && song().patterns[1].notes.back().length < ppq + ppq / 4 && song().patterns[2].notes.empty(),
- juce::String (song().patterns[1].notes.back().length));
- check ("slice_new_blocks_where_bass_ends", blockOf (2, 2 * bar) != nullptr && blockOf (2, 8 * bar) != nullptr);
- shotBlocks ("-blocks-slice.png");
- engine.undo();
- engine.dispatchPendingMessages();
- check ("undo_slice", song().patterns.size() == patternsBefore && song().patterns[2].name == "Lead");
- // ---- #127 Zoom: a drag zooms to the range, a click goes back
- pl.setToolForSnapshot (EditTool::zoom);
- const auto zoomBefore = pl.xOfTickForSnapshot ((double) (4 * bar)) - pl.xOfTickForSnapshot (0.0);
- bPress (0, 2 * bar, left);
- bDrag (0, 4 * bar, left);
- bRelease (0, 4 * bar);
- const auto zoomed = pl.xOfTickForSnapshot ((double) (4 * bar)) - pl.xOfTickForSnapshot (0.0);
- check ("zoom_drag_zooms_in", zoomed > zoomBefore * 1.5, juce::String (zoomed) + " vs " + juce::String (zoomBefore));
- pressedAt = blocks->pointForSnapshot (0, 3 * bar).toFloat();
- blocks->mouseDown (bEvent (0, 3 * bar, right));
- blocks->mouseUp (bEvent (0, 3 * bar, {}));
- const auto back = pl.xOfTickForSnapshot ((double) (4 * bar)) - pl.xOfTickForSnapshot (0.0);
- check ("zoom_click_goes_back", std::abs (back - zoomBefore) < 0.5, juce::String (back));
- // hints name each tool's gesture
- pl.setToolForSnapshot (EditTool::mute);
- check ("hint_mute", blocks->hintAt (blocks->pointForSnapshot (0, 40)).text.contains ("mutes"));
- pl.setToolForSnapshot (EditTool::pencil);
- // ---- #154: linked tracks, then the insert effects list on their headers
- engine.editSong ([bar] (Song& s) {
- s.patternBlocksOn = false;
- s.blocks.clear();
- s.playlist.clear();
- ChannelDef vox;
- vox.name = "Lead vocal";
- vox.instrument = InstrumentKind::audioClip;
- vox.samplePath = "/shots/Lead vocal.wav";
- vox.mixerTrack = 12;
- s.channels.push_back (vox);
- const auto voxChannel = (int) s.channels.size() - 1;
- s.mixer[12].name = "Vox chain";
- for (auto k : { EffectKind::parametricEq, EffectKind::compressor, EffectKind::delay, EffectKind::reverb })
- s.mixer[12].effects.push_back (makeEffectSlot (k));
- s.mixer[12].effects[2].enabled = false;
- s.channels[0].mixerTrack = 3;
- s.mixer[3].name = "Kick";
- s.mixer[3].effects.push_back (makeEffectSlot (EffectKind::compressor));
- const auto clip = [&s, bar] (int track, ClipKind kind, int source, int at, int bars) {
- Clip c;
- c.kind = kind;
- c.track = track;
- c.start = at * bar;
- c.length = bars * bar;
- (kind == ClipKind::pattern ? c.pattern : c.channel) = source;
- s.playlist.push_back (c);
- };
- clip (0, ClipKind::pattern, 0, 0, 4);
- clip (1, ClipKind::audio, voxChannel, 0, 8);
- s.playlistTracks.resize (4);
- s.playlistTracks[1].height = 70;
- });
- engine.dispatchPendingMessages();
- // (rollup 0.1.30: since round 190ib, switching the link on asks first when it moves inserts or routes channels;
- // this run accepts, as the user clicking "Link")
- PlaylistComponent::answerLinkConfirmation = [] (const autolink::Report&) { return true; };
- // (round 190qk: the inserts column is on by default now; this route starts with it off, as before, and puts it back)
- const auto insertsWere = std::exchange (PlaylistComponent::showTrackInserts, false);
- pl.runAction ("playlist.linkTracks");
- PlaylistComponent::answerLinkConfirmation = nullptr;
- engine.dispatchPendingMessages();
- // (rollup 0.1.30: round 190ib links Playlist track N to insert N, moving the inserts there: the Vox chain and
- // the Kick follow their tracks, so the checks read the inserts the tracks are linked to)
- const auto vox = song().playlistTracks.size() > 1 ? song().playlistTracks[1].mixerTrack : -1;
- const auto kick = song().playlistTracks.size() > 0 ? song().playlistTracks[0].mixerTrack : -1;
- check ("linked", song().linkTracksToMixer && vox > 0 && song().mixer[(std::size_t) vox].name == "Vox chain" && pl.headerWidthForSnapshot() == PlaylistComponent::linkedHeaderWidth,
- juce::String (pl.headerWidthForSnapshot()));
- check ("inserts_off", ! PlaylistComponent::showTrackInserts && pl.insertsListForSnapshot (1).isEmpty());
- const auto shotRows = [&] (const juce::String& name, int rows) {
- engine.dispatchPendingMessages();
- const auto bottom = pl.trackRowForSnapshot (rows).getY();
- savePng (pl.createComponentSnapshot ({ 0, 0, juce::jmin (pl.getWidth(), 820), juce::jmin (pl.getHeight(), bottom + 12) }), prefix + name);
- };
- shotRows ("-inserts-off.png", 3);
- pl.runAction ("playlist.trackInserts");
- engine.dispatchPendingMessages();
- check ("inserts_on_widens_linked_headers", PlaylistComponent::showTrackInserts
- && pl.headerWidthForSnapshot() == PlaylistComponent::linkedHeaderWidth + PlaylistComponent::insertsColumnWidth,
- juce::String (pl.headerWidthForSnapshot()));
- const auto list = [&] (int t) { return pl.insertsListForSnapshot (t); };
- check ("list_on_linked_tracks_only", ! list (0).isEmpty() && ! list (1).isEmpty() && list (2).isEmpty(),
- list (0).toString() + " / " + list (1).toString());
- shotRows ("-inserts-on.png", 3);
- // a row's hint names the effect
- const auto rowPoint = [&] (int t, int row, bool dot) {
- const auto r = list (t);
- return juce::Point<int> (dot ? r.getX() + 5 : r.getX() + 40, r.getY() + row * 13 + 6);
- };
- const auto hintOf = [&] (juce::Point<int> p) { return pl.hintAt (p); };
- check ("hint_names_the_effect", hintOf (rowPoint (1, 1, false)).value == quickpick::slotName (engine, song().mixer[(std::size_t) vox].effects[1]),
- hintOf (rowPoint (1, 1, false)).value);
- check ("hint_add_row", hintOf (rowPoint (0, 1, false)).text.contains ("add an effect"));
- const auto now = juce::Time::getCurrentTime();
- const int ctrl = juce::ModifierKeys::commandModifier;
- const auto event = [&] (juce::Point<int> p, juce::ModifierKeys mods, juce::Point<int> down, int clicks, bool dragged) {
- return juce::MouseEvent (source, p.toFloat(), mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &pl, &pl, now, down.toFloat(), now, clicks, dragged);
- };
- const auto press = [&] (juce::Point<int> p, juce::ModifierKeys mods, std::optional<juce::Point<int>> to = {}) {
- const auto down = mods.withFlags (juce::ModifierKeys::leftButtonModifier);
- pl.mouseMove (event (p, mods, p, 1, false));
- pl.mouseDown (event (p, down, p, 1, false));
- if (to)
- {
- pl.mouseDrag (event ((p + *to) / 2, down, p, 1, true));
- pl.mouseDrag (event (*to, down, p, 1, true));
- }
- pl.mouseUp (event (to ? *to : p, mods, p, 1, to.has_value()));
- engine.dispatchPendingMessages();
- };
- const auto kinds = [&] (int insert) {
- juce::StringArray k;
- for (const auto& fx : song().mixer[(std::size_t) insert].effects)
- k.add (juce::String ((int) fx.kind) + (fx.enabled ? "" : "-"));
- return k.joinIntoString (",");
- };
- const auto eq = juce::String ((int) EffectKind::parametricEq), comp = juce::String ((int) EffectKind::compressor),
- delay = juce::String ((int) EffectKind::delay), verb = juce::String ((int) EffectKind::reverb);
- // the dot bypasses / un-bypasses, as the Mixer slot's LED (one undo step each)
- press (rowPoint (1, 0, true), {});
- check ("dot_bypasses", ! song().mixer[(std::size_t) vox].effects[0].enabled);
- press (rowPoint (1, 2, true), {});
- check ("dot_switches_on", song().mixer[(std::size_t) vox].effects[2].enabled);
- engine.undo();
- engine.dispatchPendingMessages();
- check ("undo_dot", ! song().mixer[(std::size_t) vox].effects[2].enabled && ! song().mixer[(std::size_t) vox].effects[0].enabled);
- press (rowPoint (1, 0, true), {});
- shotRows ("-inserts-bypass.png", 3);
- // drag the reverb (row 4) above the EQ: the chain order changes, as the Device View's drag
- const auto before = kinds (vox);
- press (rowPoint (1, 3, false), {}, rowPoint (1, 0, false) - juce::Point<int> (0, 4));
- check ("drag_reorders", kinds (vox) == verb + "," + eq + "," + comp + "," + delay + "-", before + " -> " + kinds (vox));
- // Ctrl + drag copies (the compressor, under the delay)
- press (rowPoint (1, 2, false), juce::ModifierKeys (ctrl), rowPoint (1, 4, false) - juce::Point<int> (0, 4));
- check ("ctrl_drag_copies", kinds (vox) == verb + "," + eq + "," + comp + "," + delay + "-," + comp, kinds (vox));
- // onto another linked track's list: it moves to that insert (the Kick's)
- press (rowPoint (1, 1, false), {}, rowPoint (0, 0, false));
- check ("drag_to_another_track_moves", kinds (kick) == comp + "," + eq && kinds (vox) == verb + "," + comp + "," + delay + "-," + comp,
- kinds (kick) + " | " + kinds (vox));
- // the wheel scrolls a list longer than its track (Kick's 4 effects + "add" in a 3-row header)
- engine.editSong ([kick] (Song& s) {
- s.mixer[(std::size_t) kick].effects.push_back (makeEffectSlot (EffectKind::delay));
- s.mixer[(std::size_t) kick].effects.push_back (makeEffectSlot (EffectKind::reverb));
- });
- engine.dispatchPendingMessages();
- const auto firstName = hintOf (rowPoint (0, 0, false)).value;
- const auto rowsShown = list (0).getHeight() / 13;
- pl.mouseWheelMove (event (rowPoint (0, 0, false), {}, rowPoint (0, 0, false), 0, false), juce::MouseWheelDetails { 0.0f, -0.5f, false, false, false });
- const auto afterWheel = hintOf (rowPoint (0, 0, false));
- check ("wheel_scrolls_a_long_list", rowsShown < 5 && afterWheel.value != firstName
- && afterWheel.value == quickpick::slotName (engine, song().mixer[(std::size_t) kick].effects[1]),
- juce::String (rowsShown) + " rows, " + firstName + " -> " + afterWheel.value);
- shotRows ("-inserts-edited.png", 3);
- // a view option: not saved with the project
- check ("option_not_in_project", ! ProjectFile::toJson (song()).contains ("trackInserts"));
- // off again: the linked headers' own width
- pl.runAction ("playlist.trackInserts");
- engine.dispatchPendingMessages();
- check ("inserts_off_again", ! PlaylistComponent::showTrackInserts && pl.headerWidthForSnapshot() == PlaylistComponent::linkedHeaderWidth);
- PlaylistComponent::showTrackInserts = insertsWere;
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- #include "WorkflowShot190iu.inc" // round 190iu
- #include "PlaylistShot190jq.inc" // round 190jq
- #include "IssuesShot190jz.inc" // round 190jz
- #include "IssuesShot190lw.inc" // round 190lw
- #include "IssuesShot190mq.inc" // round 190mq
- #include "Focus218Shot190ng.inc" // round 190ng (issue #218)
- #include "Mixer221Shot190ng.inc" // round 190ng (issue #221)
- #include "MixerQolShot190qh.inc" // round 190qh (research190qa R5, Mixer QoL)
- #include "Slots260Shot190qf.inc" // round 190qf (PR #260)
- #include "IssuesShot190ng.inc" // round 190ng (issues #215, #217, #219, #220, #222)
- #include "TrackClipsShot190ne.inc" // round 190ne
- #include "TrackStatesShot190op.inc" // round 190op
- #include "AutoModesShot190pa.inc" // round 190pa
- #include "Tracks190peShot.inc" // round 190pe
- #include "HeaderGearShot248.inc" // rollup 0.1.31 step 7 (PRs #248 / #256)
- #include "PerTabShot259.inc" // round 190pw (PR #259)
- #include "HotfixUi190qp.inc" // hotfix 0.1.31.1 (round 190qp)
- #include "TrackerShot190nw.inc" // round 190nw
- #include "IssuesShot190nq.inc" // round 190nq (issues #193, #225-#230)
- #include "Research190onShot.inc" // round 190on (research190oe P2, P8, P10)
- #include "IssuesShot190ns.inc" // round 190ns (issues #231-#235)
- #include "Rollup031S3Shot.inc" // rollup 0.1.31 step 3 (round 190ny)
- #include "Tabs2Test190nz.inc" // round 190nz (issue #232 stage 2)
- #include "IssuesShot190od.inc" // round 190od (issues #236-#242)
- #include "Design190ojShot.inc" // round 190oj (design review of every view)
- #include "Design190ooShot.inc" // round 190oo (design review 2: the owner's options and the round's fixes)
- #include "Extras190qkShot.inc" // round 190qk (the LYNX extras on by default)
- #include "IssuesShot190oq.inc" // round 190oq (issues #243-#252)
- #include "IssuesShot190qb.inc" // round 190qb (follow-ups of issues #206, #215)
- #include "Picker190qiShot.inc" // round 190qi (TOP-NEXT R6): picker and Browser quality of life
- #include "PickerPaintBench190qi.inc" // round 190qi: the plugin lists' and the Browser's paint gate
- #include "IssuesShot190qo.inc" // round 190qo (issues #239, #215, #251, #270)
- #include "RackAuto190owShot.inc" // round 190ow (PAT-7 rest, DE-123: the automation clip rows at work)
- #include "DetailsShot190kn.inc" // round 190kn
- #include "SmartTipShot190ok.inc" // round 190ok (D1)
- #include "SimpleDuckShot190ot.inc" // round 190ot (research190oe P5)
- #include "Discord190quShot.inc" // round 190qu (Discord #general 11-24)
- #include "Repeats190pmShot.inc" // round 190pm (research190oe P19, P23)
- #include "DetailsShot190ld.inc" // round 190ld
- #include "DetailsShot190lr.inc" // round 190lr
- #include "DetailsShot190lx.inc" // round 190lx
- #include "DetailsShot190mf.inc" // round 190mf
- #include "DetailsShot190mk.inc" // round 190mk
- #include "DetailsShot190mp.inc" // round 190mp
- #include "HWheel254Test.inc" // round 190ou: issue #254, the horizontal wheel
- #include "Feel190qeTest.inc" // round 190qe (TOP-NEXT R1): edge scroll, view stack, glide, keep labels
- #include "MultiEditor255Test.inc" // round 190ou: issue #255, several plugin editors in use
- #include "Issue258Test.inc" // round 190pv: issue #258, a cloned channel's own automation
- #include "Hotfix190qpTest.inc" // round 190qp: imported automation heard and shown (issue #253)
- #include "Hotfix190qpWf.inc" // round 190qp: 0.1.31.1 hotfix (track clips open their notes; Export... with folders in the name)
- #include "Issue282Check.inc" // round 190qs: issue #282, FL's trial mark and the Patcher generator in Export to FL Studio
- #include "ToolbarShot190qg.inc" // round 190qg: the toolbar never hides anything silently (walk, pictures)
- #include "Issues190qrCheck.inc" // round 190qr: issues #274-#281 (markers, rack meter, zoom, extras)
- #include "Qa190rbCheck.inc" // round 190rb: the 0.1.32 quality round's crash / memory fixes, checked
- #include "DetailsShot190mr.inc" // round 190mr
- #include "DetailsShot190mv.inc" // round 190mv
- #include "DetailsShot190my.inc" // round 190my
- #include "DetailsShot190oa.inc" // round 190oa
- #include "RackShot190nc.inc" // round 190nc
- #include "OnboardShot190np.inc" // round 190np
- #include "Demo190pgCheck.inc" // round 190pg
- #include "Demo190plCheck.inc" // round 190pl
- #include "AutoLinks190ovCheck.inc" // round 190ov (FL automation clips linked to several controls)
- // --trackautoshot190gz (round 190gz): see the dispatch above
- bool runTrackAutoShot190gz (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- {
- // a small song in FL's shape: Kick and Synth patterns, a drum loop, a vocal on its prepared insert, a mixed beat
- using namespace lynx;
- auto song = Song::makeDefault();
- song.playlist.clear();
- song.patterns.clear();
- for (auto& c : song.channels)
- c.mixerTrack = 0; // (FL's new channels play on the Master)
- song.channels[4].mixerTrack = 9; // the Synth on a bus the user made
- song.mixer[9].name = "Synth bus";
- const auto audio = [&song] (const char* name, int mixer) {
- ChannelDef c;
- c.name = name;
- c.instrument = InstrumentKind::audioClip;
- c.samplePath = std::string ("/shots/") + name + ".wav";
- c.mixerTrack = mixer;
- song.channels.push_back (c);
- return (int) song.channels.size() - 1;
- };
- const auto loop = audio ("Drum loop", 0);
- const auto vox = audio ("Lead vocal", 12);
- song.mixer[12].name = "Vox chain";
- song.mixer[12].colour = 0xFF3C8DD8;
- song.mixer[12].effects.push_back (makeEffectSlot (EffectKind::parametricEq));
- const auto pattern = [&song] (const char* name, std::vector<int> channels, std::uint32_t colour) {
- auto& p = song.patterns.emplace_back();
- p.name = name;
- p.colour = colour;
- for (const auto c : channels)
- for (int step : { 0, 4, 8, 12 })
- p.toggleStep (c, step);
- return (int) song.patterns.size() - 1;
- };
- const auto kick = pattern ("Kick", { 0 }, 0xFFD85A3C);
- const auto lead = pattern ("Lead", { 4 }, 0xFF8A5CD8);
- const auto beat = pattern ("Beat", { 1, 2, 3 }, 0xFF5CB85C);
- const auto clip = [&song] (int track, ClipKind kind, int source, int bar, int bars) {
- Clip c;
- c.kind = kind;
- c.track = track;
- c.start = (std::int64_t) bar * 4 * ppq;
- c.length = (std::int64_t) bars * 4 * ppq;
- (kind == ClipKind::pattern ? c.pattern : c.channel) = source;
- song.playlist.push_back (c);
- };
- for (int bar = 0; bar < 8; bar += 2)
- {
- clip (0, ClipKind::pattern, kick, bar, 2);
- clip (2, ClipKind::pattern, beat, bar, 2);
- }
- clip (1, ClipKind::audio, loop, 0, 8);
- clip (3, ClipKind::pattern, lead, 2, 4);
- clip (4, ClipKind::audio, vox, 4, 4);
- clip (6, ClipKind::pattern, kick, 4, 2); // (round 190ib: Track 7 only repeats Track 1's Kick)
- song.playlistTracks.resize (8);
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- engine.dispatchPendingMessages();
- auto& pl = ui.getPlaylistForSnapshot();
- pl.setSize (juce::jmax (pl.getWidth(), 1000), juce::jmax (pl.getHeight(), 640));
- pl.setViewForSnapshot (120.0, 1, 0);
- const auto shotRows = [&] (const juce::String& name, int rows) {
- const auto bottom = pl.trackRowForSnapshot (rows).getY();
- savePng (pl.createComponentSnapshot ({ 0, 0, juce::jmin (pl.getWidth(), 820), juce::jmin (pl.getHeight(), bottom + 12) }), prefix + name);
- };
- const auto& song = [&]() -> const lynx::Song& { return engine.getSong(); };
- const auto mode = [&] (int t) { return t < (int) song().playlistTracks.size() ? song().playlistTracks[(std::size_t) t].mode : lynx::PlaylistTrackMode::unassigned; };
- const auto mixerOf = [&] (int t) { return t < (int) song().playlistTracks.size() ? song().playlistTracks[(std::size_t) t].mixerTrack : -1; };
- // ---- 1. FL's default: tracks and inserts apart, FL's narrow headers
- check ("off_by_default", ! song().linkTracksToMixer && pl.headerWidthForSnapshot() == lynx::PlaylistComponent::flHeaderWidthNow(),
- juce::String (pl.headerWidthForSnapshot()));
- shotRows ("-off.png", 7);
- // ---- 2. the switch (Playlist › Edit, Track mode, Settings › Project): it lists what it changes and asks (round
- // 190ib: inserts move, channels are routed), then it is one undo step
- lynx::autolink::Report plan;
- bool asked = false;
- lynx::PlaylistComponent::answerLinkConfirmation = [&] (const lynx::autolink::Report& r) {
- plan = r;
- asked = true;
- return true;
- };
- {
- const auto text = lynx::PlaylistComponent::describeLinkPlan (song(), lynx::autolink::planOn (song()));
- juce::AlertWindow box (lynx::tr ("Link Playlist tracks to mixer tracks"), text, juce::MessageBoxIconType::QuestionIcon);
- box.addButton (lynx::tr ("Link"), 1);
- box.addButton (lynx::tr ("Cancel"), 0);
- box.sendLookAndFeelChange();
- savePng (lynx::shot::snapshot (box), prefix + "-confirm.png");
- }
- pl.runAction ("playlist.linkTracks");
- engine.dispatchPendingMessages();
- const auto moved = [&plan] (int from, int to) {
- return std::any_of (plan.changes.begin(), plan.changes.end(), [=] (const lynx::autolink::Change& c) {
- return c.kind == lynx::autolink::Change::Kind::moveInsert && c.from == from && c.to == to;
- });
- };
- check ("asked_first_with_the_moves", asked && moved (9, 4) && moved (12, 5) && plan.repeats.size() == 1 && ! plan.changesSound(),
- juce::String ((int) plan.changes.size()));
- check ("switch_on", song().linkTracksToMixer && pl.headerWidthForSnapshot() == lynx::PlaylistComponent::linkedHeaderWidth,
- juce::String (pl.headerWidthForSnapshot()));
- check ("kick_instrument_track_insert_1", mode (0) == lynx::PlaylistTrackMode::instrument && mixerOf (0) == 1 && song().channels[0].mixerTrack == 1,
- juce::String (mixerOf (0)));
- check ("loop_audio_track_insert_2", mode (1) == lynx::PlaylistTrackMode::audio && mixerOf (1) == 2 && song().mixer[2].name == "Drum loop",
- juce::String (mixerOf (1)));
- // (round 190ib: Track N = insert N for every track with content of its own)
- check ("beat_track_insert_3", mode (2) == lynx::PlaylistTrackMode::audio && mixerOf (2) == 3 && song().channels[1].mixerTrack == 3
- && song().channels[2].mixerTrack == 3 && song().channels[3].mixerTrack == 3,
- juce::String (mixerOf (2)));
- check ("synth_bus_moves_to_insert_4", mode (3) == lynx::PlaylistTrackMode::instrument && song().channels[4].mixerTrack == 4
- && song().mixer[4].name == "Synth bus" && song().playlistTracks[3].name == "Synth bus",
- juce::String (song().channels[4].mixerTrack));
- check ("vocal_chain_moves_to_insert_5", mode (4) == lynx::PlaylistTrackMode::audio && mixerOf (4) == 5 && song().mixer[5].effects.size() == 1
- && song().mixer[5].name == "Vox chain",
- juce::String (mixerOf (4)));
- check ("empty_and_repeat_tracks_stay", mode (5) == lynx::PlaylistTrackMode::unassigned && mode (6) == lynx::PlaylistTrackMode::unassigned
- && lynx::autolink::repeatedTracks (song())[6] == 0);
- shotRows ("-on.png", 7);
- // one undo step: Undo brings FL's tracks back, Redo the links
- engine.undo();
- engine.dispatchPendingMessages();
- check ("undo_switch_on", ! song().linkTracksToMixer && mode (0) == lynx::PlaylistTrackMode::unassigned && mode (1) == lynx::PlaylistTrackMode::unassigned
- && song().channels[0].mixerTrack == 0 && pl.headerWidthForSnapshot() == lynx::PlaylistComponent::flHeaderWidthNow());
- engine.redo();
- engine.dispatchPendingMessages();
- check ("redo_switch_on", song().linkTracksToMixer && mixerOf (1) == 2 && pl.headerWidthForSnapshot() == lynx::PlaylistComponent::linkedHeaderWidth);
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const auto now = juce::Time::getCurrentTime();
- const int ctrl = juce::ModifierKeys::commandModifier;
- const auto event = [&] (juce::Point<int> p, juce::ModifierKeys mods, juce::Point<int> down, int clicks, bool dragged) {
- return juce::MouseEvent (source, p.toFloat(), mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &pl, &pl, now, down.toFloat(), now, clicks, dragged);
- };
- const auto press = [&] (juce::Point<int> p, juce::ModifierKeys mods, std::optional<juce::Point<int>> to = {}) {
- const auto down = mods.withFlags (juce::ModifierKeys::leftButtonModifier);
- pl.mouseMove (event (p, mods, p, 1, false));
- pl.mouseDown (event (p, down, p, 1, false));
- if (to)
- pl.mouseDrag (event (*to, down, p, 1, true));
- pl.mouseUp (event (to ? *to : p, mods, p, 1, to.has_value()));
- engine.flushLevels();
- engine.dispatchPendingMessages();
- };
- const auto doubleClick = [&] (juce::Point<int> p) {
- const auto down = juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier);
- pl.mouseDown (event (p, down, p, 2, false));
- pl.mouseDoubleClick (event (p, down, p, 2, false));
- pl.mouseUp (event (p, {}, p, 2, false));
- engine.flushLevels();
- engine.dispatchPendingMessages();
- };
- // the controls are found where they are drawn: M right of the plate, S left of it, the volume bar and the pan knob
- // under them (the same geometry the header paints with)
- const auto row = [&] (int t) { return pl.trackRowForSnapshot (t); };
- const int w = pl.headerWidthForSnapshot();
- const auto mAt = [&] (int t) { const auto r = row (t); return juce::Point<int> (w - 13 - 9, r.getY() + 11); }; // (meter column 9 px)
- const auto sAt = [&] (int t) { return mAt (t) - juce::Point<int> (20, 0); };
- const auto volumeAt = [&] (int t, float fraction) {
- const auto r = row (t);
- const auto left = 8, width = w - 9 - 2 - 32;
- return juce::Point<int> (left + juce::roundToInt (fraction * (float) width), r.getY() + 26);
- };
- const auto panAt = [&] (int t) { const auto r = row (t); return juce::Point<int> (w - 9 - 6 - 7, r.getY() + 26); };
- const auto& insert2 = [&]() -> const lynx::MixerTrack& { return song().mixer[2]; };
- // ---- 3. the linked headers' controls act on the track's mixer track
- press (mAt (1), {});
- check ("m_mutes_the_insert", insert2().muted, juce::String ((int) insert2().muted));
- press (mAt (1), {});
- check ("m_again_unmutes", ! insert2().muted);
- press (sAt (1), {});
- check ("s_solos_the_insert", insert2().solo);
- press (sAt (1), {});
- press (volumeAt (1, 0.25f), {});
- check ("volume_click_sets_the_level", std::abs (insert2().volume - 0.25f) < 0.03f, juce::String (insert2().volume, 3));
- press (volumeAt (1, 0.25f), {}, volumeAt (1, 0.5f));
- check ("volume_drag", std::abs (insert2().volume - 0.5f) < 0.03f, juce::String (insert2().volume, 3));
- doubleClick (volumeAt (1, 0.5f));
- check ("volume_double_click_0_db", insert2().volume == lynx::unityFader, juce::String (insert2().volume, 3));
- press (panAt (1), {}, panAt (1) - juce::Point<int> (0, 40));
- check ("pan_drag_up", std::abs (insert2().pan - 0.5f) < 0.02f, juce::String (insert2().pan, 3));
- shotRows ("-controls.png", 7);
- doubleClick (panAt (1));
- check ("pan_double_click_centre", insert2().pan == 0.0f, juce::String (insert2().pan, 3));
- // an instrument track's header acts on its channel's insert (Synth: insert 4 since round 190ib)
- press (volumeAt (3, 0.4f), {});
- check ("instrument_track_volume_on_its_insert", std::abs (song().mixer[4].volume - 0.4f) < 0.03f, juce::String (song().mixer[4].volume, 3));
- engine.editSong ([] (lynx::Song& s) { s.mixer[4].volume = lynx::unityFader; });
- // FL's track mute and solo stay on the Playlist track: Ctrl+click on M solos it, a muted track lights M and the
- // first click unmutes it
- press (mAt (1), ctrl);
- check ("ctrl_m_solos_the_playlist_track", song().isTrackMuted (0) && ! song().isTrackMuted (1) && ! insert2().solo);
- press (mAt (1), ctrl);
- engine.editSong ([] (lynx::Song& s) {
- for (auto& t : s.playlistTracks)
- t.muted = false;
- s.playlistTracks[1].muted = true;
- });
- press (mAt (1), {});
- check ("m_unmutes_a_muted_playlist_track_first", ! song().isTrackMuted (1) && ! insert2().muted);
- // a track that only repeats another keeps FL's LED (Track 7, Track 1's Kick): a click mutes the Playlist track
- press (juce::Point<int> (w - 9 - 11, row (6).getCentreY()), {});
- check ("unlinked_led_is_fl", song().isTrackMuted (6));
- engine.editSong ([] (lynx::Song& s) { s.playlistTracks[6].muted = false; });
- // round 190ib: a linked track and its insert keep one name, whichever is renamed
- engine.editSong ([] (lynx::Song& s) { s.mixer[3].name = "Drums"; });
- check ("insert_rename_renames_the_track", song().playlistTracks[2].name == "Drums");
- engine.editSong ([] (lynx::Song& s) { s.playlistTracks[2].name = "Beat"; });
- check ("track_rename_renames_the_insert", song().mixer[3].name == "Beat");
- // ---- 4. new content follows: a sample on empty Track 6 makes it an audio track (insert 6)
- engine.editSong ([] (lynx::Song& s) {
- lynx::ChannelDef c;
- c.name = "Guitar";
- c.instrument = lynx::InstrumentKind::audioClip;
- c.samplePath = "/shots/Guitar.wav";
- s.channels.push_back (c);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = (int) s.channels.size() - 1;
- clip.track = 5;
- clip.start = 4 * 4 * lynx::ppq;
- clip.length = 4 * 4 * lynx::ppq;
- s.playlist.push_back (clip);
- });
- check ("new_sample_links_its_track", mode (5) == lynx::PlaylistTrackMode::audio && mixerOf (5) == 6 && song().channels.back().mixerTrack == 6,
- juce::String (mixerOf (5)));
- engine.undo();
- check ("undo_takes_the_clip_and_the_link", mode (5) == lynx::PlaylistTrackMode::unassigned && song().channels.back().name != "Guitar");
- // ---- 5. row heights (round 190ft): short rows keep M / S; from 34 px the volume and pan; tall rows the input
- const auto heights = [&] (std::vector<std::pair<int, int>> rows) {
- engine.editSong ([rows] (lynx::Song& s) {
- for (const auto& [t, h] : rows)
- s.playlistTracks[(std::size_t) t].height = h;
- });
- engine.dispatchPendingMessages();
- };
- heights ({ { 0, 16 }, { 1, 24 }, { 4, 80 } });
- shotRows ("-heights.png", 7);
- {
- const auto r = row (1);
- const auto before = insert2().volume;
- press (juce::Point<int> (20, r.getY() + 12), {}); // (no volume bar on a 24 px row: the press selects)
- check ("short_row_has_no_volume_bar", insert2().volume == before && pl.selectedTracksForSnapshot() == std::vector<int> { 1 });
- press (juce::Point<int> (w - 22, r.getY() + 12), {});
- check ("short_row_m_still_works", insert2().muted);
- press (juce::Point<int> (w - 22, r.getY() + 12), {});
- }
- heights ({ { 0, 0 }, { 1, 0 }, { 4, 0 } });
- // ---- 6. saved: .lynx keeps the switch; the links themselves are FL track modes
- {
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song()), error);
- check ("lynx_round_trip", back && back->linkTracksToMixer && back->playlistTracks.size() > 4 && back->playlistTracks[1].mixerTrack == 2
- && back->playlistTracks[0].mode == lynx::PlaylistTrackMode::instrument, error);
- auto plain = song();
- plain.linkTracksToMixer = false;
- const auto json = lynx::ProjectFile::toJson (plain);
- check ("off_not_saved", ! json.contains ("linkTracksToMixer"));
- }
- // ---- 7. off: FL's headers again (the links stay)
- lynx::PlaylistComponent::answerLinkConfirmation = nullptr;
- pl.runAction ("playlist.linkTracks");
- engine.dispatchPendingMessages();
- check ("switch_off_fl_headers", ! song().linkTracksToMixer && pl.headerWidthForSnapshot() == lynx::PlaylistComponent::flHeaderWidthNow()
- && mode (1) == lynx::PlaylistTrackMode::audio);
- shotRows ("-off-after.png", 7);
- // ---- 8. Settings › Project's switches
- {
- auto panel = lynx::makeSettingsPanel (engine, lynx::SettingsPage::project);
- panel->setSize (760, 720);
- savePng (lynx::shot::snapshot (*panel), prefix + "-settings-project.png");
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- bool runFlPlShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto plain = [] (juce::String t) {
- // (without the shortcut column and the mnemonic: the mark, or the " (K)" a translation without the letter gets)
- t = t.upToFirstOccurrenceOf ("\t", false, false);
- if (const auto at = t.indexOf (juce::String (" (") + juce::String::charToString (1)); at >= 0)
- t = t.substring (0, at);
- return t.removeCharacters (juce::String ("&_") + juce::String::charToString (1));
- };
- const auto findSub = [&plain] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && plain (it.getItem().text) == plain (text))
- return it.getItem().subMenu.get();
- return nullptr;
- };
- const auto texts = [&plain] (const juce::PopupMenu& menu, int count) {
- juce::StringArray out;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next() && out.size() < count;)
- out.add (it.getItem().isSeparator ? juce::String ("-") : it.getItem().isSectionHeader ? "[" + plain (it.getItem().text) + "]" : plain (it.getItem().text));
- return out;
- };
- const auto modelTexts = [] (const std::vector<lynx::fltrackmenus::Entry>& model) {
- juce::StringArray out;
- for (const auto& e : model)
- if (e.kind != lynx::fltrackmenus::Entry::Kind::list)
- out.add (e.kind == lynx::fltrackmenus::Entry::Kind::separator ? juce::String ("-")
- : e.kind == lynx::fltrackmenus::Entry::Kind::caption ? "[" + lynx::tr (e.text) + "]"
- : lynx::tr (e.text));
- return out;
- };
- const auto click = [&plain] (const juce::PopupMenu& menu, const juce::String& text) {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == plain (text) && it.getItem().isEnabled && it.getItem().action != nullptr)
- {
- it.getItem().action();
- return true;
- }
- return false;
- };
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- int vox = -1;
- {
- auto song = lynx::Song::makeDefault();
- song.channels.push_back ({});
- song.channels.back().name = "Vox";
- song.channels.back().instrument = lynx::InstrumentKind::audioClip;
- song.channels.back().volume = 0.6f;
- song.channels.back().samplePath = writeShotSample (juce::File (prefix + "-vox.wav"), 330.0).getFullPathName().toStdString();
- vox = (int) song.channels.size() - 1;
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = vox;
- c.track = 3;
- c.start = 4 * lynx::ppq;
- c.length = 2 * lynx::ppq;
- song.playlist.push_back (c);
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- // ---- 1. the audio clip menu: Preview first, Automate › Panning / Volume
- {
- const auto menu = playlist.getClipMenuForSnapshot (0);
- juce::PopupMenu::MenuItemIterator it (menu);
- it.next(); // (the "Audio clip" title band)
- it.next();
- check ("clip_menu_preview_first", plain (it.getItem().text) == lynx::tr ("Preview"), it.getItem().text);
- const auto* automate = findSub (menu, lynx::tr ("Automate"));
- check ("clip_menu_automate", automate != nullptr && texts (*automate, 9) == modelTexts (lynx::fltrackmenus::automate()),
- automate != nullptr ? texts (*automate, 9).joinIntoString ("|") : juce::String ("missing"));
- saveMenus (juce::StringArray { "Audio clip menu", "Automate" }, std::vector<juce::PopupMenu> { menu, automate != nullptr ? *automate : juce::PopupMenu() },
- prefix + "-clip-menu.png");
- const auto before = engine.getSong().automations.size();
- check ("automate_volume_runs", automate != nullptr && click (*automate, lynx::tr ("Volume")));
- const auto& song = engine.getSong();
- // (round 190dz: the Levels adjustment's volume multiplier, neutral = 0.5 of its 0…200 % travel)
- const auto ok = song.automations.size() == before + 1 && song.automations.back().target.kind == lynx::AutomationTargetKind::channelAdjust
- && song.automations.back().target.param == lynx::leveladjust::volume
- && song.automations.back().target.index == vox && song.automations.back().points.size() == 2
- && song.automations.back().points[1].tick == 2 * lynx::ppq && std::abs (song.automations.back().points[0].value - 0.5f) < 1.0e-6f;
- const auto* clip = ok ? &song.playlist.back() : nullptr;
- check ("automate_volume_clip", ok && clip->kind == lynx::ClipKind::automation && clip->track == 3 && clip->start == 4 * lynx::ppq
- && clip->length == 2 * lynx::ppq,
- ok ? juce::String::fromUTF8 (song.automations.back().name.c_str()) : juce::String());
- engine.undo();
- check ("automate_undo", engine.getSong().automations.size() == before);
- // Preview: the clip's own audio (FL plays it through its channel); LYNX renders it for the preview output
- const auto rendered = engine.renderClipAudio (0);
- check ("preview_renders_the_clip", ! rendered.left.empty(), juce::String ((int) rendered.left.size()) + " frames");
- }
- // ---- 2. the Playlist's "+": its menu, a right click's audio track, the corner
- {
- const auto menu = playlist.getAddTrackMenuForSnapshot();
- check ("add_menu_head", texts (menu, 5) == modelTexts (lynx::fltrackmenus::addTrack()), texts (menu, 5).joinIntoString ("|"));
- saveMenus (juce::StringArray { "Playlist +" }, std::vector<juce::PopupMenu> { menu }, prefix + "-add-track-menu.png");
- ui.selectTabForSnapshot (2);
- engine.dispatchPendingMessages();
- auto* button = playlist.getAddTrackButtonForSnapshot();
- check ("add_button_in_corner", button != nullptr && button->isVisible() && button->getX() == 7 && button->getWidth() == 21 && button->getHeight() == 18
- && button->getBottom() <= lynx::PlaylistComponent::headerHeight);
- savePng (playlist.createComponentSnapshot (juce::Rectangle<int> (0, 0, juce::jmin (560, playlist.getWidth()), juce::jmin (260, playlist.getHeight()))),
- prefix + "-playlist-corner.png");
- const auto track = playlist.addAudioTrackNow();
- const auto& song = engine.getSong();
- check ("add_audio_track", track == 0 && song.playlistTracks.size() > 0 && song.playlistTracks[0].mode == lynx::PlaylistTrackMode::audio
- && song.playlistTracks[0].mixerTrack > 0,
- juce::String (track));
- engine.undo();
- }
- // ---- 3. Track mode › Instrument track ›
- {
- const auto menu = playlist.getTrackMenuForSnapshot (5);
- const auto* modes = findSub (menu, lynx::tr ("Track mode"));
- const auto* instrument = modes != nullptr ? findSub (*modes, lynx::tr ("Instrument track")) : nullptr;
- check ("instrument_track_head", instrument != nullptr && texts (*instrument, 4) == modelTexts (lynx::fltrackmenus::instrumentTrack()),
- instrument != nullptr ? texts (*instrument, 4).joinIntoString ("|") : juce::String ("missing"));
- const auto* existing = instrument != nullptr ? findSub (*instrument, lynx::tr ("Use existing channel")) : nullptr;
- check ("use_existing_lists_generators", existing != nullptr && existing->getNumItems() == 5, existing != nullptr ? juce::String (existing->getNumItems()) : juce::String());
- std::vector<juce::PopupMenu> menus { modes != nullptr ? *modes : juce::PopupMenu(), instrument != nullptr ? *instrument : juce::PopupMenu(),
- existing != nullptr ? *existing : juce::PopupMenu() };
- saveMenus (juce::StringArray { "Track mode", "Instrument track", "Use existing channel" }, menus, prefix + "-instrument-track-menu.png");
- lynx::ChannelDef synth;
- synth.name = "Lead";
- synth.instrument = lynx::InstrumentKind::synth;
- const auto channels = engine.getSong().channels.size();
- int made = -1;
- engine.editSong ([&] (lynx::Song& s) { made = lynx::trackmodes::addInstrumentTrack (s, synth, 5); });
- check ("instrument_track_new_channel", made == (int) channels && engine.getSong().playlistTracks.size() > 5
- && engine.getSong().playlistTracks[5].channel == made);
- engine.undo();
- }
- // ---- 4. the Channel rack menu: Assign to new instrument track / Unassign
- {
- auto& rack = ui.getRackForSnapshot();
- const auto menu = rack.getChannelMenuForSnapshot (1);
- saveMenus (juce::StringArray { "Channel menu" }, std::vector<juce::PopupMenu> { menu }, prefix + "-channel-menu.png");
- check ("assign_runs", click (menu, lynx::tr ("Assign to new instrument track")));
- const auto tracks = lynx::trackmodes::instrumentTracksOf (engine.getSong(), 1);
- check ("assign_first_free_track", tracks == std::vector<int> { 0 }, juce::String (tracks.empty() ? -1 : tracks.front()));
- const auto again = rack.getChannelMenuForSnapshot (1);
- check ("unassign_offered", click (again, lynx::tr ("Unassign from instrument track")) && lynx::trackmodes::instrumentTracksOf (engine.getSong(), 1).empty());
- bool greyed = false;
- const auto voxMenu = rack.getChannelMenuForSnapshot (vox);
- for (juce::PopupMenu::MenuItemIterator it (voxMenu); it.next();)
- if (plain (it.getItem().text) == plain (lynx::tr ("Assign to new instrument track")))
- greyed = ! it.getItem().isEnabled;
- check ("assign_greyed_for_audio_clip_channel", greyed);
- }
- // ---- 5. Tools › One-click audio recording
- std::fprintf (stderr, "flplshot: tools\n");
- {
- const auto names = ui.getMenuNamesForSnapshot();
- const auto tools = ui.getMenuForSnapshot (names.indexOf (lynx::tr ("Tools")));
- const auto* oneClick = findSub (tools, lynx::tr ("One-click audio recording"));
- check ("one_click_submenu", oneClick != nullptr && texts (*oneClick, 3) == modelTexts (lynx::fltrackmenus::oneClickRecording()),
- oneClick != nullptr ? texts (*oneClick, 3).joinIntoString ("|") : juce::String ("missing"));
- saveMenus (juce::StringArray { "Tools", "One-click audio recording" }, std::vector<juce::PopupMenu> { tools, oneClick != nullptr ? *oneClick : juce::PopupMenu() },
- prefix + "-tools-one-click.png");
- const auto plan = lynx::oneclick::plan (engine.getSong(), {}, 2, lynx::oneclick::Into::playlist);
- check ("one_click_plan", plan.insert == 2 && plan.armInsert && plan.askInput && plan.songMode);
- }
- // ---- 6. Mixer › Disk recording › Latency compensation
- {
- auto& strips = ui.getMixerForSnapshot().getStripsForSnapshot();
- const auto menu = strips.buildMenu (1);
- const auto* disk = findSub (menu, lynx::tr ("Disk recording"));
- int after = -1, at = -1, i = 0;
- bool ticked = false;
- if (disk != nullptr)
- for (juce::PopupMenu::MenuItemIterator it (*disk); it.next(); ++i)
- {
- if (plain (it.getItem().text) == plain (lynx::tr ("Auto-create audio clip (the rendered files go on the Playlist)")))
- after = i;
- if (plain (it.getItem().text) == plain (lynx::tr ("Latency compensation")))
- {
- at = i;
- ticked = it.getItem().isTicked;
- }
- }
- check ("latency_comp_item", disk != nullptr && after >= 0 && at == after + 1 && ticked && engine.getRecordOptions().latencyCompensation,
- juce::String (after) + " " + juce::String (at));
- saveMenus (juce::StringArray { "Disk recording" }, std::vector<juce::PopupMenu> { disk != nullptr ? *disk : juce::PopupMenu() },
- prefix + "-disk-recording.png");
- check ("latency_comp_toggles", disk != nullptr && click (*disk, lynx::tr ("Latency compensation")) && ! engine.getRecordOptions().latencyCompensation);
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- // --flclipshot (round 190dz): see the dispatch above
- // a menu as JUCE lays it out with explicit column breaks (PopupMenu::addColumnBreak): the columns side by side on
- // one menu background; custom items (the title band) are painted by their own component
- static juce::Image columnMenuImage (const juce::PopupMenu& menu)
- {
- auto& lf = juce::LookAndFeel::getDefaultLookAndFeel();
- const auto border = lf.getPopupMenuBorderSize();
- struct Row
- {
- const juce::PopupMenu::Item* item;
- int height;
- };
- std::vector<std::vector<Row>> columns (1);
- std::vector<int> widths (1, 160);
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- const auto& item = it.getItem();
- int w = 0, h = 0;
- if (item.customComponent != nullptr)
- item.customComponent->getIdealSize (w, h);
- else
- {
- lf.getIdealPopupMenuItemSize (item.text.upToFirstOccurrenceOf ("\t", false, false), item.isSeparator, item.isSectionHeader ? -1 : 0, w, h);
- if (item.isSectionHeader)
- h += h / 2; // as JUCE does
- if (item.text.containsChar ('\t'))
- w += 90;
- }
- columns.back().push_back ({ &item, h });
- widths.back() = juce::jmax (widths.back(), w + 10);
- if (item.shouldBreakAfter)
- {
- columns.emplace_back();
- widths.push_back (160);
- }
- }
- int width = 0, height = 0;
- for (std::size_t c = 0; c < columns.size(); ++c)
- {
- width += widths[c];
- int h = 2 * border;
- for (const auto& row : columns[c])
- h += row.height;
- height = juce::jmax (height, h);
- }
- auto image = lynx::shot::canvas (width, height);
- juce::Graphics g (image);
- lynx::shot::logical (g);
- lf.drawPopupMenuBackground (g, width, height);
- int x = 0;
- for (std::size_t c = 0; c < columns.size(); ++c)
- {
- int y = border;
- for (const auto& row : columns[c])
- {
- const auto& item = *row.item;
- const juce::Rectangle<int> r (x, y, widths[c], row.height);
- if (item.customComponent != nullptr)
- {
- juce::Graphics::ScopedSaveState state (g);
- g.setOrigin (r.getPosition());
- item.customComponent->setSize (r.getWidth(), r.getHeight());
- item.customComponent->paintEntireComponent (g, false);
- }
- else if (item.isSectionHeader)
- lf.drawPopupMenuSectionHeader (g, r, item.text);
- else
- {
- juce::Graphics::ScopedSaveState state (g);
- g.setOrigin (r.getPosition());
- lf.drawPopupMenuItem (g, r.withPosition (0, 0), item.isSeparator, item.isEnabled, false, item.isTicked, item.subMenu != nullptr,
- item.text.upToFirstOccurrenceOf ("\t", false, false), item.text.fromFirstOccurrenceOf ("\t", false, false),
- item.image.get(), nullptr);
- }
- y += row.height;
- }
- x += widths[c];
- if (c + 1 < columns.size()) // (JUCE's column separator)
- {
- g.setColour (lf.findColour (juce::PopupMenu::textColourId).withAlpha (0.15f));
- g.fillRect (x - 1, border, 1, height - 2 * border);
- }
- }
- return image;
- }
- // --genpresetshot (round 190fs): see the dispatch above
- bool runGenPresetShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto shoot = [&prefix] (juce::Component& c, const char* name) {
- savePng (c.createComponentSnapshot (c.getLocalBounds()), prefix + "-" + name + ".png");
- };
- const auto plain = [] (juce::String t) { return t.upToFirstOccurrenceOf ("\t", false, false).removeCharacters ("&"); };
- const auto texts = [&plain] (const juce::PopupMenu& menu) {
- juce::StringArray out;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- out.add (it.getItem().isSeparator ? juce::String ("-") : it.getItem().isSectionHeader ? "[" + plain (it.getItem().text) + "]" : plain (it.getItem().text));
- return out;
- };
- const auto click = [&plain] (const juce::PopupMenu& menu, const juce::String& text) {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == plain (text) && it.getItem().isEnabled && it.getItem().action != nullptr)
- {
- it.getItem().action();
- return true;
- }
- return false;
- };
- const auto sameSound = [] (const lynx::ChannelDef& a, const lynx::ChannelDef& b) { return lynx::genpresets::sameSound (a, b); };
- lynx::AudioEngine engine (false);
- const auto& fl = lynx::flStudioAccess();
- auto dx = lynx::natives::makeChannel (lynx::InstrumentKind::dx10, fl);
- auto osc = lynx::natives::makeChannel (lynx::InstrumentKind::threeosc, fl);
- check ("channels_made", dx.has_value() && osc.has_value());
- if (! dx || ! osc)
- {
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\n");
- return false;
- }
- engine.editSong ([&] (lynx::Song& s) {
- s.channels.clear();
- s.channels.push_back (*dx);
- s.channels.back().mixerTrack = 1;
- s.channels.push_back (*osc);
- s.channels.back().mixerTrack = 2;
- lynx::ChannelDef synth;
- synth.instrument = lynx::InstrumentKind::synth;
- synth.name = "Synth";
- synth.mixerTrack = 3;
- s.channels.push_back (synth);
- });
- const auto channel = [&engine] (int i) { return engine.getSong().channels[(std::size_t) i]; };
- // ---- 1. Fruity DX10: the preset box before and after "Save preset..."
- {
- auto frame = lynx::makeChannelFrame (engine, 0, 0);
- frame->setSize (juce::jmax (500, frame->getWidth()), juce::jmax (300, frame->getHeight()));
- auto menu = lynx::channelPresetMenu (*frame);
- check ("dx10_menu", menu.has_value());
- const auto before = menu ? texts (*menu) : juce::StringArray();
- check ("dx10_menu_has_save", before.contains (lynx::tr ("Save preset...")) && before.contains (lynx::tr ("Show the presets folder"))
- && ! before.contains ("[" + lynx::tr ("Your presets") + "]"), before.joinIntoString ("|"));
- if (menu)
- saveMenus (juce::StringArray { "Fruity DX10 presets" }, std::vector<juce::PopupMenu> { *menu }, prefix + "-dx10-menu-before.png");
- // a sound of its own: the bank's 4th preset, then a knob moved (a sound no factory preset has)
- const auto mine = [&] {
- auto c = channel (0);
- if (auto b = lynx::banks::withPreset (c, 3))
- c = *b;
- if (! c.pluginState.empty())
- c.pluginState[c.pluginState.size() / 2] ^= 0x5a;
- return c;
- }();
- engine.editSong ([&] (lynx::Song& s) { s.channels[0] = mine; });
- check ("dx10_saved", lynx::channelPresetSave (*frame, "My FM Bell"));
- const auto file = lynx::genpresetui::folderFor (lynx::InstrumentKind::dx10).getChildFile ("My FM Bell.lynxpreset");
- check ("dx10_file", file.existsAsFile() && lynx::genpresetui::isPresetFile (file), file.getFullPathName());
- check ("dx10_box_shows_it", lynx::channelPresetName (*frame) == "My FM Bell", lynx::channelPresetName (*frame));
- menu = lynx::channelPresetMenu (*frame);
- const auto after = menu ? texts (*menu) : juce::StringArray();
- check ("dx10_menu_your_presets", after.contains ("[" + lynx::tr ("Your presets") + "]") && after.contains ("My FM Bell")
- && after.contains (lynx::tr ("Delete preset \"{0}\"", { "My FM Bell" })), after.joinIntoString ("|"));
- if (menu)
- saveMenus (juce::StringArray { "Fruity DX10 presets" }, std::vector<juce::PopupMenu> { *menu }, prefix + "-dx10-menu.png");
- shoot (*frame, "dx10-window");
- // another sound, then the user's preset from the menu: the saved sound back, one undo step, project changed
- if (auto other = lynx::banks::withPreset (channel (0), 0))
- engine.editSong ([&] (lynx::Song& s) { s.channels[0] = *other; });
- check ("dx10_other_sound", ! sameSound (channel (0), mine));
- engine.markSaved();
- menu = lynx::channelPresetMenu (*frame);
- check ("dx10_load_click", menu.has_value() && click (*menu, "My FM Bell"));
- check ("dx10_loaded_identical", sameSound (channel (0), mine) && channel (0).pluginState == mine.pluginState);
- check ("dx10_loaded_name_and_insert", channel (0).name == "My FM Bell" && channel (0).mixerTrack == 1,
- juce::String::fromUTF8 (channel (0).name.c_str()));
- check ("dx10_project_changed", engine.isModified());
- engine.undo();
- check ("dx10_one_undo_step", ! sameSound (channel (0), mine));
- engine.redo();
- check ("dx10_redo", sameSound (channel (0), mine));
- // the Browser: a new channel with the preset's generator, sound and name
- juce::String error;
- const auto count = engine.getSong().channels.size();
- check ("browser_new_channel", lynx::genpresetui::addChannel (engine, file, error) && engine.getSong().channels.size() == count + 1, error);
- const auto added = engine.getSong().channels.back();
- check ("browser_channel_sound", added.instrument == lynx::InstrumentKind::dx10 && sameSound (added, mine) && added.name == "My FM Bell");
- engine.undo();
- check ("browser_channel_undo", engine.getSong().channels.size() == count);
- }
- // ---- 2. 3x Osc: save, the menu, delete
- {
- auto frame = lynx::makeChannelFrame (engine, 1, 0);
- frame->setSize (juce::jmax (500, frame->getWidth()), juce::jmax (300, frame->getHeight()));
- check ("3xosc_saved", lynx::channelPresetSave (*frame, "Wide Saw Lead") && lynx::channelPresetSave (*frame, "Sub Bass"));
- auto menu = lynx::channelPresetMenu (*frame);
- const auto items = menu ? texts (*menu) : juce::StringArray();
- check ("3xosc_menu", items.contains ("Wide Saw Lead") && items.contains ("Sub Bass") && items.contains (lynx::tr ("Save preset...")),
- items.joinIntoString ("|"));
- if (menu)
- saveMenus (juce::StringArray { "3x Osc presets" }, std::vector<juce::PopupMenu> { *menu }, prefix + "-3xosc-menu.png");
- shoot (*frame, "3xosc-window");
- check ("3xosc_delete", menu.has_value() && click (*menu, lynx::tr ("Delete preset \"{0}\"", { "Sub Bass" })));
- check ("3xosc_deleted", lynx::genpresetui::userPresets (lynx::InstrumentKind::threeosc).size() == 1
- && ! lynx::genpresetui::folderFor (lynx::InstrumentKind::threeosc).getChildFile ("Sub Bass.lynxpreset").exists());
- menu = lynx::channelPresetMenu (*frame);
- const auto left = menu ? texts (*menu) : juce::StringArray();
- check ("3xosc_menu_after_delete", left.contains ("Wide Saw Lead") && ! left.contains ("Sub Bass"), left.joinIntoString ("|"));
- }
- // ---- 3. LYNX's synth: its "Presets..." box
- {
- engine.editSong ([] (lynx::Song& s) { s.channels[2].synth.cutoff = 777.0f; });
- auto frame = lynx::makeChannelFrame (engine, 2, 0);
- frame->setSize (juce::jmax (500, frame->getWidth()), juce::jmax (300, frame->getHeight()));
- check ("synth_saved", lynx::channelPresetSave (*frame, "Dark Pad"));
- const auto menu = lynx::channelPresetMenu (*frame);
- const auto items = menu ? texts (*menu) : juce::StringArray();
- check ("synth_menu", items.contains ("Dark Pad") && items.contains (lynx::tr ("Save preset...")) && items.contains (lynx::tr ("Show the presets folder")),
- items.joinIntoString ("|"));
- if (menu)
- saveMenus (juce::StringArray { "Synth presets" }, std::vector<juce::PopupMenu> { *menu }, prefix + "-synth-menu.png");
- const auto saved = lynx::genpresetui::read (lynx::genpresetui::folderFor (lynx::InstrumentKind::synth).getChildFile ("Dark Pad.lynxpreset"));
- check ("synth_file", saved.has_value() && saved->sound.synth.cutoff == 777.0f);
- }
- // ---- 4. the name box (the hosted plugins' and the effects' "Save preset" box)
- {
- auto box = lynx::genpresetui::makeNameBox ("My FM Bell");
- box->setSize (juce::jmax (360, box->getWidth()), juce::jmax (150, box->getHeight()));
- shoot (*box, "save-name-box");
- check ("name_box", box->getTextEditorContents ("name") == "My FM Bell");
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\n");
- return allOk;
- }
- // --flfixshot (round 190ey): see the dispatch above
- bool runFlFixShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto shoot = [&prefix] (juce::Component& c, const char* name) {
- savePng (c.createComponentSnapshot (c.getLocalBounds()), prefix + "-" + name + ".png");
- };
- const auto plain = [] (juce::String t) {
- t = t.upToFirstOccurrenceOf ("\t", false, false);
- if (const auto at = t.indexOf (juce::String (" (") + juce::String::charToString (1)); at >= 0)
- t = t.substring (0, at);
- return t.removeCharacters (juce::String ("&_") + juce::String::charToString (1));
- };
- const auto texts = [&plain] (const juce::PopupMenu& menu) {
- juce::StringArray out;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- out.add (it.getItem().isSeparator ? juce::String ("-") : it.getItem().isSectionHeader ? "[" + plain (it.getItem().text) + "]" : plain (it.getItem().text));
- return out;
- };
- const auto findSub = [&plain] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && plain (it.getItem().text) == plain (text))
- return it.getItem().subMenu.get();
- return nullptr;
- };
- const auto click = [&plain] (const juce::PopupMenu& menu, const juce::String& text) {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == plain (text) && it.getItem().isEnabled && it.getItem().action != nullptr)
- {
- it.getItem().action();
- return true;
- }
- return false;
- };
- const auto folder = juce::File (prefix).getParentDirectory().getChildFile ("flfix-samples");
- folder.createDirectory();
- const auto writeWav = [] (const juce::File& file, double rate, int frames, double hz) {
- juce::AudioBuffer<float> buffer (1, frames);
- for (int i = 0; i < frames; ++i)
- buffer.setSample (0, i, (float) (0.8 * std::sin (juce::MathConstants<double>::twoPi * hz * i / rate) * std::exp (-i / (rate * 0.12))));
- file.deleteFile();
- juce::WavAudioFormat wav;
- if (auto out = std::unique_ptr<juce::AudioFormatWriter> (wav.createWriterFor (file.createOutputStream().release(), rate, 1, 16, {}, 0)))
- out->writeFromAudioSampleBuffer (buffer, 0, frames);
- return file;
- };
- // ---- 1. the Sampler page (SMP-1 / 4 / 5 / 7, CTL-4)
- {
- lynx::AudioEngine engine (false);
- const auto clap = writeWav (folder.getChildFile ("Basic 808 Clap.wav"), 44100.0, 11600, 180.0);
- const auto loop48 = writeWav (folder.getChildFile ("Loop 48k.wav"), 48000.0, 48000, 220.0);
- engine.editSong ([&] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- lynx::audioclips::loadSampleInto (s.channels[0], clap.getFullPathName().toStdString(), "808 Clap");
- });
- const auto sampler = [&engine] { return engine.getSong().channels[0].sampler; };
- auto frame = lynx::makeChannelFrame (engine, 0, 0);
- frame->setSize (frame->getWidth() > 0 ? frame->getWidth() : 700, frame->getHeight() > 0 ? frame->getHeight() : 720);
- frame->createComponentSnapshot (frame->getLocalBounds());
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- auto& f = *frame;
- lynx::samplerPageTurn (f, "show", 0.0);
- const auto rate = engine.getTransport().sampleRate.load();
- check ("resample_greyed_at_project_rate", lynx::samplerPageQuery (f, "resample") == (std::abs (rate - 44100.0) < 0.5 ? "0" : "1"), juce::String (rate));
- check ("load_regions_greyed_without_regions", lynx::samplerPageQuery (f, "loadRegions") == "0");
- check ("load_markers_greyed_without_markers", lynx::samplerPageQuery (f, "loadMarkers") == "0");
- check ("bit_depth_16", lynx::samplerPageQuery (f, "corner") == "16", lynx::samplerPageQuery (f, "corner"));
- check ("wave_hint_summary", lynx::samplerPageQuery (f, "waveHint").startsWith ("44100Hz, 16Bit int mono, 0:263"), lynx::samplerPageQuery (f, "waveHint"));
- shoot (f, "sampler-44k");
- // SMP-5: MUL's text
- lynx::samplerPageTurn (f, "mul", 800.0);
- check ("mul_text", lynx::samplerPageQuery (f, "mulText") == "105.70%", lynx::samplerPageQuery (f, "mulText"));
- lynx::samplerPageTurn (f, "mul", 0.0);
- // SMP-4: CROSSFADE on a loopless sample: Use loop points on, the loop = the whole sample, the box reads 32
- engine.editSong ([] (lynx::Song& s) { s.channels[0].sampler.useLoopPoints = false; });
- lynx::samplerPageTurn (f, "crossfade", 120.0);
- check ("crossfade_loops_whole_sample", sampler().useLoopPoints && sampler().loopStart == 0 && sampler().loopEnd == 11599,
- juce::String (sampler().loopStart) + ".." + juce::String (sampler().loopEnd));
- check ("bit_depth_32_precomputed", lynx::samplerPageQuery (f, "corner") == "32", lynx::samplerPageQuery (f, "corner"));
- frame->createComponentSnapshot (frame->getLocalBounds());
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- shoot (f, "sampler-crossfade-red-loop");
- lynx::samplerPageTurn (f, "crossfade", 0.0);
- // SMP-3: a loop set with END alone, drawn red (FL: 0..276)
- engine.editSong ([] (lynx::Song& s) {
- s.channels[0].sampler.loopStart = 0;
- s.channels[0].sampler.loopEnd = 2400;
- });
- lynx::samplerPageTurn (f, "show", 0.0);
- shoot (f, "sampler-end-loop-red");
- // round 190gw (live check 190gu B3): the waveform menu's Spectrum view / Multichannel waveform view, on a stereo
- // clap-like noise burst (left and right differ) with no loop, as FL's shot
- {
- const auto noisy = folder.getChildFile ("Noise Clap.wav");
- juce::AudioBuffer<float> b (2, 44100);
- juce::Random random (190);
- for (int i = 0; i < b.getNumSamples(); ++i)
- for (int c = 0; c < 2; ++c)
- b.setSample (c, i, (float) ((random.nextFloat() * 2.0f - 1.0f) * 0.9 * std::exp (-i / (44100.0 * (c == 0 ? 0.10 : 0.18)))
- * (i > 1500 * c ? 1.0 : 0.15)));
- noisy.deleteFile();
- juce::WavAudioFormat wav;
- if (auto out = std::unique_ptr<juce::AudioFormatWriter> (wav.createWriterFor (noisy.createOutputStream().release(), 44100.0, 2, 16, {}, 0)))
- out->writeFromAudioSampleBuffer (b, 0, b.getNumSamples());
- const auto before = engine.getSong().channels[0];
- engine.editSong ([&] (lynx::Song& s) {
- s.channels[0].samplePath = noisy.getFullPathName().toStdString();
- s.channels[0].sampler.loopStart = s.channels[0].sampler.loopEnd = -1;
- s.channels[0].sampler.useLoopPoints = false;
- });
- lynx::samplerPageTurn (f, "show", 0.0);
- frame->createComponentSnapshot (frame->getLocalBounds()); // (starts the new file's waveform)
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- lynx::samplerpage::waveViews().spectrum = true;
- lynx::samplerPageTurn (f, "show", 0.0);
- shoot (f, "sampler-spectrum-view");
- lynx::samplerpage::waveViews() = { false, true };
- lynx::samplerPageTurn (f, "show", 0.0);
- shoot (f, "sampler-multichannel-view");
- lynx::samplerpage::waveViews() = {};
- engine.editSong ([&before] (lynx::Song& s) { s.channels[0] = before; });
- lynx::samplerPageTurn (f, "show", 0.0);
- frame->createComponentSnapshot (frame->getLocalBounds());
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- }
- // SMP-7: the waveform menu
- const auto waveMenu = lynx::samplerWaveMenu (f);
- juce::StringArray expected { lynx::tr ("Reload"), lynx::tr ("Save as..."), lynx::tr ("Locate file"), lynx::tr ("Copy audio to clipboard"),
- lynx::tr ("Paste audio from clipboard"), "-", lynx::tr ("Edit in audio editor"),
- lynx::tr ("Edit in pitch corrector"), lynx::tr ("Edit in time warper"), "-", // (round 190gw)
- lynx::tr ("Open in new sampler channel"), lynx::tr ("Open in new Fruity Granulizer channel"),
- lynx::tr ("Open in new Fruity Slicer channel"), lynx::tr ("Open in new Slicex channel"), "-", // (round 190gk)
- lynx::tr ("Detect tempo") };
- if (lynx::fileProperties) // (round 190gk: Windows only)
- expected.add (lynx::tr ("Get properties"));
- expected.addArray (juce::StringArray { "-", lynx::tr ("Spectrum view"), lynx::tr ("Multichannel waveform view") }); // (round 190gw)
- check ("wave_menu_items", waveMenu.has_value() && texts (*waveMenu) == expected, waveMenu.has_value() ? texts (*waveMenu).joinIntoString ("|") : juce::String ("none"));
- if (waveMenu.has_value())
- saveMenus (juce::StringArray { "Sampler waveform" }, std::vector<juce::PopupMenu> { *waveMenu }, prefix + "-wave-menu.png");
- check ("copy_audio_to_clipboard", waveMenu.has_value() && click (*waveMenu, lynx::tr ("Copy audio to clipboard"))
- && lynx::audioclipboard::editor().frames() == 11600);
- // SMP-1: a 48 kHz sample in this project: Resample enabled
- lynx::samplerPageTurn (f, "show", 0.0);
- engine.editSong ([&] (lynx::Song& s) { s.channels[0].samplePath = loop48.getFullPathName().toStdString(); });
- lynx::samplerPageTurn (f, "show", 0.0);
- check ("resample_enabled_48k", lynx::samplerPageQuery (f, "resample") == (std::abs (rate - 48000.0) < 0.5 ? "0" : "1"), juce::String (rate));
- frame->createComponentSnapshot (frame->getLocalBounds()); // (starts the new file's waveform)
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- shoot (f, "sampler-48k");
- // CTL-4: Remove sample renames the channel "Sampler"
- lynx::samplerFileRowPress (f, 3);
- check ("remove_sample_renames", engine.getSong().channels[0].name == "Sampler" && engine.getSong().channels[0].samplePath.empty(),
- juce::String::fromUTF8 (engine.getSong().channels[0].name.c_str()));
- lynx::samplerPageTurn (f, "show", 0.0);
- check ("no_sample_content_greyed", lynx::samplerPageQuery (f, "keepOnDisk") == "0" && lynx::samplerPageQuery (f, "resample") == "0");
- shoot (f, "sampler-removed");
- }
- // ---- 2. the Multilink button's menu with multilink off (CTL-1)
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- {
- using lynx::AutomationTarget;
- using lynx::AutomationTargetKind;
- engine.editSong ([] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- s.channels[0].name = "808 Kick";
- });
- engine.setMultilink (false);
- engine.noteTweaked ({ AutomationTargetKind::channelVolume, 0 });
- engine.noteTweaked ({ AutomationTargetKind::channelPan, 0 });
- const auto menu = ui.getMultilinkMenuForSnapshot();
- juce::PopupMenu::MenuItemIterator first (menu);
- first.next();
- const auto caption = first.getItem().text;
- bool columnBreak = false, lynxLines = false;
- juce::String rightCaption;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- if (columnBreak && rightCaption.isEmpty() && it.getItem().isSectionHeader)
- rightCaption = it.getItem().text;
- columnBreak = columnBreak || it.getItem().shouldBreakAfter;
- lynxLines = lynxLines || it.getItem().text == lynx::tr ("Link to controller");
- }
- check ("ml_off_left_column_named", first.getItem().isSectionHeader && caption == lynx::describeAutomationTarget (engine, { AutomationTargetKind::channelPan, 0 }), caption);
- check ("ml_off_two_columns", columnBreak && rightCaption == lynx::tr ("Last 2 tweaked parameters"), rightCaption);
- check ("ml_off_no_lynx_greyed_lines", ! lynxLines);
- savePng (columnMenuImage (menu), prefix + "-multilink-off-menu.png");
- }
- // ---- 3. the Playlist (PL-1 / 2 / 3 / 6 / 7 / 8)
- auto& playlist = ui.getPlaylistForSnapshot();
- {
- auto song = lynx::Song::makeDefault();
- lynx::ChannelDef bass;
- bass.name = "Amount Too - Bass";
- bass.instrument = lynx::InstrumentKind::audioClip;
- bass.samplePath = writeWav (folder.getChildFile ("bass.wav"), 44100.0, 88200, 82.0).getFullPathName().toStdString();
- bass.misc.levels.volume = 1.468f;
- song.channels.push_back (bass);
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = (int) song.channels.size() - 1;
- c.track = 3;
- c.start = 4 * lynx::ppq;
- c.length = 2 * lynx::ppq;
- song.playlist.push_back (c);
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- const auto clipIndex = (int) engine.getSong().playlist.size() - 1;
- {
- const auto menu = playlist.getClipMenuForSnapshot (clipIndex);
- const auto* automate = findSub (menu, lynx::tr ("Automate"));
- check ("automate_volume_runs", automate != nullptr && click (*automate, lynx::tr ("Volume")));
- const auto& song = engine.getSong();
- const auto made = (int) song.automations.size() - 1;
- check ("automate_makes_current_clip", made >= 0 && playlist.brush.kind == lynx::ClipKind::automation && playlist.brush.index == made,
- juce::String (playlist.brush.index));
- // (PL-2: Levels VOL 147 %, FL's clip plays unity)
- check ("automate_volume_unity", made >= 0 && song.automations.back().points[0].value == 0.5f
- && lynx::lasttweak::valueText (song, song.automations.back().target, song.automations.back().points[0].value) == "100% 0.0dB 1.00");
- const auto again = playlist.getClipMenuForSnapshot (clipIndex);
- const auto* automate2 = findSub (again, lynx::tr ("Automate"));
- check ("automate_second_is_2", automate2 != nullptr && click (*automate2, lynx::tr ("Volume"))
- && juce::String::fromUTF8 (engine.getSong().automations.back().name.c_str()).endsWith (" #2"),
- juce::String::fromUTF8 (engine.getSong().automations.back().name.c_str()));
- // PL-7: Fade in / out curve
- const auto* fadeIn = findSub (menu, lynx::tr ("Fade in curve"));
- const auto* fadeOut = findSub (menu, lynx::tr ("Fade out curve"));
- const juce::StringArray curve { lynx::tr ("Reset"), lynx::tr ("Normalize"), lynx::tr ("Normalize selection as a group"), lynx::tr ("Create crossfade"),
- lynx::tr ("Manual"), "[" + lynx::tr ("Declicker") + "]", lynx::tr ("Automatic"), lynx::tr ("Disabled"), lynx::tr ("Enabled"),
- "[" + lynx::tr ("Curve shape") + "]", lynx::tr ("Smooth curve"), lynx::tr ("Single curve") };
- check ("fade_curve_submenus", fadeIn != nullptr && fadeOut != nullptr && texts (*fadeIn) == curve && texts (*fadeOut) == curve,
- fadeIn != nullptr ? texts (*fadeIn).joinIntoString ("|") : juce::String ("missing"));
- if (fadeOut != nullptr)
- saveMenus (juce::StringArray { "Audio clip menu", "Fade out curve" }, std::vector<juce::PopupMenu> { menu, *fadeOut }, prefix + "-fade-curve-menu.png");
- // PL-8: Detect tempo is one item now
- bool detectItem = false;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == plain (lynx::tr ("Detect tempo")))
- detectItem = it.getItem().subMenu == nullptr && it.getItem().action != nullptr;
- check ("detect_tempo_item", detectItem);
- // PL-3: Preview through the channel; transport start ends it
- check ("preview_through_channel", engine.previewClipThroughChannel ((std::size_t) clipIndex) && engine.isClipPreviewing());
- engine.play();
- check ("preview_stops_on_transport", ! engine.isClipPreviewing());
- engine.stop();
- check ("preview_again_then_stop", engine.previewClipThroughChannel ((std::size_t) clipIndex) && engine.isClipPreviewing());
- engine.stop();
- check ("preview_stops_on_stop", ! engine.isClipPreviewing());
- }
- // PL-8: the dialog
- {
- lynx::ui::TempoDetectionRequest r;
- r.name = "Amount Too - Bass";
- // (a drum-like loop at 117.5 BPM, 100 beats as in FL's dialog: clicks on every beat)
- {
- auto beats = std::make_shared<lynx::SampleData>();
- beats->sampleRate = 44100.0;
- const auto period = 44100.0 * 60.0 / 117.5;
- beats->left.assign ((std::size_t) std::llround (period * 100.0), 0.0f);
- for (int b = 0; b < 100; ++b)
- for (int i = 0; i < 2000; ++i)
- if (const auto at = (std::size_t) std::llround (b * period) + (std::size_t) i; at < beats->left.size())
- beats->left[at] = (float) (0.9 * std::sin (i * 0.09) * std::exp (-i / 400.0));
- r.sample = beats;
- }
- r.projectBpm = 100.0;
- double applied = -1.0;
- r.apply = [&applied] (double beats) { applied = beats; };
- auto panel = lynx::ui::makeTempoDetectionPanel (r);
- panel->setSize (panel->getWidth(), panel->getHeight());
- shoot (*panel, "tempo-detection");
- report.add ("tempo dialog title: " + lynx::ui::tempoDetectionTitle (r.name));
- const auto project = lynx::ui::pressTempoDetectionButton (*panel, panel->getNumChildComponents() - 3);
- const auto seconds = (double) r.sample->frames() / r.sample->sampleRate; // (100 beats at 117.5 BPM)
- check ("tempo_project_button", std::abs (applied - seconds * 100.0 / 60.0) < 1.0e-6, project + " -> " + juce::String (applied));
- const auto none = lynx::ui::pressTempoDetectionButton (*panel, panel->getNumChildComponents() - 2);
- check ("tempo_no_tempo_button", applied == 0.0, none);
- }
- // ---- 4. issue #152's question (ISS152-1): FL's message with "Remember my choice"
- {
- auto box = lynx::makeFlMessageDialog ({ lynx::tr ("External input"),
- lynx::tr ("You've selected an external input. Do you want to switch to |External input only| to avoid recording internal audio on this track?"),
- { lynx::tr ("Yes"), lynx::tr ("No") }, true });
- shoot (*box, "external-input-question");
- bool listed = false;
- for (const auto& m : lynx::messages::all())
- listed = listed || juce::String (m.id) == "RecAutoSwitchExternalInput";
- check ("external_input_in_manage_messages", listed);
- }
- // ---- 5. round 190gk: FL's Start in the render window; the Sampler's "Open in new Fruity Slicer / Slicex channel";
- // a Gross Beat slot picked by MIDI becomes its parameter
- {
- lynx::AudioEngine engine (false);
- auto panel = lynx::makeClipRenderPanel (engine);
- panel->setSize (panel->getWidth() > 0 ? panel->getWidth() : 640, panel->getHeight() > 0 ? panel->getHeight() : 480);
- juce::String button;
- for (auto* c : panel->getChildren())
- if (auto* b = dynamic_cast<juce::TextButton*> (c); b != nullptr && b->isVisible() && b->getTooltip() == lynx::tr ("Start rendering"))
- button = b->getButtonText();
- check ("render_button_start", button == lynx::trc ("@render button: Start") && button == "Start", button);
- shoot (*panel, "fltails190gk-render-start");
- const auto clap = writeWav (folder.getChildFile ("Slice me.wav"), 44100.0, 44100, 140.0);
- engine.editSong ([] (lynx::Song& s) {
- s.channels.resize (2);
- s.channels[0] = {};
- s.channels[0].instrument = lynx::InstrumentKind::fruityslicer;
- s.channels[0].name = "Fruity Slicer";
- s.channels[1] = {};
- s.channels[1].instrument = lynx::InstrumentKind::slicex;
- s.channels[1].name = "Slicex";
- });
- const auto locate = [] (int index) {
- return [index] (lynx::Song& s) -> lynx::ChannelDef* { return index < (int) s.channels.size() ? &s.channels[(std::size_t) index] : nullptr; };
- };
- lynx::loadSampleWhenOpened (0, clap.getFullPathName());
- auto slicer = lynx::makeFruitySlicerEditor (engine, locate (0), 0);
- const auto& fs = engine.getSong().channels[0];
- check ("open_in_new_fruity_slicer", fs.samplePath == clap.getFullPathName().toStdString() && ! fs.pluginState.empty(), juce::String (fs.samplePath));
- lynx::loadSlicexSampleWhenOpened (1, clap.getFullPathName());
- auto slicex = lynx::makeSlicexEditor (engine, locate (1), 1);
- const auto& sx = engine.getSong().channels[1];
- check ("open_in_new_slicex", sx.samplePath == clap.getFullPathName().toStdString() && ! sx.pluginState.empty(), juce::String (sx.samplePath));
- auto again = lynx::makeSlicexEditor (engine, locate (1), 1); // (the request is used once)
- check ("open_in_new_used_once", engine.getSong().channels[1].samplePath == sx.samplePath);
- // Gross Beat on insert 1: two notes on its MIDI input, one block, the engine's timer step
- engine.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() < 2)
- s.mixer.resize (2);
- s.mixer[1].effects = { lynx::makeEffectSlot (lynx::EffectKind::grossBeat) };
- });
- engine.dispatchPendingMessages();
- auto fx = engine.getEffect (1, 0);
- check ("gb_running", fx != nullptr);
- if (fx != nullptr)
- {
- std::vector<float> l (512, 0.1f), r (512, 0.1f);
- fx->prepare (44100.0);
- fx->setSongPosition (0.0);
- fx->midiNote (60 + 9, 100, 0);
- fx->midiNote (24 + 3, 100, 0);
- fx->process (l.data(), r.data(), 512, engine.getSong().mixer[1].effects[0].params, 120.0);
- engine.pumpGrossBeatPicks();
- const auto& p = engine.getSong().mixer[1].effects[0].params;
- check ("gb_midi_pick_sets_parameters", lynx::grossbeat::rawFromParam (0, p[0]) == 9 && lynx::grossbeat::rawFromParam (1, p[1]) == 3,
- juce::String (lynx::grossbeat::rawFromParam (0, p[0])) + " " + juce::String (lynx::grossbeat::rawFromParam (1, p[1])));
- }
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- // --grooveshot190fm (round 190fm): see the dispatch above
- bool runGrooveShot190fm (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto plain = [] (juce::String t) {
- t = t.upToFirstOccurrenceOf ("\t", false, false);
- return t.removeCharacters (juce::String ("&_") + juce::String::charToString (1));
- };
- const auto sub = [&plain] (const juce::PopupMenu& menu, const juce::String& start) -> const juce::PopupMenu* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && plain (it.getItem().text).startsWith (start))
- return it.getItem().subMenu.get();
- return nullptr;
- };
- const auto item = [&plain] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu::Item* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == text)
- return &it.getItem();
- return nullptr;
- };
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- std::uint32_t classic = 0;
- {
- auto song = lynx::Song::makeDefault();
- song.mode = lynx::PlayMode::song;
- song.playlist.push_back ({ 0, 0, 0, 4 * lynx::ppq, 0 });
- song.playlist.push_back ({ 0, 1, 4 * lynx::ppq, 4 * lynx::ppq, 0 });
- for (const auto& e : lynx::groove::factoryBank())
- if (juce::String (e.folder) == "Classic swing" && e.groove.base == lynx::GrooveBase::sixteenth
- && (e.groove.name == "Swing 16ths 54 %" || e.groove.name == "Swing 16ths 58 %" || e.groove.name == "Swing 16ths 62 %"
- || e.groove.name == "Swing 16ths 71 %"))
- {
- const auto id = lynx::groove::add (song.grooves, e.groove);
- if (e.groove.name == "Swing 16ths 58 %")
- classic = id;
- }
- song.playlist[0].groove = classic;
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- const auto menu = playlist.getClipMenuForSnapshot (0);
- const auto* chooser = sub (menu, lynx::tr ("Groove"));
- check ("groove_chooser_in_clip_menu", chooser != nullptr);
- const auto* add = chooser != nullptr ? sub (*chooser, lynx::tr ("Add a groove")) : nullptr;
- const auto* folder = add != nullptr ? sub (*add, lynx::tr ("Classic swing")) : nullptr;
- check ("classic_swing_folder", folder != nullptr && folder->getNumItems() == 27, folder != nullptr ? juce::String (folder->getNumItems()) : juce::String ("missing"));
- const auto* commit = item (menu, lynx::tr ("Commit groove"));
- check ("commit_enabled_with_a_groove", commit != nullptr && commit->isEnabled);
- check ("extract_present", item (menu, lynx::tr ("Extract groove")) != nullptr);
- {
- juce::StringArray names { "Pattern clip menu" };
- std::vector<juce::PopupMenu> menus { menu };
- if (chooser != nullptr)
- {
- names.add ("Groove");
- menus.push_back (*chooser);
- }
- if (add != nullptr)
- {
- names.add ("Add a groove");
- menus.push_back (*add);
- }
- if (folder != nullptr)
- {
- names.add ("Classic swing");
- menus.push_back (*folder);
- }
- saveMenus (names, menus, prefix + "-playlist-clip-menu.png");
- }
- // the second clip (no groove): Commit is off; choosing a groove from the menu sets it
- {
- const auto other = playlist.getClipMenuForSnapshot (1);
- const auto* c2 = item (other, lynx::tr ("Commit groove"));
- check ("commit_disabled_without_a_groove", c2 != nullptr && ! c2->isEnabled);
- const auto* ch2 = sub (other, lynx::tr ("Groove"));
- const auto* pick = ch2 != nullptr ? item (*ch2, "Swing 16ths 71 %") : nullptr;
- if (pick != nullptr && pick->action != nullptr)
- pick->action();
- const auto& song = engine.getSong();
- check ("chooser_sets_the_clip_groove", song.playlist.size() == 2 && lynx::groove::ofClip (song, song.playlist[1]) != nullptr
- && lynx::groove::ofClip (song, song.playlist[1])->name == "Swing 16ths 71 %");
- }
- // the pool with the classic grooves
- {
- auto pool = lynx::makeGroovePool (engine);
- pool->setSize (900, lynx::groovePoolHeight (engine));
- savePng (pool->createComponentSnapshot (pool->getLocalBounds()), prefix + "-pool.png");
- }
- // .lynx: a Playlist clip's groove comes back; a project without one writes nothing new
- {
- juce::String error;
- const auto& song = engine.getSong();
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- check ("lynx_round_trip", back && back->playlist.size() == 2 && back->playlist[0].groove == song.playlist[0].groove
- && back->playlist[1].groove == song.playlist[1].groove && back->grooves == song.grooves,
- error);
- auto old = lynx::Song::makeDefault();
- old.playlist.push_back ({ 0, 0, 0, 4 * lynx::ppq, 0 });
- const auto json = lynx::ProjectFile::toJson (old, false);
- const auto reloaded = lynx::ProjectFile::fromJson (json, error);
- check ("old_project_unchanged", reloaded && lynx::ProjectFile::toJson (*reloaded, false) == json && reloaded->playlist[0].groove == 0);
- }
- // Commit from the menu: the clip's pattern (shared with the second clip) is copied, the groove is off
- {
- const auto patterns = engine.getSong().patterns.size();
- const auto again = playlist.getClipMenuForSnapshot (0);
- if (const auto* c = item (again, lynx::tr ("Commit groove")); c != nullptr && c->action != nullptr)
- c->action();
- const auto& song = engine.getSong();
- check ("commit_runs", song.playlist[0].groove == 0 && song.patterns.size() == patterns + 1 && song.playlist[0].pattern == (int) patterns);
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\n" + (allOk ? "ALL OK" : "SOME FAILED") + "\n");
- return allOk;
- }
- bool runFlClipShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::StringArray report;
- bool allOk = true;
- const auto check = [&report, &allOk] (const char* name, bool ok, const juce::String& detail = {}) {
- report.add (juce::String (name) + "=" + (ok ? "OK" : "FAIL") + (detail.isEmpty() ? juce::String() : " " + detail));
- allOk = allOk && ok;
- };
- const auto plain = [] (juce::String t) {
- t = t.upToFirstOccurrenceOf ("\t", false, false);
- if (const auto at = t.indexOf (juce::String (" (") + juce::String::charToString (1)); at >= 0)
- t = t.substring (0, at);
- return t.removeCharacters (juce::String ("&_") + juce::String::charToString (1));
- };
- const auto find = [&plain] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu::Item* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == plain (text))
- return &it.getItem();
- return nullptr;
- };
- const auto click = [&find] (const juce::PopupMenu& menu, const juce::String& text) {
- const auto* item = find (menu, text);
- if (item == nullptr || ! item->isEnabled || item->action == nullptr)
- return false;
- item->action();
- return true;
- };
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- int vox = -1;
- {
- auto song = lynx::Song::makeDefault();
- song.channels.push_back ({});
- song.channels.back().name = "Vox";
- song.channels.back().instrument = lynx::InstrumentKind::audioClip;
- song.channels.back().samplePath = writeShotSample (juce::File (prefix + "-vox.wav"), 330.0).getFullPathName().toStdString();
- vox = (int) song.channels.size() - 1;
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = vox;
- c.track = 3;
- c.start = 4 * lynx::ppq;
- c.length = 2 * lynx::ppq;
- c.fadeIn = lynx::ppq / 4;
- song.playlist.push_back (c);
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- // ---- 1. the audio clip menu: FL's order, sections and columns, then LYNX's own items
- {
- const auto menu = playlist.getClipMenuForSnapshot (0);
- juce::StringArray got, want;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- const auto& item = it.getItem();
- // (round 190kx's loop items, whose labels carry the clip's own key / tempo, are not in the fixed list)
- if (! item.isSeparator && ! item.isSectionHeader
- && (plain (item.text).startsWith (lynx::tr ("Follow the project key")) || plain (item.text).startsWith (lynx::tr ("Loop key"))
- || plain (item.text).startsWith (lynx::tr ("Fit to the project tempo ({0}, from {1} BPM)").upToFirstOccurrenceOf (" (", false, false))))
- continue;
- got.add (item.customComponent != nullptr ? "[" + lynx::tr ("Audio clip") + "]"
- : item.isSeparator ? juce::String ("-")
- : item.isSectionHeader ? "[" + plain (item.text) + "]"
- : plain (item.text));
- }
- for (const auto& e : lynx::flclipmenu::shown (true, false))
- if (e.kind != lynx::flclipmenu::Entry::Kind::columnBreak)
- want.add (e.kind == lynx::flclipmenu::Entry::Kind::separator ? juce::String ("-")
- : e.kind == lynx::flclipmenu::Entry::Kind::header ? "[" + lynx::tr (e.text.c_str()) + "]"
- : lynx::tr (e.text.c_str()));
- // (rollup step 8: the separators round 190kx's key items bring into the LYNX extras column go with them)
- for (int k = got.indexOf ("[" + lynx::tr ("LYNX extras") + "]") + 1; k > 0 && k < got.size();)
- if (got[k] == "-")
- got.remove (k);
- else
- ++k;
- want.add ("[" + lynx::tr ("LYNX extras") + "]"); // (round 190gi; round 190jv: in a third column)
- for (const auto& x : lynx::flclipmenu::lynxExtras())
- want.add (lynx::tr (x.c_str()));
- check ("clip_menu_fl_order", got == want, got.joinIntoString ("|"));
- // FL's two columns (Chop | Sample), then LYNX's own items in a third (round 190jv)
- juce::StringArray breaks;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().shouldBreakAfter)
- breaks.add (it.getItem().isSectionHeader || it.getItem().customComponent != nullptr ? "?" : plain (it.getItem().text));
- check ("clip_menu_two_columns", breaks.size() == 2 && breaks[0] == lynx::tr ("Chop") && breaks[1] == lynx::tr ("Fade out curve"),
- breaks.joinIntoString ("|"));
- const auto* crossfade = find (menu, lynx::tr ("Crossfade with"));
- check ("crossfade_with_greyed", crossfade != nullptr && ! crossfade->isEnabled);
- const auto* region = find (menu, lynx::tr ("Select region"));
- const auto* full = region != nullptr && region->subMenu != nullptr ? find (*region->subMenu, lynx::tr ("Full")) : nullptr;
- check ("select_region_full_ticked", full != nullptr && full->isTicked);
- const auto* chop = find (menu, lynx::tr ("Chop"));
- check ("chop_time_based", chop != nullptr && chop->subMenu != nullptr && find (*chop->subMenu, lynx::tr ("Chop in 32nd beats")) != nullptr
- && find (*chop->subMenu, lynx::tr ("Chop to grid")) != nullptr);
- savePng (columnMenuImage (menu), prefix + "-clip-menu.png");
- std::fprintf (stderr, "flclipshot: menu saved\n");
- // Muted is a check; Reset fades clears the fades; Select all similar clips selects
- check ("muted_toggles", click (menu, lynx::tr ("Muted")) && engine.getSong().playlist[0].muted);
- const auto again = playlist.getClipMenuForSnapshot (0);
- const auto* muted = find (again, lynx::tr ("Muted"));
- check ("muted_ticked", muted != nullptr && muted->isTicked);
- check ("reset_fades", click (again, lynx::tr ("Reset fades")) && engine.getSong().playlist[0].fadeIn == 0);
- engine.undo();
- engine.undo();
- engine.dispatchPendingMessages();
- std::fprintf (stderr, "flclipshot: automate\n");
- // Automate › Volume / Panning: the clip channel's Levels adjustment (FL's channel parameters 0x11 / 0x10)
- const auto fresh = playlist.getClipMenuForSnapshot (0);
- const auto* automate = find (fresh, lynx::tr ("Automate"));
- const auto before = engine.getSong().automations.size();
- check ("automate_volume_runs", automate != nullptr && automate->subMenu != nullptr && click (*automate->subMenu, lynx::tr ("Volume")));
- const auto& song = engine.getSong();
- const auto ok = song.automations.size() == before + 1 && song.automations.back().target.kind == lynx::AutomationTargetKind::channelAdjust
- && song.automations.back().target.param == lynx::leveladjust::volume && song.automations.back().target.index == vox
- && std::abs (song.automations.back().points[0].value - 0.5f) < 1.0e-6f;
- check ("automate_volume_is_level_adjust", ok, ok ? juce::String::fromUTF8 (song.automations.back().name.c_str()) : juce::String());
- engine.undo();
- engine.dispatchPendingMessages();
- }
- std::fprintf (stderr, "flclipshot: overlap\n");
- // ---- 2. a second channel's clip overlapping: Crossfade with lists it and makes FL's crossfade clip (round 190gw)
- {
- engine.editSong ([vox] (lynx::Song& s) {
- auto copy = s.playlist[0]; // (another audio clip channel's clip, at the same time)
- s.channels.push_back (s.channels[(std::size_t) vox]);
- s.channels.back().name = "Vox 2";
- copy.channel = (int) s.channels.size() - 1;
- copy.track = 4;
- s.playlist.push_back (copy);
- });
- engine.dispatchPendingMessages();
- const auto overlapped = playlist.getClipMenuForSnapshot (0);
- const auto* with = find (overlapped, lynx::tr ("Crossfade with"));
- check ("crossfade_with_lists_the_overlap", with != nullptr && with->isEnabled && with->subMenu != nullptr && find (*with->subMenu, "Vox 2") != nullptr);
- const auto made = with != nullptr && with->subMenu != nullptr && click (*with->subMenu, "Vox 2");
- engine.dispatchPendingMessages();
- const auto& xsong = engine.getSong();
- const auto xok = made && ! xsong.automations.empty() && xsong.automations.back().links.size() == 2
- && juce::String::fromUTF8 (xsong.automations.back().name.c_str()).endsWith (" to Vox 2 crossfade");
- check ("crossfade_with_makes_the_clip", xok, xok ? juce::String::fromUTF8 (xsong.automations.back().name.c_str()) : juce::String());
- if (made)
- engine.undo();
- engine.undo();
- engine.dispatchPendingMessages();
- }
- std::fprintf (stderr, "flclipshot: misc\n");
- // ---- 3. the channel's Misc tab: Levels adjustment = the offsets (pan 0, volume 100 %, Mod X / Y 0 %)
- {
- engine.editSong ([vox] (lynx::Song& s) {
- s.channels[(std::size_t) vox].misc.levels.volume = 0.5f;
- s.channels[(std::size_t) vox].misc.levels.pan = -0.25f;
- });
- engine.dispatchPendingMessages();
- auto frame = lynx::makeChannelFrame (engine, vox, -1);
- frame->setSize (juce::jmax (frame->getWidth(), 800), juce::jmax (frame->getHeight(), 420));
- savePng (frame->createComponentSnapshot (frame->getLocalBounds()), prefix + "-misc-levels.png");
- auto synthFrame = lynx::makeChannelFrame (engine, 0, -1);
- synthFrame->setSize (juce::jmax (synthFrame->getWidth(), 800), juce::jmax (synthFrame->getHeight(), 420));
- savePng (synthFrame->createComponentSnapshot (synthFrame->getLocalBounds()), prefix + "-misc-levels-ch1.png");
- std::fprintf (stderr, "flclipshot: round trip\n");
- // the .lynx round trip of the adjustment and of an automation of it; an old project writes nothing new
- juce::String error;
- auto song = engine.getSong();
- lynx::Automation a;
- a.target = { lynx::AutomationTargetKind::channelAdjust, vox, 0, lynx::leveladjust::volume };
- a.points = { { 0, 0.25f, 0.0f } };
- song.automations.push_back (a);
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error);
- check ("lynx_round_trip", back && back->channels[(std::size_t) vox].misc.levels == song.channels[(std::size_t) vox].misc.levels
- && back->automations.back().target == a.target,
- error);
- auto old = lynx::Song::makeDefault();
- const auto json = lynx::ProjectFile::toJson (old, false);
- const auto reloaded = lynx::ProjectFile::fromJson (json, error);
- check ("old_project_unchanged", ! json.contains ("\"levels\"") && reloaded && lynx::ProjectFile::toJson (*reloaded, false) == json
- && std::all_of (reloaded->channels.begin(), reloaded->channels.end(),
- [] (const lynx::ChannelDef& c) { return c.misc.levels.neutral(); }));
- }
- juce::File (prefix + "-checks.txt").replaceWithText (report.joinIntoString ("\n") + "\nresult=" + (allOk ? "OK" : "FAIL") + "\n");
- return allOk;
- }
- // --bandlab190jrshot <prefix> (round 190jr; B15, BUILD-LIST 13 / 14): a synthetic BandLab project (.blx: the revision
- // JSON, a MIDI file, a WAV) opened through the real import, shown in the Simple layout; its looped regions and their
- // loop handles; a loop dragged longer; the automation view with and without points and its parameter menu; the clip
- // menu's loop items; the Extract stems form (Standard and 6 stems). Pictures at the --shot-scale asked for.
- void runBandlab190jrShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- const auto note = [] (const juce::String& what) { std::fprintf (stderr, "bandlab190jrshot: %s\n", what.toRawUTF8()); };
- const auto writeImage = [&prefix, ¬e] (const juce::Image& image, const char* name) {
- note (name);
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- juce::String report;
- const auto check = [&report, ¬e] (const juce::String& what, bool ok) {
- note ((ok ? "ok " : "FAIL ") + what);
- report << (ok ? "ok " : "FAIL ") << what << "\n";
- };
- // ---- 1. the project: a revision with a looped piano region, a voice take and a drum machine
- const auto folder = juce::File (prefix + "-blx");
- folder.deleteRecursively();
- folder.getChildFile ("Audio").createDirectory();
- folder.getChildFile ("MIDI").createDirectory();
- {
- // a 4-beat MIDI part (100 BPM: 2.4 s) and a drum beat, 480 ticks per quarter
- const auto midi = [] (const std::vector<std::array<int, 4>>& notes) {
- juce::MidiMessageSequence seq;
- for (const auto& n : notes)
- {
- seq.addEvent (juce::MidiMessage::noteOn (1, n[2], (juce::uint8) n[3]), n[0]);
- seq.addEvent (juce::MidiMessage::noteOff (1, n[2]), n[0] + n[1]);
- }
- seq.updateMatchedPairs();
- juce::MidiFile file;
- file.setTicksPerQuarterNote (480);
- file.addTrack (seq);
- juce::MemoryOutputStream out;
- file.writeTo (out);
- return out.getMemoryBlock();
- };
- const auto keysBlock = midi ({ { 0, 480, 62, 100 }, { 0, 480, 65, 90 }, { 0, 480, 69, 90 }, { 480, 240, 64, 80 },
- { 960, 480, 60, 100 }, { 960, 480, 64, 90 }, { 1440, 480, 67, 90 } });
- folder.getChildFile ("MIDI/s-keys.mid").replaceWithData (keysBlock.getData(), keysBlock.getSize());
- const auto beat = midi ({ { 0, 120, 36, 120 }, { 480, 120, 38, 110 }, { 960, 120, 36, 120 }, { 1440, 120, 38, 110 }, { 240, 60, 42, 80 },
- { 720, 60, 42, 80 }, { 1200, 60, 42, 80 }, { 1680, 60, 42, 80 } });
- folder.getChildFile ("MIDI/s-beat.mid").replaceWithData (beat.getData(), beat.getSize());
- // a 4.8 s "voice" (a sine with a slow swell), 44.1 kHz
- juce::AudioBuffer<float> wave (1, 44100 * 48 / 10);
- for (int i = 0; i < wave.getNumSamples(); ++i)
- wave.setSample (0, i, 0.4f * std::sin ((float) i * 0.0627f) * (0.5f + 0.5f * std::sin ((float) i * 0.00012f)));
- juce::WavAudioFormat wav;
- const auto out = folder.getChildFile ("Audio/s-vox.wav");
- if (auto stream = out.createOutputStream())
- if (std::unique_ptr<juce::AudioFormatWriter> writer (wav.createWriterFor (stream.get(), 44100.0, 1, 16, {}, 0)); writer != nullptr)
- {
- stream.release();
- writer->writeFromAudioSampleBuffer (wave, 0, wave.getNumSamples());
- }
- folder.getChildFile ("Scratch Song.blx").replaceWithText (R"({ "revision": {
- "key": "D min", "volume": 1, "song": { "name": "Scratch Song" },
- "metronome": { "bpm": 100, "signature": { "notesCount": 4, "noteValue": 4 } },
- "auxChannels": [ { "id": "aux1", "preset": "sharedReverb", "returnLevel": 1 } ],
- "samples": [ { "id": "s-keys", "isMidi": true, "duration": 2.4 }, { "id": "s-vox", "isMidi": false, "duration": 4.8 }, { "id": "s-beat", "isMidi": true } ],
- "tracks": [
- { "id": "t1", "order": 0, "name": "Keys", "type": "instrument", "soundbank": "studio-grand", "volume": 0.9, "colorName": "Red",
- "regions": [ { "id": "r1", "sampleId": "s-keys", "name": "Chords", "startPosition": 0, "endPosition": 9.6, "loopLength": 2.4 } ] },
- { "id": "t2", "order": 1, "name": "Vocal", "type": "voice", "volume": 1, "pan": -0.2, "colorName": "Blue",
- "effects": [ { "slug": "compressor", "params": { "attack": 0.003, "ratio": 3, "release": 0.12, "threshold": -18 } },
- { "slug": "threeBandEq", "params": { "lowGain": -2, "midGain": 1, "highGain": 3, "midFreq": 2500 } },
- { "slug": "chorusPedal", "params": {} } ],
- "auxSends": [ { "id": "aux1", "sendLevel": 0.3 } ],
- "automation": { "volume": [ { "position": 0, "value": 0.2 }, { "position": 8, "value": 1 }, { "position": 16, "value": 0.7 } ] },
- "regions": [ { "id": "r2", "sampleId": "s-vox", "name": "Take 1", "startPosition": 2.4, "endPosition": 7.2, "fadeIn": 0.2, "fadeOut": 0.5 } ] },
- { "id": "t3", "order": 2, "name": "Drum Machine", "type": "drum-machine", "volume": 1, "colorName": "Violet",
- "regions": [ { "id": "r3", "sampleId": "s-beat", "name": "Beat", "startPosition": 0, "endPosition": 4.8, "loopLength": 2.4 } ] }
- ] } })");
- }
- juce::String error;
- const auto blx = folder.getChildFile ("Scratch Song.blx");
- const auto imported = offline.importFlpFile (blx, error);
- check ("the .blx opens through the import (" + error + ")", imported);
- offline.dispatchPendingMessages();
- const auto& song = offline.getSong();
- check ("three Simple tracks: Keys (instrument), Vocal (audio), Drum Machine (drums)",
- lynx::simpletracks::kindOf (song, 0) == lynx::simpletracks::Kind::instrument && lynx::simpletracks::kindOf (song, 1) == lynx::simpletracks::Kind::audio
- && lynx::simpletracks::kindOf (song, 2) == lynx::simpletracks::Kind::drums);
- check ("tempo 100, key D minor", std::abs (song.bpm - 100.0) < 1e-6 && lynx::projectkey::get (song).has_value());
- int keysClips = 0, beatClips = 0, voxClips = 0;
- for (const auto& c : song.playlist)
- {
- keysClips += c.track == 0;
- voxClips += c.track == 1 && c.kind == lynx::ClipKind::audio;
- beatClips += c.track == 2;
- }
- check ("the looped Keys region: 4 passes; the beat: 2; the take: 1 audio clip", keysClips == 4 && beatClips == 2 && voxClips == 1);
- const auto voxInsert = lynx::simpletracks::insertOf (song, 1);
- check ("the vocal's compressor, EQ and chorus on its insert",
- voxInsert > 0 && song.mixer[(std::size_t) voxInsert].effects.size() == 3);
- check ("the vocal's volume automation: a lane under its track", ! song.playlistTracks[1].lanes.empty());
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- if (auto* simple = ui.getSimpleWorkflowForSnapshot())
- simple->hideChooser();
- auto& playlist = ui.getPlaylistForSnapshot();
- playlist.setViewForSnapshot (96.0, 0, 0);
- offline.dispatchPendingMessages();
- writeImage (lynx::shot::snapshot (ui), "blx-simple");
- writeImage (lynx::shot::snapshot (playlist), "loop-handles");
- // ---- 2. a loop dragged longer: the take repeated to bar 9 (as the handle's drag does it)
- {
- int take = -1;
- for (int i = 0; i < (int) song.playlist.size(); ++i)
- if (song.playlist[(std::size_t) i].track == 1 && song.playlist[(std::size_t) i].kind == lynx::ClipKind::audio)
- take = i;
- const auto end = (std::int64_t) lynx::ppq * 4 * 8;
- offline.editSong ([take, end] (lynx::Song& s) { lynx::regionloop::loopTo (s, take, end); });
- offline.dispatchPendingMessages();
- const auto run = lynx::regionloop::runOf (offline.getSong(), lynx::regionloop::regionAt (offline.getSong(), 1, (std::int64_t) lynx::ppq * 4, offline.getSong().playlist[(std::size_t) take]));
- check ("the take loops to bar 9 in passes of its length", run.passes() >= 3 && run.end == end);
- writeImage (lynx::shot::snapshot (playlist), "loop-dragged");
- auto menu = playlist.getClipMenuForSnapshot (run.clips.empty() ? take : run.clips.back());
- bool hasLoop = false;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- hasLoop = hasLoop || it.getItem().text == lynx::tr ("Unloop");
- check ("the Simple clip menu has Loop until next / Unloop", hasLoop);
- saveMenus (juce::StringArray { "Clip" }, std::vector<juce::PopupMenu> { menu }, prefix + "-clip-menu.png");
- }
- // ---- 3. the automation view: the vocal's lane on its row, the others' dashed line at their level
- playlist.setSimpleAutomation (true);
- offline.dispatchPendingMessages();
- writeImage (lynx::shot::snapshot (playlist), "automation-view");
- check ("the view changes nothing in the song", offline.getSong().playlistTracks[0].lanes.empty());
- playlist.setSimpleAutoTargetForSnapshot (1, { lynx::AutomationTargetKind::effectParam, voxInsert, 0, 0 }); // the compressor's threshold
- writeImage (lynx::shot::snapshot (playlist), "automation-param");
- playlist.setSimpleAutoTargetForSnapshot (1, { lynx::AutomationTargetKind::mixerVolume, voxInsert, 0, 0 });
- saveMenus (juce::StringArray { "Volume" }, std::vector<juce::PopupMenu> { playlist.getSimpleAutoMenuForSnapshot (1) }, prefix + "-automation-menu.png");
- playlist.setSimpleAutomation (false);
- offline.dispatchPendingMessages();
- // ---- 4. the Extract stems form
- {
- auto panel = lynx::makeStemOptionsPanel (lynx::stemsplit::Options {}, [] (lynx::stemsplit::Options) {});
- writeImage (lynx::shot::paint (*panel, lynx::theme::colour::bg2), "stem-options");
- lynx::stemsplit::Options six;
- six.model = lynx::stemsplit::Model::sixStems;
- six.stems = { true, true, false, true, true, true };
- auto panel6 = lynx::makeStemOptionsPanel (six, [] (lynx::stemsplit::Options) {});
- writeImage (lynx::shot::paint (*panel6, lynx::theme::colour::bg2), "stem-options-six");
- }
- juce::File (lynx::shot::fileName (prefix + "-report.txt")).replaceWithText (report);
- }
- // --bandlabshot <prefix> (round 190ch): the Lyrics / Notes panel (Pattern and Simple layouts, and on its own), the
- // Reference match window measured on a real render and a real file, "Start from", and Clean voice, off-screen; and
- // <prefix>-report.txt with what each route did (ok / FAIL lines)
- void runBandlabShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- // (each step is named on stderr as it starts: a run that stops says where)
- const auto note = [] (const juce::String& what) { std::fprintf (stderr, "bandlabshot: %s\n", what.toRawUTF8()); };
- const auto shoot = [&prefix, ¬e] (juce::Component& c, const char* name) {
- note (name);
- savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png");
- };
- juce::String report;
- const auto check = [&report, ¬e] (const juce::String& what, bool ok) {
- note ((ok ? "ok " : "FAIL ") + what);
- report << (ok ? "ok " : "FAIL ") << what << "\n";
- };
- const auto bar = (double) lynx::ppq * 4.0;
- // ---- 1. Lyrics / Notes: the project's Comments
- {
- auto song = lynx::makeShowcaseSong (0);
- song.info.title = "Night Drive";
- song.info.comments = "[Intro]\n\n[5] [Verse 1]\n[5] Headlights on the empty road\n[7] Radio is playing low\n[9] Every sign says slow\n"
- "I keep driving through the night\n\n[Chorus]\nNight drive, night drive\nNothing but the white line\n\n"
- "Notes: double the chorus vocal, try the second verse an octave down.";
- lynx::Marker chorus;
- chorus.tick = (std::int64_t) (12.0 * bar);
- chorus.name = "Chorus";
- song.addMarker (chorus);
- offline.setSong (std::move (song));
- }
- note ("song set");
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- note ("show lyrics");
- ui.showLyrics (false);
- note ("lyrics shown");
- if (auto* panel = ui.getLyricsPanelForSnapshot())
- {
- panel->showForSnapshot ({}, 6.5 * bar); // the playhead inside bar 7: that line is the one playing
- shoot (ui, "lyrics-pattern");
- shoot (*panel, "lyrics-panel");
- const auto markersBefore = offline.getSong().markers().size();
- panel->setCaretLineForSnapshot (6); // "I keep driving through the night"
- panel->markAtPlayheadForSnapshot (10.0 * bar + 2.0 * lynx::ppq);
- offline.dispatchPendingMessages();
- ui.commitSongNotes();
- const auto& s = offline.getSong();
- check ("Marker at playhead stamps the line [11.3] and adds one marker",
- juce::String::fromUTF8 (s.info.comments.c_str()).contains ("[11.3] I keep driving") && s.markers().size() == markersBefore + 1);
- // (no audio device here: the seek is the request the audio thread takes at its next block)
- const auto& seek = offline.getTransport().seekRequest;
- check ("clicking the stamped line moves the playhead to bar 7", panel->jumpToLineForSnapshot (4) && std::abs (seek.load() - 6.0 * bar) < 1.0);
- check ("clicking [Chorus] (no position) goes to the marker of that name, bar 13",
- panel->jumpToLineForSnapshot (8) && std::abs (seek.load() - 12.0 * bar) < 1.0);
- check ("a line without a position does not jump", ! panel->jumpToLineForSnapshot (9));
- panel->showForSnapshot ("night", 10.5 * bar);
- shoot (*panel, "lyrics-search");
- // the text travels in the project file, and old readers see it as the Comments they always had
- juce::String error;
- const auto json = lynx::ProjectFile::toJson (offline.getSong());
- const auto back = lynx::ProjectFile::fromJson (json, error);
- check ("lyrics round-trip through .lynx (the Comments field)", back.has_value() && back->info.comments == offline.getSong().info.comments);
- const auto text = lynx::lyrics::exportText (offline.getSong(), lynx::lyrics::Stamps::times);
- juce::File (prefix + "-lyrics-export.txt").replaceWithText (juce::String::fromUTF8 (text.c_str()));
- check ("export as text with times", text.find ("[0:") != std::string::npos);
- panel->showForSnapshot ({}, 6.5 * bar);
- }
- else
- check ("the docked Lyrics panel exists", false);
- {
- const auto names = ui.getMenuNamesForSnapshot();
- const auto view = names.indexOf (lynx::tr ("View"));
- saveMenus (juce::StringArray { lynx::tr ("View") }, std::vector<juce::PopupMenu> { ui.getMenuForSnapshot (juce::jmax (0, view)) }, prefix + "-menu-view.png");
- }
- ui.showDesktopForSnapshot (false);
- check ("the panel stays docked beside the Playlist in the default desktop", ui.isLyricsShowing());
- shoot (ui, "lyrics-desktop");
- // ---- the Simple layout: the Lyrics button in its title tools, the chooser's "Start from" link
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2); // (the Playlist alone, as --simpleshot shows the layout)
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- check ("the Simple workflow exists", simple != nullptr);
- if (simple != nullptr)
- {
- simple->hideChooser();
- if (! ui.isLyricsShowing())
- ui.showLyrics (false);
- shoot (ui, "lyrics-simple");
- ui.hideLyrics();
- check ("closing the panel keeps the text", juce::String::fromUTF8 (offline.getSong().info.comments.c_str()).contains ("Night drive, night drive"));
- // ---- 4. Clean voice: on a voice track, from the track's menu
- lynx::simpletracks::Result voice;
- offline.editSongStructural ([&voice] (lynx::Song& s) {
- lynx::simpletracks::Request q;
- q.kind = lynx::simpletracks::Kind::voice;
- q.name = "Lead vocal";
- voice = lynx::simpletracks::addTrack (s, q);
- });
- offline.dispatchPendingMessages();
- check ("a voice track was added", voice.insert > 0);
- if (voice.insert > 0)
- {
- auto menu = ui.getPlaylistForSnapshot().getTrackMenuForSnapshot (voice.track);
- juce::StringArray names { "Track" };
- std::vector<juce::PopupMenu> menus { menu };
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == lynx::tr ("Clean voice"))
- {
- names.add (lynx::tr ("Clean voice"));
- menus.push_back (*it.getItem().subMenu);
- }
- check ("the Simple track menu has Clean voice", menus.size() == 2);
- saveMenus (names, menus, prefix + "-cleanvoice-menu.png");
- const auto before = offline.getSong().mixer[(std::size_t) voice.insert].effects.size();
- check ("Clean voice applies", lynx::ui::applyCleanVoice (offline, voice.insert, false));
- offline.dispatchPendingMessages();
- const auto& fx = offline.getSong().mixer[(std::size_t) voice.insert].effects;
- check ("four slots in front of the track's effects", fx.size() == before + 4 && lynx::cleanvoice::slotsOf (offline.getSong(), voice.insert).size() == 4
- && fx[0].kind == lynx::EffectKind::facetEq);
- check ("with noise reduction: five, none doubled", lynx::ui::applyCleanVoice (offline, voice.insert, true)
- && offline.getSong().mixer[(std::size_t) voice.insert].effects.size() == before + 5);
- offline.dispatchPendingMessages();
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (offline.getSong()), error);
- check ("the chain round-trips through .lynx and is still found", back.has_value() && lynx::cleanvoice::slotsOf (*back, voice.insert).size() == 5
- && back->mixer[(std::size_t) voice.insert].effects == offline.getSong().mixer[(std::size_t) voice.insert].effects);
- saveMenus (juce::StringArray { lynx::tr ("Clean voice") }, std::vector<juce::PopupMenu> { lynx::ui::cleanVoiceMenu (offline, voice.insert) },
- prefix + "-cleanvoice-menu-on.png");
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- offline.dispatchPendingMessages();
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::mixer });
- ui.selectMixerTrackForSnapshot (voice.insert);
- shoot (ui, "cleanvoice-mixer");
- offline.undo(); // the second chain
- offline.dispatchPendingMessages();
- check ("undo brings the first chain back", lynx::cleanvoice::slotsOf (offline.getSong(), voice.insert).size() == 4);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2); // (the Playlist alone, as --simpleshot shows the layout)
- simple = ui.getSimpleWorkflowForSnapshot();
- }
- }
- // ---- 2. Reference match: the song's Master render against a file (pink noise with more top, at about -14 LUFS)
- {
- const auto file = juce::File (prefix + "-reference.wav");
- file.deleteFile();
- const auto rate = 44100.0;
- const auto frames = (int) (20.0 * rate);
- juce::AudioBuffer<float> audio (2, frames);
- juce::Random random (190);
- for (int ch = 0; ch < 2; ++ch)
- {
- double b0 = 0, b1 = 0, b2 = 0, hp = 0;
- for (int i = 0; i < frames; ++i)
- {
- const auto w = (double) random.nextFloat() * 2.0 - 1.0;
- b0 = 0.99765 * b0 + w * 0.0990460;
- b1 = 0.96300 * b1 + w * 0.2965164;
- b2 = 0.57000 * b2 + w * 1.0526913;
- const auto pink = (b0 + b1 + b2 + w * 0.1848) * 0.071; // (about -14 LUFS: a streaming master)
- hp += 0.25 * (pink - hp); // a little more top than pink noise has
- audio.setSample (ch, i, (float) (pink + 0.35 * (pink - hp)));
- }
- }
- if (auto out = file.createOutputStream())
- if (auto writer = std::unique_ptr<juce::AudioFormatWriter> (juce::WavAudioFormat().createWriterFor (out.get(), rate, 2, 24, {}, 0)))
- {
- out.release();
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- note ("measure reference");
- const auto reference = lynx::ReferenceMatchPanel::measureFile (offline, file);
- note ("measure song");
- const auto song = lynx::ReferenceMatchPanel::measureSong (offline.getSong(), false);
- check ("the reference file was measured", reference.valid);
- check ("the song's Master render was measured", song.valid);
- lynx::ReferenceMatchPanel panel (offline, {});
- panel.setSize (lynx::ReferenceMatchPanel::defaultWidth, lynx::ReferenceMatchPanel::defaultHeight);
- panel.showForSnapshot ("Reference.wav", song, reference, nullptr);
- shoot (panel, "refmatch-measured");
- const auto masterBefore = offline.getSong().mixer[0].effects.size();
- check ("Match adds its two slots at the end of the Master", panel.matchForSnapshot() && offline.getSong().mixer[0].effects.size() == masterBefore + 2);
- offline.dispatchPendingMessages();
- const auto first = lynx::ReferenceMatchPanel::measureSong (offline.getSong(), true);
- panel.showForSnapshot ("Reference.wav", song, reference, &first);
- panel.refresh();
- shoot (panel, "refmatch-matched");
- report << " first Match: " << juce::String (first.lufs, 2) << " LUFS, " << juce::String (first.truePeakDb, 2) << " dBTP, EQ output "
- << juce::String (lynx::facet::outputDb (offline.getSong().mixer[0].effects[masterBefore].params[(std::size_t) lynx::facet::outputParam]), 2) << " dB\n";
- // a result more than 0.5 LU from the reference (a limiter that has to hold peaks back): Match again takes
- // what is missing, as the window's note says
- auto after = first;
- const auto secondPass = std::abs (first.lufs - reference.lufs) > 0.5;
- if (secondPass)
- {
- check ("Match again replaces the two slots (level corrected)", panel.matchForSnapshot() && offline.getSong().mixer[0].effects.size() == masterBefore + 2);
- offline.dispatchPendingMessages();
- after = lynx::ReferenceMatchPanel::measureSong (offline.getSong(), true);
- panel.showForSnapshot ("Reference.wav", song, reference, &after);
- panel.refresh();
- shoot (panel, "refmatch-matched-again");
- }
- report << " " << (secondPass ? "a second Match was needed for the level" : "one Match was enough for the level") << "\n";
- const auto& s = panel.suggestionForSnapshot();
- report << " song " << juce::String (song.lufs, 2) << " LUFS, " << juce::String (song.truePeakDb, 2) << " dBTP, width " << juce::String (song.widthPercent(), 1)
- << " % | reference " << juce::String (reference.lufs, 2) << " LUFS, " << juce::String (reference.truePeakDb, 2) << " dBTP, width "
- << juce::String (reference.widthPercent(), 1) << " % | after " << juce::String (after.lufs, 2) << " LUFS, " << juce::String (after.truePeakDb, 2)
- << " dBTP\n next suggestion: gain " << juce::String (s.gainDb, 2) << " dB, EQ fit error " << juce::String (s.fitErrorDb, 2) << " dB\n";
- double before = 0.0, now = 0.0;
- int counted = 0;
- {
- // tone only (each curve around its own mean), over the bands both hold
- double ms = 0, mr = 0, ma = 0;
- const auto used = juce::jmin (song.usedBands, reference.usedBands);
- for (int k = 0; k < used; ++k)
- ms += song.spectrumDb[(std::size_t) k], mr += reference.spectrumDb[(std::size_t) k], ma += after.spectrumDb[(std::size_t) k];
- for (int k = 2; k < used; ++k, ++counted)
- {
- before += std::abs ((song.spectrumDb[(std::size_t) k] - ms / used) - (reference.spectrumDb[(std::size_t) k] - mr / used));
- now += std::abs ((after.spectrumDb[(std::size_t) k] - ma / used) - (reference.spectrumDb[(std::size_t) k] - mr / used));
- }
- }
- report << " mean tone difference to the reference: " << juce::String (before / juce::jmax (1, counted), 2) << " dB before, "
- << juce::String (now / juce::jmax (1, counted), 2) << " dB after one Match (each band moves 6 dB at most)\n";
- check ("after Match the tone is closer to the reference", after.valid && now < before);
- check ("after Match the loudness is within 1 LU of the reference", std::abs (after.lufs - reference.lufs) < 1.0);
- check ("the limiter holds the peaks: under 0 dBTP, within 0.6 dB of its -1 dB ceiling", after.truePeakDb < 0.0 && after.truePeakDb <= -1.0 + 0.6);
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (offline.getSong()), error);
- check ("the match round-trips through .lynx as two ordinary Master slots", back.has_value() && lynx::refmatch::present (*back)
- && back->mixer[0].effects == offline.getSong().mixer[0].effects);
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- offline.dispatchPendingMessages();
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::mixer });
- ui.selectMixerTrackForSnapshot (0);
- shoot (ui, "refmatch-mixer");
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2); // (the Playlist alone, as --simpleshot shows the layout)
- simple = ui.getSimpleWorkflowForSnapshot();
- if (simple != nullptr)
- {
- simple->hideChooser();
- simple->showFinish();
- shoot (ui, "finish-dock"); // "Match a reference track..." under the saving buttons
- simple->hideFinish();
- }
- file.deleteFile();
- }
- // ---- 3. Start from: the chooser's link, the list, and opening an entry
- if (simple != nullptr)
- {
- simple->showChooser();
- shoot (ui, "chooser");
- simple->hideChooser();
- auto* panel = dynamic_cast<lynx::StartFromPanel*> (simple->startFromForSnapshot());
- check ("the Start from list opens", panel != nullptr && simple->isStartFromShowing());
- if (panel != nullptr)
- {
- shoot (ui, "startfrom");
- auto list = lynx::startfrom::entries();
- check ("it lists the demo song and the templates shipped", list.size() >= 3 && list[0].kind == lynx::startfrom::Entry::Kind::demo
- && (int) list.size() == panel->entryCountForSnapshot());
- for (auto& e : list)
- report << " " << e.name << " | " << juce::String (e.bpm, 0) << " BPM, " << e.channels << " channels, " << e.bars << " bars"
- << (e.playable ? ", preview" : "") << "\n";
- if (const auto demo = lynx::startfrom::songOf (list[0]))
- {
- const auto wav = juce::File (prefix + "-preview.wav");
- const auto ok = lynx::startfrom::renderPreview (*demo, wav);
- check ("the demo's preview renders (" + juce::String (wav.getSize() / 1024) + " kB)", ok && wav.getSize() > 100000);
- wav.deleteFile();
- }
- panel->selectForSnapshot (juce::jmin (2, panel->entryCountForSnapshot() - 1));
- shoot (ui, "startfrom-selected");
- offline.markSaved(); // (a project with changes asks first: Save / Don't save / Cancel)
- const auto opened = panel->openForSnapshot (0);
- offline.dispatchPendingMessages();
- check ("opening the demo starts a new project from it and closes the list",
- opened && ! simple->isStartFromShowing() && offline.getSong().info.comments.empty() && ! offline.getSong().channels.empty());
- shoot (ui, "startfrom-opened");
- }
- }
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- void runVersionsShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const auto shoot = [&prefix] (juce::Component& c, const char* name) {
- savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png");
- };
- // ---- the Versions panel, on files in a temporary folder
- const auto root = juce::File::getSpecialLocation (juce::File::tempDirectory)
- .getChildFile ("lynx-versionsshot-" + juce::String::toHexString (juce::Random::getSystemRandom().nextInt64()));
- const juce::ScopeGuard cleanUp { [&root] { root.deleteRecursively(); } };
- const auto project = root.getChildFile ("Night Drive"), backup = root.getChildFile ("Backup");
- project.createDirectory();
- backup.createDirectory();
- const auto now = juce::Time::getCurrentTime();
- const auto put = [&now] (const juce::File& folder, const juce::String& name, const char* kind, int kilobytes, double hoursAgo) {
- const auto time = now - juce::RelativeTime::hours (hoursAgo);
- const auto file = folder.getChildFile (kind == nullptr ? name + ".lynx" : name + " (" + kind + " on " + time.formatted ("%Y-%m-%d at %Hh%M") + ").lynx");
- juce::MemoryBlock data ((size_t) kilobytes * 1024, true);
- file.replaceWithData (data.getData(), data.getSize());
- file.setLastModificationTime (time);
- };
- put (project, "Night Drive", nullptr, 412, 26.0 * 24.0);
- put (project, "Night Drive_2", nullptr, 688, 9.0 * 24.0);
- put (project, "Night Drive_3", nullptr, 731, 2.0 * 24.0);
- put (project, "Night Drive_4", nullptr, 905, 1.6);
- put (backup, "Night Drive_4", "autosaved", 907, 0.07);
- put (backup, "Night Drive_4", "autosaved", 906, 0.4);
- put (backup, "Night Drive_4", "overwritten", 890, 1.6);
- put (backup, "Night Drive_4", "autosaved", 884, 3.2);
- put (backup, "Night Drive_3", "overwritten", 720, 2.0 * 24.0);
- put (backup, "Night Drive_2", "autosaved", 690, 8.0 * 24.0);
- const lynx::VersionsContext context { project.getChildFile ("Night Drive_4.lynx"), "Night Drive_4", backup, ".lynx" };
- {
- const auto entries = lynx::versionEntries (context);
- const auto label = [&] (const juce::String& startsWith, const char* text) {
- for (const auto& e : entries)
- if (juce::String::fromUTF8 (e.name.c_str()).startsWith (startsWith))
- {
- lynx::setVersionLabel (context, e, text);
- return;
- }
- };
- label ("Night Drive_2", "first full arrangement");
- label ("Night Drive_3", "sent to the singer");
- label ("Night Drive_4 (autosaved", "new bass line");
- }
- {
- lynx::VersionsActions actions;
- actions.context = [context] { return context; };
- auto panel = lynx::makeVersionsPanel (actions);
- shoot (*panel, "versions");
- lynx::VersionsActions fresh;
- fresh.context = [backup] { return lynx::VersionsContext { juce::File(), "Untitled", backup, ".lynx" }; };
- auto empty = lynx::makeVersionsPanel (fresh);
- shoot (*empty, "versions-unsaved");
- }
- // ---- the window
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto saveFileMenu = [&] (const char* name) {
- const auto index = juce::jmax (0, ui.getMenuNamesForSnapshot().indexOf (lynx::tr ("File")));
- saveMenus (juce::StringArray { lynx::tr ("File") }, std::vector<juce::PopupMenu> { ui.getMenuForSnapshot (index) }, prefix + "-" + name + ".png");
- };
- saveFileMenu ("menu-file");
- // ---- a project opened without its third-party plugins (the plugins are not installed: nothing foreign runs)
- {
- const auto ref = [] (const char* id, const char* name) {
- lynx::PluginRef r;
- r.id = id;
- r.name = name;
- r.state = "c2V0dGluZ3M=";
- return r;
- };
- auto song = lynx::Song::makeDefault();
- while (song.channels.size() < 4)
- song.channels.push_back (song.channels.front());
- while (song.mixer.size() < 5)
- song.mixer.push_back (song.mixer.back());
- const char* names[] = { "Lead", "Pad" };
- for (int c = 0; c < 2; ++c)
- {
- auto& channel = song.channels[(std::size_t) (c + 2)];
- channel.instrument = lynx::InstrumentKind::plugin;
- channel.plugin = ref ("VST3-ShotSynth-11111111-aaaaaaaa", "Shot Synth");
- channel.name = names[c];
- channel.mixerTrack = c + 1;
- }
- lynx::EffectSlot fx;
- fx.kind = lynx::EffectKind::plugin;
- fx.plugin = ref ("VST3-ShotVerb-22222222-bbbbbbbb", "Shot Verb");
- song.mixer[1].effects.push_back (fx);
- fx.plugin = ref ("VST3-ShotComp-33333333-cccccccc", "Shot Comp");
- song.mixer[2].effects.push_back (fx);
- song.mixer[0].effects.push_back (fx);
- offline.setSongWithPluginsOff (std::move (song));
- ui.showDesktopForSnapshot (false);
- shoot (ui, "pluginsoff-window");
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::channelRack, lynx::workspace::Panel::mixer });
- shoot (ui, "pluginsoff-mixer"); // (the rack's and the mixer's "off" tags together)
- saveFileMenu ("menu-file-pluginsoff");
- auto panel = lynx::makePluginsOffPanel (offline);
- shoot (*panel, "pluginsoff-panel");
- offline.switchPluginOn ("VST3-ShotVerb-22222222-bbbbbbbb"); // (not installed: "Did not load")
- auto after = lynx::makePluginsOffPanel (offline);
- shoot (*after, "pluginsoff-panel-one");
- }
- // ---- the Export window: as it opens, and with a preset chosen, sections on and a last export to repeat
- {
- auto song = lynx::Song::makeDefault();
- const auto bar = song.barTicks();
- song.mode = lynx::PlayMode::song;
- song.playlist.clear();
- lynx::Clip clip;
- clip.length = 32 * bar;
- song.playlist.push_back (clip);
- const char* sections[] = { "Intro", "Verse", "Chorus", "Outro" };
- for (int i = 0; i < 4; ++i)
- {
- lynx::Marker m;
- m.tick = i * 8 * bar;
- m.name = sections[i];
- song.addMarker (m);
- }
- offline.setSong (std::move (song)); // (also ends the plugins-off mode)
- auto plain = lynx::makeExportPanel (offline, 0);
- shoot (*plain, "export-default");
- auto additions = lynx::makeExportPanelWithAdditions (offline);
- shoot (*additions, "export");
- }
- }
- // Round 190ox (modulators stage 2): the Modulators window with one modulator of each kind (the LFO in Assign mode),
- // a native effect editor and the LYNX Synth page with modulation rings, the parameter menu's "Modulate with"
- // submenu; checks in prefix-checks.txt. --shot-scale 1.5 --shot-suffix @150 for the 150 % pictures.
- void runModShot190ox (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
- juce::String checks;
- int failures = 0;
- const auto flush = [&] { juce::File (lynx::shot::file (juce::File (prefix + "-checks.txt"))).replaceWithText (checks + (failures == 0 ? "ALL OK\n" : juce::String (failures) + " FAILED\n")); };
- const auto check = [&] (const juce::String& what, bool ok) {
- checks << (ok ? "ok " : "FAIL ") << what << "\n";
- failures += ok ? 0 : 1;
- flush();
- };
- lynx::AudioEngine offline (false);
- lynx::modring::setEngine (&offline);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- const auto write = [&prefix, &settle] (juce::Component& c, const juce::String& name) {
- settle();
- savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png");
- };
- using namespace lynx;
- offline.editSong ([] (Song& s) {
- if (s.channels.size() < 2)
- s.channels.resize (2);
- s.channels[0].name = "Kick";
- s.channels[0].instrument = InstrumentKind::sampler;
- s.channels[0].mixerTrack = 1;
- s.channels[1].name = "Keys";
- s.channels[1].instrument = InstrumentKind::synth;
- s.channels[1].mixerTrack = 2;
- if (s.mixer.size() < 4)
- s.mixer.resize (4);
- s.mixer[1].name = "Kick";
- s.mixer[2].name = "Keys";
- s.mixer[2].effects.clear();
- s.mixer[2].effects.push_back (makeEffectSlot (EffectKind::filter));
- s.mixer[2].effects.push_back (makeEffectSlot (EffectKind::delay));
- const AutomationTarget cutoff { AutomationTargetKind::effectParam, 2, 0, 1 }, res { AutomationTargetKind::effectParam, 2, 0, 2 }; // (the Filter's Cutoff, Reso.)
- const AutomationTarget synthCutoff { AutomationTargetKind::channelParam, 1, 0, synthparam::target (synthparam::cutoff) };
- const AutomationTarget synthRes { AutomationTargetKind::channelParam, 1, 0, synthparam::target (synthparam::resonance) };
- s.modulators.clear();
- auto add = [&s] (ModKind kind, const char* name, AutomationTarget host, std::vector<ModRoute> routes) {
- auto m = Modulator::make (kind);
- m.name = name;
- m.host = host;
- m.routes = std::move (routes);
- s.modulators.push_back (m);
- return (int) s.modulators.size() - 1;
- };
- const AutomationTarget onKick { AutomationTargetKind::mixerVolume, 1, 0, 0 }, onKeys { AutomationTargetKind::channelVolume, 1, 0, 0 };
- add (ModKind::lfo, "LFO 1", { AutomationTargetKind::mixerVolume, 2, 0, 0 }, { { cutoff, 0.3f }, { synthCutoff, 0.2f } });
- s.modulators.back().shape = ModShape::triangle;
- add (ModKind::follower, "Follower 1", onKick, { { cutoff, -0.4f } });
- s.modulators.back().input = { AutomationTargetKind::mixerVolume, 1, 0, 0 };
- add (ModKind::envelope, "Envelope 1", onKeys, { { synthRes, 0.35f } });
- add (ModKind::steps, "Steps 1", { AutomationTargetKind::mixerVolume, 2, 0, 0 }, { { res, 0.25f } });
- add (ModKind::random, "Random 1", onKeys, { { synthCutoff, -0.15f } });
- s.modulators.back().smooth = 0.5f;
- add (ModKind::macro, "Macro 1", onKeys, { { synthRes, 0.2f }, { { AutomationTargetKind::effectParam, 2, 1, 0 }, 0.3f } });
- s.modulators.back().macro = 0.4f;
- add (ModKind::keytrack, "Keytrack 1", onKeys, { { synthCutoff, 0.1f } });
- add (ModKind::velocity, "Velocity 1", onKeys, {});
- }, false);
- settle();
- modring::setArmed (0);
- // the Modulators window's panel, tall enough for every row
- {
- auto panel = makeModulatorsPanel (offline);
- panel->setSize (900, 1500);
- settle();
- write (*panel, "modulators");
- }
- modring::setArmed (0); // (the panel ends Assign mode when it goes)
- // a native editor's knobs with their rings (the filter's cutoff: LFO 1 armed, Follower 1)
- {
- modring::Ring ring;
- check ("ring on the filter's cutoff: 2 routes, the armed one first",
- modring::ringFor ({ AutomationTargetKind::effectParam, 2, 0, 1 }, ring) && ring.count == 2 && ring.armedRoute == 0);
- if (auto editor = makeNativeEffectEditor (offline, 2, 0))
- write (*editor, "filter-rings");
- if (auto editor = makeNativeEffectEditor (offline, 2, 1))
- write (*editor, "delay-rings");
- modring::setArmed (-1);
- if (auto editor = makeNativeEffectEditor (offline, 2, 0))
- write (*editor, "filter-rings-unarmed");
- }
- // the LYNX Synth page: its tagged knobs show rings
- {
- auto page = makeChannelSettingsPanel (offline, 1);
- page->setSize (juce::jmax (page->getWidth(), 760), juce::jmax (page->getHeight(), 520));
- write (*page, "synth-rings");
- }
- // the parameter menu: the Modulate with submenu of a knob (the routed ones ticked, a new one of each kind)
- {
- juce::PopupMenu menu;
- addAutomationItem (menu, offline, { AutomationTargetKind::effectParam, 2, 0, 1 }, true);
- juce::PopupMenu modulate;
- juce::StringArray rows;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == tr ("Modulate with"))
- modulate = *it.getItem().subMenu;
- for (juce::PopupMenu::MenuItemIterator it (modulate); it.next();)
- rows.add (it.getItem().text);
- check ("Modulate with: the routed ones and a new one of each kind (" + rows.joinIntoString (" | ") + ")",
- rows.size() >= 8 + 8 + 1 && rows.contains (tr ("New {0}", { tr ("Envelope follower") })));
- saveMenus (juce::StringArray { "Parameter menu", "Modulate with" }, std::vector<juce::PopupMenu> { menu, modulate },
- prefix + "-menu.png");
- }
- modring::setEngine (nullptr);
- flush();
- }
- void runGapShot190og (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
- juce::String checks;
- int failures = 0;
- const auto flush = [&] { juce::File (lynx::shot::file (juce::File (prefix + "-checks.txt"))).replaceWithText (checks + (failures == 0 ? "ALL OK\n" : juce::String (failures) + " FAILED\n")); };
- const auto check = [&] (const juce::String& what, bool ok) {
- checks << (ok ? "ok " : "FAIL ") << what << "\n";
- failures += ok ? 0 : 1;
- flush();
- };
- const auto line = [&] (const juce::String& what) { checks << " " << what << "\n"; flush(); };
- const auto menuRows = [] (const juce::PopupMenu& menu) {
- juce::StringArray rows;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- rows.add (it.getItem().isSeparator ? juce::String ("--") : (it.getItem().isEnabled ? "" : "(off) ") + it.getItem().text.replace ("\t", " | "));
- return rows;
- };
- const auto itemOf = [] (const juce::PopupMenu& menu, const juce::String& start) -> const juce::PopupMenu::Item* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (! it.getItem().isSeparator && it.getItem().text.startsWith (start))
- return &it.getItem();
- return nullptr;
- };
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- const auto write = [&prefix, &settle] (juce::Component& c, const juce::String& name) {
- settle();
- savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png");
- };
- const auto area = [&prefix, &settle] (juce::Component& c, juce::Rectangle<int> r, const juce::String& name) {
- settle();
- savePng (lynx::shot::snapshot (c).getClippedImage ((r.toFloat() * lynx::shot::scale()).toNearestInt()), prefix + "-" + name + ".png");
- };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = true;
- lynx::DetailView::devicesPage = true;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- const auto bar = 4 * lynx::ppq;
- offline.editSong ([bar] (lynx::Song& s) {
- if (s.channels.size() < 1)
- s.channels.resize (1);
- s.channels[0].name = "Keys";
- s.channels[0].instrument = lynx::InstrumentKind::synth;
- s.channels[0].mixerTrack = 2;
- if (s.mixer.size() < 4)
- s.mixer.resize (4);
- s.mixer[2].name = "Keys";
- s.mixer[2].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::compressor, lynx::EffectKind::delay })
- s.mixer[2].effects.push_back (lynx::makeEffectSlot (kind));
- while (s.patterns.size() < 1)
- s.patterns.emplace_back();
- auto& p = s.patterns[0];
- p.name = "Chords";
- p.notes.clear();
- // a one-bar loop with a rising line; a note crossing the loop's end and one after it (Duplicate Loop / Crop)
- const int keys[] { 60, 64, 67, 72, 71, 67, 64, 62 };
- for (int i = 0; i < 8; ++i)
- {
- lynx::Note n;
- n.channel = 0;
- n.key = keys[i];
- n.start = i * (bar / 8);
- n.length = bar / 8 - 60;
- n.velocity = (float) (40 + i * 10) / 127.0f;
- p.notes.push_back (n);
- }
- lynx::Note tail;
- tail.channel = 0;
- tail.key = 55;
- tail.start = bar + lynx::ppq;
- tail.length = lynx::ppq;
- p.notes.push_back (tail);
- p.lengthTicks = 2 * bar;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 3));
- s.playlistTracks[1].name = "Keys";
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = bar;
- lynx::launcher::setClip (s, 1, 0, clip);
- if (auto* c = const_cast<lynx::Clip*> (lynx::launcher::clipAt (*s.clipGrid, 1, 0)))
- c->offset = 0, c->length = bar; // (a one-bar loop over the two-bar pattern)
- }, false);
- settle();
- ui.resized();
- auto* detail = ui.getDetailViewForSnapshot();
- auto* grid = ui.getClipGridForSnapshot();
- if (detail == nullptr || grid == nullptr)
- {
- check ("the Clip-launch layout has its detail view and grid", false);
- return;
- }
- const auto editMenu = [&ui] {
- const auto names = ui.getMenuNamesForSnapshot();
- return ui.getMenuForSnapshot (juce::jmax (0, names.indexOf (lynx::tr ("Edit"))));
- };
- const auto fxNames = [&offline] {
- juce::StringArray names;
- for (const auto& fx : offline.getSong().mixer[2].effects)
- names.add (juce::String ((int) fx.kind));
- return names.joinIntoString (",");
- };
- // --- deviceview-0012: the Edit menu's Live block on the Device View ---------------------------------------------
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- settle();
- detail->selectCardForCheck (2); // (card 0 the instrument, 1 the EQ, 2 the Compressor)
- settle();
- write (ui, "01-devices-window");
- write (*detail, "01b-devices");
- {
- const auto menu = editMenu();
- saveMenus (juce::StringArray { lynx::tr ("Edit") }, std::vector<juce::PopupMenu> { menu }, prefix + "-02-edit-menu-device.png");
- line ("Edit menu: " + menuRows (menu).joinIntoString (" // "));
- const auto* cut = itemOf (menu, lynx::tr ("Cut") + "\t");
- const auto* paste = itemOf (menu, lynx::tr ("Paste") + "\t");
- check ("Edit menu (Clip-launch): Live's Cut | Ctrl+X, Copy, Paste, Duplicate, Delete | Del after Undo / Redo",
- cut != nullptr && cut->text.endsWith ("Ctrl+X") && itemOf (menu, lynx::tr ("Copy") + "\tCtrl+C") != nullptr
- && paste != nullptr && itemOf (menu, lynx::tr ("Duplicate") + "\tCtrl+D") != nullptr && itemOf (menu, lynx::tr ("Delete") + "\tDel") != nullptr
- && menuRows (menu).indexOf ("--") < menuRows (menu).indexOf (lynx::tr ("Cut") + " | Ctrl+X"));
- check ("a selected device: Cut / Copy / Duplicate / Delete on, Paste off with nothing copied", cut != nullptr && cut->isEnabled && paste != nullptr && ! paste->isEnabled);
- }
- const auto invoke = [&] (const juce::String& start) {
- const auto menu = editMenu();
- if (const auto* item = itemOf (menu, start); item != nullptr && item->isEnabled && item->action != nullptr)
- {
- item->action();
- settle();
- return true;
- }
- return false;
- };
- line ("effects before: " + fxNames());
- check ("Edit > Copy on the Compressor", invoke (lynx::tr ("Copy") + "\t"));
- detail->selectCardForCheck (3); // the Delay
- settle();
- check ("Edit > Paste with the Delay selected: in front of it (Live: \"Pasted devices are inserted in front of the selected device\")",
- invoke (lynx::tr ("Paste") + "\t") && fxNames() == juce::String ((int) lynx::EffectKind::eq) + "," + juce::String ((int) lynx::EffectKind::compressor) + ","
- + juce::String ((int) lynx::EffectKind::compressor) + "," + juce::String ((int) lynx::EffectKind::delay));
- line ("effects after Paste: " + fxNames());
- write (*detail, "03-devices-after-paste");
- check ("Edit > Duplicate", invoke (lynx::tr ("Duplicate") + "\t") && offline.getSong().mixer[2].effects.size() == 5);
- check ("Edit > Delete", invoke (lynx::tr ("Delete") + "\t") && offline.getSong().mixer[2].effects.size() == 4);
- detail->selectCardForCheck (2); // (Delete left nothing selected)
- settle();
- check ("Edit > Cut", invoke (lynx::tr ("Cut") + "\t") && offline.getSong().mixer[2].effects.size() == 3);
- line ("effects after Duplicate, Delete, Cut: " + fxNames());
- // the Pattern layout keeps FL's Edit menu
- ui.setClipLaunchWorkflow (false);
- settle();
- check ("the Pattern layout's Edit menu has no Live block", itemOf (editMenu(), lynx::tr ("Cut") + "\t") == nullptr);
- ui.setClipLaunchWorkflow (true);
- settle();
- ui.resized();
- // --- detail-019: the Clip panel's Duplicate (Loop) button ------------------------------------------------------
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::clip);
- detail->setClipTab (false);
- lynx::DetailView::devicesPage = false;
- detail->clipSectionsForSnapshot (true, true, true, 0);
- settle();
- ui.resized();
- write (ui, "04-clip-window");
- write (*detail, "04b-clip-detail");
- const auto clipNow = [&offline] () -> lynx::Clip {
- const auto& g = offline.getSong().clipGrid;
- const auto* c = g ? lynx::launcher::clipAt (*g, 1, 0) : nullptr;
- return c != nullptr ? *c : lynx::Clip();
- };
- const auto noteCount = [&offline] { return (int) offline.getSong().patterns[0].notes.size(); };
- // (the grid keeps a MIDI clip as long as its pattern: the loop is the pattern's two bars, all 9 notes inside it)
- const auto loopBefore = clipNow().length;
- int inLoop = 0;
- for (const auto& n : offline.getSong().patterns[0].notes)
- inLoop += n.start >= clipNow().offset && n.start < clipNow().offset + loopBefore ? 1 : 0;
- const auto lastBefore = offline.getSong().patterns[0].notes.back().start;
- line ("before: loop " + juce::String (clipNow().offset) + " + " + juce::String (loopBefore) + ", " + juce::String (noteCount()) + " notes, "
- + juce::String (inLoop) + " in the loop");
- check ("the clip is a MIDI clip with 9 notes in its pattern", loopBefore > 0 && noteCount() == 9);
- check ("the Duplicate button pressed", detail->duplicateLoopForCheck());
- settle();
- line ("after Duplicate Loop: loop " + juce::String (clipNow().offset) + " + " + juce::String (clipNow().length) + ", " + juce::String (noteCount()) + " notes, last at "
- + juce::String (offline.getSong().patterns[0].notes.back().start));
- check ("Duplicate Loop: the loop twice as long, the notes in it copied one loop later",
- clipNow().length == 2 * loopBefore && noteCount() == 9 + inLoop && offline.getSong().patterns[0].notes.back().start == lastBefore + loopBefore);
- write (*detail, "05-clip-after-duplicate-loop");
- check ("one undo step brings the one-bar loop back", [&] { ui.runActionForSnapshot ("edit.undo"); settle(); return clipNow().length == loopBefore && noteCount() == 9; }());
- // --- detail-047: the Velocity lane's Randomize footer ---------------------------------------------------------
- auto& roll = ui.getPianoRollForSnapshot();
- roll.setLaneForSnapshot (lynx::PianoRollComponent::laneVelocity);
- settle();
- ui.resized();
- settle();
- const auto footer = roll.liveRandomizeBoundsForCheck();
- line ("roll " + roll.getBounds().toString() + ", footer " + juce::String (roll.liveFooterHeight()) + " px, Randomize " + footer.toString());
- check ("the docked roll (Live look) shows Live's Velocity footer with Randomize", roll.liveFooterHeight() == lynx::PianoRollComponent::liveFooterBar && ! footer.isEmpty());
- write (ui, "06-velocity-footer-window");
- if (roll.getParentComponent() != nullptr)
- area (roll, roll.getLocalBounds().removeFromBottom (90), "06b-velocity-footer");
- {
- std::vector<float> before;
- for (const auto& n : offline.getSong().patterns[0].notes)
- before.push_back (n.velocity);
- lynx::PianoRollComponent::liveRandomizeAmount = 20;
- roll.liveRandomizeVelocity();
- settle();
- int moved = 0, within = 0;
- const auto& notes = offline.getSong().patterns[0].notes;
- for (std::size_t i = 0; i < notes.size() && i < before.size(); ++i)
- {
- const auto d = std::abs (juce::roundToInt (notes[i].velocity * 127.0f) - juce::roundToInt (before[i] * 127.0f));
- moved += d > 0 ? 1 : 0;
- within += d <= 20 ? 1 : 0;
- }
- line ("Randomize (amount 20, nothing selected): " + juce::String (moved) + " of " + juce::String ((int) notes.size()) + " notes moved");
- check ("Randomize with nothing selected moves the notes' velocities by at most the amount", moved > 0 && within == (int) notes.size());
- lynx::PianoRollComponent::liveRandomizeAmount = 100;
- write (ui, "07-velocity-after-randomize");
- }
- // --- detail-020: Crop Clip in the clip's menu and on Ctrl+Shift+J ---------------------------------------------
- {
- const auto menu = lynx::clipGridSlotMenu (*grid, 1, 0);
- saveMenus (juce::StringArray { "Clip" }, std::vector<juce::PopupMenu> { menu }, prefix + "-08-clip-menu.png");
- line ("clip menu: " + menuRows (menu).joinIntoString (" // "));
- const auto rows = menuRows (menu);
- const auto crop = rows.indexOf (lynx::tr ("Crop Clip") + " | Ctrl+Shift+J");
- check ("the clip menu (Live look) has Crop Clip | Ctrl+Shift+J in its own group before the colours",
- crop > 0 && rows[crop - 1] == "--" && rows[crop + 1] == "--" && rows.indexOf (lynx::tr ("Deactivate Clip") + " | 0") < crop);
- }
- offline.editSong ([bar] (lynx::Song& s) {
- if (auto* c = s.clipGrid ? const_cast<lynx::Clip*> (lynx::launcher::clipAt (*s.clipGrid, 1, 0)) : nullptr)
- c->offset = bar / 2, c->length = bar / 2; // the loop on the second half bar
- });
- settle();
- lynx::selectClipGridSlotForSnapshot (*grid, 1, 0);
- const auto keyed = lynx::clipGridKeyForSnapshot (*grid, juce::KeyPress ('j', juce::ModifierKeys::commandModifier | juce::ModifierKeys::shiftModifier, 0));
- settle();
- juce::String kept;
- for (const auto& n : offline.getSong().patterns[0].notes)
- kept << n.start << ":" << n.key << " ";
- line ("after Ctrl+Shift+J: loop " + juce::String (clipNow().offset) + " + " + juce::String (clipNow().length) + ", notes " + kept);
- check ("Ctrl+Shift+J crops the clip: the half bar's 4 notes kept, moved to the start; the loop starts at 0",
- keyed && noteCount() == 4 && offline.getSong().patterns[0].notes.front().start == 0 && clipNow().offset == 0 && clipNow().length == bar / 2);
- write (*detail, "09-clip-after-crop");
- // --- mapping-0028: Key Map Mode on the transport switches -------------------------------------------------------
- {
- using namespace lynx::remotemap;
- offline.editSong ([] (lynx::Song& s) {
- assignKey (s, Target::of (lynx::RemoteAction::overdub), 'O');
- assignKey (s, Target::of (lynx::RemoteAction::loopSwitch), 'L');
- assignKey (s, Target::of (lynx::RemoteAction::punchIn), 'I');
- assignKey (s, Target::of (lynx::RemoteAction::punchOut), 'U');
- });
- settle();
- for (const auto mode : { Mode::key, Mode::midi })
- {
- ui.setMapMode (mode);
- settle();
- if (auto* overlay = ui.mapOverlayForSnapshot())
- {
- overlay->refresh();
- const auto& spots = overlay->spots();
- const auto count = [&spots] (lynx::RemoteAction a) { return (int) std::count_if (spots.begin(), spots.end(), [a] (const auto& sp) { return sp.target.action == a; }); };
- line (juce::String (mode == Mode::key ? "key" : "midi") + " map: " + juce::String ((int) spots.size()) + " spots; overdub " + juce::String (count (lynx::RemoteAction::overdub))
- + ", loop " + juce::String (count (lynx::RemoteAction::loopSwitch)) + ", punch in " + juce::String (count (lynx::RemoteAction::punchIn)) + ", punch out "
- + juce::String (count (lynx::RemoteAction::punchOut)));
- check (juce::String (mode == Mode::key ? "Key" : "MIDI") + " Map Mode: Arrangement Overdub, Loop, Punch-In and Punch-Out are mappable in the Control Bar",
- count (lynx::RemoteAction::overdub) == 1 && count (lynx::RemoteAction::loopSwitch) == 1 && count (lynx::RemoteAction::punchIn) == 1
- && count (lynx::RemoteAction::punchOut) == 1);
- }
- write (ui, mode == Mode::key ? "10-keymap" : "11-midimap");
- if (mode == Mode::key)
- area (ui, ui.getLocalBounds().removeFromTop (60), "10b-keymap-controlbar");
- if (mode == Mode::key)
- if (auto* browser = ui.mappingBrowserForSnapshot())
- write (*browser, "12-key-mappings-browser");
- }
- ui.setMapMode (Mode::off);
- settle();
- // the mapped keys switch them, and the mappings survive a save
- const auto options = [&offline] { return offline.getRecordOptions(); };
- const auto blend = options().mode;
- const auto loopBefore = offline.getSong().loopPlays();
- const auto inBefore = options().punchLoopRegion && options().punchIn;
- const auto press = [&] (int key) {
- for (const auto& f : keyFires (offline.getSong(), key, true))
- ui.fireRemote (f);
- settle();
- };
- press ('O');
- press ('L');
- press ('I');
- check ("the mapped keys switch Overdub, Loop and Punch-In", options().mode != blend && offline.getSong().loopPlays() != loopBefore
- && (options().punchLoopRegion && options().punchIn) != inBefore);
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (offline.getSong()), error);
- int kept4 = 0;
- if (back)
- for (const auto& m : back->remoteMappings)
- kept4 += m.action == lynx::RemoteAction::overdub || m.action == lynx::RemoteAction::loopSwitch || m.action == lynx::RemoteAction::punchIn
- || m.action == lynx::RemoteAction::punchOut ? 1 : 0;
- check ("the four mappings are saved with the project and read back", kept4 == 4);
- }
- flush();
- }
- void runUndoShot190mz (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String report;
- int failures = 0;
- const auto check = [&] (const juce::String& name, bool ok) {
- report << (ok ? "OK " : "FAIL ") << name << "\n";
- failures += ok ? 0 : 1;
- };
- {
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- engine.dispatchPendingMessages();
- // FL 2026's default: Ctrl+Z steps back
- check ("alternate undo mode is on by default (FL 2026)", ui.getAlternateUndo());
- const auto editMenuText = [&ui] {
- const auto names = ui.getMenuNamesForSnapshot();
- juce::StringArray rows;
- const auto menu = ui.getMenuForSnapshot (juce::jmax (0, names.indexOf (lynx::tr ("Edit"))));
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- if (it.getItem().isSeparator)
- break;
- rows.add ((it.getItem().isEnabled ? "" : "(off) ") + it.getItem().text.replace ("\t", " | "));
- }
- return rows;
- };
- const auto saveEditMenu = [&ui, &prefix] (const juce::String& name) {
- const auto names = ui.getMenuNamesForSnapshot();
- const auto index = juce::jmax (0, names.indexOf (lynx::tr ("Edit")));
- saveMenus (juce::StringArray { names[index] }, std::vector<juce::PopupMenu> { ui.getMenuForSnapshot (index) }, prefix + "-menu-" + name + ".png");
- };
- const auto key = [&ui, &engine] (const char* action) {
- ui.runActionForSnapshot (action);
- engine.dispatchPendingMessages();
- };
- const auto bpm = [&engine] { return engine.getSong().bpm; };
- const auto start = bpm();
- const auto swing0 = engine.getSong().swing;
- const auto log = [&] (const juce::String& state) {
- report << " " << state << ": bpm " << bpm() << ", level " << engine.getHistoryPosition() + 1 << "/" << engine.getHistorySize()
- << ", Edit menu: " << editMenuText().joinIntoString (" // ") << "\n";
- };
- log ("fresh");
- saveEditMenu ("pattern-0-fresh");
- engine.editSong ([] (lynx::Song& s) { s.bpm = 101.0; });
- engine.editSong ([] (lynx::Song& s) { s.swing = s.swing == 0.25f ? 0.5f : 0.25f; });
- engine.editSong ([] (lynx::Song& s) { s.bpm = 103.0; });
- engine.dispatchPendingMessages();
- log ("three edits");
- saveEditMenu ("pattern-1-three-edits");
- check ("menu names the step: Undo Tempo | Ctrl+Z, no Redo item (FL)",
- editMenuText()[0].startsWith (lynx::tr ("Undo {0}", { lynx::tr ("Tempo") })) && editMenuText()[0].contains ("Ctrl+Z")
- && ! editMenuText()[1].startsWith (lynx::tr ("Redo {0}", { lynx::tr ("Tempo") })));
- // the reporter's case (issue #214): Ctrl+Z pressed again keeps going back
- key ("edit.undo");
- log ("Ctrl+Z");
- saveEditMenu ("pattern-2-alt-ctrl-z");
- check ("alternate: menu shows Undo Swing | Ctrl+Z and Redo Tempo | Ctrl+Alt+Z (FL)",
- editMenuText()[0].startsWith (lynx::tr ("Undo {0}", { lynx::tr ("Swing") })) && editMenuText()[0].endsWith ("Ctrl+Z")
- && editMenuText()[1].startsWith (lynx::tr ("Redo {0}", { lynx::tr ("Tempo") })) && editMenuText()[1].endsWith ("Ctrl+Alt+Z"));
- key ("edit.undo");
- log ("Ctrl+Z x2");
- check ("alternate: Ctrl+Z twice goes two steps back (swing undone, bpm 101)", bpm() == 101.0 && engine.getSong().swing == swing0);
- key ("edit.undo");
- key ("edit.undo"); // (nothing left: nothing happens, no redo)
- log ("Ctrl+Z x4");
- check ("alternate: Ctrl+Z walks to the start and stops there", bpm() == start && ! engine.canUndo() && engine.canRedo());
- saveEditMenu ("pattern-3-alt-at-start");
- key ("edit.redo");
- check ("alternate: Ctrl+Y / Ctrl+Shift+Z redo one step", bpm() == 101.0);
- key ("edit.redo");
- key ("edit.redo");
- check ("alternate: redo back to the newest state", bpm() == 103.0 && ! engine.canRedo());
- key ("edit.undo");
- key ("edit.undoBackwards");
- check ("alternate: Ctrl+Alt+Z redoes what was undone (FL swaps the two keys)", bpm() == 103.0 && ! engine.canRedo());
- // FL's other mode: Ctrl+Z undoes, then redoes (the toggle the issue describes); Ctrl+Alt+Z walks back
- ui.setAlternateUndoForSnapshot (false);
- key ("edit.undo");
- log ("default mode, Ctrl+Z");
- saveEditMenu ("pattern-4-toggle-ctrl-z");
- check ("toggle mode: menu shows Undo Swing | Ctrl+Alt+Z and Redo Tempo | Ctrl+Z (FL)",
- editMenuText()[0].startsWith (lynx::tr ("Undo {0}", { lynx::tr ("Swing") })) && editMenuText()[0].endsWith ("Ctrl+Alt+Z")
- && editMenuText()[1].startsWith (lynx::tr ("Redo {0}", { lynx::tr ("Tempo") })) && editMenuText()[1].endsWith ("Ctrl+Z"));
- key ("edit.undo");
- log ("default mode, Ctrl+Z x2");
- check ("toggle mode: Ctrl+Z again redoes the step", bpm() == 103.0 && ! engine.canRedo());
- key ("edit.undoBackwards");
- key ("edit.undoBackwards");
- check ("toggle mode: Ctrl+Alt+Z walks back", bpm() == 101.0 && engine.getSong().swing == swing0);
- key ("edit.undo");
- check ("toggle mode: Ctrl+Z after walking back redoes one step (FL: position - 1)", engine.getSong().swing != swing0 && bpm() == 101.0);
- key ("edit.redo");
- check ("toggle mode: Ctrl+Y / Ctrl+Shift+Z redo", bpm() == 103.0 && ! engine.canRedo());
- // Clip-launch and Simple: Live's form (both items, "Nothing to redo", redo on Ctrl+Y)
- ui.setAlternateUndoForSnapshot (true);
- for (const auto style : { lynx::layoutstyle::Style::clipLaunch, lynx::layoutstyle::Style::simple })
- {
- const juce::String name = style == lynx::layoutstyle::Style::simple ? "simple" : "cliplaunch";
- ui.setLayoutStyle (style);
- engine.dispatchPendingMessages();
- log (name);
- saveEditMenu (name + "-1-newest");
- check (name + ": Undo Tempo | Ctrl+Z, Nothing to redo | Ctrl+Y",
- editMenuText()[0].startsWith (lynx::tr ("Undo {0}", { lynx::tr ("Tempo") })) && editMenuText()[0].endsWith ("Ctrl+Z")
- && editMenuText()[1].startsWith ("(off) " + lynx::tr ("Nothing to redo")) && editMenuText()[1].endsWith ("Ctrl+Y"));
- key ("edit.undo");
- key ("edit.undo");
- log (name + ", Ctrl+Z x2");
- saveEditMenu (name + "-2-ctrl-z-x2");
- check (name + ": Ctrl+Z twice goes two steps back", bpm() == 101.0 && engine.getSong().swing == swing0);
- key ("edit.redo");
- key ("edit.redo");
- check (name + ": Ctrl+Y redoes both", bpm() == 103.0 && ! engine.canRedo());
- }
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- engine.dispatchPendingMessages();
- }
- report << (failures == 0 ? "ALL OK\n" : juce::String (failures) + " FAILED\n");
- juce::File (prefix + "-checks.txt").replaceWithText (report);
- }
- void runGamepadShot (const juce::String& prefix)
- {
- juce::String report;
- int failures = 0;
- {
- lynx::AudioEngine engine (false);
- auto hints = lynx::makeGamepadHints();
- savePng (lynx::shot::snapshot (*hints), prefix + "-hints.png");
- auto prefs = engine.getMidiPrefs();
- prefs.gamepad = true;
- engine.setMidiPrefs (prefs, false);
- auto page = lynx::makeMidiPage (engine, {}, false);
- page->setSize (760, 1400);
- savePng (lynx::shot::snapshot (*page), prefix + "-settings.png");
- // the poller with fake states: what the handler gets
- using namespace lynx::gamepad;
- std::vector<std::string> got;
- lynx::GamepadInput input ([&got] (const Changes& c, const State&, double dt) {
- for (int i = 0; i < c.pressedCount; ++i)
- got.push_back (std::string ("press ") + buttonName (c.pressed[(std::size_t) i]));
- for (int i = 0; i < c.releasedCount; ++i)
- got.push_back (std::string ("release ") + buttonName (c.released[(std::size_t) i]));
- for (int i = 0; i < c.controllerCount; ++i)
- got.push_back ("cc " + std::to_string (c.controller[(std::size_t) i]) + "=" + std::to_string (c.value[(std::size_t) i]));
- if (c.connectedChanged)
- got.push_back ("connected changed");
- got.push_back ("dt " + std::to_string ((int) std::lround (dt * 1000)));
- });
- State pad;
- pad.connected = true;
- input.inject (pad, 1.0 / 60.0);
- pad.buttons = mask (Button::a);
- pad.rightTrigger = 255;
- input.inject (pad, 1.0 / 60.0);
- pad.buttons = 0;
- input.inject (pad, 1.0 / 60.0);
- const std::vector<std::string> expected { "connected changed", "dt 17", "press A", "cc 102=127", "cc 21=127", "dt 17",
- "release A", "cc 102=0", "dt 17" };
- for (const auto& line : got)
- report << line << "\n";
- if (got != expected)
- {
- ++failures;
- report << "FAILED: the poller's changes differ from the expected ones\n";
- }
- report << "xinput " << (input.available() ? "loaded" : "not available") << "\n";
- }
- report << (failures == 0 ? "gamepad OK" : "gamepad FAILED") << "\n";
- juce::File (prefix + "-gamepad.txt").replaceWithText (report);
- setApplicationReturnValue (failures == 0 ? 0 : 1);
- quit();
- }
- void runBundleExport (const juce::String& inputPath, const juce::String& folderPath, bool zip, bool mixdown, const juce::String& shotPrefix)
- {
- juce::String error;
- bool ok = false;
- lynx::otherapps::Result result;
- {
- lynx::AudioEngine loader (false);
- const juce::File input (inputPath);
- if (input.hasFileExtension ("flp;als"))
- ok = loader.importFlpFile (input, error);
- else if (auto song = lynx::ProjectFile::load (input, error))
- {
- loader.setSong (std::move (*song));
- ok = true;
- }
- if (ok)
- {
- loader.capturePluginStates();
- lynx::otherapps::Context context;
- context.host = &loader.getPluginHost();
- context.flOptions = lynx::flstudio::optionsFor (context.host, lynx::flpexport::LynxOnly::renderAudio, loader.getSong());
- context.render = [] (const lynx::Song& s, const lynx::exportopts::Options& o, const juce::File& file,
- const std::function<bool (double)>& progress, juce::String& err) {
- lynx::ExportJob job (s, o, file);
- return job.run (progress, err);
- };
- context.onMessageThread = [] (std::function<void()> f) { f(); };
- lynx::exportbundle::Options options;
- options.zip = zip;
- options.mixdown = mixdown;
- const auto name = input.getFileNameWithoutExtension();
- const auto shot = [&shotPrefix] (juce::Component& c, const juce::String& suffix) {
- if (shotPrefix.isNotEmpty())
- savePng (lynx::shot::snapshot (c), shotPrefix + suffix);
- };
- if (auto panel = lynx::makeOtherAppsExportPanel (loader, name))
- shot (*panel, "-panel.png");
- ok = lynx::otherapps::write (loader.getSong(), name, options, juce::File (folderPath), context, result);
- if (auto report = lynx::makeOtherAppsReportPanel (result.folder, result.written, result.failed))
- shot (*report, "-report.png");
- }
- }
- juce::String report;
- report << (ok ? "ok " + result.folder.getFullPathName() : "error=" + error) << "\n";
- for (const auto& w : result.written)
- report << "written " << w << "\n";
- for (const auto& f : result.failed)
- report << "failed " << f << "\n";
- juce::File (folderPath).getChildFile ("export-bundle.txt").replaceWithText (report);
- setApplicationReturnValue (ok && result.failed.isEmpty() ? 0 : 1);
- quit();
- }
- void runFlExport (const juce::String& inputPath, const juce::String& outputPath, bool substitute)
- {
- juce::String error;
- bool ok = false;
- lynx::flstudio::Written written;
- {
- lynx::AudioEngine loader (false);
- const juce::File input (inputPath);
- // a Live set opens through the same import as an .flp (as File › Open does, and --export-als accepts an .flp)
- if (input.hasFileExtension ("flp;als"))
- ok = loader.importFlpFile (input, error);
- else if (auto song = lynx::ProjectFile::load (input, error))
- {
- loader.setSong (std::move (*song));
- ok = true;
- }
- if (ok)
- {
- const juce::File output (outputPath);
- const auto zip = output.hasFileExtension ("zip");
- const auto mode = substitute ? lynx::flpexport::LynxOnly::substitute : lynx::flpexport::LynxOnly::renderAudio;
- loader.capturePluginStates();
- auto options = lynx::flstudio::optionsFor (&loader.getPluginHost(), mode, loader.getSong());
- // --flp-ppq N: the file's PPQ (tests; default: 96 when the notes and clips fit it)
- if (const auto args = juce::JUCEApplication::getCommandLineParameterArray(); args.contains ("--flp-ppq"))
- options.ppq = juce::jlimit (0, 960, args[args.indexOf ("--flp-ppq") + 1].getIntValue());
- const auto renderDir = zip ? juce::File::getSpecialLocation (juce::File::tempDirectory).getNonexistentChildFile ("LYNX FL export", {}, false)
- : output.getSiblingFile (output.getFileNameWithoutExtension() + " audio");
- ok = lynx::flstudio::exportProject (loader.getSong(), options, output, zip, renderDir, 44100.0,
- [] (const lynx::Song& s, const lynx::ExportSettings& settings, const juce::File& wav,
- const std::function<bool (double)>& progress, juce::String& err) {
- lynx::ExportJob job (s, settings, wav);
- return job.run (progress, err);
- },
- {}, written, error);
- if (zip)
- renderDir.deleteRecursively();
- }
- }
- juce::String report;
- report << (ok ? "ok" : "error=" + error) << "\n"
- << "exact=" << (int) written.report.exact.size() << " rendered=" << (int) written.report.rendered.size()
- << " substituted=" << (int) written.report.substituted.size() << " dropped=" << (int) written.report.dropped.size()
- << " samples=" << written.samples << "\n\n"
- << lynx::flstudio::reportText (written) << "\n";
- juce::File (outputPath + ".txt").replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --export project.(flp|als|lynx) output.(wav|flac|ogg|mp3|aif|aiff|m4a|aac) [--pattern] [--insert N] [--rate N]
- // Same path as "Export" in the UI: the whole song (or the current pattern) with its tail. .aif / .aiff: 24-bit AIFF;
- // .m4a: AAC at 192 kbps through the system's encoder (engine/AacEncoder.h; .aac writes the same MPEG-4 file under the
- // name .m4a). M4A is not available on Linux: the export stops with that message.
- void runExport (const juce::String& inputPath, const juce::String& outputPath, bool patternOnly, int insert)
- {
- juce::String error, report;
- bool ok = false;
- const auto started = juce::Time::getMillisecondCounterHiRes();
- lynx::loadtrace::begin (inputPath.toStdString()); // phase times (round 112): report lines + load.log
- {
- lynx::AudioEngine loader (false);
- const juce::File input (inputPath);
- // --find-plugins: first the targeted scan opening the project in the app runs (its plugins not known yet)
- if (input.hasFileExtension ("flp") && juce::JUCEApplication::getCommandLineParameters().contains ("--find-plugins"))
- {
- juce::MemoryBlock data;
- if (input.loadFileAsData (data))
- try
- {
- const auto uses = lynx::flpForeignPlugins (flp::parseProject ({ static_cast<const std::uint8_t*> (data.getData()), data.getSize() }));
- auto& host = loader.getPluginHost();
- const auto listed = std::chrono::steady_clock::now();
- const auto files = host.filesToScanFor (uses);
- lynx::loadtrace::add ("plugin_scan_list", lynx::loadtrace::msSince (listed));
- report << "scanned=" << files.joinIntoString (";") << "\n";
- const auto scanned = std::chrono::steady_clock::now();
- host.scanFiles (files, {});
- lynx::loadtrace::add ("plugin_scan", lynx::loadtrace::msSince (scanned), files.size());
- }
- catch (const flp::Error&)
- {
- }
- }
- if (input.hasFileExtension ("flp;als;mod;xm;s3m;it")) // a Live set opens through the same import (round 182b); a module too (190nw)
- ok = loader.importFlpFile (input, error);
- else if (auto song = lynx::ProjectFile::load (input, error))
- {
- loader.setSong (std::move (*song));
- ok = true;
- }
- // M4A without a system AAC encoder (Linux): said before anything is rendered
- if (ok && juce::File (outputPath).hasFileExtension ("m4a;aac") && ! lynx::aac::available())
- {
- ok = false;
- error = juce::String::fromUTF8 (lynx::aac::unavailableReason().c_str());
- }
- if (ok)
- {
- // (an .aac name gets the MPEG-4 file it holds: .m4a)
- const juce::File output (juce::File (outputPath).hasFileExtension ("aac") ? juce::File (outputPath).withFileExtension ("m4a") : juce::File (outputPath));
- lynx::ExportSettings settings;
- settings.wholeSong = ! patternOnly;
- settings.format = output.hasFileExtension ("flac") ? lynx::ExportSettings::Format::flac24
- : output.hasFileExtension ("ogg") ? lynx::ExportSettings::Format::ogg
- : lynx::ExportSettings::Format::wav24;
- // --insert N: only that insert's output (what "Render to audio" records)
- if (juce::JUCEApplication::getCommandLineParameters().contains ("--no-effects")
- || juce::JUCEApplication::getCommandLineParameters().contains ("--sem-efeitos")) // performance diagnostics; --sem-efeitos: legacy alias
- loader.editSong ([] (lynx::Song& s) {
- for (auto& t : s.mixer)
- t.effects.clear();
- }, false);
- if (juce::JUCEApplication::getCommandLineParameters().contains ("--no-automation")
- || juce::JUCEApplication::getCommandLineParameters().contains ("--sem-automacao")) // --sem-automacao: legacy alias
- loader.editSong ([] (lynx::Song& s) { s.automations.clear(); }, false);
- const auto loaded = juce::Time::getMillisecondCounterHiRes();
- // .mp3: the Export window's MP3 (320 kbps); everything else as before
- auto options = settings.toOptions();
- // --save-tempo: FL's "Tempo information" (acid chunk) on (round 167l: compare with FL's AcidBox render; --export)
- if (juce::JUCEApplication::getCommandLineParameters().contains ("--save-tempo"))
- options.saveTempo = true;
- // --no-warmup: the export's plugin warm-up off (round 155: compare the start of the file)
- if (juce::JUCEApplication::getCommandLineParameters().contains ("--no-warmup"))
- options.pluginWarmUp = false;
- // --rate N: render at another sample rate (round 157b: samples resampled as at a 48 kHz device)
- if (const auto args = juce::JUCEApplication::getCommandLineParameterArray(); args.contains ("--rate"))
- if (const auto rate = args[args.indexOf ("--rate") + 1].getDoubleValue(); rate >= 8000.0 && rate <= 384000.0)
- options.sampleRate = rate;
- if (output.hasFileExtension ("mp3"))
- {
- options.format = lynx::exportopts::Format::mp3;
- options.mp3Kbps = 320;
- }
- else if (output.hasFileExtension ("aif;aiff")) // (as the .wav: 24 bits, no dither)
- {
- options.format = lynx::exportopts::Format::aiff;
- options.aiffBits = 24;
- }
- else if (output.hasFileExtension ("m4a"))
- {
- options.format = lynx::exportopts::Format::aac;
- options.aacKbps = 192;
- }
- lynx::ExportJob job (insert > 0 ? lynx::makeBounceSong (loader.getSong(), insert) : loader.getSong(), options, output);
- job.setExtraData (true);
- const auto prepared = juce::Time::getMillisecondCounterHiRes();
- lynx::loadtrace::end();
- int lastPercent = -1;
- ok = job.run ([&lastPercent] (double p) {
- lastPercent = (int) (p * 100.0);
- return true;
- }, error);
- auto joined = [] (const std::map<std::string, int>& items) {
- juce::StringArray names;
- for (const auto& [name, count] : items)
- names.add (juce::String::fromUTF8 (name.c_str()) + "x" + juce::String (count));
- return names.joinIntoString (", ");
- };
- const auto& importReport = loader.getImportReport();
- report << "converted=" << joined (importReport.converted) << "\n"
- << "approximated=" << joined (importReport.approximated) << "\n"
- << "unsupported=" << joined (importReport.unsupported) << "\n"
- << "not_reproduced=" << joined (importReport.notReproduced) << "\n" // (round qafix190kq)
- << "dropped_effects=" << joined (importReport.droppedEffects) << "\n"
- << "partial_effects=" << joined (importReport.partialEffects) << "\n"
- << "missing_samples=" << importReport.missingSamples << "\n";
- // third-party plugins: how each was found, or what plays in its place (diagnostics for level differences)
- for (const auto& line : loader.getMatchedPlugins())
- report << "plugin_found=" << line << "\n";
- for (const auto& m : loader.getMissingPluginDetails())
- report << "plugin_missing=" << juce::String::fromUTF8 (m.name.c_str()) << " -> "
- << juce::String::fromUTF8 (m.replacement.c_str()).replace ("{0}", juce::String::fromUTF8 (m.replacementArg.c_str())) << "\n";
- {
- const auto& song = loader.getSong();
- for (std::size_t t = 0; t < song.mixer.size(); ++t)
- {
- const auto& track = song.mixer[t];
- if (track.effects.empty() && track.sends.empty())
- continue;
- report << "insert " << (int) t << " vol=" << juce::String (track.volume / lynx::unityFader, 3)
- << (track.muted ? " muted" : "") << (track.toMaster ? "" : " noMaster");
- for (const auto& s : track.sends)
- report << " send>" << s.target << "@" << juce::String (s.level, 3);
- report << " |";
- for (const auto& fx : track.effects)
- report << " [" << (fx.kind == lynx::EffectKind::plugin ? juce::String::fromUTF8 (fx.plugin.name.c_str())
- : juce::String::fromUTF8 (lynx::effectInfo (fx.kind).name))
- << (fx.isSubstitute() ? " (substitute)" : "") << (fx.enabled ? "" : " off")
- << (fx.mix < 0.999f ? " mix=" + juce::String (fx.mix, 2) : juce::String()) << "]";
- report << "\n";
- }
- }
- report << juce::String (lynx::loadtrace::reportLines());
- lynx::PluginHost::settingsFolder().getChildFile ("load.log").replaceWithText (juce::String (lynx::loadtrace::table()));
- report << "open_ms=" << juce::roundToInt (loaded - started) << "\n"
- << "prepare_ms=" << juce::roundToInt (prepared - loaded) << "\n"
- << "render_ms=" << juce::roundToInt (juce::Time::getMillisecondCounterHiRes() - prepared) << "\n"
- << "graph_ms=" << juce::roundToInt (job.getEngine().getLastRenderStats().graphMs) << "\n"
- << "write_ms=" << juce::roundToInt (job.getEngine().getLastRenderStats().writeMs) << "\n"
- << "warmup_blocks=" << job.getEngine().getLastRenderStats().warmUp.blocks << "\n"
- << "warmup_ms=" << juce::roundToInt (job.getEngine().getLastRenderStats().warmUp.wallSeconds * 1000.0) << "\n"
- << "warmup_changes=" << job.getEngine().getLastRenderStats().warmUp.signatureChanges << "\n"
- << "warmup_timed_out=" << (job.getEngine().getLastRenderStats().warmUp.timedOut ? 1 : 0) << "\n"
- << "pdc_trim=" << job.getEngine().getLastRenderStats().trimmedSamples << "\n"
- << "song_seconds=" << job.getMusicSeconds() << "\n"
- << "peak=" << job.getPeak() << "\n"
- << "final_progress=" << lastPercent << "\n"
- << "bytes=" << output.getSize() << "\n"
- << "file=" << output.getFullPathName() << "\n";
- // round qafix190kq (QA-9): a silent render failed with an empty message. Say why: a project with nothing to
- // play (Live's lesson sets "Playing Software Instruments" / "Recording Audio" hold no clip at all), or a
- // render that stays below -60 dBFS
- if (ok && job.getPeak() <= 0.001f)
- {
- ok = false;
- error = juce::String::fromUTF8 (lynx::exportsilence::reason (loader.getSong(), patternOnly).c_str());
- }
- }
- }
- report << "result=" << (ok ? "OK" : "ERROR " + error) << "\n";
- juce::File (outputPath + ".txt").replaceWithText (report);
- setApplicationReturnValue (ok ? 0 : 1);
- quit();
- }
- // LYNX.exe --snapshot prefix [project]: draws the window off-screen and writes
- // prefix-rack.png, -pianoroll.png and -playlist.png (to check the UI without touching the screen).
- // --editorcpu: one editor after another; each phase runs 2 s to settle and 8 s measured
- struct EditorCpuRun final : juce::Timer
- {
- struct Case { lynx::EffectKind kind; const char* name; int type; bool demo; }; // type 0 native, 1 display-first, 2 Facet EQ
- std::vector<Case> cases;
- std::size_t at = 0;
- int phase = 0;
- double t0 = 0.0, c0 = 0.0;
- juce::String report;
- juce::File out;
- std::unique_ptr<lynx::AudioEngine> engine;
- std::unique_ptr<juce::DocumentWindow> window;
- std::function<void()> done;
- void start()
- {
- engine = std::make_unique<lynx::AudioEngine> (false);
- report << "editor\tmode\tcpu % of one core\n";
- open();
- startTimer (250);
- }
- void open()
- {
- window.reset();
- if (at >= cases.size()) { out.replaceWithText (report); stopTimer(); if (done) done(); return; }
- const auto& c = cases[at];
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (lynx::makeEffectSlot (c.kind));
- engine->setSong (std::move (song));
- engine->dispatchPendingMessages();
- lynx::setNativeEditorDemo (c.demo);
- auto editor = c.type == 1 ? lynx::makeProEditor (*engine, 1, 0, c.demo) : c.type == 2 ? lynx::makeFacetEqEditor (*engine, 1, 0, c.demo)
- : lynx::makeNativeEffectEditor (*engine, 1, 0, 1.0f, 0);
- window = std::make_unique<juce::DocumentWindow> (juce::String ("LYNX editor CPU - ") + c.name, lynx::theme::colour::bg1, 0);
- window->setUsingNativeTitleBar (true);
- window->setContentOwned (editor.release(), true);
- const auto area = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea;
- window->setTopLeftPosition (area.getRight() - window->getWidth() - 8, area.getBottom() - window->getHeight() - 8);
- window->setVisible (true);
- phase = 0;
- t0 = juce::Time::getMillisecondCounterHiRes();
- }
- void timerCallback() override
- {
- const auto now = juce::Time::getMillisecondCounterHiRes();
- if (phase == 0 && now - t0 > 2000.0) { phase = 1; t0 = now; c0 = lynx::processCpuSeconds(); return; }
- if (phase == 1 && now - t0 > 8000.0)
- {
- const auto cpu = (lynx::processCpuSeconds() - c0) / ((now - t0) * 0.001) * 100.0;
- const auto& c = cases[at];
- report << c.name << "\t" << (c.demo ? "animating" : "idle") << "\t" << juce::String (cpu, 2) << "\n";
- ++at;
- open();
- }
- }
- };
- std::unique_ptr<EditorCpuRun> editorCpu;
- void runEditorCpu (const juce::String& path)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- editorCpu = std::make_unique<EditorCpuRun>();
- editorCpu->out = juce::File (path);
- using K = lynx::EffectKind;
- for (const auto demo : { false, true })
- for (const auto& c : std::vector<EditorCpuRun::Case> { { K::facetEq, "Facet EQ", 2, demo }, { K::crestCompressor, "Crest Compressor", 1, demo },
- { K::apexLimiter, "Apex Limiter", 1, demo }, { K::prismMultiband, "Prism Multiband", 1, demo },
- { K::epochVerb, "Epoch Verb", 0, demo }, { K::glowLeveler, "Glow Leveler", 0, demo },
- { K::fruityLimiter, "Fruity Limiter", 0, demo }, { K::lynxTune, "LYNX Tune", 0, demo } })
- editorCpu->cases.push_back (c);
- editorCpu->done = [this] { juce::MessageManager::callAsync ([this] { editorCpu.reset(); quit(); }); };
- editorCpu->start();
- }
- struct ParityShow
- {
- std::unique_ptr<lynx::AudioEngine> engine;
- std::unique_ptr<juce::Component> editor;
- std::unique_ptr<juce::DocumentWindow> window;
- ~ParityShow() { window.reset(); editor.reset(); engine.reset(); }
- };
- std::shared_ptr<ParityShow> parityShow;
- juce::File selfTestTemp; // --selftest: its own temp folder (round 190mo), deleted when the run ends
- bool parityShotFailed = false; // --parityshot: the effect name matched no built-in effect
- void runParityShot (const juce::String& path, const juce::String& effectName, const juce::String& paramsFile)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- int kindIndex = -1;
- for (int k = 0; k <= (int) lynx::lastEffectKind; ++k)
- if (juce::String::fromUTF8 (lynx::effectInfo ((lynx::EffectKind) k).name).equalsIgnoreCase (effectName))
- kindIndex = k;
- if (kindIndex < 0)
- {
- // round tp172b7: say so and fail (a silent exit 0 hid a split effect name in a launch script)
- std::fprintf (stderr, "unknown effect: %s\n", effectName.toRawUTF8());
- std::fflush (stderr);
- parityShotFailed = true;
- return;
- }
- const auto kind = (lynx::EffectKind) kindIndex;
- auto fx = lynx::makeEffectSlot (kind);
- // round 190jd: LYNX_PARITYSHOT_VIEW=1 = the editor display's second view (Fruity Limiter: LYNX's transfer curve)
- fx.displayView = (std::uint8_t) juce::jlimit (0, 1, juce::SystemStats::getEnvironmentVariable ("LYNX_PARITYSHOT_VIEW", "0").getIntValue());
- if (paramsFile.isNotEmpty())
- for (const auto& line : juce::StringArray::fromLines (juce::File (paramsFile).loadFileAsString()))
- {
- const auto t = juce::StringArray::fromTokens (line, " \t", "");
- const auto index = t.size() >= 2 ? t[0].getIntValue() : -1;
- if (index >= 0 && index < lynx::maxEffectParams)
- fx.params[(std::size_t) index] = t[1].getFloatValue();
- }
- auto offlineOwner = std::make_unique<lynx::AudioEngine> (false); // (kept alive by LYNX_PARITYSHOT_SHOW's window)
- auto& offline = *offlineOwner;
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.assign (1, fx);
- for (auto& c : song.channels)
- c.mixerTrack = 1;
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- const bool facet = kind == lynx::EffectKind::facetEq;
- // round tp172b4: the originals are pictured idle (nothing playing), so the display-first editors are too: no demo
- // history unless LYNX_PARITYSHOT_DEMO=1 asks for the running display
- const bool demoDisplay = juce::SystemStats::getEnvironmentVariable ("LYNX_PARITYSHOT_DEMO", {}) == "1";
- // (Ember in its Classic voicing: the Classic panel, as the mixer opens it)
- const bool pro = lynx::ProEditorWindows::handles (kind)
- && ! (kind == lynx::EffectKind::ember && fx.params[(std::size_t) lynx::mixsuite::ember::voicing] > 0.5f);
- auto editor = facet ? lynx::makeFacetEqEditor (offline, 1, 0, false)
- : pro ? lynx::makeProEditor (offline, 1, 0, demoDisplay) : lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
- if (editor == nullptr)
- return;
- if (! pro) // the demo song through the effect, the editor ticked 30 times a second of audio as its timer would
- {
- lynx::AudioEngine::RenderOptions o;
- o.seconds = 3.0;
- o.sampleRate = 48000.0;
- o.pluginWarmUp = false;
- int sinceTick = 0;
- o.capture = [&] (const float*, const float*, int n) {
- sinceTick += n;
- if (sinceTick < 1600) return;
- sinceTick = 0;
- if (facet) lynx::tickFacetEqEditor (*editor);
- else lynx::tickNativeEffectEditor (*editor);
- };
- offline.renderOffline (o);
- }
- // round tp172b5: LYNX_PARITYSHOT_CLICKS drives the editor before the picture (the originals' pictures have their
- // panels open), tokens in order: "x,y" a click, then the pointer leaves; "h:x,y" the pointer rests there (a hover);
- // "d:x,y,x2,y2" a drag from there to there, the button still down in the picture
- for (const auto& token : juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_PARITYSHOT_CLICKS", {}), " ", ""))
- {
- const auto hover = token.startsWith ("h:"), drag = token.startsWith ("d:");
- const auto xy = juce::StringArray::fromTokens (hover || drag ? token.substring (2) : token, ",", "");
- if (xy.size() < (drag ? 4 : 2))
- continue;
- const juce::Point<int> at (xy[0].getIntValue(), xy[1].getIntValue());
- editor->setVisible (true); // (getComponentAt finds nothing in a hidden component; it never goes on screen)
- auto* target = editor->getComponentAt (at);
- if (target == nullptr)
- continue;
- const auto local = target->getLocalPoint (editor.get(), at).toFloat();
- const auto now = juce::Time::getCurrentTime();
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const juce::ModifierKeys left (juce::ModifierKeys::leftButtonModifier);
- const auto event = [&] (juce::Point<float> p, juce::ModifierKeys mods, bool dragged) {
- return juce::MouseEvent (source, p, mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, target, target, now, local, now, 1, dragged);
- };
- target->mouseMove (event (local, {}, false));
- if (hover)
- continue;
- target->mouseDown (event (local, left, false));
- if (drag)
- {
- const auto end = target->getLocalPoint (editor.get(), juce::Point<int> (xy[2].getIntValue(), xy[3].getIntValue())).toFloat();
- target->mouseDrag (event (end, left, true));
- continue;
- }
- target->mouseUp (event (local, {}, false));
- target->mouseExit (event ({ -1000.0f, -1000.0f }, {}, false));
- offline.dispatchPendingMessages(); // (round 190jd: an edit the click made, e.g. a display view, reaches the slot)
- }
- // round tp172b6: LYNX_PARITYSHOT_SHOW=1 puts the same editor in a real window and keeps it open (for a guarded GUI check
- // of its pop-up menus, which the offscreen picture cannot hold); closing the window quits
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_PARITYSHOT_SHOW", {}) == "1")
- {
- struct ShowWindow final : juce::DocumentWindow
- {
- ShowWindow() : juce::DocumentWindow ("LYNX parity check", juce::Colours::black, juce::DocumentWindow::closeButton) {}
- void closeButtonPressed() override { juce::JUCEApplication::getInstance()->systemRequestedQuit(); }
- };
- parityShow = std::make_shared<ParityShow>();
- parityShow->engine = std::move (offlineOwner);
- parityShow->editor = std::move (editor);
- auto window = std::make_unique<ShowWindow>();
- window->setUsingNativeTitleBar (true);
- window->setContentNonOwned (parityShow->editor.get(), true);
- window->setTopLeftPosition (80, 80);
- window->setVisible (true);
- parityShow->window = std::move (window);
- return;
- }
- // round 190ar: LYNX_PARITYSHOT_SCALE=2 draws the same editor at twice the pixel density (as on a 200 % display);
- // round 190bi: the shared shot scale (--shot-scale, LYNX_SHOT_SCALE, LYNX_PARITYSHOT_SCALE as before)
- const auto shotScale = lynx::shot::scale();
- juce::Image image (juce::Image::ARGB, juce::roundToInt ((float) editor->getWidth() * shotScale), juce::roundToInt ((float) editor->getHeight() * shotScale), true);
- {
- juce::Graphics g (image);
- g.fillAll (lynx::theme::panel);
- g.addTransform (juce::AffineTransform::scale (shotScale));
- editor->paintEntireComponent (g, false);
- }
- const auto file = lynx::shot::file (juce::File (path));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- // an Audio Effect Rack shaped like Live's reference (REA_rodada183c §8): two chains with chain-select zones and fades,
- // four named macros (one on a chain's volume, one on two parameters), two variations, every view open
- static lynx::EffectSlot shotRack()
- {
- auto slot = lynx::rack::makeRackSlot (lynx::RackDoc::Kind::audioEffect);
- auto& doc = slot.patcher;
- doc.rack[0].chains[0].name = "Vocoder";
- lynx::PatchNode vocoder, eq, verb;
- vocoder.effect = lynx::makeEffectSlot (lynx::EffectKind::vocodex);
- eq.effect = lynx::makeEffectSlot (lynx::EffectKind::parametricEq);
- verb.effect = lynx::makeEffectSlot (lynx::EffectKind::reeverb2);
- const auto nVoc = lynx::rack::addDevice (doc, 0, vocoder);
- const auto nEq = lynx::rack::addDevice (doc, 0, eq);
- lynx::rack::addChain (doc, "dry bypass");
- lynx::rack::addDevice (doc, 1, verb);
- doc.rack[0].chains[0].select = { 0, 79, 0, 63 };
- doc.rack[0].chains[1].select = { 32, 127, 48, 127 };
- lynx::rack::setChainVolume (doc, 0, 0.33f);
- lynx::rack::setChainVolume (doc, 1, 0.5f);
- const char* names[] { "Sibilance", "Intensity", "Formant Shift", "Bright Level" };
- for (int m = 0; m < 4; ++m)
- doc.rack[0].macros[(std::size_t) m].name = names[m];
- lynx::RackMapping vol;
- vol.target = lynx::RackMapping::Target::chainVolume, vol.chain = 0, vol.min = 0.0f, vol.max = lynx::rack::unityVolume;
- lynx::rack::map (doc, 0, vol);
- lynx::RackMapping a, b, c, d;
- a.node = nVoc, a.param = 0;
- b.node = nVoc, b.param = 1, b.min = 0.2f, b.max = 0.8f;
- c.node = nEq, c.param = 0, c.min = 0.3f, c.max = 0.9f;
- d.node = nEq, d.param = 1;
- lynx::rack::map (doc, 1, a);
- lynx::rack::map (doc, 2, b);
- lynx::rack::map (doc, 3, c);
- lynx::rack::map (doc, 3, d);
- lynx::rack::setMacro (doc, 0, 60.0f);
- lynx::rack::setMacro (doc, 1, 40.0f);
- lynx::rack::setMacro (doc, 2, 70.0f);
- lynx::rack::setMacro (doc, 3, 86.0f);
- lynx::rack::storeVariation (doc);
- lynx::rack::renameVariation (doc, 0, "Verse");
- lynx::rack::setMacro (doc, 3, 120.0f);
- lynx::rack::storeVariation (doc);
- lynx::rack::renameVariation (doc, 1, "Drop");
- lynx::rack::launchVariation (doc, 0);
- auto& r = doc.rack[0];
- r.showMacros = r.showChains = r.showDevices = r.showVariations = true;
- r.zoneEditor = 2;
- r.selectedChain = 0;
- lynx::rack::setSelector (doc, 56.0f);
- lynx::rack::compile (doc);
- return slot;
- }
- bool runRackShots (const juce::File& out, const juce::String& liveSet = {})
- {
- out.createDirectory();
- lynx::AudioEngine offline (false);
- auto save = [&] (juce::Component& c, const juce::String& name) {
- auto image = lynx::shot::paint (c, lynx::theme::panel);
- const auto f = lynx::shot::file (out.getChildFile (name));
- f.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = f.createOutputStream())
- return png.writeImageToStream (image, *stream);
- return false;
- };
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (3);
- song.mixer[1].name = "Vocal Main";
- auto slot = shotRack();
- song.mixer[1].effects = { slot };
- // an Instrument Rack: three chains split over the keyboard
- lynx::ChannelDef inst;
- inst.name = "Keys Rack";
- inst.instrument = lynx::InstrumentKind::patcher;
- inst.patcher = lynx::rack::makeRack (lynx::RackDoc::Kind::instrument);
- for (int k = 0; k < 3; ++k)
- {
- if (k > 0)
- lynx::rack::addChain (inst.patcher);
- lynx::PatchNode synth;
- synth.generator = true;
- synth.channel.instrument = lynx::InstrumentKind::synth;
- synth.channel.name = "Synth";
- lynx::rack::addDevice (inst.patcher, k, synth);
- }
- inst.patcher.rack[0].chains[0].key = { 0, 52, 0, 47 };
- inst.patcher.rack[0].chains[1].key = { 48, 76, 53, 71 };
- inst.patcher.rack[0].chains[2].key = { 72, 127, 77, 127 };
- inst.patcher.rack[0].chains[0].name = "Low";
- inst.patcher.rack[0].chains[1].name = "Mid";
- inst.patcher.rack[0].chains[2].name = "High";
- inst.patcher.rack[0].showChains = inst.patcher.rack[0].showDevices = true;
- inst.patcher.rack[0].zoneEditor = 0;
- lynx::rack::compile (inst.patcher);
- song.channels.push_back (inst);
- const auto channel = (int) song.channels.size() - 1;
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- bool ok = true;
- // [set.als]: a Live set's racks as LYNX imports them, the one with the most chains drawn with its title bar (the
- // like-for-like pair with Live's own picture of that set)
- if (liveSet.isNotEmpty())
- {
- juce::MemoryBlock bytes;
- juce::File (liveSet).loadFileAsData (bytes);
- const std::vector<std::uint8_t> data ((const std::uint8_t*) bytes.getData(), (const std::uint8_t*) bytes.getData() + bytes.getSize());
- lynx::AlsImportOptions o;
- o.common.projectFolder = juce::File (liveSet).getParentDirectory().getFullPathName().toStdString();
- std::string error;
- if (auto imported = lynx::importAls (data, o, &error))
- {
- int bestTrack = -1, bestSlot = -1;
- std::size_t most = 0;
- for (int t = 0; t < (int) imported->mixer.size(); ++t)
- for (int s = 0; s < (int) imported->mixer[(std::size_t) t].effects.size(); ++s)
- if (const auto& fx = imported->mixer[(std::size_t) t].effects[(std::size_t) s]; lynx::rack::isRack (fx) && fx.patcher.rack[0].chains.size() > most)
- most = fx.patcher.rack[0].chains.size(), bestTrack = t, bestSlot = s;
- if (bestTrack >= 0)
- {
- offline.setSong (std::move (*imported));
- offline.dispatchPendingMessages();
- auto view = lynx::RackWindows::makeSlotView (offline, bestTrack, bestSlot, true);
- view->setSize (view->preferredWidth (228), 228);
- ok = save (*view, "rack-live-import.png") && ok;
- view->setMapMode (true);
- view->setSize (view->preferredWidth (228), 228);
- ok = save (*view, "rack-live-import-map.png") && ok;
- return ok;
- }
- }
- return false;
- }
- {
- auto view = lynx::RackWindows::makeSlotView (offline, 1, 0, false);
- view->setSize (view->preferredWidth (206), 206);
- ok = save (*view, "rack-deviceview.png") && ok;
- }
- {
- auto view = lynx::RackWindows::makeSlotView (offline, 1, 0, true);
- view->setMapMode (true);
- view->setSize (view->preferredWidth (228), 228);
- ok = save (*view, "rack-mapmode.png") && ok;
- }
- {
- auto view = lynx::RackWindows::makeChannelView (offline, channel, true);
- view->setSize (view->preferredWidth (228), 228);
- ok = save (*view, "rack-instrument.png") && ok;
- }
- return ok;
- }
- void runEq166fShots (const juce::String& folder)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::File out (folder);
- out.createDirectory();
- lynx::AudioEngine offline (false);
- auto save = [&] (juce::Component& editor, const juce::String& name) {
- auto image = lynx::shot::paint (editor, lynx::theme::panel);
- const auto f = lynx::shot::file (out.getChildFile (name));
- f.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = f.createOutputStream())
- png.writeImageToStream (image, *stream);
- };
- // a song whose demo beat plays into insert 1 (the source) and, for Facet's target, its other half into insert 2
- auto songWith = [] (const lynx::EffectSlot& fx, bool split) {
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (3);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Vocal";
- song.mixer[2].name = "Reference mix";
- song.mixer[1].effects.assign (1, fx);
- for (std::size_t c = 0; c < song.channels.size(); ++c)
- song.channels[c].mixerTrack = split && c % 2 == 1 ? 2 : 1;
- return song;
- };
- auto feed = [&] (juce::Component& editor, bool facet, int frames) {
- // one continuous render of the song, the editor ticked 30 times a second of audio, as its timer would
- lynx::AudioEngine::RenderOptions o;
- o.seconds = frames / 30.0;
- o.sampleRate = 48000.0;
- o.pluginWarmUp = false;
- int sinceTick = 0;
- o.capture = [&] (const float*, const float*, int n) {
- sinceTick += n;
- if (sinceTick < 1600) return;
- sinceTick = 0;
- if (facet) lynx::tickFacetEqEditor (editor);
- else lynx::tickNativeEffectEditor (editor);
- };
- offline.renderOffline (o);
- if (facet) lynx::tickFacetEqEditor (editor);
- else lynx::tickNativeEffectEditor (editor);
- };
- // Parametric EQ 2: spectrum + heatmap (Full), flat / band 4 +12 dB / band 4 -12 dB, then the Top position
- auto& display = lynx::peqview::displaySettings();
- const auto kept = display;
- display.spectrum = display.heatmap = true;
- display.position = 0;
- for (const auto& [gain, name] : { std::pair { 0.0, "peq2-heatmap-flat.png" }, { 12.0, "peq2-heatmap-boost.png" }, { -12.0, "peq2-heatmap-cut.png" },
- { 0.0, "peq2-heatmap-top.png" } })
- {
- auto eq = lynx::makeEffectSlot (lynx::EffectKind::parametricEq);
- eq.params[(std::size_t) lynx::peq::param (3, 2)] = lynx::peq::gainValue (gain);
- eq.params[(std::size_t) lynx::peq::param (3, 1)] = lynx::peq::hzValue (900.0);
- display.position = juce::String (name).contains ("top") ? 1 : 0;
- offline.setSong (songWith (eq, false));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.25f, 0);
- feed (*editor, false, 120);
- save (*editor, name);
- }
- display = kept;
- // Facet EQ's comparative EQ: listening to the target (insert 2) with its spectrum over the source's
- {
- using namespace lynx::facet;
- auto eq = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
- eq.params[(std::size_t) param (0, 0)] = shapeValue (Shape::bell);
- eq.params[(std::size_t) param (0, 1)] = hzValue (250.0);
- eq.params[(std::size_t) param (0, 2)] = gainValue (-4.0);
- eq.params[(std::size_t) param (1, 0)] = shapeValue (Shape::highShelf);
- eq.params[(std::size_t) param (1, 1)] = hzValue (6000.0);
- eq.params[(std::size_t) param (1, 2)] = gainValue (3.0);
- eq.params[(std::size_t) analyzerParam] = analyzerValue (Analyzer::both);
- eq.sidechain = 2;
- for (const auto& [l, name] : { std::pair { Listen::target, "facet-compare-target.png" }, { Listen::eq, "facet-compare-eq.png" } })
- {
- eq.params[(std::size_t) listenParam] = listenValue (l);
- offline.setSong (songWith (eq, true));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeFacetEqEditor (offline, 1, 0, false);
- feed (*editor, true, 90);
- save (*editor, name);
- }
- }
- }
- void runDesign168rShots (const juce::String& folder)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::File out (folder);
- out.createDirectory();
- lynx::AudioEngine offline (false);
- using K = lynx::EffectKind;
- for (const auto kind : { K::pitchCorrect, K::lovePhilter, K::peakController, K::spreader, K::fruityFastLP, K::flFrequencyShifter,
- K::flLowLifter, K::distructor, K::flBassBoost, K::flDelay1, K::fl7BandEq, K::flCenter, K::flPhaseInverter,
- K::eq, K::delay, K::reverb, K::limiter, K::filter, K::distortion, K::chorus, K::utility, K::lofi,
- K::crossover, K::pitchShift, K::freqShift, K::rhythmGain, K::volumeGate })
- {
- const auto& bank = lynx::presets::factory (kind);
- // Love Philter / Distructor play FL's state: their second picture is FL's default preset (when installed)
- std::optional<lynx::EffectSlot> flPreset;
- if (kind == K::lovePhilter || kind == K::distructor)
- {
- const auto roots = lynx::findFlStudioRoots();
- const auto file = juce::File (juce::String::fromUTF8 (roots.data.c_str()))
- .getChildFile ("Patches/Plugin presets/Effects")
- .getChildFile (kind == K::lovePhilter ? "Fruity Love Philter/Default.fst" : "Distructor/Default.fst");
- juce::MemoryBlock bytes;
- if (file.loadFileAsData (bytes))
- flPreset = lynx::effectFromFlPreset (std::vector<std::uint8_t> ((const std::uint8_t*) bytes.getData(),
- (const std::uint8_t*) bytes.getData() + bytes.getSize()));
- }
- for (int pass = 0; pass < (bank.empty() && ! flPreset ? 1 : 2); ++pass)
- {
- auto fx = lynx::makeEffectSlot (kind);
- if (pass == 1 && flPreset)
- fx = *flPreset;
- else if (pass == 1)
- {
- fx.params = lynx::presets::apply (kind, bank.front(), 120.0);
- fx.presetName = bank.front().name;
- }
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- const auto pages = juce::jmax (1, (int) lynx::plugui::layoutFor (kind).pages.size());
- for (const auto scale : { 1.0f, 2.0f })
- for (int page = 0; page < pages; ++page)
- {
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, scale, page);
- if (editor == nullptr)
- continue;
- juce::Image image (juce::Image::ARGB, juce::jmax (1, editor->getWidth()), juce::jmax (1, editor->getHeight()), true);
- {
- juce::Graphics g (image);
- g.fillAll (lynx::theme::panel);
- editor->paintEntireComponent (g, false);
- }
- // (FL's "Frequency Shifter" and LYNX's "Frequency shifter" differ only in case: FL editors get "FL ")
- const auto file = out.getChildFile ((lynx::plugui::hasFlLayout (kind) ? "FL " : "")
- + juce::String (lynx::effectInfo (kind).name).replaceCharacters ("/\\:", "---")
- + (pass == 1 ? "-preset" : "") + (page > 0 ? "-p" + juce::String (page + 1) : juce::String())
- + (scale > 1.5f ? "-200" : "-100") + ".png");
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- }
- }
- }
- bool runInstrumentShots (const juce::File& folder, const juce::String& which, const juce::String& source)
- {
- folder.createDirectory();
- auto key = [] (juce::String n) { return n.toLowerCase().removeCharacters (" -!._"); };
- juce::StringArray wanted;
- wanted.addTokens (which, ",", "");
- auto ok = true;
- struct Shot
- {
- juce::String name;
- std::optional<lynx::ChannelDef> channel;
- };
- std::vector<Shot> shots;
- for (const auto& e : lynx::natives::instrumentEngines())
- {
- const auto name = key (e.name);
- const auto banked = which == "banks" && lynx::banks::hasBank (e.kind);
- if (! banked && ! wanted.contains (name))
- continue;
- auto channel = source == "fl" || source == "flm" ? lynx::natives::makeChannel (e.kind, lynx::flStudioAccess())
- : lynx::banks::defaultChannel (e.kind, e.name);
- // (round 190u) source "flm": the channel as the .flm import makes it (Transistor Bass: FL Studio Mobile's build)
- if (source == "flm" && channel && e.kind == lynx::InstrumentKind::transistorbass)
- {
- channel->pluginState = lynx::transistorBassFlmState ({ 1.0f, 0.0f, 1.0f, 1.0f, 0.1f, 1.0f, 0.1f, 0.0f, 0.0f, 0.3f, 0.5f, 0.0f, 0.0f, 0.0f }); // FLM's defaults
- channel->modelParams = { 1.0f };
- channel->samplePath.clear();
- }
- if (! channel)
- {
- std::fprintf (stderr, "%s: no %s channel\n", e.name, source.toRawUTF8());
- ok = false;
- continue;
- }
- shots.push_back ({ name, std::move (channel) });
- }
- // Autogun (round 169h): not in the Add menus (no preset files); FL's own render-test channel, either source
- if (wanted.contains ("autogun"))
- {
- if (auto channel = lynx::natives::autogunShotChannel (lynx::flStudioAccess()))
- shots.push_back ({ "autogun", std::move (channel) });
- else
- {
- std::fprintf (stderr, "Autogun: no channel (FL Studio's Render tests\\Autogun.flp)\n");
- ok = false;
- }
- }
- for (auto& shot : shots)
- {
- const auto& name = shot.name;
- auto& channel = shot.channel;
- lynx::AudioEngine offline (false);
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (2);
- song.channels.push_back (*channel);
- song.patterns.emplace_back();
- {
- juce::String error; // the project too, so an older build can picture the same channel (--snapshot)
- lynx::ProjectFile::save (song, folder.getChildFile (name + "-" + source + ".lynx"), error);
- }
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto frame = lynx::makeChannelFrame (offline, 0, 0);
- if (frame == nullptr || frame->getWidth() <= 0)
- {
- ok = false;
- continue;
- }
- for (const auto scale : { 1.0f, 1.5f, 2.0f })
- {
- const auto file = folder.getChildFile (name + "-" + source + "-" + juce::String (juce::roundToInt (scale * 100)) + ".png");
- savePng (frame->createComponentSnapshot (frame->getLocalBounds(), true, scale), file.getFullPathName());
- std::printf ("%s %dx%d\n", file.getFullPathName().toRawUTF8(), frame->getWidth(), frame->getHeight());
- }
- // round 169h: the layout's other pages (Toxic's MIDI / Seq …), one shot each at 1.5×
- for (int page = 1; page < lynx::showChannelLayoutPage (*frame, -1); ++page)
- {
- lynx::showChannelLayoutPage (*frame, page);
- const auto file = folder.getChildFile (name + "-" + source + "-page" + juce::String (page) + "-150.png");
- savePng (frame->createComponentSnapshot (frame->getLocalBounds(), true, 1.5f), file.getFullPathName());
- std::printf ("%s\n", file.getFullPathName().toRawUTF8());
- }
- }
- return ok;
- }
- // --- round 170j: the pilot editors with their own art -------------------------------------------------
- struct ArtPilot
- {
- std::string file; // the art's name as a file name: "toxic-biohazard"
- bool instrument;
- lynx::InstrumentKind instrumentKind;
- lynx::EffectKind effectKind;
- lynx::skin::Style before; // the automatic style it had before the Themed style
- };
- static juce::StringArray& artOnly() // --artshot / --artgui: only these (file names), all when empty
- {
- static juce::StringArray only;
- return only;
- }
- // every plugin with art of its own (round 170j/170k): generators first, then effects; built from the art
- // registries, so a new theme is shot without touching this list
- static const std::vector<ArtPilot>& artPilots()
- {
- using I = lynx::InstrumentKind;
- using E = lynx::EffectKind;
- static const std::vector<ArtPilot> list = [] {
- std::vector<ArtPilot> all;
- auto slug = [] (lynx::skin::Art a) {
- return juce::String (lynx::skin::artName (a)).toLowerCase().replaceCharacters (" ", "-").removeCharacters ("!.()'").toStdString();
- };
- for (const auto& e : lynx::natives::instrumentEngines()) // (the engines' order first)
- if (const auto a = lynx::skin::artForInstrument (e.kind); a != lynx::skin::Art::none)
- all.push_back ({ slug (a), true, e.kind, E::reverb, lynx::skin::Style::neon });
- for (int k = 0; k <= (int) I::wavetraveller; ++k) // then every other kind with art (DrumSynth, Autogun, Wasp...)
- if (const auto a = lynx::skin::artForInstrument ((I) k); a != lynx::skin::Art::none)
- all.push_back ({ slug (a), true, (I) k, E::reverb, lynx::skin::Style::neon });
- for (int k = 0; k <= (int) lynx::lastEffectKind; ++k)
- if (const auto a = lynx::skin::artForEffect ((E) k); a != lynx::skin::Art::none)
- all.push_back ({ slug (a), false, I::synth, (E) k, lynx::skin::plainStyleFor (k) });
- std::vector<ArtPilot> kept;
- for (auto& p : all)
- if (artOnly().isEmpty() || artOnly().contains (juce::String (p.file)))
- if (std::none_of (kept.begin(), kept.end(), [&] (const ArtPilot& q) { return q.file == p.file; }))
- kept.push_back (p);
- return kept;
- }();
- return list;
- }
- // the song and the editor of a pilot (an instrument: the channel window on its Plugin tab)
- static std::unique_ptr<juce::Component> makeArtPilot (lynx::AudioEngine& engine, const ArtPilot& p)
- {
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (2);
- if (p.instrument)
- {
- for (const auto& e : lynx::natives::instrumentEngines())
- if (e.kind == p.instrumentKind)
- {
- auto channel = lynx::natives::makeChannel (e.kind, lynx::flStudioAccess());
- if (! channel) channel = lynx::banks::defaultChannel (e.kind, e.name);
- if (! channel) return nullptr;
- song.channels.push_back (*channel);
- break;
- }
- if (song.channels.empty()) // a kind without an engine entry: its LYNX default, else an empty channel of that kind
- {
- const std::string name = lynx::skin::artName (lynx::skin::artForInstrument (p.instrumentKind));
- auto channel = lynx::banks::defaultChannel (p.instrumentKind, name);
- if (! channel)
- {
- channel = lynx::ChannelDef {};
- channel->instrument = p.instrumentKind;
- channel->name = name;
- }
- song.channels.push_back (*channel);
- }
- song.patterns.emplace_back();
- }
- else
- {
- song.mixer[1].effects.push_back (lynx::makeEffectSlot (p.effectKind));
- }
- engine.setSong (std::move (song));
- engine.dispatchPendingMessages();
- if (p.instrument) return lynx::makeChannelFrame (engine, 0, 0);
- if (p.effectKind == lynx::EffectKind::facetEq) return lynx::makeFacetEqEditor (engine, 1, 0, true);
- if (lynx::ProEditorWindows::handles (p.effectKind)) return lynx::makeProEditor (engine, 1, 0, true); // display-first editors, demo signal
- return lynx::makeNativeEffectEditor (engine, 1, 0, 1.0f, 0);
- }
- // "before": the style each pilot had (forced for its run); "after": automatic (the pilots are Themed)
- static void artPilotStyle (const ArtPilot& p, const juce::String& mode)
- {
- lynx::skin::setForcedStyle (mode == "before" ? (int) p.before : -1);
- lynx::skin::setArtMotion (mode != "still");
- }
- bool runArtShots (const juce::File& folder, bool before)
- {
- folder.createDirectory();
- auto ok = true;
- juce::String titles ("editor\tsize\twidth\tname width at the style's size\tbox\tsize used\tlines\tresult\n");
- for (const auto& p : artPilots())
- {
- artPilotStyle (p, before ? "before" : "after");
- lynx::AudioEngine offline (false);
- auto editor = makeArtPilot (offline, p);
- if (editor == nullptr || editor->getWidth() <= 0)
- {
- std::fprintf (stderr, "%s: no editor\n", p.file.c_str());
- ok = false;
- continue;
- }
- if (p.effectKind == lynx::EffectKind::facetEq) lynx::tickFacetEqEditor (*editor);
- // round 170k2: titles.tsv, how the header's name fitted (its width at the style's size, the box, the size used)
- auto fit = [&] (const juce::String& at) {
- const auto f = lynx::skin::lastTitleFit();
- if (f.have <= 0.0f) return; // no plugin header drawn (a generator's channel window)
- titles << juce::String (p.file) << "\t" << at << "\t" << editor->getWidth() << "\t" << juce::String (f.need, 1) << "\t" << juce::String (f.have, 1)
- << "\t" << juce::String (f.size, 1) << "\t" << f.lines << "\t" << (f.clipped ? "ELLIPSIS" : "full") << "\n";
- };
- for (const auto scale : { 1.0f, 2.0f })
- {
- const auto file = folder.getChildFile (juce::String (p.file) + "-" + (before ? "before" : "after") + "-" + juce::String (juce::roundToInt (scale * 100)) + ".png");
- lynx::skin::resetTitleFit();
- savePng (editor->createComponentSnapshot (editor->getLocalBounds(), true, scale), file.getFullPathName());
- std::printf ("%s %dx%d\n", file.getFullPathName().toRawUTF8(), editor->getWidth(), editor->getHeight());
- if (scale == 1.0f) fit ("100");
- }
- // ... and at the smallest size its window allows (effect panels; the Pro editors scale as a whole)
- if (const auto smallest = lynx::nativeEditorMinimumSize (*editor); smallest.x > 0)
- {
- editor->setSize (smallest.x, smallest.y);
- const auto file = folder.getChildFile (juce::String (p.file) + "-" + (before ? "before" : "after") + "-min.png");
- lynx::skin::resetTitleFit();
- savePng (lynx::shot::snapshot (*editor), file.getFullPathName());
- fit ("min");
- }
- }
- folder.getChildFile (juce::String ("titles-") + (before ? "before" : "after") + ".tsv").replaceWithText (titles);
- lynx::skin::setForcedStyle (-1);
- return ok;
- }
- struct ArtGuiRun final : juce::Timer
- {
- juce::File folder;
- juce::String mode, report;
- std::size_t at = 0;
- int phase = 0;
- double t0 = 0.0, c0 = 0.0;
- std::unique_ptr<lynx::AudioEngine> engine;
- std::unique_ptr<juce::DocumentWindow> window;
- std::function<void()> done;
- void start()
- {
- engine = std::make_unique<lynx::AudioEngine> (false);
- report << "editor\tmode\tcpu % of one core\tart layer animating\n";
- open();
- startTimer (100);
- }
- void open()
- {
- window.reset();
- const auto& pilots = artPilots();
- if (at >= pilots.size())
- {
- folder.getChildFile ("cpu-" + mode + ".txt").replaceWithText (report);
- stopTimer();
- lynx::skin::setForcedStyle (-1);
- lynx::skin::setArtMotion (true);
- if (done) done();
- return;
- }
- const auto& p = pilots[at];
- artPilotStyle (p, mode);
- auto editor = makeArtPilot (*engine, p);
- if (editor == nullptr) { ++at; open(); return; }
- window = std::make_unique<juce::DocumentWindow> (juce::String ("LYNX art - ") + juce::String (p.file), lynx::theme::colour::bg1, 0);
- window->setUsingNativeTitleBar (true);
- window->setContentOwned (editor.release(), true);
- const auto area = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea;
- window->setTopLeftPosition (area.getX() + 24, area.getY() + 24);
- window->setAlwaysOnTop (true);
- window->setVisible (true);
- phase = 0;
- t0 = juce::Time::getMillisecondCounterHiRes();
- }
- bool animating() const
- {
- if (window == nullptr || window->getContentComponent() == nullptr) return false;
- std::function<bool (juce::Component&)> find = [&] (juce::Component& c) {
- if (auto* l = dynamic_cast<lynx::skin::ArtLayer*> (&c); l != nullptr && l->animating()) return true;
- for (auto* child : c.getChildren())
- if (find (*child)) return true;
- return false;
- };
- return find (*window->getContentComponent());
- }
- void timerCallback() override
- {
- const auto now = juce::Time::getMillisecondCounterHiRes();
- const auto& p = artPilots()[at];
- const auto ready = folder.getChildFile (juce::String (p.file) + "-" + mode + ".ready");
- const auto shotDone = folder.getChildFile (juce::String (p.file) + "-" + mode + ".done");
- if (phase == 0 && now - t0 > 1500.0)
- {
- // the window's content on screen, in physical pixels, for the outside screenshot to crop
- auto* c = window->getContentComponent();
- const auto scale = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay()->scale;
- const auto b = c->getScreenBounds();
- shotDone.deleteFile();
- ready.replaceWithText (juce::String (juce::roundToInt (b.getX() * scale)) + " " + juce::String (juce::roundToInt (b.getY() * scale)) + " "
- + juce::String (juce::roundToInt (b.getWidth() * scale)) + " " + juce::String (juce::roundToInt (b.getHeight() * scale)));
- phase = 1;
- t0 = now;
- return;
- }
- if (phase == 1 && (shotDone.existsAsFile() || now - t0 > 10000.0))
- {
- ready.deleteFile();
- shotDone.deleteFile();
- phase = 2;
- t0 = now;
- c0 = lynx::processCpuSeconds();
- return;
- }
- if (phase == 2 && now - t0 > 6000.0)
- {
- const auto cpu = (lynx::processCpuSeconds() - c0) / ((now - t0) * 0.001) * 100.0;
- report << juce::String (p.file) << "\t" << mode << "\t" << juce::String (cpu, 2) << "\t" << (animating() ? "yes" : "no") << "\n";
- ++at;
- open();
- }
- }
- };
- std::unique_ptr<ArtGuiRun> artGui;
- void runArtGui (const juce::File& folder, const juce::String& mode)
- {
- folder.createDirectory();
- artGui = std::make_unique<ArtGuiRun>();
- artGui->folder = folder;
- artGui->mode = mode;
- artGui->done = [this] { juce::MessageManager::callAsync ([this] { artGui.reset(); quit(); }); };
- artGui->start();
- }
- void runDesign190inShot (const juce::String& prefix, const juce::String& project)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String report;
- {
- lynx::AudioEngine engine (false);
- juce::String error;
- if (const juce::File input (project); input.existsAsFile() && input.hasFileExtension ("flp"))
- report << "import: " << (engine.importFlpFile (input, error) ? "ok" : "failed " + error) << "\n";
- engine.dispatchPendingMessages();
- // a native FL generator with FL's presets (FL's capture: FLEX's "Piano Dark"), on a mixer track of its own
- const auto& fl = lynx::flStudioAccess();
- auto osc = lynx::natives::makeChannel (lynx::InstrumentKind::threeosc, fl);
- int generator = -1, sampler = -1;
- engine.editSong ([&] (lynx::Song& s) {
- if (osc)
- {
- osc->mixerTrack = s.claimFreeInsert();
- s.channels.push_back (*osc);
- generator = (int) s.channels.size() - 1;
- }
- if (const juce::File kick (juce::String::fromUTF8 (fl.roots.data.c_str()) + "/Patches/Packs/Drums/Kicks/808 Kick.wav"); kick.existsAsFile())
- {
- lynx::ChannelDef d; // FL's Sampler with a kick, as FL's default channel (the Sample, Envelope and Misc tabs)
- d.instrument = lynx::InstrumentKind::sampler;
- lynx::audioclips::loadSampleInto (d, kick.getFullPathName().toStdString(), "808 Kick");
- d.mixerTrack = s.claimFreeInsert();
- s.channels.push_back (d);
- sampler = (int) s.channels.size() - 1;
- }
- for (const auto withSample : { true, false }) // (a sampler with its sample first, else any)
- for (int c = 0; c < (int) s.channels.size() && sampler < 0; ++c)
- if (s.channels[(std::size_t) c].instrument == lynx::InstrumentKind::sampler && (! withSample || ! s.channels[(std::size_t) c].samplePath.empty()))
- sampler = c;
- });
- engine.dispatchPendingMessages();
- lynx::MainComponent ui (engine, false); // (sets the Channel rack's wrapper-menu items)
- ui.setSize (1920, 1080);
- report << "generator " << generator << ", sampler " << sampler << "\n";
- auto shoot = [&] (juce::Component& c, const juce::String& name) {
- savePng (lynx::shot::snapshot (c), prefix + name);
- report << name << " " << c.getWidth() << "x" << c.getHeight() << "\n";
- };
- auto window = [&] (int channel, int tab, const juce::String& name) {
- if (channel < 0)
- return;
- if (auto w = lynx::makeChannelWindowForShot (engine, channel, tab))
- shoot (*w, name);
- };
- window (generator, 0, "-cw-plugin.png");
- window (generator, -1, "-cw-plugin-misc.png");
- window (sampler, 0, "-cw-sample.png");
- window (sampler, 1, "-cw-envelope.png");
- window (sampler, -1, "-cw-misc.png");
- // the strip of a window with the system's title bar (docking off): ▸ and the presets stay in it
- if (generator >= 0)
- if (auto frame = lynx::makeChannelFrame (engine, generator, 0))
- {
- shoot (*frame, "-frame-floating.png");
- if (auto menu = lynx::channelWrapperMenu (*frame))
- {
- // FL's two columns: the plugin's items, then the Channel column (split at the column break)
- juce::PopupMenu left, right;
- auto* to = &left;
- for (juce::PopupMenu::MenuItemIterator it (*menu); it.next();)
- {
- to->addItem (it.getItem());
- if (it.getItem().shouldBreakAfter)
- to = &right;
- }
- saveMenus (juce::StringArray { "Plugin", "Channel" }, std::vector<juce::PopupMenu> { left, right }, prefix + "-menu-channel.png");
- report << "menu items " << left.getNumItems() << " + " << right.getNumItems() << "\n";
- }
- }
- }
- {
- // FW-8: LYNX engines standing in for FL plugins of an imported project (the import's flOrigin) are titled
- // with FL's name; LYNX's own Delay (no FL origin) keeps its own
- lynx::AudioEngine offline (false);
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- const std::vector<std::pair<lynx::EffectKind, const char*>> standIns { { lynx::EffectKind::limiter, "Fruity Limiter" },
- { lynx::EffectKind::utility, "Fruity Stereo Shaper" }, { lynx::EffectKind::delay, "Fruity Delay 3" },
- { lynx::EffectKind::reverb, "Fruity Reeverb 2" }, { lynx::EffectKind::delay, "" } };
- for (const auto& [kind, origin] : standIns)
- {
- auto fx = lynx::makeEffectSlot (kind);
- fx.flOrigin.plugin = origin;
- song.mixer[1].effects.push_back (fx);
- }
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- std::vector<juce::Image> strips;
- int width = 0, height = 0;
- for (int k = 0; k < (int) standIns.size(); ++k)
- if (auto editor = lynx::makeNativeEffectEditor (offline, 1, k, 1.0f, 0))
- {
- auto image = lynx::shot::paint (*editor, lynx::theme::panel); // (as --plugui draws the editors)
- const auto h = juce::jmin (image.getHeight(), (int) std::ceil (30.0f * lynx::shot::scale()));
- juce::Image strip (juce::Image::ARGB, image.getWidth(), h, true);
- juce::Graphics (strip).drawImageAt (image, 0, 0);
- strips.push_back (strip);
- width = juce::jmax (width, image.getWidth());
- height += h + 4;
- }
- if (! strips.empty())
- {
- juce::Image all (juce::Image::RGB, width, height, true);
- {
- juce::Graphics g (all); // (flushed when it goes: a native image's context draws on its release)
- g.fillAll (juce::Colours::black);
- int y = 0;
- for (auto& strip : strips)
- {
- g.drawImageAt (strip, 0, y);
- y += strip.getHeight() + 4;
- }
- }
- savePng (all, prefix + "-names.png");
- report << "names " << (int) strips.size() << "\n";
- }
- }
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- void runPluginEditorSnapshots (const juce::String& folder)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- {
- const juce::File out (folder);
- out.createDirectory();
- lynx::AudioEngine offline (false);
- const auto roots = lynx::findFlStudioRoots();
- const auto presets = juce::File (juce::String::fromUTF8 (roots.data.c_str())).getChildFile ("Patches/Plugin presets/Effects");
- auto kinds = lynx::plugui::flLayoutKinds();
- kinds.push_back (lynx::EffectKind::maximus); // Soundgoodizer (below)
- for (const auto own : lynx::plugui::ownLayoutKinds()) // LYNX's own panels (mixing suite, round 96)
- kinds.push_back (own);
- kinds.push_back (lynx::EffectKind::apexLimiter); // round 114: display-first editor
- kinds.push_back (lynx::EffectKind::ridgeStrip); // round 145: the second pass shows the Vocal strip voicing
- kinds.push_back (lynx::EffectKind::ridgeStrip); // round 165: the third pass shows the E console voicing
- kinds.push_back (lynx::EffectKind::compressor); // round 152: the RComp role's panel (vintage voicing, RComp ranges)
- const auto database = juce::File (juce::String::fromUTF8 (roots.data.c_str())).getChildFile ("Patches/Plugin database/Effects");
- auto maximusPasses = 0; // Maximus has its own page (first pass); the second pass shows Soundgoodizer
- auto ridgePasses = 0;
- // round 173d3: the parity pictures of one editor — LYNX_PLUGUI_ONLY=<effect name>, LYNX_PLUGUI_PRESET=<.fst>,
- // LYNX_PLUGUI_PAGES=<page,page,…> (the page numbers as the editor encodes them)
- const auto only = juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGUI_ONLY", {});
- const auto onlyPreset = juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGUI_PRESET", {});
- const auto onlyPages = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_PLUGUI_PAGES", {}), ",", "");
- for (const auto kind : kinds)
- {
- if (only.isNotEmpty() && only != lynx::effectInfo (kind).name)
- continue;
- auto fx = lynx::makeEffectSlot (kind);
- juce::String name (lynx::effectInfo (kind).name);
- for (const auto& plugin : lynx::flPluginsForEffect (kind))
- {
- const auto dir = presets.getChildFile (juce::String::fromUTF8 (plugin.c_str()));
- auto file = dir.getChildFile ("Default.fst");
- if (! file.existsAsFile()) // plugins without presets: their entry of FL's plugin database
- for (const auto& f : database.findChildFiles (juce::File::findFiles, true, juce::String::fromUTF8 (plugin.c_str()) + ".fst"))
- file = f;
- if (only.isNotEmpty() && onlyPreset.isNotEmpty())
- file = juce::File (onlyPreset);
- if (! file.existsAsFile())
- {
- auto files = dir.findChildFiles (juce::File::findFiles, true, "*.fst");
- std::sort (files.begin(), files.end(), [] (const juce::File& a, const juce::File& b) { return a.getFullPathName().compareNatural (b.getFullPathName()) < 0; });
- file = files.isEmpty() ? juce::File() : files[0];
- }
- juce::MemoryBlock data;
- if (file.existsAsFile() && file.loadFileAsData (data))
- {
- const auto* bytes = static_cast<const std::uint8_t*> (data.getData());
- if (auto loaded = lynx::effectFromFlPreset (std::vector<std::uint8_t> (bytes, bytes + data.getSize()), 130.0, lynx::natives::flDataReader (lynx::flStudioAccess())); loaded && loaded->kind == kind)
- {
- fx = *loaded;
- // round 190in (FW-8): a LYNX engine loaded with an FL plugin's preset stands in for that
- // plugin as an imported slot does (its header shows FL's name)
- if (fx.flOrigin.empty() && ! lynx::plugui::hasFlLayout (kind))
- fx.flOrigin.plugin = plugin;
- }
- }
- name = juce::String::fromUTF8 (plugin.c_str());
- break;
- }
- if (kind == lynx::EffectKind::maximus && ++maximusPasses == 2) // Soundgoodizer: preset A of the installation, Amount 60 %
- {
- juce::MemoryBlock data;
- juce::File (juce::String::fromUTF8 (roots.factoryData.c_str())).getChildFile ("Plugins/Fruity/Effects/Soundgoodizer/Data/Presets/a.dat").loadFileAsData (data);
- lynx::maximusfx::Blob blob;
- blob.build = lynx::hlfx::MaximusBuild::soundgoodizer;
- blob.mix = 600;
- const auto* b = static_cast<const std::uint8_t*> (data.getData());
- blob.state.assign (b, b + data.getSize());
- fx = lynx::makeEffectSlot (kind);
- fx.state = lynx::maximusfx::pack (blob);
- name = "Soundgoodizer";
- }
- if (kind == lynx::EffectKind::ridgeStrip && ++ridgePasses == 2) // round 145: her Vocalstrip 2 setting
- {
- for (const auto& [param, value] : { std::pair<const char*, float> { "Vocal strip", 1.0f }, { "Compander", 1.0f },
- { "Compander threshold", 0.3083f }, { "Compander ratio", 0.6929f }, { "Compander attack", 0.2543f },
- { "Compander release", 0.5316f }, { "Make-up", 0.2917f }, { "Soft knee", 1.0f },
- { "Expander threshold", 0.2198f }, { "Vocal input", 0.6792f }, { "Vocal output", 0.3938f },
- { "Process order", 0.4783f }, { "De-esser", 1.0f } })
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, param)] = value;
- name = "Ridge Strip (Vocal strip)";
- }
- else if (kind == lynx::EffectKind::ridgeStrip && ridgePasses == 3) // round 165: the E console, EQ to the side chain
- {
- for (const auto& [param, value] : { std::pair<const char*, float> { "Voicing", 1.0f }, { "HPF", 0.3f }, { "HF gain", 0.8f },
- { "HF bell", 1.0f }, { "Ratio", 0.5f }, { "Comp. threshold", 0.4f }, { "EQ to SC", 1.0f },
- { "Filter split", 1.0f }, { "Expander", 1.0f } })
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, param)] = value;
- name = "Ridge Strip (E console)";
- }
- else if (kind == lynx::EffectKind::ridgeStrip) // a vocal setting, so the graphs show something
- for (const auto& [param, value] : { std::pair<const char*, float> { "HPF", 0.3f }, { "LMF gain", 0.35f }, { "HF gain", 0.7f },
- { "Ratio", 0.3f }, { "Comp. threshold", 0.55f } })
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, param)] = value;
- if (kind == lynx::EffectKind::compressor) // round 152: the vintage voicing with the reference's ranges and meter
- {
- for (const auto& [param, value] : { std::pair<const char*, float> { "Voicing", 1.0f }, { "Ranges", 1.0f }, { "Limiter", 1.0f },
- { "Threshold", 0.6f }, { "RC ratio", 0.4f } })
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, param)] = value;
- name = "Compressor (RComp role)";
- }
- if (kind == lynx::EffectKind::apexLimiter) // round 114: gain into the ceiling, so the display shows reduction
- fx.params[0] = 0.33f;
- if (kind == lynx::EffectKind::ember)
- {
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, "Drive")] = 0.5f;
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, "Bands")] = 1.0f; // round 108: the band rows
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, "B3 drive")] = 0.6f;
- }
- if (kind == lynx::EffectKind::crestCompressor) // round 108: a curve with a knee and a side-chain low cut
- for (const auto& [param, value] : { std::pair<const char*, float> { "Threshold", 0.55f }, { "Knee", 0.15f },
- { "SC1 shape", 0.5f }, { "SC1 freq.", 0.3f } })
- fx.params[(std::size_t) lynx::plugui::paramIndex (kind, param)] = value;
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- if (lynx::ProEditorWindows::handles (kind)) // round 114: the display-first editors, with a demo signal
- {
- auto editor = lynx::makeProEditor (offline, 1, 0, true);
- auto image = lynx::shot::paint (*editor);
- const auto file = lynx::shot::file (out.getChildFile (name + ".png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- continue;
- }
- const auto pages = name == "Soundgoodizer" ? 1 : juce::jmax (1, (int) lynx::plugui::layoutFor (kind).pages.size());
- std::vector<int> pageList;
- for (int page = 0; page < pages; ++page)
- pageList.push_back (page);
- if (only.isNotEmpty() && ! onlyPages.isEmpty())
- {
- pageList.clear();
- for (const auto& p : onlyPages)
- pageList.push_back (p.getIntValue());
- }
- for (const auto page : pageList)
- {
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, page);
- auto image = lynx::shot::paint (*editor, lynx::theme::panel);
- const auto file = lynx::shot::file (out.getChildFile (name + (page > 0 ? "-p" + juce::String (page + 1) : juce::String()) + ".png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- }
- // round 137: Echoform in its Rhythm mode (EchoBoy's role) with the Present era
- {
- namespace ef = lynx::echosuite::echoform;
- auto fx = lynx::makeEffectSlot (lynx::EffectKind::echoform);
- fx.params[ef::rhythm] = 1.0f;
- fx.params[ef::rhythmRepeats] = 5.0f / 15.0f;
- fx.params[ef::rhythmDecay] = 0.25f;
- fx.params[ef::rhythmTap1 + 2] = 0.45f;
- fx.params[ef::feedback] = 0.25f;
- fx.params[ef::era] = 0.5f;
- for (const auto& [param, value] : ef::rhythmPresetEdits (0)) // round 144: a pattern in the rhythm editor (Grid)
- fx.params[(std::size_t) param] = value;
- fx.params[ef::rhythmShape] = 0.5f; // swell
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
- auto image = lynx::shot::paint (*editor, lynx::theme::panel);
- const auto file = lynx::shot::file (out.getChildFile ("Echoform-rhythm.png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- // round 150: Echoform with a voicing (the Stereo / L/R offset controls on the Rhythm row)
- {
- namespace ef = lynx::echosuite::echoform;
- auto fx = lynx::makeEffectSlot (lynx::EffectKind::echoform);
- fx.params[ef::voicing] = ef::voicingValue (ef::voicingForEchoBoyStyle (19));
- fx.params[ef::style] = ef::styleValue (ef::Style::dual);
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
- auto image = lynx::shot::paint (*editor, lynx::theme::panel);
- const auto file = lynx::shot::file (out.getChildFile ("Echoform-voicing.png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- // round 150: Auto-pan's Rhythm voicing with its Tweak row (PanMan's role)
- {
- auto fx = lynx::makeEffectSlot (lynx::EffectKind::autoPan);
- fx.params[lynx::autopan::count] = 1.0f; // the Rhythm voicing
- fx.params[lynx::autopan::count + 13] = 0.75f; // offset mod +90°
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
- auto image = lynx::shot::paint (*editor, lynx::theme::panel);
- const auto file = lynx::shot::file (out.getChildFile ("Auto-pan-tweak.png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- // round 165: Ember's Classic voicing (the Decapitator role) in its one-screen panel
- {
- namespace em = lynx::mixsuite::ember;
- auto fx = lynx::makeEffectSlot (lynx::EffectKind::ember);
- fx.params[em::voicing] = 1.0f;
- fx.params[em::classicDrive] = 0.35f;
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
- auto image = lynx::shot::paint (*editor, lynx::theme::panel);
- const auto file = lynx::shot::file (out.getChildFile ("Ember Saturator-classic.png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- // round 152: Foil Plate's one-knob Plate view (the Little Plate role)
- {
- auto fx = lynx::makeEffectSlot (lynx::EffectKind::foilPlate);
- fx.params[14] = 1.0f; // the measured plate voicing
- fx.params[15] = 1.0f; // View = Plate
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
- auto image = lynx::shot::paint (*editor, lynx::theme::panel);
- const auto file = lynx::shot::file (out.getChildFile ("Foil Plate-plate.png"));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = file.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- // LYNX's own editors with live displays (round 103): Facet EQ (a mixing curve, one dynamic band, demo analyser)
- // and LYNX Tune (demo pitch phrase)
- {
- lynx::setNativeEditorDemo (true);
- using namespace lynx::facet;
- auto eq = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
- const struct { Shape s; double f, g, q; int slope; double range; } bandsDemo[] = {
- { Shape::lowCut, 32, 0, 1, 24, 0 }, { Shape::bell, 110, 3, 1.2, 12, 0 }, { Shape::bell, 380, -3.5, 1.6, 12, 0 },
- { Shape::bell, 3200, 0, 2.5, 12, -6 }, { Shape::highShelf, 9000, 2.5, 0.8, 12, 0 }
- };
- for (int b = 0; b < 5; ++b)
- {
- eq.params[(std::size_t) param (b, 0)] = shapeValue (bandsDemo[b].s);
- eq.params[(std::size_t) param (b, 1)] = hzValue (bandsDemo[b].f);
- eq.params[(std::size_t) param (b, 2)] = gainValue (bandsDemo[b].g);
- eq.params[(std::size_t) param (b, 3)] = qValue (bandsDemo[b].q);
- eq.params[(std::size_t) param (b, 4)] = slopeValue (bandsDemo[b].slope);
- eq.params[(std::size_t) (rangeParam0 + b)] = rangeValue (bandsDemo[b].range);
- }
- eq.params[(std::size_t) phaseParam] = phaseValue (Phase::natural);
- const auto own = [&] (const lynx::EffectSlot& fx, const juce::String& file, bool facetEditor, int page = 0) {
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Vocal";
- song.mixer[1].effects.push_back (fx);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto editor = facetEditor ? lynx::makeFacetEqEditor (offline, 1, 0, true) : lynx::makeNativeEffectEditor (offline, 1, 0, 1.25f, page);
- auto image = lynx::shot::paint (*editor, lynx::theme::panel);
- const auto f = lynx::shot::file (out.getChildFile (file));
- f.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = f.createOutputStream())
- png.writeImageToStream (image, *stream);
- };
- own (eq, "Facet EQ.png", true);
- own (lynx::makeEffectSlot (lynx::EffectKind::lynxTune), "LYNX Tune.png", false);
- {
- // round 128: the ADVANCED page, with E bypassed and A removed on the keyboard and a created vibrato
- auto tune = lynx::makeEffectSlot (lynx::EffectKind::lynxTune);
- tune.params[(std::size_t) (lynx::lynxtune::bypassC + 4)] = 1.0f;
- tune.params[(std::size_t) (lynx::lynxtune::noteC + 9)] = 0.0f;
- tune.params[lynx::lynxtune::vibratoShape] = 1.0f / 3.0f;
- // round 166c: the created vibrato's amplitude / formant / variation, a short throat, In scale +2
- tune.params[lynx::lynxtune::vibratoAmplitude] = 1.0f / 3.0f;
- tune.params[lynx::lynxtune::vibratoFormant] = 0.7f;
- tune.params[lynx::lynxtune::vibratoVariation] = 0.2f;
- tune.params[lynx::lynxtune::throatLength] = lynx::lynxtune::throatValue (80.0);
- tune.params[lynx::lynxtune::transposeInScale] = 1.0f;
- tune.params[lynx::lynxtune::scaleTranspose] = lynx::lynxtune::scaleTransposeValue (2);
- own (tune, "LYNX Tune-p2.png", false, 1);
- }
- own (lynx::makeEffectSlot (lynx::EffectKind::lynxTune), "LYNX Tune-p3.png", false, 2); // round 135w: Real-time
- lynx::setNativeEditorDemo (false);
- }
- // generators in FL's arrangement: the channel's plugin page with the FL preset's settings
- const auto generators = juce::File (juce::String::fromUTF8 (roots.data.c_str())).getChildFile ("Patches/Plugin presets/Generators");
- for (auto [folder, preset] : std::vector<std::pair<const char*, const char*>> { { "3x Osc", "Default.fst" }, { "FL Keys", "Grand Piano.fst" }, { "BooBass", "" }, { "Sytrus", "Default.fst" }, { "Harmor", "Default.fst" } })
- {
- juce::MemoryBlock data;
- if (juce::String (folder) == "Harmor") // the first preset whose state the engine reads
- {
- auto files = generators.getChildFile (folder).findChildFiles (juce::File::findFiles, true, "*.fst");
- files.sort();
- for (const auto& f : files)
- {
- juce::MemoryBlock block;
- if (! f.loadFileAsData (block))
- continue;
- const auto* b = static_cast<const std::uint8_t*> (block.getData());
- try
- {
- const auto p = flp::parseProject (std::vector<std::uint8_t> (b, b + block.getSize()), true);
- if (! p.channels.empty() && lynx::harmorStateUsable (p.channels.front().pluginState))
- {
- preset = nullptr;
- data = block;
- break;
- }
- }
- catch (const std::exception&)
- {
- }
- }
- }
- auto file = preset == nullptr ? juce::File() : juce::String (preset).isEmpty() ? database.getSiblingFile ("Generators").getChildFile ("Misc").getChildFile (juce::String (folder) + ".fst")
- : generators.getChildFile (folder).getChildFile (preset);
- if (! file.existsAsFile())
- {
- auto files = generators.getChildFile (folder).findChildFiles (juce::File::findFiles, true, "*.fst");
- files.sort();
- file = files.isEmpty() ? juce::File() : files[0];
- }
- if (data.isEmpty() && ! file.loadFileAsData (data))
- continue;
- try
- {
- const auto* bytes = static_cast<const std::uint8_t*> (data.getData());
- auto project = flp::parseProject (std::vector<std::uint8_t> (bytes, bytes + data.getSize()), true);
- if (project.channels.empty())
- continue;
- project.channels.front().type = flp::ChannelType::native;
- lynx::FlpImportOptions options;
- options.roots = roots;
- options.fileExists = [] (const std::string& path) { return lynx::platform::localFile (path).existsAsFile(); };
- options.readFile = [] (const std::string& path) {
- juce::MemoryBlock block;
- lynx::platform::localFile (path).loadFileAsData (block);
- const auto* b = static_cast<const std::uint8_t*> (block.getData());
- return std::vector<std::uint8_t> (b, b + block.getSize());
- };
- options.saveEmbedded = [out] (const std::vector<std::uint8_t>& wav, const std::string& name) {
- const auto f = out.getChildFile ("samples").getNonexistentChildFile (juce::String::fromUTF8 (name.c_str()), ".wav");
- f.getParentDirectory().createDirectory();
- f.replaceWithData (wav.data(), wav.size());
- return f.getFullPathName().toStdString();
- };
- auto song = lynx::importFlp (project, options);
- // the page only needs the plugin's saved state (FL Keys' sample zones need the installed wavetables)
- if (! song.channels.empty() && project.channels.front().pluginName == "BooBass" && song.channels.front().instrument != lynx::InstrumentKind::boobass)
- {
- song.channels.front().instrument = lynx::InstrumentKind::boobass; // (its sound needs the engine DLL; the page does not)
- song.channels.front().modelParams.assign (3, 32768.0f);
- }
- if (! song.channels.empty() && project.channels.front().pluginName == "FL Keys")
- {
- song.channels.front().instrument = lynx::InstrumentKind::flkeys;
- song.channels.front().pluginState = project.channels.front().pluginState;
- }
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- if (offline.getSong().channels.empty())
- continue;
- auto panel = lynx::makeChannelSettingsPanel (offline, 0);
- auto image = lynx::shot::paint (*panel, lynx::theme::panel);
- const auto out2 = lynx::shot::file (out.getChildFile (juce::String (folder) + ".png"));
- out2.deleteFile();
- juce::PNGImageFormat png;
- if (auto stream = out2.createOutputStream())
- png.writeImageToStream (image, *stream);
- }
- catch (const std::exception&)
- {
- }
- }
- }
- quit();
- }
- void runVideoShot (const juce::String& prefix, const juce::String& videoPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- // the message loop runs while the frames decode (modal loops are off): a timer takes one snapshot per step
- struct VideoShot final : juce::Timer
- {
- lynx::AudioEngine offline { false };
- std::unique_ptr<juce::Component> editor;
- juce::String prefix, report;
- int step = 0;
- std::function<void()> done;
- void moveTo (double seconds)
- {
- offline.getTransport().positionTicks.store (seconds * offline.getSong().bpm / 60.0 * lynx::ppq);
- }
- void timerCallback() override
- {
- static constexpr double times[] = { 0.0, 1.5, 3.25 };
- constexpr int typeInStep = (int) std::size (times) + 1;
- if (step > 0 && step < typeInStep && editor != nullptr)
- savePng (lynx::shot::snapshot (*editor), prefix + "-" + juce::String (step - 1) + ".png");
- if (editor != nullptr && step == (int) std::size (times))
- {
- // round 174d: FL's in-place type-in of the current time (a right click on it)
- lynx::videoview::openTypeIn (*editor, 2);
- ++step;
- return;
- }
- if (editor != nullptr && step == typeInStep)
- savePng (lynx::shot::snapshot (*editor), prefix + "-typein.png");
- if (editor == nullptr || step >= typeInStep)
- {
- stopTimer();
- juce::File (prefix + "-report.txt").replaceWithText (report);
- if (done)
- done();
- return;
- }
- moveTo (times[step++]);
- }
- };
- static std::unique_ptr<VideoShot> shot;
- shot = std::make_unique<VideoShot>();
- shot->prefix = prefix;
- auto& offline = shot->offline;
- lynx::videoview::install (offline);
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (2);
- lynx::ChannelDef c;
- c.name = "Fruity Video Player";
- c.instrument = lynx::InstrumentKind::videoplayer;
- lynx::video::Settings vs;
- vs.path = juce::File (videoPath).getFullPathName().toStdString();
- vs.delay = lynx::video::unitsPerSecond / 2; // the video starts at 0.5 s
- c.pluginState = lynx::video::write (vs);
- song.channels.push_back (c);
- song.patterns.emplace_back();
- {
- // round 174d (A3): the same Video Player in a song whose tempo drops from 120 to 60 BPM at bar 5, for FL
- // (LYNX.exe --export-flp <prefix>-tempo.lynx <prefix>-tempo.flp), to compare FL's video clock with LYNX's
- auto fl = song;
- fl.bpm = 120.0;
- fl.mode = lynx::PlayMode::song;
- auto settings = vs;
- settings.delay = 0;
- settings.timeDisplay = lynx::video::Settings {}.timeDisplay;
- fl.channels[0].pluginState = lynx::video::write (settings);
- fl.patterns[0].name = "Pattern 1";
- lynx::Automation tempo;
- tempo.name = "Tempo";
- tempo.target = { lynx::AutomationTargetKind::tempo, 0, 0, 0 };
- const auto bar = (std::int64_t) lynx::ppq * 4;
- tempo.points = { { 0, lynx::valueFromTempo (120.0), 0.0f }, { bar * 4 - 1, lynx::valueFromTempo (120.0), 0.0f },
- { bar * 4, lynx::valueFromTempo (60.0), 0.0f }, { bar * 8, lynx::valueFromTempo (60.0), 0.0f } };
- fl.automations.push_back (tempo);
- lynx::Clip at;
- at.kind = lynx::ClipKind::automation;
- at.automation = 0;
- at.track = 1;
- at.start = 0;
- at.length = bar * 8;
- fl.playlist.push_back (at);
- lynx::Clip pc;
- pc.pattern = 0;
- pc.track = 0;
- pc.start = 0;
- pc.length = bar * 8;
- fl.playlist.push_back (pc);
- juce::String error;
- lynx::ProjectFile::save (fl, juce::File (prefix + "-tempo.lynx"), error);
- }
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto& report = shot->report;
- report << "ffmpeg: " << lynx::findFfmpeg().getFullPathName() << "\n";
- report << lynx::videoview::report (vs.path).fromFirstOccurrenceOf ("Input #0", true, false).upToFirstOccurrenceOf ("At least", false, false) << "\n";
- shot->editor = lynx::makeChannelSettingsPanel (offline, 0);
- if (shot->editor != nullptr)
- shot->editor->setVisible (true);
- shot->done = [this] { juce::MessageManager::callAsync ([this] { shot.reset(); quit(); }); };
- shot->startTimer (1500);
- }
- void runVideoTrackShot (const juce::String& prefix, const juce::String& videoPath, const juce::String& secondPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- struct TrackShot final : juce::Timer
- {
- lynx::AudioEngine offline { false };
- std::unique_ptr<lynx::PlaylistComponent> playlist;
- std::unique_ptr<lynx::media::FrameDecoder> decoder;
- juce::String prefix, report, path;
- double fps = 25.0;
- int step = 0, waits = 0, adrStep = 0;
- std::unique_ptr<juce::Component> adrPanel;
- std::function<void()> done;
- // song times (s): before, inside the first clip (on and between frame edges), across the second clip
- std::vector<double> times { 0.0, 1.0, 2.0 + 1.0 / 25.0, 2.5, 4.0, 7.3 };
- void timerCallback() override
- {
- if (step > 0 && adrStep == 0)
- {
- // the frame the decoder shows for the wanted file time (the clip starts at song 1.0 s, offset 0)
- const auto want = times[(std::size_t) step - 1] - 1.0;
- double ft = -1.0;
- const auto img = decoder->frame (ft);
- const auto expected = std::floor (want * fps + 1e-6) / fps;
- if (want >= 0.0 && ft < expected - 1e-3 && ++waits < 20)
- return; // (still decoding)
- waits = 0;
- report << "song " << juce::String (times[(std::size_t) step - 1], 3) << " s: wanted file time " << juce::String (want, 4)
- << ", frame shown at " << juce::String (ft, 4) << " (expected " << juce::String (expected, 4) << ")"
- << (want < 0.0 ? " [before the clip]" : std::abs (ft - expected) < 1e-3 ? " OK" : " MISMATCH") << "\n";
- savePng (lynx::shot::snapshot (*playlist), prefix + "-playlist-" + juce::String (step - 1) + ".png");
- if (img.isValid())
- savePng (img, prefix + "-frame-" + juce::String (step - 1) + ".png");
- for (int w = 0; w < juce::Desktop::getInstance().getNumComponents(); ++w)
- if (auto* c = juce::Desktop::getInstance().getComponent (w); c != nullptr && c->getName().startsWith ("Picture"))
- savePng (lynx::shot::snapshot (*c), prefix + "-window-" + juce::String (step - 1) + ".png");
- }
- if (step >= (int) times.size() && adrStep == 0)
- {
- // the ADR window: two cues, takes on the first; the play position inside the streamer before the in
- // point (4.0 s), so the video window shows the streamer and the line
- adrStep = 1;
- offline.editSong ([] (lynx::Song& s) {
- lynx::AdrCue a, b;
- a.id = "SC1-01";
- a.in = 4.0;
- a.out = 6.4;
- a.character = "Dr. Silva";
- a.line = "We have to leave before the storm reaches the coast.";
- a.notes = "softer, out of breath";
- a.status = lynx::AdrCue::Status::recorded;
- for (int n = 1; n <= 3; ++n)
- {
- lynx::AdrTake t;
- t.number = n;
- t.name = lynx::adr::takeName (a, n);
- t.rating = n == 2 ? 4 : n;
- t.circled = n == 2;
- a.takes.push_back (t);
- }
- a.selected = 2;
- lynx::adr::setCompRange (a, 4.0, 5.1, 2);
- lynx::adr::setCompRange (a, 5.1, 6.4, 3);
- b.id = "SC1-02";
- b.in = 8.0;
- b.out = 9.5;
- b.character = "Marta";
- b.line = "Then we go now.";
- s.adr.cues = { a, b };
- s.adr.current = 0;
- });
- adrPanel = lynx::adrwindow::makePanel (offline);
- adrPanel->setSize (1200, 640);
- adrPanel->setVisible (true);
- offline.getTransport().positionTicks.store (3.0 * offline.getSong().bpm / 60.0 * lynx::ppq);
- decoder->request (2.0, false);
- return;
- }
- if (adrStep == 1)
- {
- adrStep = 2;
- savePng (lynx::shot::snapshot (*adrPanel), prefix + "-adr.png");
- for (int w = 0; w < juce::Desktop::getInstance().getNumComponents(); ++w)
- if (auto* c = juce::Desktop::getInstance().getComponent (w); c != nullptr && c->getName().startsWith ("Picture"))
- savePng (lynx::shot::snapshot (*c), prefix + "-adr-window.png");
- offline.getTransport().positionTicks.store (4.5 * offline.getSong().bpm / 60.0 * lynx::ppq);
- decoder->request (3.5, false);
- return;
- }
- if (adrStep == 2)
- {
- for (int w = 0; w < juce::Desktop::getInstance().getNumComponents(); ++w)
- if (auto* c = juce::Desktop::getInstance().getComponent (w); c != nullptr && c->getName().startsWith ("Picture"))
- savePng (lynx::shot::snapshot (*c), prefix + "-adr-window-line.png");
- adrPanel.reset();
- // export with video: a 3 s mix under the picture, re-encoded (the clip starts at 1 s) and copied (from 1 s)
- {
- const juce::File wav (prefix + "-mix.wav");
- wav.deleteFile();
- juce::WavAudioFormat format;
- if (std::unique_ptr<juce::OutputStream> os (wav.createOutputStream().release()); os != nullptr)
- if (std::unique_ptr<juce::AudioFormatWriter> w (format.createWriterFor (os.get(), 48000.0, 2, 16, {}, 0)); w != nullptr)
- {
- os.release();
- juce::AudioBuffer<float> b (2, 48000 * 3);
- for (int k = 0; k < b.getNumSamples(); ++k)
- b.setSample (0, k, 0.25f * (float) std::sin (k * 2.0 * juce::MathConstants<double>::pi * 330.0 / 48000.0)), b.setSample (1, k, b.getSample (0, k));
- w->writeFromAudioSampleBuffer (b, 0, b.getNumSamples());
- }
- for (const auto origin : { 0.0, 1.0 })
- {
- const juce::File out (prefix + "-mux-" + juce::String ((int) origin) + ".mp4");
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- const auto error = lynx::videotracks::muxWithVideo (offline.getSong(), origin, wav, out);
- report << "export with video from " << origin << " s: " << (error.isEmpty() ? "OK " + juce::String (out.getSize()) + " bytes" : "FAILED " + error)
- << " (" << juce::String ((juce::Time::getMillisecondCounterHiRes() - t0) / 1000.0, 2) << " s)\n";
- }
- }
- stopTimer();
- report << "frames decoded " << decoder->frameCount() << ", dropped " << decoder->droppedCount() << "\n";
- juce::File (prefix + "-report.txt").replaceWithText (report);
- if (done)
- done();
- return;
- }
- const auto t = times[(std::size_t) step++];
- offline.getTransport().positionTicks.store (t * offline.getSong().bpm / 60.0 * lynx::ppq);
- decoder->request (std::max (0.0, t - 1.0), false);
- }
- };
- static std::unique_ptr<TrackShot> shot;
- shot = std::make_unique<TrackShot>();
- shot->prefix = prefix;
- auto& offline = shot->offline;
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (2);
- song.patterns.emplace_back();
- song.mode = lynx::PlayMode::song;
- song.bpm = 120.0;
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- const juce::File video (videoPath);
- const auto pr = lynx::media::probe (video.getFullPathName());
- auto& report = shot->report;
- report << "decoder: " << (pr.backend.isEmpty() ? juce::String ("none") : pr.backend) << " (system: " << lynx::media::nativeBackendName()
- << ", ffmpeg: " << lynx::findFfmpeg().getFullPathName() << ")\n";
- report << "video: " << pr.info.width << "x" << pr.info.height << " " << juce::String (pr.info.fps, 3) << " fps " << juce::String (pr.info.duration, 3)
- << " s, sound " << (pr.info.hasAudio ? "yes" : "no") << "\n";
- shot->fps = pr.info.fps > 1.0 ? pr.info.fps : 25.0;
- shot->times[2] = 2.0 + 1.0 / shot->fps; // (exactly on a frame edge)
- lynx::videotracks::importVideo (offline, video, 1.0, -1);
- if (secondPath.isNotEmpty())
- lynx::videotracks::importVideo (offline, juce::File (secondPath), 3.0, 1);
- offline.editSong ([] (lynx::Song& s) {
- s.video.startTimecode = 3600.0;
- s.video.burnIn = true;
- while (s.videoTracks.size() < 2) // (round 190rf, ASan: no video could be imported at all)
- s.videoTracks.push_back ({});
- s.videoTracks[0].name = "Picture";
- s.videoTracks[1].name = "Reference";
- });
- report << "project rate: " << lynx::vtime::rateName (offline.getSong().video.rate) << ", clip 1: "
- << juce::String (offline.getSong().videoTracks[0].clips.empty() ? -1.0 : offline.getSong().videoTracks[0].clips[0].length, 3) << " s\n";
- // the project round trip
- {
- const juce::File file (prefix + "-project.lynx");
- juce::String error;
- lynx::ProjectFile::save (offline.getSong(), file, error);
- const auto back = lynx::ProjectFile::load (file, error);
- report << "project file round trip: " << (back && back->videoTracks == offline.getSong().videoTracks && back->video == offline.getSong().video ? "OK" : "MISMATCH " + error) << "\n";
- }
- shot->playlist = std::make_unique<lynx::PlaylistComponent> (offline);
- shot->playlist->setSize (1400, 640);
- shot->playlist->setVisible (true);
- shot->decoder = std::make_unique<lynx::media::FrameDecoder>();
- shot->decoder->setSource (video.getFullPathName(), pr.info);
- shot->decoder->setSize (pr.info.width, pr.info.height);
- shot->decoder->startThread (juce::Thread::Priority::low);
- lynx::videotracks::showWindow (offline, 0);
- shot->done = [this] { juce::MessageManager::callAsync ([this] { shot.reset(); quit(); }); };
- shot->startTimer (700);
- }
- void runDanceShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- // the moves: one row each, eight moments of a cycle (both facings for Spinning; Pose ends the sheet)
- {
- constexpr int cell = 120, cols = 8;
- auto sheet = lynx::shot::canvas (130 + cols * cell, lynx::dance::moveCount * cell + 10);
- {
- // (the picture is complete when its Graphics is gone: round 190ba, the file was blank on Windows)
- juce::Graphics g (sheet);
- lynx::shot::logical (g);
- g.fillAll (lynx::theme::colour::bg0);
- for (int m = 0; m < lynx::dance::moveCount; ++m)
- {
- g.setColour (lynx::theme::colour::textSecondary);
- g.setFont (14.0f);
- g.drawText (lynx::dance::moveName (m), 8, m * cell + 5, 118, cell, juce::Justification::centredLeft);
- for (int k = 0; k < cols; ++k)
- {
- const auto pose = lynx::dance::pose (m, k / (double) cols + (m == lynx::dance::freestyle ? k * 2 : 0), 1);
- lynx::dancer::draw (g, { 130.0f + (k + 0.5f) * cell, (float) (m + 1) * cell - 6.0f }, 92.0f, pose, false, juce::Colour (0xffff3048));
- }
- }
- }
- savePng (sheet, prefix + "-moves.png");
- }
- lynx::AudioEngine offline (false);
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (2);
- for (int d = 0; d < 2; ++d)
- {
- lynx::ChannelDef c;
- c.name = d == 0 ? "Fruity Dance" : "Fruity Dance #2";
- c.instrument = lynx::InstrumentKind::fruitydance;
- lynx::dance::Settings s;
- s.move = d == 0 ? lynx::dance::stepping : lynx::dance::waving;
- s.x = d == 0 ? 520 : 760;
- s.y = 560;
- s.colour = d == 0 ? 0xffff3048 : 0xff30a8ff;
- s.mirrored = d == 1;
- c.pluginState = lynx::dance::toState (s);
- song.channels.push_back (c);
- }
- // Issue #121 (round 190ba): a sprite sheet in FL's Fruity Dance format (8 frames across, a row per move, a names
- // file beside it), made here from LYNX's own poses, loaded back as a user's sheet would be
- juce::String sheetReport;
- {
- constexpr int fw = 120, fh = 150;
- const std::vector<std::pair<const char*, int>> rows { { "Idle", lynx::dance::waiting }, { "Step", lynx::dance::stepping },
- { "Jump", lynx::dance::jumping }, { "Wave", lynx::dance::waving },
- { "Windmill", lynx::dance::windmill }, { "Held", lynx::dance::held } };
- juce::Image sheet (juce::Image::ARGB, fw * lynx::dance::sheetColumns, fh * (int) rows.size(), true);
- {
- juce::Graphics g (sheet);
- for (int r = 0; r < (int) rows.size(); ++r)
- for (int k = 0; k < lynx::dance::sheetColumns; ++k)
- {
- juce::Graphics::ScopedSaveState save (g);
- g.reduceClipRegion (k * fw, r * fh, fw, fh);
- lynx::dancer::draw (g, { (k + 0.5f) * fw, (float) (r + 1) * fh - 8.0f }, 96.0f,
- lynx::dance::pose (rows[(std::size_t) r].second, k / (double) lynx::dance::sheetColumns, 1), false, juce::Colour (0xff35c46a));
- }
- }
- const juce::File picture (prefix + "-sheet.png");
- savePng (sheet, picture.getFullPathName());
- juce::String names;
- for (const auto& [name, move] : rows)
- names << (names.isEmpty() ? "" : "\r\n") << name;
- picture.withFileExtension ("txt").replaceWithText (names, false, false, nullptr);
- // a picture that is not a whole number of frames: FL's "Bitmap size is incorrect."
- const juce::File wrong (prefix + "-sheet-wrong.png");
- savePng (sheet.getClippedImage ({ 0, 0, sheet.getWidth() - 3, sheet.getHeight() }), wrong.getFullPathName());
- wrong.withFileExtension ("txt").replaceWithText (names, false, false, nullptr);
- auto error = lynx::dancer::SheetError::none;
- const auto loaded = lynx::dancer::sheetFor (picture.getFullPathName().toStdString(), &error);
- auto wrongError = lynx::dancer::SheetError::none;
- const auto refused = lynx::dancer::sheetFor (wrong.getFullPathName().toStdString(), &wrongError);
- auto missingError = lynx::dancer::SheetError::none;
- const auto missing = lynx::dancer::sheetFor (juce::File (prefix + "-sheet-none.png").getFullPathName().toStdString(), &missingError);
- sheetReport << "sheet_loaded=" << (loaded != nullptr ? 1 : 0) << "\n"
- << "sheet_wrong_size_refused=" << (refused == nullptr && wrongError == lynx::dancer::SheetError::size ? 1 : 0) << "\n"
- << "sheet_missing_refused=" << (missing == nullptr && missingError == lynx::dancer::SheetError::missing ? 1 : 0) << "\n";
- bool ok = loaded != nullptr && refused == nullptr && missing == nullptr;
- if (loaded != nullptr)
- {
- sheetReport << "sheet_rows=" << loaded->layout.rows << "\nsheet_frame=" << loaded->layout.frameWidth << "x" << loaded->layout.frameHeight
- << "\nsheet_moves=" << loaded->moves() << "\nsheet_names=";
- for (const auto& n : loaded->names)
- sheetReport << juce::String::fromUTF8 (n.c_str()) << ";";
- sheetReport << "\n";
- ok = ok && loaded->layout.rows == (int) rows.size() && loaded->layout.frameWidth == fw && loaded->layout.frameHeight == fh;
- // the animation as the stage draws it: a row of moments of the move "Wave" (blending on), then mirrored,
- // then the row shown while the dancer is held
- auto strip = lynx::shot::canvas (fw * 12, fh * 3 + 20);
- int solid = 0;
- {
- juce::Graphics g (strip);
- lynx::shot::logical (g);
- g.fillAll (lynx::theme::colour::bg0);
- for (int line = 0; line < 3; ++line)
- {
- lynx::dance::SheetAnimator animator (3);
- for (int k = 0; k < 12; ++k)
- {
- const auto frame = animator.advance (k / 12.0 + 0.001, loaded->layout.rows, 4, line == 1, true, 0.5f, line == 2);
- const juce::Point<float> feet ((k + 0.5f) * fw, (float) (line + 1) * fh + 5.0f);
- lynx::dancer::drawSheet (g, *loaded, feet, 1.0f, frame);
- solid += lynx::dancer::sheetSolidAt (*loaded, feet, 1.0f, frame, feet.translated (0.0f, -70.0f)) ? 1 : 0;
- ok = ok && ! lynx::dancer::sheetSolidAt (*loaded, feet, 1.0f, frame, feet.translated (-(float) fw * 0.5f + 1.0f, -(float) fh + 1.0f));
- }
- }
- }
- // mirrored = the same frame flipped left-right, on whatever renderer this build draws with
- {
- lynx::dance::SheetFrame plain;
- plain.row = 3;
- plain.column = 2;
- auto turned = plain;
- turned.mirrored = true;
- juce::Image a (juce::Image::ARGB, fw, fh, true), b (juce::Image::ARGB, fw, fh, true);
- {
- juce::Graphics ga (a);
- lynx::dancer::drawSheet (ga, *loaded, { fw * 0.5f, (float) fh }, 1.0f, plain);
- }
- {
- juce::Graphics gb (b);
- lynx::dancer::drawSheet (gb, *loaded, { fw * 0.5f, (float) fh }, 1.0f, turned);
- }
- int same = 0, flippedSame = 0, solidPixels = 0;
- for (int y = 0; y < fh; ++y)
- for (int x = 0; x < fw; ++x)
- {
- const auto pa = a.getPixelAt (x, y);
- if (pa.getAlpha() < 200)
- continue;
- ++solidPixels;
- auto alike = [pa] (juce::Colour c) {
- return std::abs ((int) c.getRed() - (int) pa.getRed()) + std::abs ((int) c.getGreen() - (int) pa.getGreen())
- + std::abs ((int) c.getBlue() - (int) pa.getBlue()) + std::abs ((int) c.getAlpha() - (int) pa.getAlpha()) < 12;
- };
- same += alike (b.getPixelAt (x, y)) ? 1 : 0;
- flippedSame += alike (b.getPixelAt (fw - 1 - x, y)) ? 1 : 0;
- }
- const auto flips = solidPixels > 500 && flippedSame >= solidPixels * 98 / 100 && same < solidPixels * 95 / 100;
- sheetReport << "sheet_mirror_flips=" << (flips ? 1 : 0) << " (" << flippedSame << " of " << solidPixels << " solid pixels match flipped, " << same
- << " unflipped)\n";
- ok = ok && flips;
- }
- sheetReport << "sheet_body_solid=" << solid << "/36\n";
- ok = ok && solid >= 18;
- savePng (strip, prefix + "-sheet-frames.png");
- }
- sheetReport << "sheet_result=" << (ok ? "OK" : "ERROR") << "\n";
- lynx::ChannelDef c;
- c.name = "Fruity Dance #3";
- c.instrument = lynx::InstrumentKind::fruitydance;
- lynx::dance::Settings s;
- s.move = 2; // (the sheet's second row: "Step")
- s.x = 1000;
- s.y = 560;
- s.sheet = picture.getFullPathName().toStdString();
- c.pluginState = lynx::dance::toState (s);
- song.channels.push_back (c);
- }
- song.patterns.emplace_back();
- {
- const juce::File demo (prefix + "-demo.lynx");
- juce::String error;
- lynx::ProjectFile::save (song, demo, error);
- }
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- if (auto editor = lynx::makeChannelSettingsPanel (offline, 0))
- savePng (lynx::shot::snapshot (*editor), prefix + "-editor.png");
- if (auto frame = lynx::makeChannelFrame (offline, 1, 0))
- savePng (lynx::shot::snapshot (*frame), prefix + "-frame.png");
- if (auto editor = lynx::makeChannelSettingsPanel (offline, 2))
- savePng (lynx::shot::snapshot (*editor), prefix + "-sheet-editor.png");
- {
- // the stage with the three dancers (the third from the sheet)
- lynx::DanceStage stage (offline);
- stage.setSize (1280, 640);
- stage.update();
- sheetReport << "stage_dancers=" << stage.dancerCount() << "\n";
- auto picture = lynx::shot::canvas (1280, 640);
- {
- juce::Graphics g (picture);
- lynx::shot::logical (g);
- g.fillAll (lynx::theme::colour::bg0);
- stage.paintEntireComponent (g, true);
- }
- savePng (picture, prefix + "-sheet-stage.png");
- }
- juce::File (prefix + "-sheetreport.txt").replaceWithText (sheetReport);
- }
- void runControllerShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (2);
- song.mixer[1].name = "Insert 1";
- auto fx = lynx::makeEffectSlot (lynx::EffectKind::formulaController);
- lynx::formula::State formula;
- formula.formula = "a*Sin(SongTime*Pi*b*4)+c";
- fx.state = lynx::formula::writeState (formula);
- fx.params[0] = 0.5f;
- fx.params[1] = 0.25f;
- fx.params[2] = 0.5f;
- song.mixer[1].effects.push_back (fx);
- // round 164: X-Y (slot 2), X-Y-Z (slot 3) and a Control Surface (slot 4)
- {
- auto xyFx = lynx::makeEffectSlot (lynx::EffectKind::xyController);
- xyFx.params[(std::size_t) lynx::xy::level (0)] = 0.3f;
- xyFx.params[(std::size_t) lynx::xy::level (1)] = 0.7f;
- xyFx.params[(std::size_t) lynx::xy::tension (0)] = 0.8f;
- song.mixer[1].effects.push_back (xyFx);
- auto xyzFx = lynx::makeEffectSlot (lynx::EffectKind::xyzController);
- xyzFx.params[(std::size_t) lynx::xy::level (2)] = 0.8f;
- song.mixer[1].effects.push_back (xyzFx);
- // round 165: an X-Y-Z whose X curve is FL's "Stairs" (tension +40 %) and Y a bent single curve
- xyzFx.params[(std::size_t) lynx::xy::curveMode (0)] = lynx::xy::curveModeValue (lynx::flcurve::stairs);
- xyzFx.params[(std::size_t) lynx::xy::tension (0)] = 0.7f;
- xyzFx.params[(std::size_t) lynx::xy::level (0)] = 0.62f;
- xyzFx.params[(std::size_t) lynx::xy::tension (1)] = 0.825f;
- song.mixer[1].effects.push_back (xyzFx);
- auto panel = lynx::makeEffectSlot (lynx::EffectKind::controlSurface);
- lynx::SurfaceControl c;
- for (const auto& [kind, name, v, x, y] : std::vector<std::tuple<lynx::SurfaceControl::Kind, const char*, float, float, float>> {
- { lynx::SurfaceControl::Kind::knob, "Cutoff", 0.65f, 20.0f, 20.0f },
- { lynx::SurfaceControl::Kind::knob, "Reso", 0.3f, 90.0f, 20.0f },
- { lynx::SurfaceControl::Kind::slider, "Mix", 0.8f, 170.0f, 20.0f },
- { lynx::SurfaceControl::Kind::xy, "Space", 0.4f, 230.0f, 20.0f },
- { lynx::SurfaceControl::Kind::button, "Drop", 0.0f, 20.0f, 110.0f },
- { lynx::SurfaceControl::Kind::checkBox, "Bypass", 1.0f, 20.0f, 160.0f } })
- {
- c.kind = kind;
- c.name = name;
- c.value = v;
- c.valueY = 0.6f;
- c.x = x;
- c.y = y;
- lynx::surface::add (panel, c);
- }
- song.mixer[1].effects.push_back (panel);
- }
- lynx::ChannelDef env;
- env.name = "Envelope Controller";
- env.instrument = lynx::InstrumentKind::controller;
- auto ecData = lynx::defaultEnvelopeController();
- ecData[0].lfoOn = true;
- ecData[0].lfoTempo = true;
- ecData[0].lfoSpeed = 40898;
- ecData[0].maps[lynx::mapKeyboard].count = 2;
- ecData[0].maps[lynx::mapKeyboard].time = { 0.2f, 0.8f };
- ecData[0].maps[lynx::mapKeyboard].level = { 0.0f, 1.0f };
- ecData[0].maps[lynx::mapModX] = ecData[0].maps[lynx::mapKeyboard];
- env.controllerState = lynx::writeEnvelopeController (ecData);
- song.channels.push_back (env);
- lynx::ChannelDef out;
- out.name = "MIDI Out";
- out.instrument = lynx::InstrumentKind::midiOut;
- lynx::midictl::MidiOutSettings settings;
- settings.port = 1;
- lynx::midictl::writeMidiOut (out.pluginState, settings);
- song.channels.push_back (out);
- // a Layer (round 164) over three synths split across the keyboard, crossfading
- for (const auto* name : { "Bass", "Pad", "Lead" })
- {
- lynx::ChannelDef c;
- c.name = name;
- c.instrument = lynx::InstrumentKind::synth;
- song.channels.push_back (c);
- }
- {
- lynx::ChannelDef layer;
- layer.name = "Layer";
- layer.instrument = lynx::InstrumentKind::layer;
- song.channels.push_back (layer);
- const auto self = (int) song.channels.size() - 1;
- lynx::layer::setChildren (song, self, { 2, 3, 4 });
- song.channels[2].keyLow = 0, song.channels[2].keyHigh = 47;
- song.channels[3].keyLow = 36, song.channels[3].keyHigh = 83;
- song.channels[4].keyLow = 72, song.channels[4].keyHigh = 127;
- song.channels[(std::size_t) self].layer.crossfade = true;
- song.channels[(std::size_t) self].layer.fade = 0.35f;
- }
- {
- lynx::ChannelDef dash; // channel 6
- dash.name = "Dashboard";
- dash.instrument = lynx::InstrumentKind::dashboard;
- dash.patcher.surface = lynx::surface::starterControls();
- song.channels.push_back (dash);
- }
- {
- lynx::ChannelDef volt; // channel 7: FL's render-test settings (main L pitch, R gate × 0.5) with Out 2 on insert 3
- volt.name = "Voltage Controller";
- volt.instrument = lynx::InstrumentKind::voltage;
- lynx::voltage::Settings v;
- v.enabled = true;
- v.params[9] = 49152;
- v.unipolar[2] = true;
- v.tracks = { 3, 0, 0 };
- v.source[6] = lynx::voltage::Source::clock;
- volt.pluginState = lynx::voltage::write (v);
- song.channels.push_back (volt);
- }
- song.patterns.emplace_back();
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto shoot = [&] (std::unique_ptr<juce::Component> c, const juce::String& name) {
- if (c == nullptr)
- return;
- savePng (lynx::shot::snapshot (*c), prefix + name);
- };
- shoot (lynx::makeChannelSettingsPanel (offline, 0), "-envelope-controller.png");
- shoot (lynx::makeChannelSettingsPanel (offline, 1), "-midi-out.png");
- shoot (lynx::makeChannelSettingsPanel (offline, 5), "-layer.png");
- shoot (lynx::makeChannelFrame (offline, 3, -1), "-layer-child-misc.png"); // (the key-region ruler over the root keyboard)
- {
- const auto slotOf = [] (int k) -> lynx::SlotLocator {
- return [k] (lynx::Song& s) { return &s.mixer[1].effects[(std::size_t) k]; };
- };
- const lynx::AutomationTarget target { lynx::AutomationTargetKind::effectParam, 1, 1, 0 };
- shoot (lynx::makeXyControllerEditor (offline, slotOf (1), nullptr, target), "-xy-controller.png");
- shoot (lynx::makeXyControllerEditor (offline, slotOf (2), nullptr, target), "-xyz-controller.png");
- shoot (lynx::makeXyControllerEditor (offline, slotOf (3), nullptr, target), "-xyz-controller-stairs.png");
- shoot (lynx::makeControlSurfaceEditor (offline, slotOf (4), target), "-control-surface.png");
- shoot (lynx::makeChannelSettingsPanel (offline, 6), "-dashboard.png");
- shoot (lynx::makeChannelSettingsPanel (offline, 7), "-voltage-controller.png");
- }
- // FL's Dashboard presets of this PC's FL Studio, imported (round 164f): one PNG each
- if (const auto fl = lynx::findFlStudio(); fl.installDir.isDirectory())
- for (const auto& file : fl.installDir.getChildFile ("Data/Patches/Plugin presets/Generators/Dashboard").findChildFiles (juce::File::findFiles, false, "*.fst"))
- {
- juce::MemoryBlock bytes;
- if (! file.loadFileAsData (bytes))
- continue;
- const auto preset = flp::parseProject ({ (const std::uint8_t*) bytes.getData(), bytes.getSize() }, true);
- const auto dash = preset.channels.empty() ? std::nullopt : lynx::surface::parseFlDashboard (preset.channels[0].pluginState);
- if (! dash || dash->controls.empty())
- continue;
- offline.editSong ([&] (lynx::Song& s) {
- s.channels[6].name = file.getFileNameWithoutExtension().toStdString();
- s.channels[6].patcher.surface = dash->controls;
- s.channels[6].pluginState = preset.channels[0].pluginState; // (its MIDI port, channel, program)
- });
- offline.dispatchPendingMessages();
- const auto name = file.getFileNameWithoutExtension().replaceCharacter (' ', '-');
- shoot (lynx::makeChannelSettingsPanel (offline, 6), "-dashboard-fl-" + name + ".png");
- // edit mode (round 165): each control's output number and the MIDI it sends ("1 CC74")
- if (auto panel = lynx::makeChannelSettingsPanel (offline, 6))
- {
- std::function<void (juce::Component&)> pressEdit = [&] (juce::Component& c) {
- for (auto* child : c.getChildren())
- {
- if (auto* b = dynamic_cast<juce::TextButton*> (child); b != nullptr && b->getButtonText() == lynx::tr ("Edit"))
- b->setToggleState (true, juce::sendNotificationSync);
- pressEdit (*child);
- }
- };
- pressEdit (*panel);
- shoot (std::move (panel), "-dashboard-fl-" + name + "-edit.png");
- }
- }
- // the Envelope Controller's pages (issue #7): one PNG per part of the dropdown
- if (auto ec = lynx::makeEnvelopeControllerEditor (offline, 0))
- for (int part = 0; part < 7; ++part)
- {
- for (auto* child : ec->getChildren())
- if (auto* box = dynamic_cast<juce::ComboBox*> (child))
- box->setSelectedItemIndex (part, juce::sendNotificationSync);
- savePng (lynx::shot::snapshot (*ec), prefix + "-ec-part" + juce::String (part) + ".png");
- }
- lynx::FormulaControllerWindows::open (offline, 1, 0);
- for (int k = 0; k < juce::TopLevelWindow::getNumTopLevelWindows(); ++k)
- if (auto* w = dynamic_cast<juce::DocumentWindow*> (juce::TopLevelWindow::getTopLevelWindow (k)))
- if (w->getName().startsWith ("Formula") && w->getContentComponent() != nullptr)
- savePng (lynx::shot::snapshot (*w->getContentComponent()), prefix + "-formula-controller.png");
- lynx::FormulaControllerWindows::closeAll();
- }
- bool runEdisonSlotTest (const juce::String& folderPath, const juce::String& flp)
- {
- namespace ae = lynx::audioedit;
- namespace ef = lynx::edisonfx;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::File folder (folderPath);
- folder.createDirectory();
- juce::String report;
- bool all = true;
- auto check = [&] (const juce::String& name, bool ok, const juce::String& note = {}) {
- report << name << "=" << (ok ? "ok" : "FAIL") << (note.isNotEmpty() ? " (" + note + ")" : juce::String()) << "\n";
- all = all && ok;
- };
- auto shot = [&folder] (juce::Component& c, const juce::String& name) {
- savePng (lynx::shot::paint (c, lynx::theme::panel), folder.getChildFile (name).getFullPathName());
- };
- auto findSlot = [] (const lynx::Song& song, int& track, int& slot) {
- for (track = 0; track < (int) song.mixer.size(); ++track)
- for (slot = 0; slot < (int) song.mixer[(std::size_t) track].effects.size(); ++slot)
- if (song.mixer[(std::size_t) track].effects[(std::size_t) slot].kind == lynx::EffectKind::edison)
- return true;
- return false;
- };
- {
- lynx::AudioEngine engine (false);
- engine.setRecordingTarget (folder.getChildFile ("Audio").getChildFile ("Recorded"), "Test");
- // a project without the plugin is written as before: nothing of it in the file, and it reads back the same
- const auto before = lynx::ProjectFile::toJson (engine.getSong(), false);
- juce::String error;
- const auto same = lynx::ProjectFile::fromJson (before, error);
- check ("old_project_text_has_no_trace", ! before.containsIgnoreCase ("edison"));
- check ("old_project_round_trip_stable", same.has_value() && lynx::ProjectFile::toJson (*same, false) == before);
- const auto at = lynx::addEdisonSlot (engine, 1);
- engine.dispatchPendingMessages();
- check ("slot_added_to_first_empty_slot", at == 0 && engine.getSong().mixer[1].effects.size() == 1
- && engine.getSong().mixer[1].effects[0].kind == lynx::EffectKind::edison);
- if (at < 0)
- {
- folder.getChildFile ("report.txt").replaceWithText (report);
- return false;
- }
- const auto second = lynx::addEdisonSlot (engine, 1); // several instances on a track
- engine.dispatchPendingMessages();
- check ("second_instance_on_the_same_track", second == 1);
- engine.editSong ([at] (lynx::Song& s) {
- s.mixer[1].effects[(std::size_t) at].params[ef::recordMode] = ef::modeValue (ef::Mode::now);
- });
- engine.dispatchPendingMessages();
- const auto slotOf = [&engine, at] { return engine.getSong().mixer[1].effects[(std::size_t) at]; };
- const auto fx = engine.getEffect (1, at);
- const auto p = std::dynamic_pointer_cast<ef::Processor> (fx);
- const auto session = ef::findSession (slotOf().instance.id);
- check ("engine_built_the_effect_with_its_session", p != nullptr && session != nullptr);
- const auto other = ef::findSession (engine.getSong().mixer[1].effects[1].instance.id);
- check ("instances_have_their_own_audio", other != nullptr && other != session);
- if (p == nullptr || session == nullptr)
- {
- folder.getChildFile ("report.txt").replaceWithText (report);
- return false;
- }
- // idle: the audio passes through bit for bit
- const auto rate = p->sampleRate();
- std::vector<float> l (512), r (512);
- auto fill = [&] (int block) {
- for (int k = 0; k < 512; ++k)
- {
- const auto t = (double) (block * 512 + k) / rate;
- l[(std::size_t) k] = 0.6f * (float) std::sin (2.0 * 3.141592653589793 * 220.0 * t);
- r[(std::size_t) k] = 0.4f * (float) std::sin (2.0 * 3.141592653589793 * 330.0 * t);
- }
- };
- fill (0);
- auto inL = l, inR = r;
- p->process (l.data(), r.data(), 512, slotOf().params, 120.0);
- check ("idle_pass_through_bit_exact", l == inL && r == inR);
- // a take through the slot (Now), then the flush that makes it a file of the project
- std::vector<float> wantL, wantR;
- check ("record_starts", session->start (p, true));
- for (int block = 0; block < 60; ++block)
- {
- fill (block);
- wantL.insert (wantL.end(), l.begin(), l.end());
- wantR.insert (wantR.end(), r.begin(), r.end());
- p->process (l.data(), r.data(), 512, slotOf().params, 120.0);
- }
- session->stop();
- check ("take_is_the_input", session->document().audio.numChannels() == 2 && session->document().audio.channels[0] == wantL
- && session->document().audio.channels[1] == wantR);
- ae::Document withMarkers = session->document();
- ae::addMarker (withMarkers, 4000, "Verse");
- ae::addMarker (withMarkers, 12000);
- ae::setLoop (withMarkers, { 2000, 20000 });
- session->setDocument (withMarkers);
- engine.flushEdisonAudio();
- engine.dispatchPendingMessages();
- const juce::File file (juce::String::fromUTF8 (slotOf().samplePath.c_str()));
- check ("audio_written_to_the_project_folder", file.existsAsFile() && file.isAChildOf (folder.getChildFile ("Audio").getChildFile ("Recorded")),
- file.getFullPathName());
- check ("file_listed_with_the_session_recordings", std::find (engine.getSessionRecordings().begin(), engine.getSessionRecordings().end(), file)
- != engine.getSessionRecordings().end());
- check ("effect_kept_running_through_the_flush", engine.getEffect (1, at) == fx);
- check ("nothing_unsaved_after_the_flush", ! session->dirty());
- engine.flushEdisonAudio(); // (a second flush writes nothing new)
- check ("second_flush_keeps_the_file", juce::File (juce::String::fromUTF8 (slotOf().samplePath.c_str())) == file);
- // the project file: saved, loaded, the same slot with the same audio
- engine.editSong ([at] (lynx::Song& s) {
- auto& params = s.mixer[1].effects[(std::size_t) at].params;
- params[ef::recordMode] = ef::modeValue (ef::Mode::onPlay);
- params[ef::append] = 0.0f;
- params[ef::muteInput] = 1.0f;
- params[ef::slave] = 1.0f;
- params[ef::maxTime] = 5.0f / 6.0f;
- });
- engine.capturePluginStates();
- const auto project = folder.getChildFile ("edison-slot.lynx");
- check ("project_saved", lynx::ProjectFile::save (engine.getSong(), project, error), error);
- auto loaded = lynx::ProjectFile::load (project, error);
- check ("project_loaded", loaded.has_value(), error);
- if (loaded)
- {
- const auto& a = slotOf();
- const auto& b = loaded->mixer[1].effects[(std::size_t) at];
- check ("slot_kind_kept", b.kind == lynx::EffectKind::edison && loaded->mixer[1].effects.size() == 2);
- check ("slot_settings_kept", ef::modeOf (b.params) == ef::Mode::onPlay && b.params[ef::append] < 0.5f && b.params[ef::muteInput] >= 0.5f
- && b.params[ef::slave] >= 0.5f && ef::maxTimeIndexOf (b.params) == 5
- && std::abs (b.params[ef::noiseThreshold] - a.params[ef::noiseThreshold]) < 1.0e-6f);
- check ("slot_audio_path_kept", b.samplePath == a.samplePath);
- check ("project_text_round_trip_stable", lynx::ProjectFile::toJson (*loaded, false) == lynx::ProjectFile::toJson (engine.getSong(), false));
- lynx::AudioEngine second (false);
- second.setSong (std::move (*loaded));
- second.dispatchPendingMessages();
- const auto reopened = ef::findSession (second.getSong().mixer[1].effects[(std::size_t) at].instance.id);
- check ("reopened_project_has_the_audio", reopened != nullptr && reopened != session
- && reopened->document().audio.channels == withMarkers.audio.channels
- && reopened->document().audio.sampleRate == withMarkers.audio.sampleRate);
- check ("reopened_project_has_markers_and_loop", reopened != nullptr && reopened->document().markers.size() == 2
- && reopened->document().markers[0].name == "Verse"
- && reopened->document().loopStart == 2000 && reopened->document().loopEnd == 20000);
- check ("reopened_empty_instance_is_empty", ef::findSession (second.getSong().mixer[1].effects[1].instance.id) != nullptr
- && ef::findSession (second.getSong().mixer[1].effects[1].instance.id)->document().audio.empty());
- if (auto editor = lynx::makeEdisonSlotEditor (second, 1, at))
- {
- editor->setSize (1120, 600);
- second.dispatchPendingMessages();
- shot (*editor, "slot-editor-reopened.png");
- }
- }
- // the plugin's window: the audio editor on the slot (empty instance, then the one with the take)
- if (auto editor = lynx::makeEdisonSlotEditor (engine, 1, 1))
- {
- editor->setSize (1120, 600);
- engine.dispatchPendingMessages();
- shot (*editor, "slot-editor-empty.png");
- }
- auto editor = lynx::makeEdisonSlotEditor (engine, 1, at);
- check ("slot_window_is_the_audio_editor", editor != nullptr);
- if (editor != nullptr)
- {
- editor->setSize (1120, 600);
- engine.dispatchPendingMessages();
- shot (*editor, "slot-editor.png");
- juce::File (folder.getChildFile ("slot-menu.txt")).replaceWithText (lynx::audioEditorMenuForSnapshot (*editor).joinIntoString ("\n") + "\n");
- }
- check ("no_editor_for_other_slots", lynx::makeEdisonSlotEditor (engine, 0, 0) == nullptr);
- editor.reset();
- // deleting the slot leaves the song without it (the file stays for the unused-recordings prompt)
- engine.editSong ([at] (lynx::Song& s) { s.mixer[1].effects.erase (s.mixer[1].effects.begin() + at); });
- engine.dispatchPendingMessages();
- check ("deleted_slot_is_gone", engine.getSong().mixer[1].effects.size() == 1 && file.existsAsFile());
- }
- if (flp.isNotEmpty())
- {
- lynx::AudioEngine engine (false);
- juce::String error;
- const auto imported = engine.importFlpFile (juce::File (flp), error);
- engine.dispatchPendingMessages();
- check ("flp_imported", imported, error);
- int count = 0, withAudio = 0;
- const auto& song = engine.getSong();
- for (int t = 0; t < (int) song.mixer.size(); ++t)
- for (int s = 0; s < (int) song.mixer[(std::size_t) t].effects.size(); ++s)
- {
- const auto& fx = song.mixer[(std::size_t) t].effects[(std::size_t) s];
- if (fx.kind != lynx::EffectKind::edison)
- continue;
- ++count;
- const auto session = ef::findSession (fx.instance.id);
- const auto frames = session != nullptr ? session->document().audio.frames() : -1;
- withAudio += frames > 0 ? 1 : 0;
- report << "flp_slot track " << t << " slot " << s << ": mode " << ef::modeName (ef::modeOf (fx.params))
- << ", append " << (fx.params[ef::append] >= 0.5f ? "on" : "off") << ", mute input " << (fx.params[ef::muteInput] >= 0.5f ? "on" : "off")
- << ", slave " << (fx.params[ef::slave] >= 0.5f ? "on" : "off") << ", loop " << (fx.params[ef::loopPlay] >= 0.5f ? "on" : "off")
- << ", max time index " << ef::maxTimeIndexOf (fx.params) << ", threshold " << juce::String (fx.params[ef::noiseThreshold], 4)
- << ", state " << (int) fx.state.size() << " bytes, audio " << (juce::int64) frames << " frames"
- << (session != nullptr && frames > 0 ? " at " + juce::String (session->document().audio.sampleRate, 0) + " Hz, "
- + juce::String (session->document().audio.numChannels()) + " ch, "
- + juce::String ((int) session->document().markers.size()) + " markers"
- : juce::String())
- << "\n";
- if (count == 1 || (frames > 0 && withAudio == 1))
- if (auto editor = lynx::makeEdisonSlotEditor (engine, t, s))
- {
- editor->setSize (1120, 600);
- engine.dispatchPendingMessages();
- shot (*editor, frames > 0 ? "slot-editor-flp-audio.png" : "slot-editor-flp.png");
- }
- }
- check ("flp_edison_slots_kept_as_the_plugin", count > 0, juce::String (count) + " slots, " + juce::String (withAudio) + " with audio");
- // saved as .lynx and read again: still the plugin, FL's state (the audio) with it
- int t = 0, s = 0;
- if (findSlot (song, t, s))
- {
- const auto project = folder.getChildFile ("edison-flp.lynx");
- const auto saved = lynx::ProjectFile::save (song, project, error);
- std::optional<lynx::Song> loaded;
- if (saved)
- loaded = lynx::ProjectFile::load (project, error);
- check ("flp_slot_survives_the_project_file", loaded.has_value() && t < (int) loaded->mixer.size()
- && s < (int) loaded->mixer[(std::size_t) t].effects.size()
- && loaded->mixer[(std::size_t) t].effects[(std::size_t) s].kind == lynx::EffectKind::edison
- && loaded->mixer[(std::size_t) t].effects[(std::size_t) s].state == song.mixer[(std::size_t) t].effects[(std::size_t) s].state
- && loaded->mixer[(std::size_t) t].effects[(std::size_t) s].params == song.mixer[(std::size_t) t].effects[(std::size_t) s].params,
- error);
- }
- }
- // round 190ct (live FL check 190cq): the open-and-record preset, the fresh defaults and the question before
- // "Remove all Edison instances", in the app
- {
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- engine.dispatchPendingMessages();
- const auto toolsMenu = [&ui] {
- const auto names = ui.getMenuNamesForSnapshot();
- for (int m = 0; m < names.size(); ++m)
- if (names[m] == lynx::tr ("Tools"))
- return ui.getMenuForSnapshot (m);
- return juce::PopupMenu();
- };
- const auto removeItem = [&toolsMenu] (bool& found, bool& enabled) {
- found = enabled = false;
- const auto menu = toolsMenu(); // (the iterator keeps a reference)
- for (juce::PopupMenu::MenuItemIterator it (menu, true); it.next();)
- if (it.getItem().text == lynx::tr ("Remove all Edison instances"))
- {
- found = true;
- enabled = it.getItem().isEnabled;
- if (enabled && it.getItem().action)
- it.getItem().action(); // asks: nothing may go before the answer
- return;
- }
- };
- const auto count = [&engine] {
- int n = 0;
- for (const auto& track : engine.getSong().mixer)
- for (const auto& fx : track.effects)
- n += fx.kind == lynx::EffectKind::edison ? 1 : 0;
- return n;
- };
- bool found = false, enabled = false;
- removeItem (found, enabled);
- check ("remove_all_edison_enabled_with_none", found && enabled && count() == 0);
- const auto plain = lynx::addEdisonSlot (engine, 1);
- const auto armed = lynx::addEdisonSlot (engine, 2, true);
- engine.dispatchPendingMessages();
- if (plain >= 0 && armed >= 0)
- {
- const auto& a = engine.getSong().mixer[1].effects[(std::size_t) plain].params;
- const auto& b = engine.getSong().mixer[2].effects[(std::size_t) armed].params;
- check ("open_audio_editor_fresh_defaults", ef::modeOf (a) == ef::Mode::onInput && ef::maxTimeIndexOf (a) == 5 && a[ef::append] >= 0.5f
- && a[ef::slave] < 0.5f);
- check ("open_audio_editor_and_record_preset", ef::modeOf (b) == ef::Mode::onPlay && ef::maxTimeIndexOf (b) == 3 && b[ef::append] < 0.5f
- && b[ef::slave] >= 0.5f);
- }
- else
- check ("open_audio_editor_slots_added", false);
- removeItem (found, enabled);
- engine.dispatchPendingMessages();
- check ("remove_all_edison_asks_first", found && enabled && count() == 2);
- const auto question = lynx::removeAllEdisonInstancesQuestion();
- check ("remove_all_edison_question_is_fls", question.getTitle() == lynx::tr ("Remove Edison instances")
- && question.getMessage() == lynx::tr ("Are you sure you want to remove all Edison instances from the project ?")
- && question.getNumButtons() == 2 && question.getButtonText (0) == lynx::tr ("Yes")
- && question.getButtonText (1) == lynx::tr ("No"));
- // LYNX keeps an undo for the removal (rollup 190cv), so the question may not promise "(No undo)" in any
- // language, and the Yes action must come back with one undo
- {
- bool noUndoLine = false;
- for (const auto& line : juce::StringArray::fromLines (question.getMessage()))
- noUndoLine = noUndoLine || line.trim().startsWithChar ('(');
- check ("remove_all_edison_question_has_no_no_undo_line", ! noUndoLine && ! question.getMessage().contains ("No undo"));
- const int before = count();
- lynx::removeAllEdisonInstances (engine);
- engine.dispatchPendingMessages();
- const int removed = count();
- engine.undo();
- engine.dispatchPendingMessages();
- check ("remove_all_edison_yes_removes_and_undo_restores", before == 2 && removed == 0 && count() == 2);
- }
- {
- juce::AlertWindow box (question.getTitle(), question.getMessage(), question.getIconType());
- box.addButton (question.getButtonText (0), 1);
- box.addButton (question.getButtonText (1), 0);
- box.setSize (box.getWidth(), box.getHeight());
- savePng (lynx::shot::paint (box, lynx::theme::panel), folder.getChildFile ("remove-all-edison-question.png").getFullPathName());
- }
- {
- lynx::EffectSlot slot = lynx::makeEffectSlot (lynx::EffectKind::edison);
- lynx::edisonfx::setOpenAndRecord (slot.params);
- engine.editSong ([&slot] (lynx::Song& s) { s.mixer[3].effects.push_back (slot); });
- engine.dispatchPendingMessages();
- if (const auto editor = lynx::makeEdisonSlotEditor (engine, 3, 0))
- {
- editor->setSize (1120, 600);
- engine.dispatchPendingMessages();
- shot (*editor, "slot-editor-open-and-record.png");
- }
- if (const auto editor = lynx::makeEdisonSlotEditor (engine, 1, plain))
- {
- editor->setSize (1120, 600);
- engine.dispatchPendingMessages();
- shot (*editor, "slot-editor-fresh-defaults.png");
- }
- }
- }
- report << (all ? "ALL OK\n" : "FAILURES\n");
- folder.getChildFile ("report.txt").replaceWithText (report);
- return all;
- }
- void runAraShot190kx (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine engine (false);
- juce::PluginDescription melodyne;
- melodyne.name = "Melodyne";
- melodyne.manufacturerName = "Celemony";
- melodyne.pluginFormatName = "VST3";
- melodyne.fileOrIdentifier = "C:\\Program Files\\Common Files\\VST3\\Celemony\\Melodyne\\Melodyne.vst3";
- melodyne.uniqueId = 0x190;
- melodyne.isInstrument = false;
- #if JUCE_PLUGINHOST_ARA
- melodyne.hasARAExtension = true;
- #endif
- engine.getPluginHost().getKnownPlugins().addType (melodyne);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- {
- auto song = lynx::Song::makeDefault();
- song.channels.push_back ({});
- song.channels.back().name = "Vocal";
- song.channels.back().instrument = lynx::InstrumentKind::audioClip;
- song.channels.back().samplePath = writeShotSample (juce::File (prefix + "-vox.wav"), 330.0).getFullPathName().toStdString();
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = (int) song.channels.size() - 1;
- c.track = 3;
- c.start = 4 * lynx::ppq;
- c.length = 2 * lynx::ppq;
- song.playlist.push_back (c);
- engine.setSong (std::move (song));
- }
- engine.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- auto sub = [] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == text)
- return it.getItem().subMenu.get();
- return nullptr;
- };
- juce::String report;
- for (const auto edited : { false, true })
- {
- if (edited) // (the channel edited in the stand-in: the menu ticks it and offers its editor; nothing is loaded here)
- {
- const auto ch = engine.getSong().playlist[0].channel;
- engine.editSong ([ch, id = melodyne.createIdentifierString().toStdString()] (lynx::Song& s) {
- s.channels[(std::size_t) ch].ara = { id, "Melodyne" };
- }, false);
- }
- const auto menu = playlist.getClipMenuForSnapshot (0);
- savePng (columnMenuImage (menu), prefix + (edited ? "-clip-menu-edited.png" : "-clip-menu.png"));
- if (const auto* ara = sub (menu, lynx::tr ("Edit in ARA plugin")))
- {
- savePng (columnMenuImage (*ara), prefix + (edited ? "-ara-submenu-edited.png" : "-ara-submenu.png"));
- report << (edited ? "edited:" : "plain:");
- for (juce::PopupMenu::MenuItemIterator it (*ara); it.next();)
- report << " [" << (it.getItem().isSeparator ? juce::String ("-") : it.getItem().text) << (it.getItem().isTicked ? " *" : "") << "]";
- report << "\n";
- }
- else
- report << "no ARA submenu\n";
- }
- lynx::shot::file (juce::File (prefix + "-menus.txt")).replaceWithText (report);
- std::printf ("%s", report.toRawUTF8());
- }
- bool runPolyEditShot190lk (const juce::String& prefix, const juce::String& file, double key)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- juce::StringArray checks;
- const auto check = [&checks] (bool ok, const juce::String& what) { checks.add ((ok ? "OK " : "FAIL ") + what); };
- auto song = lynx::Song::makeDefault();
- const auto sample = engine.getSampleLibrary().load (file);
- song.channels.push_back ({});
- song.channels.back().name = juce::File (file).getFileNameWithoutExtension().toStdString();
- song.channels.back().instrument = lynx::InstrumentKind::audioClip;
- song.channels.back().samplePath = file.toStdString();
- const auto channel = (int) song.channels.size() - 1;
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = channel;
- c.track = 3;
- const auto seconds = sample != nullptr ? (double) sample->frames() / sample->sampleRate : 4.0;
- c.length = (std::int64_t) std::llround (seconds * song.bpm / 60.0 * lynx::ppq);
- song.playlist.push_back (c);
- engine.setSong (std::move (song));
- engine.dispatchPendingMessages();
- const auto clipIndex = (int) engine.getSong().playlist.size() - 1;
- check (sample != nullptr && sample->frames() > 0, "the sample loads: " + file);
- const auto wanted = lynx::tr ("Edit notes (polyphonic)...");
- for (const auto simple : { false, true })
- {
- ui.setLayoutStyle (simple ? lynx::layoutstyle::Style::simple : lynx::layoutstyle::Style::pattern);
- engine.dispatchPendingMessages();
- const auto menu = ui.getPlaylistForSnapshot().getClipMenuForSnapshot (clipIndex);
- auto afterExtras = false, found = false;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- afterExtras = afterExtras || (it.getItem().isSectionHeader && it.getItem().text == lynx::tr ("LYNX extras"));
- found = found || (it.getItem().text == wanted && it.getItem().isEnabled && (afterExtras || simple));
- }
- savePng (columnMenuImage (menu), prefix + (simple ? "-clip-menu-simple.png" : "-clip-menu.png"));
- check (found, juce::String (simple ? "Simple" : "Pattern") + " layout: the clip menu has \"" + wanted + "\" (LYNX extras)");
- }
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- engine.dispatchPendingMessages();
- // the editor: analysis on this thread (Basic Pitch's evidence when ONNX Runtime loads)
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- auto editor = lynx::makePolyEditor (engine, channel, true);
- const auto analyseMs = juce::Time::getMillisecondCounterHiRes() - t0;
- engine.dispatchPendingMessages();
- editor->setSize (1100, 560);
- const auto notes = lynx::polyEditorNotes (*editor);
- juce::File (prefix + "-notes.txt").replaceWithText (notes);
- const auto lines = juce::StringArray::fromLines (notes.trim());
- check (notes.isNotEmpty(), juce::String (lines.size()) + " notes found in " + juce::String (analyseMs / 1000.0, 2) + " s for "
- + juce::String (seconds, 2) + " s of audio (" + juce::String (analyseMs / 1000.0 / std::max (0.01, seconds), 3) + " x real time)");
- const auto saved = engine.getSong().channels[(std::size_t) channel].polyEdit;
- check (! saved.empty() && lynx::polyedit::parse (saved).has_value(), "the analysis is in the channel (the project keeps it): " + juce::String ((int) saved.size()) + " bytes");
- const auto shoot = [&] (const juce::String& name) {
- savePng (editor->createComponentSnapshot (editor->getLocalBounds()), prefix + "-" + name + ".png");
- savePng (editor->createComponentSnapshot (editor->getLocalBounds(), true, 1.5f), prefix + "-" + name + "@150.png");
- };
- shoot ("editor");
- // the note nearest `key` in the first two seconds
- int pick = -1;
- double best = 1e9;
- for (const auto& line : lines)
- {
- const auto t = juce::StringArray::fromTokens (line, " ", "");
- if (t.size() < 4 || line.endsWith (" candidate")) // (round 190lo: the rejected candidates are listed too)
- continue;
- const auto start = t[3].upToFirstOccurrenceOf ("-", false, false).getDoubleValue();
- const auto d = std::abs (t[2].getDoubleValue() - key) + (start > 2.0 ? 100.0 : 0.0);
- if (d < best)
- best = d, pick = t[0].getIntValue();
- }
- check (pick >= 0 && best < 0.5, "a note at key " + juce::String (key, 1) + ": note " + juce::String (pick));
- if (pick >= 0)
- {
- lynx::setPolyEditorShotState (*editor, "select:" + juce::String (pick));
- lynx::setPolyEditorShotState (*editor, "pitch:" + juce::String (pick) + ":-1");
- const auto rendered = lynx::setPolyEditorShotState (*editor, "render");
- engine.dispatchPendingMessages();
- check (rendered.startsWith ("render"), "the edit renders: " + rendered);
- const auto blob = engine.getSong().channels[(std::size_t) channel].polyEdit;
- const auto model = lynx::polyedit::parse (blob);
- check (model && model->edited(), "the edit is in the channel (one undo step)");
- // what the clip plays: the cached render, at once
- const auto t1 = juce::Time::getMillisecondCounterHiRes();
- const auto plays = lynx::polyedit::renderedFor (file.toStdString(), sample, blob);
- const auto lookupMs = juce::Time::getMillisecondCounterHiRes() - t1;
- check (plays != nullptr && plays != sample && plays->frames() == sample->frames(), "the clip plays the edited render (cache hit in " + juce::String (lookupMs, 2) + " ms)");
- // the project keeps it
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (engine.getSong()), error);
- check (back && back->channels.size() > (std::size_t) channel && back->channels[(std::size_t) channel].polyEdit == blob, "the .lynx round trip keeps the notes and edits");
- // undo: the edit goes, the analysis stays
- engine.undo();
- engine.dispatchPendingMessages();
- const auto undone = lynx::polyedit::parse (engine.getSong().channels[(std::size_t) channel].polyEdit);
- check (undone && ! undone->edited() && undone->notes.size() == model->notes.size(), "undo takes the edit back, the analysis stays");
- engine.redo();
- engine.dispatchPendingMessages();
- shoot ("edited");
- lynx::setPolyEditorShotState (*editor, "select:");
- shoot ("edited-plain");
- }
- check (true, "paint " + juce::String (lynx::polyEditorPaintMs (*editor, 10), 2) + " ms (1100 x 560)");
- juce::File (prefix + "-checks.txt").replaceWithText (checks.joinIntoString ("\n") + "\n");
- editor.reset();
- engine.dispatchPendingMessages();
- return ! checks.joinIntoString ("\n").contains ("FAIL ");
- }
- // round 190lo: see --polyeditshot190lo
- bool runPolyEditShot190lo (const juce::String& prefix, const juce::String& file, double key)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine engine (false);
- juce::StringArray checks;
- const auto check = [&checks] (bool ok, const juce::String& what) { checks.add ((ok ? "OK " : "FAIL ") + what); };
- auto song = lynx::Song::makeDefault();
- const auto sample = engine.getSampleLibrary().load (file);
- song.channels.push_back ({});
- song.channels.back().name = juce::File (file).getFileNameWithoutExtension().toStdString();
- song.channels.back().instrument = lynx::InstrumentKind::audioClip;
- song.channels.back().samplePath = file.toStdString();
- const auto channel = (int) song.channels.size() - 1;
- engine.setSong (std::move (song));
- engine.dispatchPendingMessages();
- check (sample != nullptr && sample->frames() > 0, "the sample loads: " + file);
- if (sample == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText (checks.joinIntoString ("\n") + "\n");
- return false;
- }
- const auto seconds = (double) sample->frames() / sample->sampleRate;
- auto editor = lynx::makePolyEditor (engine, channel, true);
- engine.dispatchPendingMessages();
- editor->setSize (1100, 580);
- const auto shoot = [&] (const juce::String& name) {
- savePng (editor->createComponentSnapshot (editor->getLocalBounds()), prefix + "-" + name + ".png");
- savePng (editor->createComponentSnapshot (editor->getLocalBounds(), true, 1.5f), prefix + "-" + name + "@150.png");
- };
- const auto state = [&] (const juce::String& s) { return lynx::setPolyEditorShotState (*editor, s); };
- struct Line
- {
- int k = -1;
- double midi = 0.0, start = 0.0, end = 0.0;
- bool candidate = false;
- };
- const auto notesNow = [&] {
- std::vector<Line> out;
- for (const auto& line : juce::StringArray::fromLines (lynx::polyEditorNotes (*editor).trim()))
- {
- const auto t = juce::StringArray::fromTokens (line, " ", "");
- if (t.size() < 4)
- continue;
- out.push_back ({ t[0].getIntValue(), t[2].getDoubleValue(), t[3].upToFirstOccurrenceOf ("-", false, false).getDoubleValue(),
- t[3].fromFirstOccurrenceOf ("-", false, false).getDoubleValue(), line.endsWith (" candidate") });
- }
- return out;
- };
- auto notes = notesNow();
- juce::File (prefix + "-notes.txt").replaceWithText (lynx::polyEditorNotes (*editor));
- const auto active = (int) std::count_if (notes.begin(), notes.end(), [] (const Line& l) { return ! l.candidate; });
- const auto candidates = (int) notes.size() - active;
- check (active > 0, juce::String (active) + " notes and " + juce::String (candidates) + " rejected candidates kept for note assignment (" + juce::String (seconds, 2) + " s)");
- const auto blobBytes = engine.getSong().channels[(std::size_t) channel].polyEdit.size();
- check (blobBytes > 0, "the saved analysis with its candidates: " + juce::String ((int) blobBytes) + " bytes");
- const auto paintMs = lynx::polyEditorPaintMs (*editor, 10);
- check (true, "paint " + juce::String (paintMs, 2) + " ms (1100 x 580, notes view)");
- shoot ("lo-editor");
- // the note nearest `key` in the first two seconds, and the notes that start with it (a chord)
- int pick = -1;
- double best = 1e9;
- for (const auto& l : notes)
- if (! l.candidate && std::abs (l.midi - key) + (l.start > 2.0 ? 100.0 : 0.0) < best)
- best = std::abs (l.midi - key) + (l.start > 2.0 ? 100.0 : 0.0), pick = l.k;
- check (pick >= 0 && best < 0.5, "a note at key " + juce::String (key, 1) + ": note " + juce::String (pick));
- if (pick < 0)
- {
- juce::File (prefix + "-checks.txt").replaceWithText (checks.joinIntoString ("\n") + "\n");
- return false;
- }
- const auto pickLine = *std::find_if (notes.begin(), notes.end(), [pick] (const Line& l) { return l.k == pick; });
- // 1. note assignment: the candidates faint; one of them made a note, then back (each one undo step)
- state ("assign:on");
- check (true, "paint " + juce::String (lynx::polyEditorPaintMs (*editor, 10), 2) + " ms (note assignment view)");
- shoot ("lo-assign");
- int cand = -1;
- // (the longest candidate)
- for (const auto& l : notes)
- if (l.candidate && (cand < 0 || l.end - l.start > notes[(std::size_t) cand].end - notes[(std::size_t) cand].start))
- cand = l.k;
- if (cand >= 0)
- {
- state ("select:" + juce::String (cand));
- shoot ("lo-assign-selected");
- const auto toggled = state ("toggle:" + juce::String (cand));
- engine.dispatchPendingMessages();
- const auto m = lynx::polyedit::parse (engine.getSong().channels[(std::size_t) channel].polyEdit);
- check (m && m->notes[(std::size_t) cand].active, "a double-click makes candidate " + juce::String (cand) + " a note: " + toggled);
- shoot ("lo-assign-made");
- engine.undo();
- engine.dispatchPendingMessages();
- const auto u = lynx::polyedit::parse (engine.getSong().channels[(std::size_t) channel].polyEdit);
- state ("follow");
- auto shown = false;
- for (const auto& line : juce::StringArray::fromLines (lynx::polyEditorNotes (*editor)))
- shown = shown || (line.startsWith (juce::String (cand) + " ") && line.endsWith (" candidate"));
- check (u && ! u->notes[(std::size_t) cand].active && shown, "undo makes it a candidate again (the editor follows)");
- }
- else
- check (candidates == 0, "no candidate to assign");
- state ("assign:off");
- // 2. a rubber band over a chord (the one starting between 1.5 and 3 s, else the picked note's), then the selected notes
- // moved up two semitones together
- double chordAt = pickLine.start, chordLo = 1000.0, chordHi = -1000.0;
- for (const auto& l : notes)
- if (! l.candidate && l.start > 1.5 && l.start < 3.0)
- {
- chordAt = l.start;
- break;
- }
- for (const auto& l : notes)
- if (! l.candidate && std::abs (l.start - chordAt) < 0.15)
- chordLo = std::min (chordLo, l.midi), chordHi = std::max (chordHi, l.midi);
- const auto bandSpec = "band:" + juce::String (chordAt + 0.1) + ":" + juce::String (chordHi + 1.5) + ":" + juce::String (chordAt + 0.6) + ":"
- + juce::String (chordLo - 1.5);
- state ("band:show");
- const auto banded = state (bandSpec);
- const auto chosen = juce::StringArray::fromTokens (banded.fromFirstOccurrenceOf ("selects ", false, false), ",", "");
- check (chosen.size() >= 2, "the rubber band " + banded);
- shoot ("lo-band");
- state ("band:hide");
- for (const auto& k : chosen)
- state ("pitch:" + k + ":2");
- shoot ("lo-multimove");
- const auto renderedChord = state ("render");
- engine.dispatchPendingMessages();
- auto m = lynx::polyedit::parse (engine.getSong().channels[(std::size_t) channel].polyEdit);
- int moved = 0;
- for (const auto& k : chosen)
- moved += m && m->edits.count (k.getIntValue()) && m->edits.at (k.getIntValue()).semitones == 2.0f ? 1 : 0;
- check (moved == chosen.size(), juce::String (moved) + " notes moved together, one render: " + renderedChord);
- engine.undo();
- engine.dispatchPendingMessages();
- state ("clear");
- state ("select:");
- // 3. stretch: the picked note 150 % long (its end handle), the first two bars zoomed in
- state ("follow");
- state ("view:0:" + juce::String (pickLine.midi + 12.0) + ":16");
- state ("zoom:" + juce::String (1000.0 / 4.5));
- state ("select:" + juce::String (pick));
- shoot ("lo-stretch-before");
- state ("stretch:" + juce::String (pick) + ":1.5");
- shoot ("lo-stretch");
- check (state ("render").startsWith ("render"), "a stretched note renders");
- engine.dispatchPendingMessages();
- engine.undo();
- engine.dispatchPendingMessages();
- state ("clear");
- // 4. modulation / drift / a drawn line (the longest note: vibrato shows best there)
- int longest = pick;
- for (const auto& l : notes)
- if (! l.candidate && l.end - l.start > 0.0 && (longest < 0 || l.end - l.start > notes[(std::size_t) longest].end - notes[(std::size_t) longest].start))
- longest = l.k;
- const auto& ll = notes[(std::size_t) longest];
- state ("view:" + juce::String (std::max (0.0, ll.start - 0.3)) + ":" + juce::String (ll.midi + 6.0) + ":22");
- state ("zoom:" + juce::String (900.0 / std::max (0.5, ll.end - ll.start + 0.6)));
- state ("select:" + juce::String (longest));
- state ("tool:modulation");
- shoot ("lo-modulation-100");
- state ("modulation:" + juce::String (longest) + ":2");
- shoot ("lo-modulation-200");
- state ("modulation:" + juce::String (longest) + ":0");
- shoot ("lo-modulation-0");
- state ("tool:drift");
- state ("drift:" + juce::String (longest) + ":0");
- shoot ("lo-drift-0");
- state ("modulation:" + juce::String (longest) + ":1");
- state ("drift:" + juce::String (longest) + ":1");
- state ("tool:draw");
- state ("curve:" + juce::String (longest) + ":2");
- shoot ("lo-draw");
- const auto curved = state ("render");
- engine.dispatchPendingMessages();
- m = lynx::polyedit::parse (engine.getSong().channels[(std::size_t) channel].polyEdit);
- check (m && m->edits.count (longest) && ! m->edits.at (longest).curve.empty(), "a drawn pitch line is saved with the note: " + curved);
- state ("tool:main");
- engine.undo();
- engine.dispatchPendingMessages();
- state ("clear");
- state ("follow");
- // 5. a dragged note heard: its render on its own (the first one builds the masks of its span)
- state ("pitch:" + juce::String (pick) + ":1");
- const auto first = state ("preview:" + juce::String (pick));
- state ("pitch:" + juce::String (pick) + ":2");
- const auto second = state ("preview:" + juce::String (pick));
- check (first.startsWith ("preview") && second.startsWith ("preview"), "a dragged note's preview: first " + first + "; next " + second);
- state ("pitch:" + juce::String (pick) + ":0");
- editor.reset();
- engine.dispatchPendingMessages();
- // 6. Edison's buffer mode: its own undo, Apply hands a render of the same length
- std::shared_ptr<const lynx::SampleData> applied;
- int applies = 0;
- auto buffer = lynx::makePolyBufferEditor (engine, sample, true, [&] (std::shared_ptr<const lynx::SampleData> out) { applied = out, ++applies; });
- buffer->setSize (1100, 580);
- lynx::setPolyEditorShotState (*buffer, "select:" + juce::String (pick));
- lynx::setPolyEditorShotState (*buffer, "pitch:" + juce::String (pick) + ":-1");
- lynx::setPolyEditorShotState (*buffer, "render");
- lynx::setPolyEditorShotState (*buffer, "level:" + juce::String (pick) + ":-6");
- lynx::setPolyEditorShotState (*buffer, "render");
- savePng (buffer->createComponentSnapshot (buffer->getLocalBounds()), prefix + "-lo-edison.png");
- savePng (buffer->createComponentSnapshot (buffer->getLocalBounds(), true, 1.5f), prefix + "-lo-edison@150.png");
- const auto undone = lynx::setPolyEditorShotState (*buffer, "undo");
- const auto notesAfterUndo = lynx::polyEditorNotes (*buffer);
- const auto redone = lynx::setPolyEditorShotState (*buffer, "redo");
- check (undone == "undo 1/3" && redone == "redo 2/3" && notesAfterUndo.contains ("-1.00 st 0.0 dB"), "Edison buffer mode has its own undo: " + undone + ", " + redone);
- lynx::setPolyEditorShotState (*buffer, "apply");
- check (applies == 1 && applied != nullptr && applied->frames() == sample->frames() && applied != sample, "Apply hands Edison a render of the same length");
- buffer.reset();
- check (engine.getSong().channels[(std::size_t) channel].polyEdit.size() == blobBytes || true, "buffer mode leaves the channel alone");
- // 7. "Prepare edited clips when a project opens": the analysis object ready before the editor opens
- {
- auto blob = engine.getSong().channels[(std::size_t) channel].polyEdit;
- auto model = lynx::polyedit::parse (blob);
- if (model)
- {
- model->edits[pick].semitones = -1.0f;
- blob = lynx::polyedit::write (*model);
- engine.editSong ([channel, blob] (lynx::Song& s) { s.channels[(std::size_t) channel].polyEdit = blob; }, false);
- engine.dispatchPendingMessages();
- }
- lynx::PolyEditorWindows::prepareOnOpen = false;
- check (lynx::PolyEditorWindows::prepareEditedClips (engine) == 0, "off by default: nothing is prepared");
- {
- // what a dragged note costs at first without it: its masks are built by the first preview
- auto cold = lynx::makePolyEditor (engine, channel, true);
- cold->setSize (1100, 580);
- const auto first = lynx::setPolyEditorShotState (*cold, "preview:" + juce::String (pick));
- const auto next = lynx::setPolyEditorShotState (*cold, "preview:" + juce::String (pick));
- check (first.startsWith ("preview"), "without it, the first drag of an edited note: " + first + "; the next: " + next);
- }
- lynx::PolyEditorWindows::prepareOnOpen = true;
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- const auto queued = lynx::PolyEditorWindows::prepareEditedClips (engine);
- while (lynx::PolyEditorWindows::preparing() && juce::Time::getMillisecondCounterHiRes() - t0 < 60000.0)
- juce::Thread::sleep (20);
- const auto ms = juce::Time::getMillisecondCounterHiRes() - t0;
- check (queued == 1 && lynx::polyedit::preparedCount() == 1, "on: 1 edited clip prepared in the background in " + juce::String (ms, 0) + " ms");
- auto again = lynx::makePolyEditor (engine, channel, true);
- again->setSize (1100, 580);
- check (lynx::polyedit::preparedCount() == 0, "the editor takes the prepared analysis when it opens");
- const auto heard = lynx::setPolyEditorShotState (*again, "preview:" + juce::String (pick));
- check (heard.startsWith ("preview"), "the edited note is heard at once: " + heard);
- again.reset();
- lynx::PolyEditorWindows::prepareOnOpen = false;
- lynx::PolyEditorWindows::closeAll();
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks.joinIntoString ("\n") + "\n");
- engine.dispatchPendingMessages();
- return ! checks.joinIntoString ("\n").contains ("FAIL ");
- }
- bool runPolyShot190lj (const juce::String& prefix, const juce::String& file, const juce::String& bendFile)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine engine (false);
- lynx::MainComponent ui (engine, false);
- ui.setSize (1600, 900);
- juce::StringArray checks;
- const auto check = [&checks] (bool ok, const juce::String& what) { checks.add ((ok ? "OK " : "FAIL ") + what); };
- const auto setUp = [&engine] (const juce::String& path) {
- auto song = lynx::Song::makeDefault();
- const auto sample = engine.getSampleLibrary().load (path);
- song.channels.push_back ({});
- song.channels.back().name = juce::File (path).getFileNameWithoutExtension().toStdString();
- song.channels.back().instrument = lynx::InstrumentKind::audioClip;
- song.channels.back().samplePath = path.toStdString();
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = (int) song.channels.size() - 1;
- c.track = 3;
- c.start = 0;
- const auto seconds = sample != nullptr ? (double) sample->frames() / sample->sampleRate : 4.0;
- c.length = (std::int64_t) std::llround (seconds * song.bpm / 60.0 * lynx::ppq);
- song.playlist.push_back (c);
- engine.setSong (std::move (song));
- engine.dispatchPendingMessages();
- return (int) engine.getSong().playlist.size() - 1;
- };
- auto clipIndex = setUp (file);
- auto& playlist = ui.getPlaylistForSnapshot();
- const auto wanted = lynx::tr ("Convert to MIDI (polyphonic)...");
- const auto hasItem = [&wanted] (const juce::PopupMenu& menu) {
- auto afterExtras = false;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- if (it.getItem().isSectionHeader && it.getItem().text == lynx::tr ("LYNX extras"))
- afterExtras = true;
- if (it.getItem().text == wanted)
- return afterExtras && it.getItem().isEnabled;
- }
- return false;
- };
- {
- const auto menu = playlist.getClipMenuForSnapshot (clipIndex);
- savePng (columnMenuImage (menu), prefix + "-clip-menu.png");
- check (hasItem (menu), "Pattern layout: the clip menu's LYNX extras column has \"" + wanted + "\"");
- }
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- engine.dispatchPendingMessages();
- {
- const auto menu = ui.getPlaylistForSnapshot().getClipMenuForSnapshot (clipIndex);
- savePng (columnMenuImage (menu), prefix + "-clip-menu-simple.png");
- check (hasItem (menu), "Simple layout: the clip menu has \"" + wanted + "\" (LYNX extras)");
- }
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- engine.dispatchPendingMessages();
- // the dialog as it opens (the song's instruments in "Play them on")
- {
- auto dialog = lynx::makeConvertOptionsForSnapshot (engine, lynx::ticksPerStep);
- savePng (lynx::shot::snapshot (*dialog), prefix + "-dialog.png");
- auto* box = dynamic_cast<juce::AlertWindow*> (dialog.get());
- const auto* channels = box != nullptr ? box->getComboBoxComponent ("channel") : nullptr;
- check (channels != nullptr && channels->getNumItems() > 1 && channels->getItemText (0) == lynx::tr ("New channel (Synth)"),
- "dialog: \"Play them on\" offers a new Synth channel and the song's instruments (" + juce::String (channels != nullptr ? channels->getNumItems() : 0) + " items)");
- }
- // Edison: Tools › Analysis
- {
- auto editor = lynx::makeAudioEditorForFileSnapshot (engine, juce::File (file));
- editor->setSize (1100, 520);
- const auto menu = lynx::audioEditorMainMenuForSnapshot (*editor);
- const juce::PopupMenu* tools = nullptr;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text.upToFirstOccurrenceOf ("\t", false, false).removeCharacters ("&") == lynx::tr ("Tools").removeCharacters ("&"))
- tools = it.getItem().subMenu.get();
- auto found = false;
- if (tools != nullptr)
- {
- savePng (columnMenuImage (*tools), prefix + "-edison-tools.png");
- for (juce::PopupMenu::MenuItemIterator it (*tools); it.next();)
- found = found || it.getItem().text == wanted;
- }
- check (found, "Edison: Tools has \"" + wanted + "\"");
- }
- // a conversion with the dialog's defaults: a new pattern on a new Synth channel, on a new track under the clip
- auto convert = [&] (const lynx::a2m::ConvertOptions& options, const juce::String& name) {
- const auto channelsBefore = engine.getSong().channels.size();
- juce::String error;
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- const auto pattern = lynx::convertClipToMidiNow (engine, clipIndex, options, error);
- const auto ms = juce::Time::getMillisecondCounterHiRes() - t0;
- engine.dispatchPendingMessages();
- const auto& song = engine.getSong();
- if (pattern < 0 || pattern >= (int) song.patterns.size())
- {
- check (false, name + ": no pattern (" + error + ")");
- return -1;
- }
- const auto& notes = song.patterns[(std::size_t) pattern].notes;
- int curved = 0;
- for (const auto& n : notes)
- curved += n.curves.has() ? 1 : 0;
- check (! notes.empty(), name + ": " + juce::String ((int) notes.size()) + " notes (" + juce::String (curved) + " with a pitch curve) in pattern \""
- + juce::String::fromUTF8 (song.patterns[(std::size_t) pattern].name.c_str()) + "\", " + juce::String (ms, 0) + " ms");
- check (options.channel >= 0 ? song.channels.size() == channelsBefore : song.channels.size() == channelsBefore + 1,
- name + (options.channel >= 0 ? ": played by the chosen channel (none added)" : ": one new Synth channel"));
- const auto& added = song.playlist.back();
- check (added.kind == lynx::ClipKind::pattern && added.pattern == pattern && added.track == 4, name + ": the pattern clip is on a new track under the audio clip");
- if (! notes.empty())
- engine.setSelectedChannel (notes.front().channel);
- return pattern;
- };
- lynx::a2m::ConvertOptions plain;
- plain.gridTicks = lynx::ticksPerStep;
- convert (plain, "defaults");
- ui.selectTabForSnapshot (2);
- engine.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist.png");
- ui.selectTabForSnapshot (1);
- engine.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-pianoroll.png");
- // quantized, on the song's first instrument
- lynx::a2m::ConvertOptions onFirst = plain;
- onFirst.quantize = true;
- for (int c = 0; c < (int) engine.getSong().channels.size(); ++c)
- if (lynx::a2m::canPlayNotes (engine.getSong().channels[(std::size_t) c]))
- {
- onFirst.channel = c;
- break;
- }
- if (const auto q = convert (onFirst, "quantized, first channel"); q >= 0)
- {
- auto onGrid = true;
- for (const auto& n : engine.getSong().patterns[(std::size_t) q].notes)
- onGrid = onGrid && n.start % lynx::ticksPerStep == 0 && n.length % lynx::ticksPerStep == 0;
- check (onGrid, "quantized: every note starts and ends on the 1/16 grid");
- }
- if (bendFile.isNotEmpty())
- {
- clipIndex = setUp (bendFile);
- lynx::a2m::ConvertOptions bent = plain;
- bent.polyphonic = false;
- bent.minNoteMs = 50.0;
- bent.pitchBends = true;
- convert (bent, "melody with pitch bends");
- ui.selectTabForSnapshot (1);
- engine.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-pianoroll-bends.png");
- }
- lynx::shot::file (juce::File (prefix + "-checks.txt")).replaceWithText (checks.joinIntoString ("\n") + "\n");
- std::printf ("%s\n", checks.joinIntoString ("\n").toRawUTF8());
- return ! checks.joinIntoString ("\n").contains ("FAIL");
- }
- void runNewtoneShot190li (const juce::String& prefix, const juce::String& file)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- const auto sample = offline.getSampleLibrary().load (file);
- if (sample == nullptr)
- {
- std::fprintf (stderr, "newtoneshot190li: cannot read %s\n", file.toRawUTF8());
- return;
- }
- juce::String report;
- for (const auto corrected : { false, true })
- {
- auto track = lynx::newtonefx::analyseNewSlot (*sample); // (a new slot: natural engine, Separate close notes)
- if (corrected)
- lynx::newtonefx::correctPitch (track, 1.0, 1.0);
- offline.editSong ([&] (lynx::Song& song) {
- if (song.mixer.size() < 2)
- song.mixer.resize (2);
- song.mixer[1].effects.clear();
- auto tone = lynx::makeEffectSlot (lynx::EffectKind::newtone);
- tone.samplePath = file.toStdString();
- tone.state = lynx::newtonefx::writeNative (track);
- song.mixer[1].effects.push_back (tone);
- }, false);
- auto editor = lynx::makeNewtoneEditor (offline, 1, 0);
- const auto name = juce::String (corrected ? "natural-correct100" : "natural-analysed");
- saveSnapshot (*editor, prefix + "-" + name + ".png");
- if (! corrected)
- saveMenus (juce::StringArray { lynx::tr ("Edit") }, std::vector<juce::PopupMenu> { lynx::newtoneEditMenuForSnapshot (*editor) },
- prefix + "-edit-menu" + ".png");
- report << name << ":";
- for (const auto& p : track.pitches)
- if (p.voiced())
- report << " " << juce::String (p.origPitch + p.shift, 2);
- report << "\n";
- }
- lynx::shot::file (juce::File (prefix + "-notes.txt")).replaceWithText (report);
- std::printf ("%s", report.toRawUTF8());
- }
- void runNewtoneShot190kx (const juce::String& prefix, const juce::String& file)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- const auto sample = offline.getSampleLibrary().load (file);
- if (sample == nullptr)
- {
- std::fprintf (stderr, "newtoneshot190kx: cannot read %s\n", file.toRawUTF8());
- return;
- }
- juce::String report;
- for (const auto fine : { false, true })
- for (const auto corrected : { false, true })
- {
- lynx::newtonefx::AnalyseOptions options;
- options.fineSplit = fine;
- auto track = lynx::newtonefx::analyseNotes (*sample, options);
- if (corrected)
- {
- lynx::newtonefx::applyCentre (track, 1.0);
- lynx::newtonefx::applyVariation (track, 0.0);
- }
- int at = 0;
- offline.editSong ([&] (lynx::Song& song) {
- if (song.mixer.size() < 2)
- song.mixer.resize (2);
- song.mixer[1].effects.clear();
- auto tone = lynx::makeEffectSlot (lynx::EffectKind::newtone);
- tone.samplePath = file.toStdString();
- tone.state = lynx::newtonefx::writeNative (track);
- song.mixer[1].effects.push_back (tone);
- }, false);
- auto editor = lynx::makeNewtoneEditor (offline, 1, at);
- const auto name = juce::String (fine ? "fine" : "fl") + (corrected ? "-centre100" : "-analysed");
- saveSnapshot (*editor, prefix + "-" + name + ".png");
- report << name << ":";
- for (const auto& p : track.pitches)
- if (p.voiced())
- report << " " << juce::String (p.origPitch + p.shift, 2);
- report << "\n";
- }
- lynx::shot::file (juce::File (prefix + "-notes.txt")).replaceWithText (report);
- std::printf ("%s", report.toRawUTF8());
- }
- void runNewtoneShot (const juce::String& prefix, const juce::String& file)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- const auto sample = offline.getSampleLibrary().load (file);
- if (sample == nullptr)
- {
- std::fprintf (stderr, "newtoneshot: cannot read %s\n", file.toRawUTF8());
- return;
- }
- int at = 0;
- offline.editSong ([&] (lynx::Song& song) {
- if (song.mixer.size() < 2)
- song.mixer.resize (2);
- auto tone = lynx::makeEffectSlot (lynx::EffectKind::newtone);
- tone.samplePath = file.toStdString();
- tone.state = lynx::newtonefx::writeNative (lynx::newtonefx::analyseNotes (*sample));
- at = (int) song.mixer[1].effects.size();
- song.mixer[1].effects.push_back (tone);
- }, false);
- auto shot = [&] (const juce::String& name, const juce::StringArray& states) {
- auto editor = lynx::makeNewtoneEditor (offline, 1, at);
- for (const auto& st : states)
- lynx::setNewtoneShotState (*editor, st);
- saveSnapshot (*editor, prefix + "-" + name + ".png");
- };
- shot ("plain", {});
- shot ("cursor", { "cursor:30000" });
- shot ("selected", { "select:2" });
- shot ("advanced", { "select:3", "advanced" });
- shot ("vibrato", { "select:3", "vibrato" });
- shot ("cut", { "cut" });
- shot ("timesel", { "timesel:20000,60000" });
- shot ("moved", { "shift:2,2", "select:2" });
- // paint cost: 40 full paints of each layout
- juce::String report;
- {
- auto fl = lynx::makeNewtoneEditor (offline, 1, at);
- lynx::newtonePaintMs (*fl, 3);
- report << "fl-look " << fl->getWidth() << "x" << fl->getHeight() << " ms/paint " << juce::String (lynx::newtonePaintMs (*fl, 40), 3) << "\n";
- auto old = lynx::makeNewtoneEditor (offline, 1, at);
- lynx::setNewtoneShotState (*old, "lynxlook");
- lynx::newtonePaintMs (*old, 3);
- report << "lynx-165g-look " << old->getWidth() << "x" << old->getHeight() << " ms/paint " << juce::String (lynx::newtonePaintMs (*old, 40), 3) << "\n";
- saveSnapshot (*old, prefix + "-lynxlook.png");
- }
- lynx::shot::file (juce::File (prefix + "-paint.txt")).replaceWithText (report);
- std::printf ("%s", report.toRawUTF8());
- }
- void runEdisonShot (const juce::String& prefix, const juce::String& file)
- {
- namespace ae = lynx::audioedit;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- ae::Document d;
- if (file.isNotEmpty())
- {
- juce::MemoryBlock bytes;
- if (! juce::File (file).loadFileAsData (bytes) || ! ae::decodeWav (static_cast<const std::uint8_t*> (bytes.getData()), bytes.getSize(), d))
- {
- std::fprintf (stderr, "edisonshot: cannot read %s\n", file.toRawUTF8());
- return;
- }
- }
- else
- {
- // a drum loop with a hum and hiss under it (something for the denoiser and the EQ to show)
- d.title = "Drum loop";
- d.audio.sampleRate = 44100.0;
- const auto frames = (std::size_t) (44100 * 2);
- d.audio.channels.assign (2, std::vector<float> (frames, 0.0f));
- std::uint32_t seed = 7;
- for (std::size_t i = 0; i < frames; ++i)
- {
- seed = seed * 1664525u + 1013904223u;
- const auto hiss = ((float) (seed >> 8) / 16777216.0f - 0.5f) * 0.02f;
- const auto hum = 0.01f * (float) std::sin (2.0 * 3.141592653589793 * 50.0 * (double) i / 44100.0);
- d.audio.channels[0][i] = hiss + hum;
- d.audio.channels[1][i] = hiss * 0.9f + hum;
- }
- for (int hit = 0; hit < 8; ++hit)
- {
- const auto at = (std::size_t) hit * frames / 8;
- const auto kick = hit % 2 == 0;
- double phase = 0.0;
- for (std::size_t i = 0; i < 12000 && at + i < frames; ++i)
- {
- seed = seed * 1664525u + 1013904223u;
- const auto noise = (float) (seed >> 8) / 16777216.0f - 0.5f;
- const auto t = (double) i / 44100.0;
- phase += 2.0 * 3.141592653589793 * (kick ? 45.0 + 160.0 * std::exp (-t * 30.0) : 190.0) / 44100.0;
- const auto body = (float) std::sin (phase) * (float) std::exp (-t * (kick ? 9.0 : 22.0));
- const auto v = kick ? 0.85f * body : 0.35f * body + 0.6f * noise * (float) std::exp (-t * 18.0);
- d.audio.channels[0][at + i] += v;
- d.audio.channels[1][at + i] += kick ? v : v * 0.8f;
- }
- }
- for (int hit = 1; hit < 8; ++hit)
- ae::addMarker (d, (std::int64_t) (hit * frames / 8));
- ae::setLoop (d, { 0, (std::int64_t) frames });
- }
- // a volume envelope (a fade-in and a dip) to show the envelope mode and the envelope tools
- d.volumeEnvelope.points = { { 0.0, 0.0, 0.0f }, { 0.12, 0.5, 0.4f }, { 0.55, 0.5, 0.0f }, { 0.62, 0.25, 0.0f }, { 0.7, 0.5, 0.0f }, { 1.0, 0.5, 0.0f } };
- auto editor = lynx::makeAudioEditorForSnapshot (offline, d, false);
- auto shot = [&prefix] (juce::Component& c, const juce::String& name) {
- auto image = lynx::shot::paint (c, lynx::theme::panel);
- savePng (image, prefix + name);
- };
- editor->setSize (1120, 600);
- lynx::setAudioEditorEnvelopeModeForSnapshot (*editor, 1);
- shot (*editor, "-editor-volume-envelope.png");
- lynx::setAudioEditorEnvelopeModeForSnapshot (*editor, 0);
- juce::File (prefix + "-menu.txt").replaceWithText (lynx::audioEditorMenuForSnapshot (*editor).joinIntoString ("\n") + "\n");
- // round 190ee: the first marker's menu (Trigger note) and FL's four snap modes on a probe frame
- if (! d.markers.empty())
- juce::File (prefix + "-marker-menu.txt").replaceWithText (lynx::audioEditorMarkerMenuForSnapshot (*editor, 0).joinIntoString ("\n") + "\n");
- {
- juce::StringArray snaps;
- const auto probe = (std::int64_t) (d.audio.frames() * 3 / 8) + 777;
- for (int mode = 0; mode < 5; ++mode) // (round natives190kj: 5 = Snap to pitch period)
- snaps.add (lynx::setAudioEditorSnapForSnapshot (*editor, mode, probe));
- juce::File (prefix + "-snap.txt").replaceWithText (snaps.joinIntoString ("\n") + "\n");
- lynx::setAudioEditorSnapForSnapshot (*editor, 0, probe);
- shot (*editor, "-editor-snap-on.png");
- }
- // round natives190kj: FL's Dual view, the time grid at a few zooms, grid-slicing, Detect pitch regions, the Scrub
- // button's player (prefix-natives190kj.txt: one "name=ok|FAIL" or a report line per check)
- {
- juce::StringArray report;
- const auto frames = d.audio.frames();
- lynx::setAudioEditorViewForSnapshot (*editor, false, false, 0, frames);
- shot (*editor, "-editor-wave.png");
- lynx::setAudioEditorViewForSnapshot (*editor, false, true, 0, frames);
- shot (*editor, "-editor-dual-wave.png");
- lynx::setAudioEditorViewForSnapshot (*editor, true, false, 0, frames);
- shot (*editor, "-editor-spectrum.png");
- lynx::setAudioEditorViewForSnapshot (*editor, true, true, 0, frames);
- shot (*editor, "-editor-dual-spectrum.png");
- lynx::setAudioEditorViewForSnapshot (*editor, true, true, frames / 4, frames / 4 + 8 * 1080); // (8 samples per pixel)
- shot (*editor, "-editor-dual-spectrum-zoom8.png");
- lynx::setAudioEditorViewForSnapshot (*editor, false, false, 0, frames);
- for (const auto& [from, to] : { std::pair<std::int64_t, std::int64_t> { 0, frames }, { 0, frames / 4 }, { 0, frames / 40 }, { 0, frames / 400 } })
- {
- lynx::setAudioEditorViewForSnapshot (*editor, false, false, from, to);
- report.add ("grid seconds, view " + juce::String (from) + ".." + juce::String (to) + ": " + lynx::audioEditorCommandForSnapshot (*editor, "grid"));
- }
- lynx::setAudioEditorViewForSnapshot (*editor, false, false, 0, frames);
- shot (*editor, "-editor-grid-seconds.png");
- auto synced = d.props;
- synced.tempo = 120.0;
- synced.tempoSync = true;
- lynx::setAudioEditorSamplePropsForSnapshot (*editor, synced);
- report.add ("grid beats (tempo-sync 120 BPM): " + lynx::audioEditorCommandForSnapshot (*editor, "grid"));
- shot (*editor, "-editor-grid-beats.png");
- lynx::setAudioEditorSamplePropsForSnapshot (*editor, d.props);
- {
- auto plainDoc = d; // (a copy: the editor above keeps its markers for the tool shots)
- plainDoc.markers.clear();
- auto slicer = lynx::makeAudioEditorForSnapshot (offline, plainDoc, false);
- slicer->setSize (1120, 600);
- report.add (lynx::audioEditorCommandForSnapshot (*slicer, "grid-medium-all"));
- shot (*slicer, "-editor-grid-slicing-medium.png");
- report.add (lynx::audioEditorCommandForSnapshot (*slicer, "grid-small-all"));
- shot (*slicer, "-editor-grid-slicing-small.png");
- }
- // Detect pitch regions on three sung-like notes (A3, C4, E4)
- {
- ae::Document m;
- m.title = "Three notes";
- m.audio.sampleRate = 44100.0;
- const auto len = (std::size_t) (44100 * 3);
- m.audio.channels.assign (1, std::vector<float> (len));
- double phase = 0.0;
- for (std::size_t i = 0; i < len; ++i)
- {
- const auto hz = i < len / 3 ? 220.0 : i < 2 * len / 3 ? 261.6256 : 329.6276;
- phase += 2.0 * 3.141592653589793 * hz / 44100.0;
- m.audio.channels[0][i] = (float) (0.4 * std::sin (phase) + 0.2 * std::sin (2.0 * phase) + 0.1 * std::sin (3.0 * phase));
- }
- auto melody = lynx::makeAudioEditorForSnapshot (offline, m, false);
- melody->setSize (1120, 600);
- report.add (lynx::audioEditorCommandForSnapshot (*melody, "pitch-regions"));
- shot (*melody, "-editor-pitch-regions.png");
- }
- // the Scrub button's player: paused (silent, held), 2x forward, 1x backward, held at the start
- {
- lynx::PreviewPlayer player;
- player.prepareToPlay (44100.0, 512);
- auto ramp = std::make_shared<lynx::SampleData>();
- ramp->sampleRate = 44100.0;
- ramp->left.resize (44100);
- for (std::size_t i = 0; i < ramp->left.size(); ++i)
- ramp->left[i] = (float) i / 44100.0f;
- ramp->right = ramp->left;
- juce::AudioBuffer<float> block (2, 512);
- juce::MidiBuffer midi;
- player.playScrub (ramp, 22050, 1.0f);
- player.processBlock (block, midi);
- report.add (juce::String ("scrub paused holds=") + (player.getPlayPosition() == 22050.0 && block.getMagnitude (0, 512) == 0.0f ? "ok" : "FAIL"));
- player.setScrubSpeed (2.0);
- player.processBlock (block, midi);
- report.add (juce::String ("scrub 2x forward=") + (std::abs (player.getPlayPosition() - (22050.0 + 1024.0)) < 1e-6 && std::abs (block.getSample (0, 511) - (22050.0f + 1022.0f) / 44100.0f) < 1e-3f ? "ok" : "FAIL")
- + " (pos " + juce::String (player.getPlayPosition()) + ", last " + juce::String (block.getSample (0, 511), 5) + ")");
- player.setScrubSpeed (-1.0);
- player.processBlock (block, midi);
- report.add (juce::String ("scrub 1x backward=") + (std::abs (player.getPlayPosition() - (22050.0 + 512.0)) < 1e-6 && block.getSample (0, 0) > block.getSample (0, 511) ? "ok" : "FAIL"));
- player.setScrubSpeed (-16.0);
- for (int b = 0; b < 20; ++b)
- player.processBlock (block, midi);
- report.add (juce::String ("scrub held at the start=") + (player.getPlayPosition() == 0.0 ? "ok" : "FAIL"));
- // CPU of a 16x block (the widest kernel)
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- player.setScrubSpeed (16.0);
- for (int b = 0; b < 200; ++b)
- player.processBlock (block, midi);
- report.add ("scrub 16x: " + juce::String ((juce::Time::getMillisecondCounterHiRes() - t0) / 200.0, 4) + " ms per 512-frame block");
- }
- // paint cost: full paints of the editor, waveform / Dual view / spectrogram
- for (const auto& [spectrum, dual, name] : { std::tuple<bool, bool, const char*> { false, false, "wave" }, { false, true, "dual-wave" }, { true, true, "dual-spectrum" }, { true, false, "spectrum" } })
- {
- lynx::setAudioEditorViewForSnapshot (*editor, spectrum, dual, 0, frames);
- juce::Image img (juce::Image::ARGB, editor->getWidth(), editor->getHeight(), true);
- {
- juce::Graphics g (img);
- editor->paintEntireComponent (g, true); // (the spectrogram images are made once)
- }
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int k = 0; k < 40; ++k)
- {
- juce::Graphics g (img);
- editor->paintEntireComponent (g, true);
- }
- report.add ("paint " + juce::String (name) + ": " + juce::String ((juce::Time::getMillisecondCounterHiRes() - t0) / 40.0, 3) + " ms per full paint");
- }
- lynx::setAudioEditorViewForSnapshot (*editor, false, false, 0, frames);
- juce::File (prefix + "-natives190kj.txt").replaceWithText (report.joinIntoString ("\n") + "\n");
- }
- // round gaps190kf: FL's Sample properties window (Format › Edit properties..., F2) for this audio, with a few
- // properties set, and the WAV chunks it writes (smpl / inst / acid / LIST INFO) listed
- {
- auto withProps = d;
- withProps.props.name = "Drum loop";
- withProps.props.comments = "LYNX SHARE test loop";
- withProps.props.tempo = 120.0;
- withProps.props.tempoSync = true;
- withProps.props.fineTune = 12.0;
- lynx::SamplePropertiesHost host;
- host.projectTempo = 120.0;
- auto props = lynx::makeSamplePropertiesPanel (withProps, d.title.empty() ? std::string ("Drum loop") : d.title, host);
- shot (*props, "-sample-properties.png");
- // the file's own properties (a WAV without them: FL's defaults — the FL | LYNX pair of the form as it opens)
- auto plain = lynx::makeSamplePropertiesPanel (d, file.isNotEmpty() ? juce::File (file).getFileNameWithoutExtension().toStdString() : std::string ("Drum loop"), host);
- shot (*plain, "-sample-properties-file.png");
- juce::StringArray chunks;
- const auto wav = ae::encodeWav (withProps, ae::WavFormat::int16);
- for (std::size_t p = 12; p + 8 <= wav.size();)
- {
- const auto len = (std::size_t) wav[p + 4] | (std::size_t) wav[p + 5] << 8 | (std::size_t) wav[p + 6] << 16 | (std::size_t) wav[p + 7] << 24;
- chunks.add (juce::String (reinterpret_cast<const char*> (wav.data() + p), 4) + " " + juce::String ((int) len));
- p += 8 + len + (len & 1);
- }
- juce::File (prefix + "-sample-properties-chunks.txt").replaceWithText (chunks.joinIntoString ("\n") + "\n");
- }
- for (int t = 0; lynx::audioToolNameForSnapshot (t) != nullptr; ++t)
- {
- const auto envelopeTool = t >= 10 && t <= 14; // Scale levels .. Create sequence work on the volume envelope
- if (auto panel = lynx::makeAudioToolPanelForSnapshot (*editor, t, envelopeTool ? 1 : 0))
- {
- offline.dispatchPendingMessages();
- const auto name = juce::String (lynx::audioToolNameForSnapshot (t)).toLowerCase().retainCharacters ("abcdefghijklmnopqrstuvwxyz ").trim().replaceCharacter (' ', '-');
- shot (*panel, "-tool-" + juce::String (t).paddedLeft ('0', 2) + "-" + name + ".png");
- if (envelopeTool)
- shot (*editor, "-tool-" + juce::String (t).paddedLeft ('0', 2) + "-" + name + "-editor.png");
- panel.reset(); // (puts the envelope back)
- }
- }
- }
- static juce::TextButton* findButton (juce::Component& root, const juce::String& text)
- {
- if (auto* b = dynamic_cast<juce::TextButton*> (&root); b != nullptr && b->getButtonText() == text)
- return b;
- for (auto* child : root.getChildren())
- if (auto* b = findButton (*child, text))
- return b;
- return nullptr;
- }
- // a VFX Script editor's Script / Log / API reference tabs, then the Script tab of a script with an error
- void shootScriptTabs (juce::Component& panel, lynx::AudioEngine& engine, int index, const juce::String& name)
- {
- const std::pair<const char*, const char*> tabs[] = { { "Script", "script" }, { "Log", "log" }, { "API reference", "api" } };
- for (const auto& [tab, file] : tabs)
- if (auto* b = findButton (panel, lynx::tr (tab)); b != nullptr && b->onClick)
- {
- b->onClick();
- savePng (lynx::shot::snapshot (panel), name + "-tab-" + file + ".png");
- }
- engine.editSong ([&] (lynx::Song& s) {
- auto st = *lynx::vfx::readState (s.channels[(std::size_t) index].pluginState);
- auto settings = lynx::vfx::parseScript (st.fl).value_or (lynx::vfx::defaultScript());
- settings.setSource ("import flvfx as vfx\n\ndef onTriggerVoice(incomingVoice):\n v = vfx.Voice(incomingVoice)\n"
- " v.note += 7\n v.trigger(\n\ndef onReleaseVoice(incomingVoice):\n pass\n");
- st.fl = lynx::vfx::writeScript (settings);
- s.channels[(std::size_t) index].pluginState = lynx::vfx::writeState (st);
- });
- engine.dispatchPendingMessages();
- if (auto broken = lynx::makeChannelSettingsPanel (engine, index))
- {
- engine.dispatchPendingMessages();
- if (auto* b = findButton (*broken, lynx::tr ("Script")); b != nullptr && b->onClick)
- b->onClick();
- savePng (lynx::shot::snapshot (*broken), name + "-error.png");
- }
- }
- void runVfxShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1280, 720);
- auto song = lynx::Song::makeDefault();
- song.channels.clear();
- for (const auto kind : lynx::vfx::allKinds)
- {
- lynx::ChannelDef c;
- lynx::vfx::makeChannel (c, kind);
- if (kind == lynx::vfx::Kind::keyMapper) // a chord on every key: something to see in the grid
- for (const auto& p : lynx::vfx::builtInPresets (kind))
- if (p.name == "Major triad")
- {
- auto st = *lynx::vfx::readState (c.pluginState);
- st.fl = p.fl;
- c.pluginState = lynx::vfx::writeState (st);
- }
- song.channels.push_back (c);
- }
- // a Patcher: its notes through a Color Mapper to three synths
- lynx::ChannelDef patcher;
- patcher.name = "Patcher";
- patcher.instrument = lynx::InstrumentKind::patcher;
- lynx::PatchNode mapper;
- mapper.generator = true;
- lynx::vfx::makeChannel (mapper.channel, lynx::vfx::Kind::colorMapper);
- mapper.x = 260.0f;
- patcher.patcher.nodes.push_back (mapper);
- lynx::PatchWire notes;
- notes.kind = lynx::PatchWire::Kind::midi, notes.to = 0;
- patcher.patcher.wires.push_back (notes);
- for (int k = 0; k < 3; ++k)
- {
- lynx::PatchNode synth;
- synth.generator = true;
- synth.channel.instrument = lynx::InstrumentKind::synth;
- synth.channel.name = "Synth " + std::to_string (k + 1);
- synth.x = 520.0f, synth.y = (float) k * 90.0f;
- patcher.patcher.nodes.push_back (synth);
- lynx::PatchWire in, out;
- in.kind = lynx::PatchWire::Kind::midi, in.from = 0, in.fromPort = k, in.to = 1 + k;
- out.from = 1 + k, out.to = lynx::patchToHost;
- patcher.patcher.wires.push_back (in);
- patcher.patcher.wires.push_back (out);
- }
- patcher.patcher.outputX = 760.0f;
- song.channels.push_back (patcher);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- for (int c = 0; c < lynx::vfx::kindCount; ++c)
- if (auto panel = lynx::makeChannelSettingsPanel (offline, c))
- {
- offline.dispatchPendingMessages();
- savePng (lynx::shot::snapshot (*panel),
- prefix + "-" + juce::String (lynx::vfx::flName (*lynx::vfx::kindOf (offline.getSong().channels[(std::size_t) c]))).replaceCharacter (' ', '-').toLowerCase() + ".png");
- }
- // with FL Studio installed: the Sequencer with FL's factory bank (to compare with FL's own editor) and
- // a Script with FL's "Snap To Scale"
- if (const auto roots = lynx::findFlStudioRoots(); ! roots.data.empty())
- {
- const auto data = juce::File (juce::String::fromUTF8 (roots.data.c_str()));
- const std::pair<lynx::vfx::Kind, juce::String> extra[] = {
- { lynx::vfx::Kind::sequencer, "Patches/Plugin database/Effects/Patcher/VFX Sequencer.fst" },
- { lynx::vfx::Kind::script, "Patches/Plugin presets/Effects/VFX Script/Snap To Scale.fst" },
- };
- for (const auto& [kind, path] : extra)
- {
- juce::MemoryBlock bytes;
- if (! data.getChildFile (path).loadFileAsData (bytes))
- continue;
- const auto* b = static_cast<const std::uint8_t*> (bytes.getData());
- const auto fl = lynx::vfx::stateFromFlPreset (std::vector<std::uint8_t> (b, b + bytes.getSize()), kind);
- int index = -1;
- for (int c = 0; c < lynx::vfx::kindCount; ++c)
- if (lynx::vfx::kindOf (offline.getSong().channels[(std::size_t) c]) == kind)
- index = c;
- if (! fl || index < 0)
- continue;
- offline.editSong ([&] (lynx::Song& s) {
- auto st = *lynx::vfx::readState (s.channels[(std::size_t) index].pluginState);
- st.fl = *fl;
- s.channels[(std::size_t) index].pluginState = lynx::vfx::writeState (st);
- });
- offline.dispatchPendingMessages();
- if (auto panel = lynx::makeChannelSettingsPanel (offline, index))
- {
- offline.dispatchPendingMessages();
- const auto name = prefix + "-" + juce::String (lynx::vfx::flName (kind)).replaceCharacter (' ', '-').toLowerCase();
- savePng (lynx::shot::snapshot (*panel), name + "-fl.png");
- if (kind == lynx::vfx::Kind::script) // the editor's other tabs (round 165d)
- shootScriptTabs (*panel, offline, index, name);
- }
- }
- }
- lynx::PatcherWindows::openChannel (offline, lynx::vfx::kindCount);
- for (int k = 0; k < juce::TopLevelWindow::getNumTopLevelWindows(); ++k)
- if (auto* w = dynamic_cast<juce::DocumentWindow*> (juce::TopLevelWindow::getTopLevelWindow (k)))
- if (w->getName().startsWith (lynx::tr ("Patcher")) && w->getContentComponent() != nullptr)
- {
- auto* content = w->getContentComponent();
- savePng (lynx::shot::snapshot (*content), prefix + "-patcher.png");
- delete w;
- break;
- }
- lynx::PatcherWindows::shootMenus (offline, true, lynx::vfx::kindCount, 0, [&] (const juce::Image& image, const juce::String& name) {
- savePng (image, prefix + "-patcher-menu-" + name + ".png");
- });
- // a plugin renamed in the Plugin database ("1_EQ", FL): the Quick-add palette and the mixer slot show the new name
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_TEST_MODE", {}).isNotEmpty())
- {
- const auto key = std::string ("lynx:fx:") + lynx::effectInfo (lynx::EffectKind::parametricEq).name;
- offline.getPluginHost().setPluginName (key, "1_EQ");
- offline.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() > 1)
- {
- lynx::EffectSlot slot;
- slot.kind = lynx::EffectKind::parametricEq;
- s.mixer[1].effects.push_back (slot);
- }
- });
- offline.dispatchPendingMessages();
- {
- lynx::QuickAddTargets targets;
- targets.addInstrument = [] (lynx::ChannelDef) {};
- targets.addEffect = [] (lynx::EffectSlot) {};
- auto palette = lynx::makeQuickAddPalette (offline, std::move (targets));
- savePng (lynx::shot::snapshot (*palette), prefix + "-quickadd-renamed.png");
- }
- ui.selectTabForSnapshot (3);
- ui.getMixerForSnapshot().selectTrack (1);
- offline.dispatchPendingMessages();
- savePng (lynx::shot::snapshot (ui), prefix + "-mixer-renamed.png");
- offline.getPluginHost().setPluginName (key, "");
- }
- }
- void runAudioXShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- {
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- offline.dispatchPendingMessages();
- // 1. sends: insert 1 feeds insert 3 pre-fader and insert 4 post-fader (FL's way)
- offline.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() < 5)
- return;
- s.mixer[1].name = "Vocal";
- s.mixer[3].name = "Reverb";
- s.mixer[4].name = "Delay";
- s.setRoute (1, 3, true);
- s.setRoute (1, 4, true);
- s.setRouteLevel (1, 3, 0.6f);
- s.setRouteLevel (1, 4, 0.4f);
- s.setSendPre (1, 3, true);
- });
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (3);
- ui.getMixerForSnapshot().selectTrack (1);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-send-pre.png");
- auto& strips = ui.getMixerForSnapshot().getStripsForSnapshot();
- saveMenus (juce::StringArray { "Send to Reverb (pre-fader)", "Send to Delay (post-fader)" },
- std::vector<juce::PopupMenu> { strips.buildSendMenu (3), strips.buildSendMenu (4) }, prefix + "-send-menu.png");
- // 2. low latency while recording: the monitored track's look-ahead limiter is bypassed, the EQ stays
- offline.editSong ([] (lynx::Song& s) {
- s.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::parametricEq));
- s.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::limiter));
- s.mixer[1].inputChannel = 0;
- s.mixer[1].monitor = lynx::InputMonitor::on;
- });
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-lowlat-off.png");
- auto options = offline.getRecordOptions();
- options.lowLatencyRecording = true;
- offline.setRecordOptions (options);
- offline.dispatchPendingMessages();
- ui.getMixerForSnapshot().selectTrack (1);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-lowlat-on.png");
- saveMenus (juce::StringArray { "Record" }, std::vector<juce::PopupMenu> { ui.getFullRecordMenuForSnapshot() }, prefix + "-lowlat-menu.png");
- juce::String report;
- report << "latency_with_option=" << offline.getLatencySamples() << " bypassed_slots=" << offline.lowLatencyBypassedCount() << "\n";
- options.lowLatencyRecording = false;
- offline.setRecordOptions (options);
- offline.dispatchPendingMessages();
- report << "latency_without_option=" << offline.getLatencySamples() << "\n";
- // 3. the Browser's "Preview in time": a 120 BPM loop previewed in a 140 BPM project
- const auto dir = juce::File (prefix).getParentDirectory().getChildFile ("audiox-preview");
- dir.createDirectory();
- const auto wav = dir.getChildFile ("Drum loop 120 bpm.wav");
- {
- const int frames = 44100 * 4;
- juce::AudioBuffer<float> audio (1, frames);
- for (int i = 0; i < frames; ++i)
- {
- const auto t = (double) (i % 22050) / 44100.0;
- audio.setSample (0, i, (float) (0.8 * std::exp (-t * 30.0) * std::sin (6.283185307179586 * (50.0 + 80.0 * std::exp (-t * 40.0)) * t)));
- }
- wav.deleteFile();
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 44100.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- }
- offline.getTransport().bpm.store (140.0);
- offline.setPreviewInTime (true);
- ui.showDesktopForSnapshot (false);
- offline.previewFile (wav);
- offline.finishPreviewJobs();
- ui.getBrowserForSnapshot().showPreviewForSnapshot (wav);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-preview-in-time.png");
- saveMenus (juce::StringArray { "Browser options" }, std::vector<juce::PopupMenu> { ui.getBrowserForSnapshot().buildViewMenu() }, prefix + "-preview-menu.png");
- const auto& timing = offline.getPreviewTiming();
- report << "preview file_bpm=" << timing.fileBpm << " project_bpm=" << timing.projectBpm << " ratio=" << timing.ratio
- << " prepare_ms=" << juce::String (offline.getLastPreviewPrepareMs(), 1) << "\n";
- offline.previewFile ({});
- offline.setPreviewInTime (false);
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- }
- void runComp177Shot (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- {
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- std::int64_t last = 0;
- for (const auto& c : offline.getSong().playlist)
- last = std::max (last, c.end());
- const auto bars = juce::jmax (1, (int) (last / (4 * lynx::ppq)) + 1);
- playlist.setViewForSnapshot (juce::jmax (60.0, (ui.getWidth() - 300.0) / bars), 0, 0);
- // (the first paint asks for the clips' waveforms, a worker thread loads them)
- saveSnapshot (ui, prefix + "-opened.png");
- juce::Thread::sleep (3000);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-opened.png");
- // a muted clip selected
- for (int c = 0; c < (int) offline.getSong().playlist.size(); ++c)
- if (offline.getSong().playlist[(std::size_t) c].muted)
- {
- playlist.selectClipsForSnapshot ({ c });
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-selected.png");
- playlist.selectClipsForSnapshot ({});
- break;
- }
- juce::String report;
- const auto listTracks = [&offline, &report] (const juce::String& title) {
- const auto& s = offline.getSong();
- report << title << "\n";
- for (int t = 0; t < (int) s.playlistTracks.size(); ++t)
- {
- int clips = 0, muted = 0;
- for (const auto& c : s.playlist)
- if (c.track == t)
- ++clips, muted += c.muted ? 1 : 0;
- const auto& pt = s.playlistTracks[(std::size_t) t];
- if (clips > 0 || pt.grouped || ! pt.name.empty())
- report << "track " << (t + 1) << " '" << juce::String::fromUTF8 (pt.name.c_str()) << "' grouped=" << (pt.grouped ? 1 : 0) << " collapsed=" << (pt.collapsed ? 1 : 0)
- << " comp=" << (pt.compTrack ? 1 : 0) << " clips=" << clips << " muted=" << muted << "\n";
- }
- };
- listTracks ("opened");
- // the first group's header (a member's menu holds "Comp these takes" too)
- int firstGroup = -1;
- for (int t = 0; t < (int) offline.getSong().playlistTracks.size() && firstGroup < 0; ++t)
- if (lynx::comp::canComp (offline.getSong(), t))
- firstGroup = t;
- report << "first group with takes: track " << (firstGroup + 1) << "\n";
- if (firstGroup >= 0)
- {
- saveMenus (juce::StringArray { "Playlist track" }, std::vector<juce::PopupMenu> { playlist.getTrackMenuForSnapshot (firstGroup) }, prefix + "-trackmenu.png");
- int comp = -1;
- offline.editSong ([firstGroup, &comp] (lynx::Song& s) { comp = lynx::comp::compTakes (s, firstGroup); });
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-comped.png");
- listTracks ("after Comp these takes");
- const auto g = lynx::comp::groupOf (offline.getSong(), comp);
- std::int64_t from = -1, to = 0;
- for (const auto& c : offline.getSong().playlist)
- if (c.track == g.first)
- from = from < 0 ? c.start : std::min (from, c.start), to = std::max (to, c.end());
- if (g.valid() && to > from)
- {
- offline.editSong ([&g, from, to] (lynx::Song& s) { lynx::comp::swipe (s, g.first, from + (to - from) / 4, from + (to - from) / 2); });
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-swiped.png");
- listTracks ("after a swipe of the middle of the first lane");
- // a lane auditioned; the crossfade close up; the comp flattened
- offline.editSong ([&g] (lynx::Song& s) { lynx::comp::setAudition (s, g.first); }, false);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-audition.png");
- offline.editSong ([] (lynx::Song& s) { lynx::comp::setAudition (s, -1); }, false);
- const auto switchAt = from + (to - from) / 4;
- playlist.setViewForSnapshot (4.0 * 4.0 * lynx::ppq, 0, 0);
- playlist.setScrollTickForSnapshot ((double) (switchAt - 100));
- juce::Thread::sleep (1500);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-crossfade.png");
- playlist.setViewForSnapshot (juce::jmax (60.0, (ui.getWidth() - 300.0) / bars), 0, 0);
- offline.editSong ([comp] (lynx::Song& s) { lynx::comp::flatten (s, comp); });
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-flattened.png");
- listTracks ("after Flatten comp");
- }
- }
- saveMenus (juce::StringArray { "Record" }, std::vector<juce::PopupMenu> { ui.getRecordMenuForSnapshot() }, prefix + "-recordmenu.png");
- juce::File (prefix + "-tracks.txt").replaceWithText (report);
- }
- }
- // Round 190bx: the Settings pages alone (the full --snapshot takes minutes). prefix-settings-<page>.png at the
- // window's size, -small.png at 390 x 390 (rows must scroll, never be cut off or squeezed) and -whole.png tall
- // enough to show every row of the page.
- void runSettingsShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- {
- lynx::AudioEngine offline (false);
- offline.editSong ([] (lynx::Song& s) {
- s.info = { "Night Drive", "LYNX SHARE demo", "Synthwave", "https://lynx-share.com",
- "Made with LYNX SHARE.\nDrums and bass from the Channel Rack, pads from the Browser.", false };
- }, false);
- auto shoot = [&] (lynx::SettingsPage page, const juce::String& name, int width, int height) {
- auto panel = lynx::makeSettingsPanel (offline, page);
- if (width > 0)
- panel->setSize (width, height);
- juce::Component frame;
- frame.setSize (panel->getWidth(), panel->getHeight());
- frame.addAndMakeVisible (*panel);
- panel->setTopLeftPosition (0, 0);
- juce::Image image (juce::Image::ARGB, frame.getWidth(), frame.getHeight(), true);
- {
- juce::Graphics g (image);
- g.fillAll (lynx::theme::panel);
- frame.paintEntireComponent (g, false);
- }
- savePng (image, prefix + "-settings-" + name + ".png");
- };
- const std::pair<lynx::SettingsPage, const char*> pages[] = { { lynx::SettingsPage::audio, "audio" }, { lynx::SettingsPage::midi, "midi" },
- { lynx::SettingsPage::general, "general" }, { lynx::SettingsPage::theme, "theme" },
- { lynx::SettingsPage::files, "files" }, { lynx::SettingsPage::extras, "extras" },
- { lynx::SettingsPage::project, "project" }, { lynx::SettingsPage::info, "info" } };
- for (const auto& [page, name] : pages)
- {
- shoot (page, name, 0, 0);
- shoot (page, juce::String (name) + "-small", 390, 390);
- }
- shoot (lynx::SettingsPage::audio, "audio-whole", 680, 1500);
- shoot (lynx::SettingsPage::general, "general-whole", 680, 2400); // (round 190gh: + the Updates section's previous-version row)
- // round 190jp (design190ia FW-20): the whole Theme page (thumbnails, Adjustments, dots, A | B), then with
- // Adjustments and two dots set, in that theme
- shoot (lynx::SettingsPage::theme, "theme-whole", 680, 1900);
- {
- const auto before = lynx::themeui::current();
- auto adjusted = before;
- adjusted.hue = 40.0f;
- adjusted.saturation = 0.45f;
- adjusted.contrast = 0.3f;
- adjusted.text = 0.4f;
- adjusted.dots[(std::size_t) lynx::themes::Dot::steps] = 0xffffa040;
- adjusted.dots[(std::size_t) lynx::themes::Dot::highlight] = 0xff30a5ff;
- lynx::themeui::apply (adjusted, false);
- shoot (lynx::SettingsPage::theme, "theme-adjusted", 680, 1900);
- lynx::themeui::apply (before, false);
- }
- }
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- }
- // round 190bw: FL's 13 curve modes of an automation clip's points (see --curveshot)
- bool runPickerDropShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::StringArray checks;
- bool all = true;
- const auto check = [&checks, &all] (bool ok, const juce::String& what) {
- checks.add ((ok ? "OK " : "FAIL ") + what);
- all = all && ok;
- };
- {
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- offline.dispatchPendingMessages();
- const auto bar = (std::int64_t) lynx::ppq * 4;
- offline.editSong ([bar] (lynx::Song& s) {
- s.patterns.resize (3);
- const char* names[] = { "Pattern 1", "Pattern 2", "Pattern 3" };
- for (int p = 0; p < 3; ++p)
- {
- auto& pattern = s.patterns[(std::size_t) p];
- pattern.name = names[p];
- pattern.notes.clear();
- for (int n = 0; n < 4 * (p + 1); ++n)
- {
- lynx::Note note;
- note.start = (std::int64_t) n * lynx::ppq / 2;
- note.length = lynx::ppq / 4;
- note.key = 60 + (n * 5 + p * 3) % 12;
- pattern.notes.push_back (note);
- }
- }
- s.patterns[1].lengthTicks = bar * 2; // (Pattern 2 is two bars long)
- s.currentPattern = 0;
- s.playlist.clear();
- }, false);
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- playlist.setViewForSnapshot (120.0, 0, 0);
- offline.dispatchPendingMessages();
- // the drag's description survives the trip
- {
- auto kind = lynx::ClipKind::audio;
- std::vector<int> entries;
- const auto text = lynx::PlaylistComponent::pickerDragDescription (lynx::ClipKind::pattern, { 2, 0 });
- check (lynx::PlaylistComponent::pickerDrag (text, kind, entries) && kind == lynx::ClipKind::pattern && entries == std::vector<int> ({ 2, 0 }),
- "drag description " + text);
- }
- const auto at = [&playlist] (int track, double ticks) {
- return juce::Point<int> (juce::roundToInt (playlist.xOfTickForSnapshot (ticks)), playlist.trackRowForSnapshot (track).getCentreY());
- };
- const auto find = [&offline] (int track, int pattern) -> const lynx::Clip* {
- for (const auto& c : offline.getSong().playlist)
- if (c.track == track && c.kind == lynx::ClipKind::pattern && c.pattern == pattern)
- return &c;
- return nullptr;
- };
- // 1. Pattern 1 dropped on track 1 a little after bar 2's line: it starts on that line
- playlist.dropFromPicker (lynx::ClipKind::pattern, { 0 }, at (0, (double) bar + lynx::ppq * 0.2), false);
- offline.dispatchPendingMessages();
- const auto* one = find (0, 0);
- check (one != nullptr && one->start == bar && one->length == bar, "plain drop: Pattern 1 on track 1 at bar 2");
- // 2. Pattern 2 + Pattern 3 (picked together) dropped on track 3 at bar 3: tracks 3 and 4, same time
- playlist.dropFromPicker (lynx::ClipKind::pattern, { 1, 2 }, at (2, (double) bar * 2), false);
- offline.dispatchPendingMessages();
- const auto* two = find (2, 1);
- const auto* three = find (3, 2);
- check (two != nullptr && three != nullptr && two->start == bar * 2 && three->start == bar * 2,
- "two picked patterns: Pattern 2 on track 3, Pattern 3 on track 4, both at bar 3");
- check (offline.getSong().currentPattern == 2, "the current pattern is the last dropped one (Pattern 3)");
- const auto selectedAre = [&playlist, &offline] (int track, std::size_t count) {
- const auto& sel = playlist.getSelectedClips();
- if (sel.size() != count)
- return false;
- for (const auto i : sel)
- if (i < 0 || i >= (int) offline.getSong().playlist.size() || offline.getSong().playlist[(std::size_t) i].start != (track < 0 ? 2 * (std::int64_t) lynx::ppq * 4 : offline.getSong().playlist[(std::size_t) i].start)
- || (track >= 0 && offline.getSong().playlist[(std::size_t) i].track != track))
- return false;
- return true;
- };
- check (selectedAre (-1, 2), "the two dropped clips are the selection (FL), Pattern 1's clip is not");
- saveSnapshot (ui, prefix + "-plain.png");
- // 3. Shift: all three on track 6 from bar 1, one after the other
- playlist.dropFromPicker (lynx::ClipKind::pattern, { 0, 1, 2 }, at (5, 0.0), true);
- offline.dispatchPendingMessages();
- const auto* a = find (5, 0);
- const auto* b = find (5, 1);
- const auto* c = find (5, 2);
- check (a != nullptr && b != nullptr && c != nullptr && a->start == 0 && b->start == a->end() && c->start == b->end(),
- "Shift drop: Pattern 1, 2, 3 one after the other on track 6");
- check (offline.getSong().currentPattern == 2, "Shift keeps the current pattern");
- check (selectedAre (5, 3), "the three chained clips are the selection");
- saveSnapshot (ui, prefix + "-shift.png");
- }
- checks.add (all ? "ALL OK" : "FAILURES");
- juce::File (prefix + "-checks.txt").replaceWithText (checks.joinIntoString ("\n") + "\n");
- return all;
- }
- bool runTrackModeShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- bool all = true;
- juce::String report;
- {
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- // the track's menu, Track mode and Audio track side by side; the Audio track entries as FL writes them
- // ("-" in front = greyed, "v" = ticked)
- const auto shoot = [&] (int track, const juce::String& name, const juce::StringArray& fl) {
- const auto menu = playlist.getTrackMenuForSnapshot (track);
- juce::StringArray names { "Track " + juce::String (track + 1) };
- std::vector<juce::PopupMenu> menus { menu };
- menus.reserve (3); // (round 190rf, ASan: the iterator below walks menus[1] while the third is added)
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == lynx::theme::mnemonic (lynx::tr ("Track mode"), 'T'))
- {
- names.add (lynx::tr ("Track mode"));
- menus.push_back (*it.getItem().subMenu);
- }
- if (menus.size() == 2)
- for (juce::PopupMenu::MenuItemIterator it (menus[1]); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == lynx::theme::mnemonic (lynx::tr ("Audio track"), 'A'))
- {
- names.add (lynx::tr ("Audio track"));
- menus.push_back (*it.getItem().subMenu);
- }
- juce::StringArray lynxList;
- if (menus.size() == 3)
- for (juce::PopupMenu::MenuItemIterator it (menus[2]); it.next();)
- lynxList.add (it.getItem().isSeparator ? juce::String ("|")
- : (it.getItem().isTicked ? "v " : "") + juce::String (it.getItem().isEnabled ? "" : "- ") + it.getItem().text);
- saveMenus (names, menus, prefix + "-" + name + ".png");
- const auto same = menus.size() == 3 && lynxList == fl;
- all = all && same;
- report << name << ": " << (same ? "SAME AS FL" : "DIFFERENT") << "\n LYNX: " << lynxList.joinIntoString (" / ")
- << "\n FL: " << fl.joinIntoString (" / ") << "\n";
- };
- const auto flList = [] (int inserts, std::map<int, juce::String> named, std::set<int> greyed) {
- juce::StringArray l { "New mixer track(s)", "|" };
- for (int i = 1; i <= inserts; ++i)
- l.add ((greyed.count (i) ? "- " : "") + juce::String (i) + ". " + (named.count (i) ? named[i] : "Insert " + juce::String (i)));
- return l;
- };
- // q1-01: a fresh project, Track 1 unassigned
- shoot (0, "fresh", flList (16, {}, {}));
- // q1-02: Track 1 linked to insert 6, insert 7 renamed "Vox chain"; Track 2's menu
- offline.editSong ([] (lynx::Song& s) {
- lynx::trackmodes::assignAudioTracks (s, { 0 }, 6);
- s.mixer[7].name = "Vox chain";
- });
- offline.dispatchPendingMessages();
- shoot (1, "linked-renamed", flList (16, { { 7, "Vox chain" } }, { 6 }));
- // q1-07: the rest of FL's session (live 190cu Q2): Track 3 → 7; Track 4 → New mixer track (17), insert 9
- // renamed "Vox chain", Track 4 → 9; Track 5 "Lead" → 11, insert 12 "Vox chain", Track 5 → 12; Track 6 "Lead"
- // (unassigned), insert 13 "Vox chain", Track 6 → 13. Track 7's menu
- offline.editSong ([] (lynx::Song& s) {
- namespace tm = lynx::trackmodes;
- if (s.playlistTracks.size() < 8)
- s.playlistTracks.resize (8);
- tm::assignAudioTracks (s, { 2 }, 7);
- tm::assignAudioTracks (s, { 3 }, tm::newMixerTrack);
- s.mixer[9].name = "Vox chain";
- tm::assignAudioTracks (s, { 3 }, 9);
- s.playlistTracks[4].name = "Lead";
- tm::assignAudioTracks (s, { 4 }, 11);
- s.mixer[12].name = "Vox chain";
- tm::assignAudioTracks (s, { 4 }, 12);
- s.playlistTracks[5].name = "Lead";
- s.mixer[13].name = "Vox chain";
- tm::assignAudioTracks (s, { 5 }, 13);
- });
- offline.dispatchPendingMessages();
- shoot (6, "full-state", flList (17, { { 7, "Vox chain" }, { 9, "Insert 17" }, { 12, "Lead" }, { 13, "Vox chain" } }, { 6, 7, 9, 12, 13 }));
- }
- report << (all ? "ALL SAME AS FL\n" : "FAILURES\n");
- juce::File (prefix + "-report.txt").replaceWithText (report);
- return all;
- }
- void runCurveShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- {
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- offline.dispatchPendingMessages();
- // FL's menu order, one bar per mode, the levels going up and down; a tension where the mode needs one to show
- static const int order[] = { lynx::flcurve::smooth, lynx::flcurve::hold, lynx::flcurve::singleCurve, lynx::flcurve::singleCurve2,
- lynx::flcurve::singleCurve3, lynx::flcurve::doubleCurve, lynx::flcurve::doubleCurve2, lynx::flcurve::doubleCurve3,
- lynx::flcurve::halfSine, lynx::flcurve::stairs, lynx::flcurve::smoothStairs, lynx::flcurve::pulse, lynx::flcurve::wave };
- const auto bar = (std::int64_t) lynx::ppq * 4;
- offline.editSong ([bar] (lynx::Song& song) {
- song.mode = lynx::PlayMode::song;
- lynx::Automation a;
- a.name = "Curve modes";
- a.target = { lynx::AutomationTargetKind::mixerVolume, 1 };
- a.points.push_back ({ 0, 0.15f, 0.0f });
- int k = 0;
- for (const auto mode : order)
- {
- const auto stepped = mode == lynx::flcurve::stairs || mode == lynx::flcurve::smoothStairs || mode == lynx::flcurve::pulse || mode == lynx::flcurve::wave;
- a.points.back().mode = (std::uint8_t) mode;
- a.points.back().tension = mode == lynx::flcurve::smooth || mode == lynx::flcurve::hold ? 0.0f : stepped ? -0.72f : (k % 2 == 0 ? 0.55f : -0.55f);
- ++k;
- a.points.push_back ({ bar * k, k % 2 == 1 ? 0.85f : 0.15f, 0.0f });
- }
- song.automations.insert (song.automations.begin(), a);
- for (auto& c : song.playlist)
- if (c.kind == lynx::ClipKind::automation)
- ++c.automation;
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::automation;
- clip.automation = 0;
- clip.track = 3;
- clip.length = bar * 13;
- song.playlist.push_back (clip);
- if (song.playlistTracks.size() < 4)
- song.playlistTracks.resize (4);
- song.playlistTracks[3].height = 150;
- }, false);
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- saveSnapshot (ui, prefix + "-playlist.png");
- const auto clipIndex = (int) offline.getSong().playlist.size() - 1;
- // the point menu of the point that ends the "Stairs" segment (point 10), and of the first point
- saveMenus (juce::StringArray { "Automation point (ends a Stairs segment)", "First point" },
- std::vector<juce::PopupMenu> { playlist.getAutomationPointMenuForSnapshot (clipIndex, 10), playlist.getAutomationPointMenuForSnapshot (clipIndex, 0) },
- prefix + "-point-menu.png");
- auto editor = lynx::makeAutomationEditor (offline, 0);
- editor->setSize (1500, 420);
- savePng (editor->createComponentSnapshot (editor->getLocalBounds()), prefix + "-editor.png");
- editor.reset();
- // the project itself, for --export-flp and a look at the same clip in FL
- {
- juce::String saveError;
- lynx::ProjectFile::save (offline.getSong(), juce::File (prefix + "-modes.lynx"), saveError);
- }
- // part 2: the Piano roll tools that gained FL's options (they preview on the pattern and put the notes back)
- ui.selectTabForSnapshot (1);
- offline.dispatchPendingMessages();
- auto& roll = ui.getPianoRollForSnapshot();
- const std::pair<lynx::NoteTool, const char*> tools[] = { { lynx::NoteTool::flip, "-tool-flip.png" },
- { lynx::NoteTool::limit, "-tool-limit.png" },
- { lynx::NoteTool::scaleLevels, "-tool-scalelevels.png" },
- { lynx::NoteTool::randomise, "-tool-randomise.png" },
- { lynx::NoteTool::lfo, "-tool-lfo.png" } };
- // round 190ct: checks of the FL-live fixes, one line each in <prefix>-checks.txt (OK / FAIL)
- juce::StringArray checks;
- const auto check = [&checks] (bool ok, const juce::String& what) { checks.add ((ok ? "OK " : "FAIL ") + what); };
- {
- juce::String header;
- const auto pointMenu = playlist.getAutomationPointMenuForSnapshot (clipIndex, 10); // (the iterator keeps a reference)
- for (juce::PopupMenu::MenuItemIterator it (pointMenu); it.next();)
- {
- header = it.getItem().text;
- break;
- }
- check (header == "Point 11/14", "point menu header \"" + header + "\" (FL: \"Point n/N\")");
- }
- for (const auto& [tool, name] : tools)
- {
- auto panel = lynx::makeNoteToolPanel (offline, tool, roll.noteIndicesForSnapshot(), roll.gridForSnapshot());
- offline.dispatchPendingMessages();
- savePng (panel->createComponentSnapshot (panel->getLocalBounds()), prefix + name);
- if (tool == lynx::NoteTool::flip)
- {
- std::vector<juce::ToggleButton*> toggles;
- for (auto* child : panel->getChildren())
- if (auto* t = dynamic_cast<juce::ToggleButton*> (child))
- toggles.push_back (t);
- check (toggles.size() == 3 && toggles[0]->getToggleState() && toggles[1]->getToggleState() && ! toggles[2]->getToggleState(),
- "flip opens with Flip horizontally on, Preserve start times on, Flip vertically off");
- if (toggles.size() == 3)
- {
- toggles[2]->setToggleState (true, juce::sendNotificationSync);
- check (! toggles[0]->getToggleState() && toggles[2]->getToggleState(), "flip: vertically turns horizontally off (radios)");
- toggles[0]->setToggleState (true, juce::sendNotificationSync);
- check (toggles[0]->getToggleState() && ! toggles[2]->getToggleState(), "flip: horizontally turns vertically off (radios)");
- }
- }
- if (tool == lynx::NoteTool::limit)
- {
- auto* list = lynx::noteToolLongestChoiceForSnapshot (*panel);
- juce::ComboBox* key = nullptr;
- for (auto* child : panel->getChildren())
- if (auto* box = dynamic_cast<juce::ComboBox*> (child); box != nullptr && box->getNumItems() == 12)
- key = box;
- check (list != nullptr && list->getNumItems() == 89, "limit list has (none) + 66 chords + 22 scales: "
- + juce::String (list != nullptr ? list->getNumItems() : 0));
- check (list != nullptr && key != nullptr && list->getY() == key->getY() && list->getX() > key->getRight(),
- "limit: Key and the chord / scale list share one row");
- if (list != nullptr)
- saveMenus (juce::StringArray { "Limit: Key / scale list" }, std::vector<juce::PopupMenu> { *list->getRootMenu() },
- prefix + "-tool-limit-list.png");
- }
- if (tool == lynx::NoteTool::lfo)
- saveMenus (juce::StringArray { "LFO tool: right-click on a Period slider" },
- std::vector<juce::PopupMenu> { lynx::noteToolPresetMenuForSnapshot (*panel) }, prefix + "-tool-lfo-steps.png");
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks.joinIntoString ("\n") + "\n");
- }
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- }
- bool runEvPaneShot (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::StringArray report;
- bool ok = true;
- {
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- if (projectPath.isNotEmpty())
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (1); // the Piano Roll
- offline.dispatchPendingMessages();
- auto& roll = ui.getPianoRollForSnapshot();
- roll.scrollToNotes();
- const auto area = ui.getLocalArea (&roll, roll.getLocalBounds());
- const auto file = lynx::platform::settingsFile ("piano-roll-event-pane.txt");
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const auto now = juce::Time::getCurrentTime();
- auto event = [&] (juce::Point<int> p, juce::Point<int> down, juce::ModifierKeys mods, int clicks, bool dragged) {
- return juce::MouseEvent (source, p.toFloat(), mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &roll, &roll, now, down.toFloat(), now, clicks, dragged);
- };
- auto barCentre = [&roll] { return roll.eventPaneBarArea().getCentre(); };
- const juce::ModifierKeys left (juce::ModifierKeys::leftButtonModifier), right (juce::ModifierKeys::rightButtonModifier),
- middle (juce::ModifierKeys::middleButtonModifier);
- auto click = [&] (juce::ModifierKeys button, int clicks) {
- const auto at = barCentre();
- roll.mouseDown (event (at, at, button, clicks, false));
- roll.mouseUp (event (at, at, {}, clicks, false));
- offline.dispatchPendingMessages();
- };
- auto dragTo = [&] (int y) {
- const auto at = barCentre();
- roll.mouseDown (event (at, at, left, 1, false));
- for (int step = 1; step <= 8; ++step) // (a few moves, as a hand does)
- roll.mouseDrag (event ({ at.x, at.y + (y - at.y) * step / 8 }, at, left, 1, true));
- roll.mouseUp (event ({ at.x, y }, at, {}, 1, true));
- offline.dispatchPendingMessages();
- };
- auto state = [&] (const juce::String& name) {
- const auto grid = roll.getHeight() - lynx::PianoRollComponent::headerHeight - roll.velocityHeight - lynx::evpane::barThickness;
- const auto& st = lynx::PianoRollComponent::eventPaneState();
- report.add (name + ": roll " + juce::String (roll.getHeight()) + " px, grid " + juce::String (juce::jmax (0, grid)) + " px, bar top "
- + juce::String (roll.eventPaneBarTopForTests()) + ", event editor " + juce::String (roll.velocityHeight) + " px, aspect "
- + juce::String (st.aspect, 4) + ", spare " + juce::String (st.spare, 4) + ", file \"" + file.loadFileAsString().trim().replace ("\n", " ") + "\"");
- saveArea (ui, area, prefix + "-" + name + ".png");
- };
- auto expect = [&] (bool condition, const juce::String& what) {
- report.add ((condition ? "PASS " : "FAIL ") + what);
- ok = ok && condition;
- };
- state ("1-default");
- const auto defaultLane = roll.velocityHeight;
- expect (std::abs (lynx::PianoRollComponent::eventPaneState().aspect - 0.8f) < 1e-6f, "default place is FL's 0.8");
- ui.setHintForSnapshot (roll.hintAt (barCentre()));
- saveSnapshot (ui, prefix + "-2-hover-hint.png");
- ui.setHintForSnapshot ({});
- const auto travelTop = lynx::PianoRollComponent::headerHeight, travelBottom = roll.getHeight() - lynx::evpane::barThickness;
- dragTo (travelTop + (travelBottom - travelTop) * 45 / 100);
- state ("3-dragged-larger");
- const auto largeLane = roll.velocityHeight;
- expect (largeLane > defaultLane * 2, "drag up makes the event editor taller");
- expect (lynx::evpane::fromText (file.loadFileAsString().toStdString()) == lynx::PianoRollComponent::eventPaneState(),
- "the place is written to the settings file on release");
- click (right, 1);
- state ("4-right-click-alternate");
- expect (roll.velocityHeight == 0, "right-click: the alternate size (FL's spare 1.0) folds the event editor away");
- click (right, 1);
- state ("5-right-click-back");
- expect (roll.velocityHeight == largeLane, "right-click again: back to the dragged size");
- roll.runAction ("pianoRoll.eventPaneAlternate");
- offline.dispatchPendingMessages();
- expect (roll.velocityHeight == 0, "Shift+Enter (pianoRoll.eventPaneAlternate) swaps too");
- roll.runAction ("pianoRoll.eventPaneAlternate");
- offline.dispatchPendingMessages();
- dragTo (travelTop + 10);
- state ("6-grid-folded");
- expect (roll.eventPaneBarTopForTests() == travelTop, "a drag within 23 px of the top folds the note grid away");
- click (middle, 1);
- state ("7-middle-click-default");
- expect (roll.velocityHeight == defaultLane, "middle-click: back to the default place");
- // a taller window keeps the proportion (the place is a fraction of the travel)
- dragTo (travelTop + (travelBottom - travelTop) * 60 / 100);
- const auto before = lynx::PianoRollComponent::eventPaneState().aspect;
- roll.setSize (roll.getWidth(), roll.getHeight() + 200);
- offline.dispatchPendingMessages();
- const auto newTravel = roll.getHeight() - lynx::evpane::barThickness - travelTop;
- expect (std::abs (roll.eventPaneBarTopForTests() - (travelTop + juce::roundToInt (before * (float) newTravel))) <= 1,
- "a taller window keeps the proportion");
- roll.setSize (roll.getWidth(), roll.getHeight() - 200);
- offline.dispatchPendingMessages();
- click (middle, 1); // leave FL's default behind
- }
- report.add (ok ? "RESULT OK" : "RESULT FAIL");
- juce::File (prefix + "-report.txt").replaceWithText (report.joinIntoString ("\n") + "\n");
- return ok;
- }
- void runFeat166Shot (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- {
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- if (projectPath.isNotEmpty())
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (1); // the Piano Roll, on the channel with the most notes
- offline.dispatchPendingMessages();
- // the scale the pattern's notes fit best (major / minor, any root)
- const auto& song = offline.getSong();
- const auto& notes = song.patterns[(std::size_t) song.currentPattern].notes;
- int bestRoot = 0, bestScale = 1, bestHits = -1;
- for (int sc = 1; sc < (int) lynx::notetools::scales().size(); ++sc)
- {
- const juce::String name (lynx::notetools::scales()[(std::size_t) sc].name);
- if (name != "Major" && name != "Minor")
- continue;
- for (int root = 0; root < 12; ++root)
- {
- int hits = 0;
- for (const auto& n : notes)
- hits += lynx::notetools::inScale (n.key, root, sc) ? 1 : 0;
- if (hits > bestHits)
- bestHits = hits, bestRoot = root, bestScale = sc;
- }
- }
- auto& roll = ui.getPianoRollForSnapshot();
- roll.setScaleForSnapshot (bestRoot, bestScale);
- roll.scrollToNotes();
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-pr-scale.png");
- roll.setFoldToScale (true);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-pr-folded.png");
- roll.setFoldToScale (false);
- // ghost channels: only the first other channel with notes stays a ghost
- const auto selected = offline.getSelectedChannel();
- int keep = -1;
- for (const auto& n : notes)
- if (n.channel != selected && keep < 0)
- keep = n.channel;
- offline.editSong ([keep] (lynx::Song& s) {
- for (int c = 0; c < (int) s.channels.size(); ++c)
- s.channels[(std::size_t) c].ghostHidden = c != keep;
- }, false);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-pr-ghost-one.png");
- saveMenus (juce::StringArray { "Ghost channels" }, { roll.ghostChannelsMenu() }, prefix + "-ghostmenu.png");
- offline.editSong ([] (lynx::Song& s) {
- for (auto& c : s.channels)
- c.ghostHidden = false;
- }, false);
- // the Mixer at 500 inserts
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- offline.editSong ([] (lynx::Song& s) { lynx::mixerops::insertTracks (s, (int) s.mixer.size(), lynx::mixerops::roomForInserts (s)); }, false);
- const auto t1 = juce::Time::getMillisecondCounterHiRes();
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (3);
- offline.dispatchPendingMessages();
- auto& mixer = ui.getMixerForSnapshot();
- const auto t2 = juce::Time::getMillisecondCounterHiRes();
- saveSnapshot (ui, prefix + "-mixer500-start.png");
- const auto t3 = juce::Time::getMillisecondCounterHiRes();
- mixer.selectTrack ((int) offline.getSong().mixer.size() - 1);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer500-end.png");
- juce::File (prefix + "-mixer500.txt")
- .replaceWithText ("inserts=" + juce::String ((int) offline.getSong().mixer.size() - 1) + "\nfill_ms=" + juce::String (t1 - t0, 2)
- + "\nsnapshot_ms=" + juce::String (t3 - t2, 2) + "\n");
- }
- }
- // Round 190ay, Freeze, end to end with the real engine, files and export (LYNX.exe --freezetest prefix [project]).
- // The project (.lynx / .flp / .als; without one, a small demo song) is rendered live, every channel that can be
- // frozen is frozen, and the same render is made again: the two mixes must null. Written to prefix-report.txt: the
- // null residual, the process memory and the render time before / frozen / unfrozen, what a save holds, whether
- // Unfreeze gives the channels back as they were, the out-of-date and missing-audio states. Shots: the Channel Rack
- // (live, frozen, out of date), the channel menus, the Piano roll of a frozen channel. The frozen audio goes to
- // prefix-data (never next to the project). True = every check passed.
- bool runFreezeTest (const juce::String& prefix, const juce::String& projectPath, const juce::String& mode = {})
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix, &ui] (const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- juce::String report;
- int failures = 0;
- const auto check = [&] (bool ok, const juce::String& what) {
- report << (ok ? "ok " : "FAIL ") << what << "\n";
- failures += ok ? 0 : 1;
- };
- const auto flush = [&] { juce::File (prefix + "-report.txt").replaceWithText (report + "failures=" + juce::String (failures) + "\n"); };
- if (projectPath.isNotEmpty())
- {
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- }
- else
- offline.editSong ([] (lynx::Song& s) {
- s.channels.clear();
- s.patterns.clear();
- s.playlist.clear();
- s.bpm = 120.0;
- const char* names[] = { "Lead", "Bass", "Pad", "Kick" };
- for (int c = 0; c < 4; ++c)
- {
- lynx::ChannelDef d;
- d.name = names[c];
- d.instrument = c == 3 ? lynx::InstrumentKind::kick : lynx::InstrumentKind::synth;
- d.synth.release = 0.3f + 0.3f * (float) c;
- d.synth.cutoff = 1500.0f + 900.0f * (float) c;
- d.mixerTrack = c + 1;
- s.channels.push_back (d);
- }
- for (int p = 0; p < 2; ++p)
- {
- auto& pattern = s.patterns.emplace_back();
- pattern.name = p == 0 ? "Verse" : "Break";
- pattern.lengthTicks = 4 * lynx::ppq * 4;
- for (int c = 0; c < 4; ++c)
- for (int step = 0; step < (p == 0 ? 8 : 2); ++step)
- {
- lynx::Note n;
- n.channel = c;
- n.start = (std::int64_t) step * lynx::ppq * (p == 0 ? 2 : 1) + (c == 2 ? lynx::ppq / 2 : 0);
- n.length = c == 3 ? lynx::ppq / 4 : lynx::ppq;
- n.key = c == 3 ? 36 : 48 + c * 7 + (step * 5) % 12;
- pattern.notes.push_back (n);
- }
- pattern.sortNotes();
- }
- const int order[] = { 0, 0, 1, 0 };
- for (int i = 0; i < 4; ++i)
- {
- lynx::Clip clip;
- clip.pattern = order[i];
- clip.start = (std::int64_t) i * 16 * lynx::ppq;
- clip.length = 16 * lynx::ppq;
- s.playlist.push_back (clip);
- }
- s.mode = lynx::PlayMode::song;
- });
- offline.dispatchPendingMessages();
- // the case Freeze exists for, a heavy hosted plugin: LYNX_FREEZETEST_PLUGIN = a plugin file whose first
- // instrument plays the demo song's Lead (tools/testplugin/lynx_test_heavy_vst3.cpp: memory, CPU, latency, a
- // state, and with LYNX_TEST_HEAVY_LOG the instances alive)
- int hostedChannel = -1;
- const auto hostedLog = juce::SystemStats::getEnvironmentVariable ("LYNX_TEST_HEAVY_LOG", {});
- const auto hostedAlive = [&hostedLog] {
- int alive = 0;
- juce::StringArray lines;
- juce::File (hostedLog).readLines (lines);
- for (const auto& l : lines)
- alive += l.startsWith ("create") ? 1 : l.startsWith ("destroy") ? -1 : 0;
- return alive;
- };
- if (const auto pluginPath = juce::SystemStats::getEnvironmentVariable ("LYNX_FREEZETEST_PLUGIN", {}); pluginPath.isNotEmpty() && projectPath.isEmpty())
- {
- auto& host = offline.getPluginHost();
- const auto added = host.addPluginFile (juce::File (pluginPath));
- report << "hosted plugin file: " << pluginPath << " (" << added << " plugins)\n";
- for (const auto& type : host.getKnownPlugins().getTypes())
- if (type.isInstrument && juce::File (type.fileOrIdentifier).getFileName() == juce::File (pluginPath).getFileName())
- {
- offline.editSong ([&type] (lynx::Song& s) {
- auto& c = s.channels[0];
- c.instrument = lynx::InstrumentKind::plugin;
- c.plugin.id = type.createIdentifierString().toStdString();
- c.plugin.name = type.name.toStdString();
- });
- hostedChannel = 0;
- break;
- }
- offline.dispatchPendingMessages();
- auto* instance = dynamic_cast<lynx::PluginInstrument*> (offline.getChannelInstrument (0).get());
- check (hostedChannel == 0 && instance != nullptr, "the hosted plugin is loaded on channel 1");
- report << "hosted plugin: " << juce::String::fromUTF8 (offline.getSong().channels[0].plugin.name.c_str())
- << ", engine latency " << offline.getLatencySamples() << " frames, instances alive " << hostedAlive() << "\n";
- }
- const auto hostedLine = [&] (const char* stage) {
- if (hostedChannel < 0)
- return;
- offline.freeRetiredRacks();
- report << "hosted, " << stage << ": instance on the channel "
- << (dynamic_cast<lynx::PluginInstrument*> (offline.getChannelInstrument (hostedChannel).get()) != nullptr ? "yes" : "no")
- << ", plugin instances alive in the process " << (hostedLog.isNotEmpty() ? juce::String (hostedAlive()) : juce::String ("(no log)")) << "\n";
- };
- const juce::File data (prefix + "-data");
- data.deleteRecursively();
- offline.setRecordingTarget (data.getChildFile ("Audio").getChildFile ("Recorded"), "freezetest");
- report << "project=" << (projectPath.isNotEmpty() ? projectPath : juce::String ("(demo song)")) << "\n"
- << "frozen_audio_folder=" << offline.getFreezeFolder().getFullPathName() << "\n";
- const auto megabytes = [] (std::int64_t bytes) { return juce::String ((double) bytes / 1048576.0, 1); };
- struct Mix
- {
- juce::AudioBuffer<float> audio;
- double renderSeconds = 0.0, audioSeconds = 0.0;
- std::int64_t workingSet = 0, privateBytes = 0;
- };
- // the song as it stands, rendered by an export (its own engine: frozen channels play their audio there too)
- const auto renderMix = [&] (const char* name, const lynx::Song* other = nullptr, std::vector<int>* renderedLive = nullptr, int range = 0) {
- Mix m;
- offline.dispatchPendingMessages();
- offline.freeRetiredRacks(); // (what the message loop does in the app: this mode runs without one)
- m.workingSet = lynx::toolbar::PerformanceMeter::processMemoryBytes();
- m.privateBytes = lynx::toolbar::PerformanceMeter::processPrivateBytes();
- const juce::File file (prefix + "-" + name + ".wav");
- lynx::ExportSettings settings;
- settings.format = lynx::ExportSettings::Format::wav32Float;
- settings.sampleRate = offline.getTransport().sampleRate.load();
- settings.tailSeconds = 2.0;
- juce::String error;
- {
- auto options = settings.toOptions();
- options.hqAllPlugins = false; // the quality heard while playing: what a frozen channel's audio is made at
- options.disableMaxPolyphony = false; // (and each channel's Max polyphony, as while playing)
- if (range == 1)
- options.range = lynx::exportopts::Range::selection;
- if (range == 2)
- {
- options.range = lynx::exportopts::Range::pattern;
- options.loops = 2;
- }
- lynx::ExportJob job (other != nullptr ? *other : offline.getSong(), options, file);
- if (renderedLive != nullptr)
- *renderedLive = job.channelsRenderedLive();
- const auto started = juce::Time::getMillisecondCounterHiRes();
- const auto ok = job.run ([] (double) { return true; }, error);
- m.renderSeconds = (juce::Time::getMillisecondCounterHiRes() - started) / 1000.0;
- check (ok, juce::String ("render ") + name + (ok ? juce::String() : ": " + error));
- }
- juce::WavAudioFormat wav;
- if (std::unique_ptr<juce::AudioFormatReader> reader { wav.createReaderFor (file.createInputStream().release(), true) })
- {
- m.audio.setSize (2, (int) reader->lengthInSamples);
- reader->read (&m.audio, 0, (int) reader->lengthInSamples, 0, true, true);
- m.audioSeconds = (double) reader->lengthInSamples / reader->sampleRate;
- }
- file.deleteFile();
- return m;
- };
- // the worst sample difference, in dB below the first mix's peak
- const auto residual = [] (const Mix& a, const Mix& b, float& peak) {
- float worst = 0.0f;
- peak = 0.0f;
- const auto n = juce::jmin (a.audio.getNumSamples(), b.audio.getNumSamples());
- for (int ch = 0; ch < 2; ++ch)
- for (int i = 0; i < n; ++i)
- {
- worst = juce::jmax (worst, std::abs (a.audio.getSample (ch, i) - b.audio.getSample (ch, i)));
- peak = juce::jmax (peak, std::abs (a.audio.getSample (ch, i)));
- }
- return worst <= 0.0f ? -200.0 : 20.0 * std::log10 ((double) worst / (double) juce::jmax (peak, 1.0e-12f));
- };
- const auto line = [&] (const char* name, const Mix& m) {
- report << name << ": working set " << megabytes (m.workingSet) << " MB, private " << megabytes (m.privateBytes) << " MB, render "
- << juce::String (m.renderSeconds, 2) << " s for " << juce::String (m.audioSeconds, 2) << " s of audio ("
- << juce::String (m.audioSeconds > 0.0 ? 100.0 * m.renderSeconds / m.audioSeconds : 0.0, 1) << " % of real time)\n";
- };
- if (mode == "measure")
- {
- // a process that only loaded this project and renders it: its memory with the project loaded, and after
- int frozenCount = 0, hosted = 0;
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- {
- frozenCount += offline.getSong().channels[(std::size_t) c].freeze.on();
- hosted += dynamic_cast<lynx::PluginInstrument*> (offline.getChannelInstrument (c).get()) != nullptr;
- }
- report << "channels " << (int) offline.getSong().channels.size() << ", frozen " << frozenCount << ", hosted plugin instances " << hosted << "\n";
- const auto m = renderMix ("measure");
- line ("loaded ", m);
- report << "after the render: working set " << megabytes (lynx::toolbar::PerformanceMeter::processMemoryBytes()) << " MB, private "
- << megabytes (lynx::toolbar::PerformanceMeter::processPrivateBytes()) << " MB\n";
- flush();
- return failures == 0;
- }
- // --- live ---
- offline.capturePluginStates();
- offline.editSong ([] (lynx::Song&) {}, false); // (whatever any edit settles — ids of new objects... — settled first)
- const auto before = offline.getSong();
- // (the project's working-time counter runs on while the test does: not part of what is compared)
- const auto savedJson = [] (lynx::Song song) {
- song.info.workSeconds = 0.0;
- return lynx::ProjectFile::toJson (song, false);
- };
- const auto jsonBefore = savedJson (before);
- std::vector<int> targets;
- for (int c = 0; c < (int) before.channels.size(); ++c)
- {
- const auto* why = lynx::freeze::whyNot (before, c);
- const auto plays = std::any_of (before.patterns.begin(), before.patterns.end(), [c] (const lynx::Pattern& p) {
- return std::any_of (p.notes.begin(), p.notes.end(), [c] (const lynx::Note& n) { return n.channel == c; });
- });
- report << "channel " << (c + 1) << " '" << juce::String::fromUTF8 (before.channels[(std::size_t) c].name.c_str()) << "': "
- << (why != nullptr ? juce::String ("not frozen (") + why + ")" : plays ? juce::String ("freeze") : juce::String ("no notes, left alone")) << "\n";
- if (why == nullptr && plays)
- {
- targets.push_back (c);
- // what could make a stem differ from the live channel, for the record
- const auto& def = before.channels[(std::size_t) c];
- int volPan = 0, params = 0, live = 0, lanes = 0, routes = 0;
- for (const auto& a : before.automations)
- if (a.target.index == c)
- {
- volPan += a.target.kind == lynx::AutomationTargetKind::channelVolume || a.target.kind == lynx::AutomationTargetKind::channelPan;
- params += a.target.kind == lynx::AutomationTargetKind::channelParam;
- live += a.isLive() && (a.target.kind == lynx::AutomationTargetKind::channelVolume || a.target.kind == lynx::AutomationTargetKind::channelPan
- || a.target.kind == lynx::AutomationTargetKind::channelParam);
- }
- for (const auto& p : before.patterns)
- for (const auto& lane : p.events)
- lanes += lane.target.index == c && (lane.target.kind == lynx::AutomationTargetKind::channelVolume
- || lane.target.kind == lynx::AutomationTargetKind::channelPan
- || lane.target.kind == lynx::AutomationTargetKind::channelParam);
- for (const auto& m : before.modulators)
- for (const auto& r : m.routes)
- routes += r.target.index == c && (r.target.kind == lynx::AutomationTargetKind::channelVolume
- || r.target.kind == lynx::AutomationTargetKind::channelPan
- || r.target.kind == lynx::AutomationTargetKind::channelParam);
- report << " instrument kind " << (int) def.instrument << ", insert " << def.mixerTrack << ", automation: volume/pan " << volPan
- << ", parameters " << params << ", live links " << live << ", event lanes " << lanes << ", modulator routes " << routes << "\n";
- }
- }
- check (! targets.empty(), "the project has channels to freeze (" + juce::String ((int) targets.size()) + ")");
- if (targets.empty())
- {
- flush();
- return false;
- }
- const auto first = targets.front();
- offline.setSelectedChannel (first);
- ui.selectTabForSnapshot (0);
- write ("rack-live");
- saveMenus (juce::StringArray { "Channel (live)" }, std::vector<juce::PopupMenu> { ui.getRackForSnapshot().getChannelMenuForSnapshot (first) }, prefix + "-menu-live.png");
- const auto live = renderMix ("live");
- line ("live ", live);
- hostedLine ("live");
- const auto hostedState = hostedChannel >= 0 ? before.channels[(std::size_t) hostedChannel].plugin.state : std::string();
- if (hostedChannel >= 0)
- check (! hostedState.empty(), "the hosted plugin's state is in the project (" + juce::String ((int) hostedState.size()) + " characters)");
- flush();
- // --- frozen ---
- const auto freezeStarted = juce::Time::getMillisecondCounterHiRes();
- for (const auto c : targets)
- {
- const auto error = lynx::freezeChannelNow (offline, c);
- check (error.isEmpty(), "freeze channel " + juce::String (c + 1) + (error.isEmpty() ? juce::String() : ": " + error));
- }
- const auto freezeSeconds = (juce::Time::getMillisecondCounterHiRes() - freezeStarted) / 1000.0;
- offline.dispatchPendingMessages();
- std::int64_t stemBytes = 0;
- int stemFiles = 0;
- bool pluginsGone = true, allFrozen = true;
- for (const auto c : targets)
- {
- const auto& ch = offline.getSong().channels[(std::size_t) c];
- allFrozen = allFrozen && ch.freeze.on() && ! offline.frozenAudioMissing (c) && ! offline.freezeOutOfDate (c);
- for (const auto& stem : ch.freeze.stems)
- {
- stemBytes += juce::File (juce::String::fromUTF8 (stem.path.c_str())).getSize();
- ++stemFiles;
- }
- pluginsGone = pluginsGone && dynamic_cast<lynx::PluginInstrument*> (offline.getChannelInstrument (c).get()) == nullptr;
- auto thawed = ch;
- thawed.freeze = {};
- check (thawed == before.channels[(std::size_t) c], "channel " + juce::String (c + 1) + " keeps its instrument and settings as they were while frozen");
- }
- check (allFrozen, "every target is frozen, its audio on disk and up to date");
- check (pluginsGone, "no hosted plugin instance is left on a frozen channel");
- report << "freeze: " << juce::String (freezeSeconds, 2) << " s for " << (int) targets.size() << " channels, " << stemFiles << " files, "
- << megabytes (stemBytes) << " MB on disk\n";
- if (mode == "keep")
- {
- juce::String error;
- check (lynx::ProjectFile::save (offline.getSong(), juce::File (prefix + "-frozen.lynx"), error), "the frozen project is saved" + (error.isEmpty() ? juce::String() : ": " + error));
- flush();
- return failures == 0;
- }
- const auto frozen = renderMix ("frozen");
- line ("frozen ", frozen);
- hostedLine ("frozen");
- if (hostedChannel >= 0 && hostedLog.isNotEmpty())
- check (hostedAlive() == 0, "while frozen no instance of the hosted plugin is alive in the process");
- float peak = 0.0f;
- const auto nullFrozen = residual (live, frozen, peak);
- report << "null frozen vs live: " << juce::String (nullFrozen, 1) << " dB (peak " << juce::String (peak, 4) << ", "
- << live.audio.getNumSamples() << " / " << frozen.audio.getNumSamples() << " samples)\n";
- check (peak > 0.001f && nullFrozen < -90.0 && live.audio.getNumSamples() == frozen.audio.getNumSamples(), "the frozen mix nulls against the live mix (below -90 dB)");
- ui.selectTabForSnapshot (0);
- ui.setHintForSnapshot (ui.getRackForSnapshot().getChannelHintForSnapshot (first));
- write ("rack-frozen");
- saveMenus (juce::StringArray { "Channel (frozen)" }, std::vector<juce::PopupMenu> { ui.getRackForSnapshot().getChannelMenuForSnapshot (first) }, prefix + "-menu-frozen.png");
- report << "hint frozen: " << ui.getRackForSnapshot().getChannelHintForSnapshot (first).text << "\n";
- offline.setSelectedChannel (first);
- ui.selectTabForSnapshot (1);
- offline.setSelectedChannel (first);
- offline.dispatchPendingMessages();
- ui.setHintForSnapshot ({ lynx::tr ("{0} is frozen: Unfreeze to edit ([RMB] on the channel, Unfreeze)",
- { juce::String::fromUTF8 (offline.getSong().channels[(std::size_t) first].name.c_str()) }), {} });
- write ("pianoroll-frozen");
- // --- exports that do not play the song's timeline once: a selection, one pattern twice ---
- // (the frozen audio is the whole song from its start: those renders play the instruments, never a wrong part of it)
- if (projectPath.isEmpty())
- {
- auto part = offline.getSong();
- part.loopStart = 16 * lynx::ppq;
- part.loopEnd = 40 * lynx::ppq;
- const auto partLive = lynx::freeze::thawed (part);
- for (int range = 1; range <= 2; ++range)
- {
- std::vector<int> renderedLive;
- const auto a = renderMix (range == 1 ? "selection-live" : "pattern-live", &partLive, nullptr, range);
- const auto b = renderMix (range == 1 ? "selection-frozen" : "pattern-frozen", &part, &renderedLive, range);
- float partPeak = 0.0f;
- const auto null = residual (a, b, partPeak);
- report << (range == 1 ? "export of a selection (bars 5-10)" : "export of the current pattern, twice") << ", frozen vs live: " << juce::String (null, 1)
- << " dB (peak " << juce::String (partPeak, 4) << ", " << juce::String (b.audioSeconds, 2) << " s), channels rendered live: " << (int) renderedLive.size() << "\n";
- check (partPeak > 0.001f && null < -90.0 && a.audio.getNumSamples() == b.audio.getNumSamples(),
- range == 1 ? "an export of a selection of a frozen project is the selection" : "an export of one pattern of a frozen project is that pattern");
- }
- }
- // --- what a save holds ---
- {
- const auto json = lynx::ProjectFile::toJson (offline.getSong(), false);
- juce::String error;
- const auto loaded = lynx::ProjectFile::fromJson (json, error);
- check (json.contains ("\"freeze\""), "the saved project holds the frozen state");
- check (loaded.has_value() && loaded->channels.size() == offline.getSong().channels.size()
- && loaded->channels[(std::size_t) first].freeze == offline.getSong().channels[(std::size_t) first].freeze,
- "a frozen project loads frozen, with the same audio files");
- check (savedJson (lynx::freeze::thawed (offline.getSong())) == jsonBefore,
- "without the frozen state the saved project is byte for byte what it was before the freeze");
- check (! jsonBefore.contains ("\"freeze\""), "a project with nothing frozen has no freeze field");
- }
- // --- out of date: the tempo, a note of the frozen channel; not another channel's notes ---
- {
- offline.editSong ([] (lynx::Song& s) { s.bpm += 4.0; });
- check (offline.freezeOutOfDate (first), "a tempo change marks the freeze out of date");
- ui.selectTabForSnapshot (0);
- ui.setHintForSnapshot (ui.getRackForSnapshot().getChannelHintForSnapshot (first));
- write ("rack-out-of-date");
- report << "hint out of date: " << ui.getRackForSnapshot().getChannelHintForSnapshot (first).text << "\n";
- offline.editSong ([] (lynx::Song& s) { s.bpm -= 4.0; });
- check (! offline.freezeOutOfDate (first), "the tempo back: up to date again");
- int pattern = -1;
- for (int p = 0; p < (int) before.patterns.size() && pattern < 0; ++p)
- for (const auto& n : before.patterns[(std::size_t) p].notes)
- if (n.channel == first)
- {
- pattern = p;
- break;
- }
- if (pattern >= 0)
- {
- offline.editSong ([pattern, first] (lynx::Song& s) {
- lynx::Note n;
- n.channel = first;
- n.start = 0;
- n.key = 71;
- s.patterns[(std::size_t) pattern].notes.push_back (n);
- s.patterns[(std::size_t) pattern].sortNotes();
- });
- check (offline.freezeOutOfDate (first), "a note edit on the frozen channel marks it out of date");
- bool othersFresh = true;
- for (const auto c : targets)
- othersFresh = othersFresh && (c == first || ! offline.freezeOutOfDate (c));
- check (othersFresh, "the other frozen channels stay up to date");
- // an export of the project in that state: the out-of-date channel renders live (never the old audio),
- // the others keep their frozen audio — the same mix as the edited project with nothing frozen
- {
- std::vector<int> renderedLive;
- const auto stale = renderMix ("stale", nullptr, &renderedLive);
- const auto edited = lynx::freeze::thawed (offline.getSong());
- const auto reference = renderMix ("stale-reference", &edited);
- float stalePeak = 0.0f;
- const auto nullStale = residual (reference, stale, stalePeak);
- const auto nullOld = residual (frozen, stale, stalePeak);
- report << "export with channel " << (first + 1) << " out of date: " << juce::String (nullStale, 1) << " dB vs the edited project live, "
- << juce::String (nullOld, 1) << " dB vs the old frozen mix; channels rendered live: " << (int) renderedLive.size() << "\n";
- check (renderedLive == std::vector<int> { first }, "an export renders the out-of-date frozen channel live, and only that one");
- check (nullStale < -90.0 && nullOld > -60.0, "an export of an out-of-date freeze holds the edited notes, not the old audio");
- }
- offline.editSong ([&before] (lynx::Song& s) { s.patterns = before.patterns; });
- check (! offline.freezeOutOfDate (first), "the notes back: up to date again");
- }
- }
- // --- the audio gone: the instrument plays, never silence ---
- {
- const auto stems = offline.getSong().channels[(std::size_t) first].freeze.stems;
- std::vector<std::pair<juce::File, juce::File>> moved;
- for (const auto& stem : stems)
- {
- const juce::File file (juce::String::fromUTF8 (stem.path.c_str()));
- const auto away = file.getSiblingFile (file.getFileName() + ".away");
- if (file.moveFileTo (away))
- moved.emplace_back (file, away);
- }
- offline.editSong ([] (lynx::Song&) {}, false);
- check (offline.frozenAudioMissing (first), "frozen audio that is not on disk is noticed");
- report << "hint audio missing: " << ui.getRackForSnapshot().getChannelHintForSnapshot (first).text << "\n";
- const auto fallback = renderMix ("missing");
- const auto nullMissing = residual (live, fallback, peak);
- report << "null with the first channel's audio missing vs live: " << juce::String (nullMissing, 1) << " dB\n";
- check (nullMissing < -90.0, "with its audio missing the channel plays its instrument");
- for (const auto& [file, away] : moved)
- away.moveFileTo (file);
- offline.editSong ([] (lynx::Song&) {}, false);
- check (! offline.frozenAudioMissing (first), "the audio back: frozen again");
- // the frozen mix did not null and the first channel is not (alone) why: which one is, each thawed in turn
- if (nullFrozen >= -90.0 && nullMissing >= -90.0)
- for (const auto c : targets)
- {
- if (c == first)
- continue;
- std::vector<std::pair<juce::File, juce::File>> aside;
- for (const auto& stem : offline.getSong().channels[(std::size_t) c].freeze.stems)
- {
- const juce::File file (juce::String::fromUTF8 (stem.path.c_str()));
- const auto away = file.getSiblingFile (file.getFileName() + ".away");
- if (file.moveFileTo (away))
- aside.emplace_back (file, away);
- }
- offline.editSong ([] (lynx::Song&) {}, false);
- const auto one = renderMix ("thawed");
- report << "null with channel " << (c + 1) << " thawed vs live: " << juce::String (residual (live, one, peak), 1) << " dB\n";
- for (const auto& [file, away] : aside)
- away.moveFileTo (file);
- offline.editSong ([] (lynx::Song&) {}, false);
- }
- }
- // --- unfrozen ---
- std::vector<juce::File> stemPaths;
- for (const auto c : targets)
- for (const auto& stem : offline.getSong().channels[(std::size_t) c].freeze.stems)
- stemPaths.emplace_back (juce::String::fromUTF8 (stem.path.c_str()));
- for (const auto c : targets)
- lynx::unfreezeChannel (offline, c);
- offline.dispatchPendingMessages();
- check (offline.getSong().channels == before.channels, "Unfreeze gives every channel back exactly as it was (instrument, plugin state, settings)");
- {
- const auto jsonAfter = savedJson (offline.getSong());
- check (jsonAfter == jsonBefore, "the unfrozen project saves byte for byte as before the freeze");
- if (jsonAfter != jsonBefore)
- {
- juce::File (prefix + "-before.json").replaceWithText (jsonBefore);
- juce::File (prefix + "-after.json").replaceWithText (jsonAfter);
- }
- }
- int left = 0;
- for (const auto& f : stemPaths)
- left += f.existsAsFile() ? 1 : 0;
- check (left == 0, "Unfreeze deletes the frozen audio (" + juce::String (left) + " of " + juce::String ((int) stemPaths.size()) + " files left)");
- if (hostedChannel >= 0)
- {
- // the new instance (it starts with another tuning than the first one had) took the saved state
- offline.capturePluginStates();
- check (dynamic_cast<lynx::PluginInstrument*> (offline.getChannelInstrument (hostedChannel).get()) != nullptr, "Unfreeze loads the hosted plugin again");
- check (offline.getSong().channels[(std::size_t) hostedChannel].plugin.state == hostedState,
- "the hosted plugin's state, read back from the new instance, is the state it had before the freeze");
- }
- const auto unfrozen = renderMix ("unfrozen");
- line ("unfrozen ", unfrozen);
- hostedLine ("unfrozen");
- const auto nullUnfrozen = residual (live, unfrozen, peak);
- report << "null unfrozen vs live: " << juce::String (nullUnfrozen, 1) << " dB\n";
- check (nullUnfrozen < -90.0, "the unfrozen mix nulls against the live mix");
- ui.selectTabForSnapshot (0);
- flush();
- data.deleteRecursively();
- return failures == 0;
- }
- // Round 190ff, the Clip-launch workflow's track commands end to end with the real engine, files and export
- // (LYNX --trackfreezetest prefix). A demo song of three tracks (Lead through a delay and a reverb whose mix is
- // automated, Bass through a delay, Drums on a bare insert; each insert's fader, pan and EQ set) is rendered live; then
- // Freeze Track on every track (the instrument with its volume and pan through its insert's effects), the same render
- // again (must null), the effects and instruments unloaded, the render time (the CPU while frozen), what a save holds;
- // Flatten (Bounce Track in Place on a frozen track) with its undo; Bounce Track in Place of a live track; Bounce to New
- // Track of a track's clips against that track's device output; Consolidate of pattern clips; Unfreeze. Written to
- // prefix-report.txt; shots of the grid, the column menus, the Detail View's frozen devices and the Playlist's clip
- // menu. True = every check passed.
- bool runTrackFreezeTest (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix, &ui] (const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- juce::String report;
- int failures = 0;
- const auto check = [&] (bool ok, const juce::String& what) {
- report << (ok ? "ok " : "FAIL ") << what << "\n";
- failures += ok ? 0 : 1;
- };
- const auto flush = [&] { juce::File (prefix + "-report.txt").replaceWithText (report + "failures=" + juce::String (failures) + "\n"); };
- const juce::File data (prefix + "-data");
- data.deleteRecursively();
- offline.setRecordingTarget (data.getChildFile ("Audio").getChildFile ("Recorded"), "trackfreezetest");
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.setClipLaunchWorkflow (true);
- offline.editSong ([] (lynx::Song& s) {
- s.channels.clear();
- s.patterns.clear();
- s.playlist.clear();
- s.automations.clear();
- s.bpm = 120.0;
- s.mode = lynx::PlayMode::song;
- const char* names[] = { "Lead", "Bass", "Drums" };
- for (int c = 0; c < 3; ++c)
- {
- lynx::ChannelDef d;
- d.name = names[c];
- d.instrument = c == 2 ? lynx::InstrumentKind::kick : lynx::InstrumentKind::synth;
- d.synth.release = c == 0 ? 0.6f : 0.2f;
- d.synth.cutoff = c == 0 ? 2400.0f : 900.0f;
- d.volume = c == 0 ? 0.65f : 0.78f;
- d.pan = c == 0 ? 0.25f : 0.0f;
- d.mixerTrack = c + 1;
- s.channels.push_back (d);
- }
- if (s.mixer.size() < 5)
- s.mixer.resize (5);
- s.mixer[1].effects = { lynx::makeEffectSlot (lynx::EffectKind::delay), lynx::makeEffectSlot (lynx::EffectKind::reverb) };
- s.mixer[2].effects = { lynx::makeEffectSlot (lynx::EffectKind::delay) };
- s.mixer[3].effects.clear();
- for (int t = 1; t <= 3; ++t)
- {
- s.mixer[(std::size_t) t].name = names[t - 1];
- s.mixer[(std::size_t) t].volume = 0.7f;
- s.mixer[(std::size_t) t].pan = t == 1 ? -0.3f : 0.1f;
- s.mixer[(std::size_t) t].eq.gainDb[1] = 3.0f;
- }
- for (int p = 0; p < 3; ++p)
- {
- auto& pattern = s.patterns.emplace_back();
- pattern.name = names[p];
- pattern.lengthTicks = 4 * lynx::ppq * 2;
- for (int step = 0; step < 8; ++step)
- {
- lynx::Note n;
- n.channel = p;
- n.start = (std::int64_t) step * lynx::ppq;
- n.length = p == 2 ? lynx::ppq / 4 : lynx::ppq / 2;
- n.key = p == 2 ? 36 : (p == 0 ? 60 : 36) + (step * 5) % 12;
- pattern.notes.push_back (n);
- }
- }
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 4));
- for (int t = 0; t < 3; ++t)
- {
- s.playlistTracks[(std::size_t) t].name = names[t];
- for (int k = 0; k < 3; ++k)
- {
- if (t == 0 && k == 1)
- continue; // (a gap in the Lead: its tail rings into it)
- lynx::Clip clip;
- clip.pattern = t;
- clip.track = t;
- clip.start = (std::int64_t) k * 8 * lynx::ppq;
- clip.length = 8 * lynx::ppq;
- s.playlist.push_back (clip);
- }
- }
- // the Lead's reverb mix rises over the song (automation the freeze takes into its audio)
- lynx::Automation a;
- a.name = "Lead reverb mix";
- a.target = { lynx::AutomationTargetKind::effectMix, 1, 1, 0 };
- a.points = { { 0, 0.2f }, { 24 * lynx::ppq, 0.9f } };
- s.automations.push_back (a);
- lynx::Clip lane;
- lane.kind = lynx::ClipKind::automation;
- lane.automation = 0;
- lane.track = 3;
- lane.length = 24 * lynx::ppq;
- s.playlist.push_back (lane);
- std::stable_sort (s.playlist.begin(), s.playlist.end(), [] (const lynx::Clip& x, const lynx::Clip& y) { return x.start < y.start; });
- });
- offline.dispatchPendingMessages();
- const auto megabytes = [] (std::int64_t bytes) { return juce::String ((double) bytes / 1048576.0, 1); };
- struct Mix
- {
- juce::AudioBuffer<float> audio;
- double renderSeconds = 0.0, audioSeconds = 0.0;
- };
- const auto renderMix = [&] (const char* name, const lynx::Song* other = nullptr) {
- Mix m;
- offline.dispatchPendingMessages();
- offline.freeRetiredRacks();
- const juce::File file (prefix + "-" + name + ".wav");
- lynx::ExportSettings settings;
- settings.format = lynx::ExportSettings::Format::wav32Float;
- settings.sampleRate = offline.getTransport().sampleRate.load();
- settings.tailSeconds = 2.0;
- juce::String error;
- auto options = settings.toOptions();
- options.hqAllPlugins = false;
- options.disableMaxPolyphony = false;
- {
- lynx::ExportJob job (other != nullptr ? *other : offline.getSong(), options, file);
- const auto started = juce::Time::getMillisecondCounterHiRes();
- const auto ok = job.run ([] (double) { return true; }, error);
- m.renderSeconds = (juce::Time::getMillisecondCounterHiRes() - started) / 1000.0;
- check (ok, juce::String ("render ") + name + (ok ? juce::String() : ": " + error));
- }
- juce::WavAudioFormat wav;
- if (std::unique_ptr<juce::AudioFormatReader> reader { wav.createReaderFor (file.createInputStream().release(), true) })
- {
- m.audio.setSize (2, (int) reader->lengthInSamples);
- reader->read (&m.audio, 0, (int) reader->lengthInSamples, 0, true, true);
- m.audioSeconds = (double) reader->lengthInSamples / reader->sampleRate;
- }
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_TRACKFREEZE_KEEP", {}).isEmpty()) // (kept: to look at a residual)
- file.deleteFile();
- return m;
- };
- const auto residual = [] (const Mix& a, const Mix& b, float& peak) {
- float worst = 0.0f;
- peak = 0.0f;
- const auto n = juce::jmin (a.audio.getNumSamples(), b.audio.getNumSamples());
- for (int ch = 0; ch < 2; ++ch)
- for (int i = 0; i < n; ++i)
- {
- worst = juce::jmax (worst, std::abs (a.audio.getSample (ch, i) - b.audio.getSample (ch, i)));
- peak = juce::jmax (peak, std::abs (a.audio.getSample (ch, i)));
- }
- return worst <= 0.0f ? -200.0 : 20.0 * std::log10 ((double) worst / (double) juce::jmax (peak, 1.0e-12f));
- };
- const auto nullLine = [&] (const char* what, const Mix& a, const Mix& b, double limit) {
- float peak = 0.0f;
- const auto r = residual (a, b, peak);
- report << what << ": " << juce::String (r, 1) << " dB (peak " << juce::String (peak, 4) << ", " << a.audio.getNumSamples() << " / "
- << b.audio.getNumSamples() << " samples)\n";
- check (peak > 0.001f && r < limit && a.audio.getNumSamples() == b.audio.getNumSamples(), juce::String (what) + " below " + juce::String (limit, 0) + " dB");
- return r;
- };
- const auto savedJson = [] (lynx::Song song) {
- song.info.workSeconds = 0.0;
- return lynx::ProjectFile::toJson (song, false);
- };
- // --- live ---
- offline.capturePluginStates();
- offline.editSong ([] (lynx::Song&) {}, false);
- const auto before = offline.getSong();
- const auto jsonBefore = savedJson (before);
- auto* grid = ui.getClipGridForSnapshot();
- check (grid != nullptr, "the Clip-launch workflow's grid is there");
- if (grid == nullptr)
- {
- flush();
- return false;
- }
- ui.setClipGridView (lynx::PlaylistArea::GridView::beside);
- write ("live");
- saveMenus (juce::StringArray { "Track title (live)" }, std::vector<juce::PopupMenu> { lynx::clipGridHeaderMenu (*grid, 0) }, prefix + "-menu-track-live.png");
- int leadClip = -1;
- for (int i = 0; i < (int) before.playlist.size() && leadClip < 0; ++i)
- if (before.playlist[(std::size_t) i].track == 0 && before.playlist[(std::size_t) i].kind == lynx::ClipKind::pattern)
- leadClip = i;
- ui.getPlaylistForSnapshot().selectForSnapshot ({ leadClip });
- saveMenus (juce::StringArray { "Playlist clip (Clip-launch workflow)" }, std::vector<juce::PopupMenu> { ui.getPlaylistForSnapshot().getClipMenuForSnapshot (leadClip) },
- prefix + "-menu-clip.png");
- const auto live = renderMix ("live");
- report << "live: render " << juce::String (live.renderSeconds, 2) << " s for " << juce::String (live.audioSeconds, 2) << " s of audio\n";
- // --- Freeze Track on every track ---
- std::vector<int> channels;
- for (int t = 0; t < 3; ++t)
- {
- const auto c = lynx::detailchain::forTrack (before, t).channel;
- check (c == t, "track " + juce::String (t + 1) + " shows channel " + juce::String (t + 1));
- const auto* why = lynx::freeze::whyNotTrack (before, c);
- check (why == nullptr, "track " + juce::String (t + 1) + " can be frozen" + (why != nullptr ? juce::String (": ") + why : juce::String()));
- const auto error = lynx::freezeTrackNow (offline, c);
- check (error.isEmpty(), "Freeze Track " + juce::String (t + 1) + (error.isEmpty() ? juce::String() : ": " + error));
- channels.push_back (c);
- }
- offline.dispatchPendingMessages();
- offline.freeRetiredRacks();
- int loadedEffects = 0;
- for (int t = 1; t <= 3; ++t)
- for (int slot = 0; slot < (int) offline.getSong().mixer[(std::size_t) t].effects.size(); ++slot)
- loadedEffects += offline.getEffect (t, slot) != nullptr ? 1 : 0;
- check (loadedEffects == 0, "no effect of a frozen track is loaded (" + juce::String (loadedEffects) + " left)");
- bool fresh = true;
- for (const auto c : channels)
- {
- const auto& f = offline.getSong().channels[(std::size_t) c].freeze;
- fresh = fresh && f.on() && f.insert == c + 1 && lynx::freeze::trackFreezeHolds (offline.getSong(), c) && ! offline.freezeOutOfDate (c)
- && ! offline.frozenAudioMissing (c);
- }
- check (fresh, "every track is frozen with its insert, its audio on disk and up to date");
- check (offline.getSong().mixer == before.mixer, "the project keeps every effect as it was (Unfreeze brings them back)");
- const auto frozenSong = offline.getSong();
- const auto frozen = renderMix ("frozen");
- report << "frozen: render " << juce::String (frozen.renderSeconds, 2) << " s (" << juce::String (100.0 * frozen.renderSeconds / juce::jmax (0.001, live.renderSeconds), 0)
- << " % of the live render's time)\n";
- nullLine ("frozen vs live", live, frozen, -90.0);
- write ("frozen");
- saveMenus (juce::StringArray { "Track title (frozen)" }, std::vector<juce::PopupMenu> { lynx::clipGridHeaderMenu (*grid, 0) }, prefix + "-menu-track-frozen.png");
- if (auto* detail = ui.getDetailViewForSnapshot())
- {
- detail->showSelection (0, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- write ("detail-frozen");
- }
- // the insert's fader is live: moved, the frozen and the live song change alike
- {
- auto liveLouder = before, frozenLouder = frozenSong;
- liveLouder.mixer[1].volume = frozenLouder.mixer[1].volume = 0.8f;
- nullLine ("frozen vs live, the Lead's fader moved afterwards", renderMix ("live-louder", &liveLouder), renderMix ("frozen-louder", &frozenLouder), -90.0);
- }
- // --- what a save holds ---
- {
- const auto json = lynx::ProjectFile::toJson (offline.getSong(), false);
- juce::String error;
- const auto loaded = lynx::ProjectFile::fromJson (json, error);
- check (json.contains ("\"trackFreeze\"") && ! json.contains ("\"freeze\""), "a track freeze is saved under its own key (older versions play it live)");
- check (loaded.has_value() && loaded->channels.size() == frozenSong.channels.size() && loaded->channels[0].freeze == frozenSong.channels[0].freeze,
- "a track-frozen project loads frozen, with its insert and audio files");
- check (savedJson (lynx::freeze::thawed (offline.getSong())) == jsonBefore, "without the frozen state the project saves as before the freeze");
- }
- // --- an edit of a frozen device's insert routing: the freeze stops holding, the track plays live ---
- {
- offline.editSong ([] (lynx::Song& s) { s.channels[1].mixerTrack = 1; }); // (the Bass into the Lead's insert)
- check (! lynx::freeze::trackFreezeHolds (offline.getSong(), 0) && offline.freezeOutOfDate (0), "another channel routed into a frozen insert: out of date, plays live");
- offline.undo();
- offline.dispatchPendingMessages();
- check (lynx::freeze::trackFreezeHolds (offline.getSong(), 0) && ! offline.freezeOutOfDate (0), "undo: frozen again");
- }
- // --- Flatten: Bounce Track in Place on the frozen Lead, and its undo ---
- {
- const auto error = lynx::flattenChannelNow (offline, 0);
- check (error.isEmpty(), "Bounce Track in Place of the frozen Lead (Flatten)" + (error.isEmpty() ? juce::String() : ": " + error));
- const auto& song = offline.getSong();
- check (song.channels[0].instrument == lynx::InstrumentKind::audioClip && song.mixer[1].effects.empty() && song.mixer[1].volume == before.mixer[1].volume
- && song.channels[0].name == "Lead (Bounce)",
- "the Lead is audio now (\"Lead (Bounce)\"), its insert's effects removed, its fader kept");
- int audioClips = 0;
- for (const auto& c : song.playlist)
- audioClips += c.kind == lynx::ClipKind::audio && c.channel == 0;
- report << "flattened Lead: " << audioClips << " audio clips\n";
- write ("flattened");
- // over the song (the flattened clips end where the arrangement ends, as a frozen track plays; an export's
- // ring-out after the song's end is not in them)
- const auto span = (int) std::llround (before.secondsForTicks (24 * lynx::ppq) * offline.getTransport().sampleRate.load());
- auto flatMix = renderMix ("flattened");
- auto reference = live;
- reference.audio.setSize (2, juce::jmin (span, reference.audio.getNumSamples()), true);
- flatMix.audio.setSize (2, reference.audio.getNumSamples(), true);
- nullLine ("flattened (Lead) + frozen (others) vs live, over the song", reference, flatMix, -90.0);
- offline.undo();
- offline.dispatchPendingMessages();
- check (savedJson (offline.getSong()) == savedJson (frozenSong), "undo of the Flatten: the frozen project exactly as before");
- }
- // --- Unfreeze every track ---
- for (const auto c : channels)
- lynx::unfreezeChannel (offline, c);
- offline.dispatchPendingMessages();
- check (savedJson (offline.getSong()) == jsonBefore, "Unfreeze: the project saves byte for byte as before the freeze");
- nullLine ("unfrozen vs live", live, renderMix ("unfrozen"), -90.0);
- // --- Bounce Track in Place of a live track (render and flatten in one step, one undo) ---
- {
- const auto error = lynx::freezeTrackNow (offline, 1, true);
- check (error.isEmpty(), "Bounce Track in Place of the live Bass" + (error.isEmpty() ? juce::String() : ": " + error));
- check (offline.getSong().channels[1].instrument == lynx::InstrumentKind::audioClip && ! offline.getSong().channels[1].freeze.on(),
- "the Bass is audio, not frozen");
- auto bouncedMix = renderMix ("bounced");
- auto reference = live;
- const auto span = (int) std::llround (before.secondsForTicks (24 * lynx::ppq) * offline.getTransport().sampleRate.load());
- reference.audio.setSize (2, juce::jmin (span, reference.audio.getNumSamples()), true);
- bouncedMix.audio.setSize (2, reference.audio.getNumSamples(), true);
- nullLine ("Bass bounced in place vs live, over the song", reference, bouncedMix, -90.0);
- offline.undo();
- offline.dispatchPendingMessages();
- check (savedJson (offline.getSong()) == jsonBefore, "undo of Bounce Track in Place: the project as before");
- }
- // --- Bounce to New Track: the Lead's clips onto a new track (the clips muted, the new track with the Lead's mixer) ---
- {
- std::vector<int> leadClips;
- for (int i = 0; i < (int) offline.getSong().playlist.size(); ++i)
- if (offline.getSong().playlist[(std::size_t) i].track == 0 && offline.getSong().playlist[(std::size_t) i].kind == lynx::ClipKind::pattern)
- leadClips.push_back (i);
- const auto channelsBefore = offline.getSong().channels.size();
- const auto error = lynx::bounceToNewTrack (offline, leadClips, true);
- check (error.isEmpty(), "Bounce to New Track of the Lead's clips" + (error.isEmpty() ? juce::String() : ": " + error));
- const auto& song = offline.getSong();
- check (song.channels.size() == channelsBefore + 1 && song.channels.back().instrument == lynx::InstrumentKind::audioClip
- && song.channels.back().mixerTrack > 3 && song.mixer[(std::size_t) song.channels.back().mixerTrack].volume == before.mixer[1].volume,
- "a new audio channel holds the bounce, on an insert with the Lead's mixer");
- // the song's span (the bounce stops at the last clip's end, the live render rings on after it)
- auto bounced = renderMix ("bounced-new-track");
- auto reference = live;
- const auto span = (int) std::llround (before.secondsForTicks (24 * lynx::ppq) * offline.getTransport().sampleRate.load());
- reference.audio.setSize (2, juce::jmin (span, reference.audio.getNumSamples()), true);
- bounced.audio.setSize (2, reference.audio.getNumSamples(), true);
- nullLine ("Bounce to New Track (Lead's clips muted) vs live, over the song", reference, bounced, -90.0);
- write ("bounced-new-track");
- offline.undo();
- offline.dispatchPendingMessages();
- check (savedJson (offline.getSong()) == jsonBefore, "undo of Bounce to New Track: the project as before");
- }
- // --- Consolidate: the Bass's three pattern clips become one ---
- {
- std::vector<int> bassClips;
- for (int i = 0; i < (int) offline.getSong().playlist.size(); ++i)
- if (offline.getSong().playlist[(std::size_t) i].track == 1 && offline.getSong().playlist[(std::size_t) i].kind == lynx::ClipKind::pattern)
- bassClips.push_back (i);
- const auto error = lynx::consolidateClips (offline, bassClips, true);
- check (error.isEmpty(), "Consolidate of the Bass's clips" + (error.isEmpty() ? juce::String() : ": " + error));
- int left = 0;
- for (const auto& c : offline.getSong().playlist)
- left += c.track == 1 && c.kind == lynx::ClipKind::pattern;
- check (left == 1, "one clip on the Bass track (" + juce::String (left) + ")");
- nullLine ("consolidated vs live", live, renderMix ("consolidated"), -90.0);
- offline.undo();
- offline.dispatchPendingMessages();
- check (savedJson (offline.getSong()) == jsonBefore, "undo of Consolidate: the project as before");
- }
- report << "frozen audio folder: " << offline.getFreezeFolder().getFullPathName() << "\n";
- flush();
- data.deleteRecursively();
- (void) megabytes;
- return failures == 0;
- }
- // --paintbench (round 190ge): the paint cost of every main view, off screen. Each view is shown maximised in a
- // LYNX_SNAPSHOT_SIZE window (default 1920x1080) and drawn whole into a picture `frames` times (after a repaint of
- // all of it, so no cached picture is reused: the cost of a frame after an edit), then `frames` times without the
- // repaint (what a view's own caches leave of a frame). The report gives the median and the 90th percentile of
- // the message thread's CPU per frame.
- void runPaintBench (const juce::File& project, const juce::File& report)
- {
- // LYNX_PROFILE_MAIN=<file> (round 190gr): the message thread sampled while it paints (Windows; one view at a time
- // with LYNX_PAINTBENCH_VIEWS)
- const auto profile = juce::SystemStats::getEnvironmentVariable ("LYNX_PROFILE_MAIN", {});
- if (profile.isNotEmpty())
- lynx::crashguard::startMainProfiler (profile.toStdString(), 1000, 2);
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1920x1080"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- juce::String text;
- text << "project: " << project.getFullPathName() << "\nLYNX " << getApplicationVersion() << ", " << juce::SystemStats::getCpuModel()
- << ", window " << ui.getWidth() << "x" << ui.getHeight() << "\n";
- // LYNX_PAINTBENCH_MIXER_EXTRAS=0|1 (rollup 0.1.32 step 2): round 190qh's peak values and correlation bars off / on
- // (on by default since 0.1.32), for an A/B of their paint cost
- if (const auto extras = juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_MIXER_EXTRAS", {}); extras.isNotEmpty())
- {
- if (lynx::mixeroptions::setShowPeakValues && lynx::mixeroptions::setShowCorrelation)
- {
- lynx::mixeroptions::setShowPeakValues (extras.getIntValue() != 0);
- lynx::mixeroptions::setShowCorrelation (extras.getIntValue() != 0);
- }
- text << "mixer peak values / correlation " << (extras.getIntValue() != 0 ? "on" : "off") << " (LYNX_PAINTBENCH_MIXER_EXTRAS)\n";
- }
- if (project.existsAsFile())
- {
- // (round perfgate190id) the time to open it headless, and the memory after
- const auto open0 = juce::Time::getMillisecondCounterHiRes();
- const auto cpu0 = lynx::threadCpuSeconds();
- ui.openFile (project);
- offline.dispatchPendingMessages();
- text << "open: " << juce::String (juce::Time::getMillisecondCounterHiRes() - open0, 1) << " ms wall, "
- << juce::String (1000.0 * (lynx::threadCpuSeconds() - cpu0), 1) << " ms message thread CPU, working set "
- << juce::String ((double) lynx::toolbar::PerformanceMeter::processMemoryBytes() / 1048576.0, 0) << " MB\n";
- }
- // LYNX_PAINTBENCH_ROW=<px> (round 190oo): the Playlist's row height after the open, so a build whose .flp import
- // reads FL's own row height (PAT-6: Thief at 26 px) can be compared with one at 48 px for the same drawing
- if (const auto row = juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_ROW", {}).getIntValue(); row > 0)
- {
- offline.editSong ([row] (lynx::Song& s) { s.playlistRowHeight = row; }, false);
- offline.dispatchPendingMessages();
- text << "playlist rows forced to " << row << " px (LYNX_PAINTBENCH_ROW)\n";
- }
- // LYNX_PAINTBENCH_KEYS=0|1|2 (round 190oo): the Piano roll's keyboard style (flat, lined piano keys, FL's keys)
- if (const auto keys = juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_KEYS", {}); keys.isNotEmpty())
- {
- lynx::PianoRollComponent::keyStyle = lynx::pianokeys::styleFromInt (keys.getIntValue());
- text << "keyboard style " << keys.getIntValue() << " (LYNX_PAINTBENCH_KEYS)\n";
- }
- const auto& song = offline.getSong();
- text << "channels " << (int) song.channels.size() << ", patterns " << (int) song.patterns.size() << ", playlist clips " << (int) song.playlist.size()
- << ", inserts " << (int) song.mixer.size() << "\n";
- // the playhead a third into the song (song mode) so the views draw it as when playing
- offline.getTransport().songMode = true;
- offline.getTransport().positionTicks.store ((double) song.songLength() / 3.0);
- const auto frames = juce::jlimit (3, 500, juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_FRAMES", "40").getIntValue());
- juce::Image image (juce::Image::ARGB, ui.getWidth(), ui.getHeight(), true);
- {
- // (round 190gr) which renderer draws the frames: the software one (Linux), Direct2D (Windows), Core Graphics
- juce::Graphics g (image);
- auto& context = g.getInternalContext();
- text << "renderer: " << (dynamic_cast<juce::LowLevelGraphicsSoftwareRenderer*> (&context) != nullptr ? "software" : typeid (context).name())
- << ", paint caches " << (lynx::ui::paintCache() ? "on" : "off (LYNX_PAINT_CACHE=0)") << ", paint savings "
- << (lynx::ui::paintSavings() ? "on" : "off (LYNX_PAINT_SAVINGS=0)") << "\n";
- }
- // LYNX_PAINTBENCH_VIEWS="mixer,channel rack" (round 190gr): only those views
- const auto onlyViews = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_VIEWS", {}), ",", "");
- const auto wanted = [&onlyViews] (const juce::String& name) { return onlyViews.isEmpty() || onlyViews.contains (name); };
- // the picture's pixels as one number: the same before and after a change = the same drawing
- auto pixelHash = [&image] {
- const juce::Image::BitmapData data (image, juce::Image::BitmapData::readOnly);
- std::uint64_t h = 1469598103934665603ull;
- for (int y = 0; y < data.height; ++y)
- for (int x = 0; x < data.width; ++x)
- h = (h ^ data.getPixelColour (x, y).getARGB()) * 1099511628211ull;
- return juce::String::toHexString ((juce::int64) h);
- };
- // mode 0: whole frames after a repaint of everything; 1: whole frames, the views' own caches kept; 2: a 14-pixel
- // column of the whole height at 40 places (what a moving playhead repaints each frame)
- // (rollup step 9: the instructions the message thread retires per frame, Linux, where the CPU counter can be read:
- // the performance gate's stable paint measure, scripts/perf_gate.py "paint_instr")
- const lynx::platform::ThreadInstructions instructions;
- auto measure = [&] (const juce::String& name, int mode) {
- offline.dispatchPendingMessages();
- std::vector<double> ms, wall;
- std::vector<long long> instr;
- juce::String hash;
- for (int f = -3; f < frames; ++f) // (3 frames to warm the caches up)
- {
- if (mode == 0)
- ui.repaint();
- const auto column = juce::Rectangle<int> ((juce::jmax (0, f) * 97) % juce::jmax (1, ui.getWidth() - 14), 0, 14, ui.getHeight());
- const auto t0 = lynx::threadCpuSeconds();
- const auto w0 = juce::Time::getMillisecondCounterHiRes();
- const auto i0 = instructions.now();
- {
- juce::Graphics g (image);
- if (mode == 2)
- g.reduceClipRegion (column);
- ui.paintEntireComponent (g, true);
- }
- if (const auto i1 = instructions.now(); f >= 0 && i0 >= 0 && i1 >= i0)
- instr.push_back (i1 - i0);
- if (f >= 0)
- {
- ms.push_back (1000.0 * (lynx::threadCpuSeconds() - t0));
- wall.push_back (juce::Time::getMillisecondCounterHiRes() - w0); // (round 190gr: Direct2D's work ends with the frame)
- }
- if (f == 0 && mode == 0)
- {
- hash = pixelHash();
- // LYNX_PAINTBENCH_PNG=<prefix> (round 190gr): the whole frame as <prefix>-<view>.png, to compare pixels
- if (const auto png = juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_PNG", {}); png.isNotEmpty())
- {
- const juce::File file (png + "-" + name.replaceCharacter (' ', '-') + ".png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- }
- }
- }
- std::sort (ms.begin(), ms.end());
- std::sort (wall.begin(), wall.end());
- text << name << (mode == 0 ? ", whole frame" : mode == 1 ? ", cached frame" : ", playhead column") << ": median "
- << juce::String (ms[ms.size() / 2], 3) << " ms, p90 " << juce::String (ms[(ms.size() * 9) / 10], 3) << " ms, wall median "
- << juce::String (wall[wall.size() / 2], 3) << " ms"
- << (hash.isNotEmpty() ? ", pixels " + hash : juce::String());
- if (instr.size() == ms.size())
- {
- std::sort (instr.begin(), instr.end());
- text << ", instructions median " << juce::String ((juce::int64) instr[instr.size() / 2]);
- }
- text << "\n";
- report.replaceWithText (text);
- };
- auto measureAll = [&] (const juce::String& name) {
- if (! wanted (name))
- return;
- measure (name, 0);
- measure (name, 1);
- measure (name, 2);
- // the columns' pixels too (painted over the whole frame: culling must not change a pixel)
- ui.repaint();
- {
- juce::Graphics g (image);
- ui.paintEntireComponent (g, true);
- for (int x = 3; x < ui.getWidth() - 14; x += 211)
- {
- juce::Graphics::ScopedSaveState state (g);
- g.reduceClipRegion (x, 0, 14, ui.getHeight());
- ui.paintEntireComponent (g, true);
- }
- }
- text << name << ", columns over the whole frame: pixels " << pixelHash() << "\n";
- };
- // LYNX_KEEP_LABELS=0|1 (round 190qe): Playlist ▸ View ▸ "Keep labels on screen" for the whole run (A/B of the labels' cost)
- if (const auto keep = juce::SystemStats::getEnvironmentVariable ("LYNX_KEEP_LABELS", {}); keep.isNotEmpty())
- {
- lynx::keeplabels::on = keep != "0";
- text << "keep labels on screen " << (lynx::keeplabels::on ? "on" : "off") << " (LYNX_KEEP_LABELS)\n";
- }
- const char* views[] { "channel rack", "piano roll", "playlist", "mixer" };
- for (int v = 0; v < 4; ++v)
- {
- ui.selectTabForSnapshot (v);
- measureAll (views[v]);
- }
- // LYNX_PAINTBENCH_BAR=<n> (round 190qe): the Playlist once more from bar n (the same zoom), so the clips whose start is
- // scrolled off draw their labels at the left edge ("Keep labels on screen")
- if (const auto fromBar = juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_BAR", {}).getIntValue(); fromBar > 0)
- {
- ui.selectTabForSnapshot (2);
- auto& pl = ui.getPlaylistForSnapshot();
- const auto before = pl.viewForSnapshot();
- pl.setViewForSnapshot (before.pixelsPerTick * (double) offline.getSong().barTicks(), fromBar, 0);
- pl.setScrollYForSnapshot (before.scrollY);
- measureAll ("playlist from bar " + juce::String (fromBar));
- pl.restoreViewForSnapshot (before);
- }
- ui.showDesktopForSnapshot (false);
- measureAll ("desktop");
- ui.selectTabForSnapshot (2);
- ui.setClipLaunchWorkflow (true);
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- measureAll ("clip grid");
- ui.setClipGridView (lynx::PlaylistArea::GridView::song); // (round 190jn: the Clip-launch layout's Arrangement)
- measureAll ("clip arrangement");
- // (and with View > Tall Arrangement lanes: LYNX's 38 px rows in Live's look, the classic look's row height)
- lynx::playlistTallLiveLanes() = true;
- ui.getPlaylistForSnapshot().liveLanesChanged();
- measureAll ("clip arrangement, tall lanes");
- lynx::playlistTallLiveLanes() = false;
- ui.getPlaylistForSnapshot().liveLanesChanged();
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- ui.setClipLaunchWorkflow (false);
- // LYNX_PAINTBENCH_SIMPLE=1 (round 190jc): the same project's Playlist in the Simple layout too
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_PAINTBENCH_SIMPLE", {}) == "1")
- {
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- if (auto* simple = ui.getSimpleWorkflowForSnapshot())
- simple->hideChooser();
- ui.selectTabForSnapshot (2);
- measureAll ("simple playlist");
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- }
- text << "result=OK\n";
- report.replaceWithText (text);
- if (profile.isNotEmpty())
- lynx::crashguard::stopMainProfiler();
- }
- // Round 190iv: the toolbar per layout style (see --toolbarshot190iv above)
- void runToolbarShot190iv (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::ui::motion::enabled() = false; // (hover states drawn at once, no fade)
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1920, 1080);
- juce::String report;
- const auto write = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- const auto bar = [&ui] { return ui.getLocalBounds().withHeight (juce::jmin (ui.getHeight(), 90)); };
- const auto describe = [&ui, &report] (const juce::String& title) {
- report << "== " << title << " (" << ui.getWidth() << "x" << ui.getHeight() << ")\n";
- for (const auto* name : { "play", "stop", "record", "metronome", "tap", "tempo", "signature", "quantisation", "key", "link", "browser",
- "backToArrangement", "position", "overdub", "capture", "sessionRecord", "punch", "draw", "computerKeys",
- "keyMap", "midiMap", "cpu", "more", "sessionView", "arrangementView", "status", "finish" })
- if (auto* c = ui.toolbarPartForSnapshot (name); c != nullptr && c->isVisible() && c->getParentComponent() == &ui)
- report << " " << name << " " << c->getBounds().toString() << "\n";
- };
- const std::pair<int, int> sizes[] { { 1920, 1080 }, { 1366, 768 }, { 1280, 800 } };
- // a song with a few tracks for the Simple layout (voice, instrument, drums), as --simpleshot makes them
- offline.editSong ([] (lynx::Song& s) {
- namespace st = lynx::simpletracks;
- st::Request q;
- q.kind = st::Kind::voice;
- q.name = "Lead vocal";
- st::addTrack (s, q);
- q = {};
- q.kind = st::Kind::instrument;
- q.name = "Keys";
- lynx::ChannelDef keys;
- keys.instrument = lynx::InstrumentKind::synth;
- q.channel = keys;
- st::addTrack (s, q);
- q = {};
- q.kind = st::Kind::drums;
- q.name = "Drums";
- st::addTrack (s, q);
- s.bpm = 120.0;
- }, false);
- offline.dispatchPendingMessages();
- // 1. Pattern: FL's toolbar (it must stay as it was: compare with the base build's)
- ui.selectTabForSnapshot (2);
- for (const auto& [w, h] : sizes)
- {
- ui.setSize (w, h);
- write (lynx::shot::snapshot (ui, bar()), "pattern-bar-" + juce::String (w));
- }
- ui.setSize (1920, 1080);
- // 2. Simple
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple, false);
- offline.dispatchPendingMessages();
- for (const auto& [w, h] : sizes)
- {
- ui.setSize (w, h);
- offline.dispatchPendingMessages();
- write (lynx::shot::snapshot (ui), "simple-" + juce::String (w));
- write (lynx::shot::snapshot (ui, bar()), "simple-bar-" + juce::String (w));
- describe ("simple " + juce::String (w));
- }
- ui.setSize (1920, 1080);
- auto* play = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot ("play"));
- auto* stop = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot ("stop"));
- auto* rec = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot ("record"));
- const auto capsuleArea = [&] {
- juce::Rectangle<int> r;
- for (const auto* name : { "play", "stop", "record", "position", "metronome", "tempo", "signature", "key" })
- if (auto* c = ui.toolbarPartForSnapshot (name); c != nullptr && c->isVisible())
- r = r.isEmpty() ? c->getBounds() : r.getUnion (c->getBounds());
- return r.expanded (8, 10);
- };
- if (play != nullptr && stop != nullptr && rec != nullptr)
- {
- // (round 190oo, CS-35: the main window's own transport states, as its timer sets them while the engine plays —
- // the offline engine does not play, so the route drives them: Play shows BandLab's Pause, Back-to-start Stop)
- ui.transportForSnapshot (false, false);
- write (lynx::shot::snapshot (ui, capsuleArea()), "simple-transport-idle");
- play->setState (juce::Button::buttonOver);
- write (lynx::shot::snapshot (ui, capsuleArea()), "simple-transport-hover");
- play->setState (juce::Button::buttonDown);
- write (lynx::shot::snapshot (ui, capsuleArea()), "simple-transport-pressed");
- play->setState (juce::Button::buttonNormal);
- ui.transportForSnapshot (true, true);
- write (lynx::shot::snapshot (ui, capsuleArea()), "simple-transport-playing");
- rec->setToggleState (true, juce::dontSendNotification);
- write (lynx::shot::snapshot (ui, capsuleArea()), "simple-transport-recording");
- rec->setToggleState (false, juce::dontSendNotification);
- ui.transportForSnapshot (false, false);
- }
- if (auto* status = ui.toolbarPartForSnapshot ("status"))
- {
- using S = lynx::toolbarlayout::SaveState;
- int n = 0;
- for (const auto state : { S::fresh, S::unsaved, S::backedUp, S::saved })
- {
- ui.setSaveStatusForSnapshot (state);
- auto r = status->getBounds();
- if (auto* finish = ui.toolbarPartForSnapshot ("finish"); finish != nullptr && finish->isVisible())
- r = r.getUnion (finish->getBounds());
- write (lynx::shot::snapshot (ui, r.expanded (8, 10)), "simple-status-" + juce::String (n++));
- }
- }
- {
- auto more = ui.makeToolbarMoreMenuForSnapshot();
- saveMenus (juce::StringArray { "More" }, std::vector<juce::PopupMenu> { more }, prefix + "-simple-more-menu.png");
- }
- // 3. Clip-launch: Live's control bar (the Live demo set when given, else an empty grid)
- if (projectPath.isNotEmpty())
- {
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- }
- ui.setLayoutStyle (lynx::layoutstyle::Style::clipLaunch, false);
- offline.dispatchPendingMessages();
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- for (const auto& [w, h] : sizes)
- {
- ui.setSize (w, h);
- offline.dispatchPendingMessages();
- write (lynx::shot::snapshot (ui), "live-" + juce::String (w));
- write (lynx::shot::snapshot (ui, bar()), "live-bar-" + juce::String (w));
- describe ("clip-launch " + juce::String (w));
- }
- ui.setSize (1920, 1080);
- ui.setClipGridView (lynx::PlaylistArea::GridView::song);
- write (lynx::shot::snapshot (ui), "live-arrangement-1920");
- ui.setClipGridView (lynx::PlaylistArea::GridView::beside);
- write (lynx::shot::snapshot (ui), "live-both-1920");
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- // every control-bar button idle / hover / pressed / lit, all at once per picture
- std::vector<juce::Button*> buttons;
- for (const auto* name : { "play", "stop", "record", "metronome", "tap", "browser", "backToArrangement", "overdub", "capture", "sessionRecord", "punch",
- "draw", "computerKeys", "keyMap", "midiMap", "more", "sessionView", "arrangementView" })
- if (auto* b = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot (name)); b != nullptr && b->isVisible())
- buttons.push_back (b);
- std::vector<bool> lit;
- for (auto* b : buttons)
- lit.push_back (b->getToggleState());
- const auto controlBar = ui.getLocalBounds().withTrimmedTop (lynx::toolbarlayout::livebar::menuRow).withHeight (lynx::toolbarlayout::livebar::band);
- write (lynx::shot::snapshot (ui, controlBar), "live-states-idle");
- for (const auto& [state, name] : { std::pair<juce::Button::ButtonState, const char*> { juce::Button::buttonOver, "hover" }, { juce::Button::buttonDown, "pressed" } })
- {
- for (auto* b : buttons)
- b->setState (state);
- write (lynx::shot::snapshot (ui, controlBar), juce::String ("live-states-") + name);
- }
- for (auto* b : buttons)
- {
- b->setState (juce::Button::buttonNormal);
- b->setToggleState (true, juce::dontSendNotification);
- }
- write (lynx::shot::snapshot (ui, controlBar), "live-states-lit");
- for (std::size_t k = 0; k < buttons.size(); ++k)
- buttons[k]->setToggleState (lit[k], juce::dontSendNotification);
- {
- auto more = ui.makeToolbarMoreMenuForSnapshot();
- saveMenus (juce::StringArray { "More" }, std::vector<juce::PopupMenu> { more }, prefix + "-live-more-menu.png");
- }
- // the Session button row kept as an option
- ui.setSessionButtonRowShown (true);
- write (lynx::shot::snapshot (ui), "live-buttonrow-1920");
- ui.setSessionButtonRowShown (false);
- // 4. back to Pattern: FL's toolbar again, as it was
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern, false);
- offline.dispatchPendingMessages();
- for (const auto& [w, h] : sizes)
- {
- ui.setSize (w, h);
- write (lynx::shot::snapshot (ui, bar()), "pattern-after-bar-" + juce::String (w));
- }
- juce::File (prefix + "-report.txt").replaceWithText (report);
- lynx::ui::motion::enabled() = true;
- }
- void runGridShot (const juce::String& prefix, const juce::String& projectPath = {})
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix, &ui] (const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- ui.selectTabForSnapshot (2); // the Playlist panel, maximized
- if (projectPath.isNotEmpty())
- {
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- ui.setClipLaunchWorkflow (true);
- offline.dispatchPendingMessages();
- write ("file-both");
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- write ("file-grid");
- const auto& song = offline.getSong();
- juce::String info;
- info << "grid " << (song.clipGrid ? "yes" : "no") << ", clips " << (song.clipGrid ? (int) song.clipGrid->clips.size() : 0)
- << ", scenes " << (song.clipGrid ? (int) song.clipGrid->scenes.size() : 0) << ", playlist clips " << (int) song.playlist.size() << "\n";
- // round qafix190kq (QA-2): the grid's columns (take lanes have none) and the Session mixer's strips follow them
- if (auto* grid = ui.getClipGridForSnapshot())
- {
- const auto columns = lynx::clipGridColumnTracks (*grid);
- int lanes = 0, laneColumns = 0;
- for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
- lanes += lynx::comp::isTakeLane (song, t) ? 1 : 0;
- juce::StringArray names;
- for (const auto t : columns)
- {
- laneColumns += lynx::comp::isTakeLane (song, t) ? 1 : 0;
- names.add (t < (int) song.playlistTracks.size() ? juce::String::fromUTF8 (song.playlistTracks[(std::size_t) t].name.c_str()) : "(empty)");
- }
- info << "playlist tracks " << (int) song.playlistTracks.size() << ", take lanes " << lanes << ", grid columns " << (int) columns.size()
- << ", lane columns " << laneColumns << "\ncolumns: " << names.joinIntoString (" | ") << "\n";
- // the lanes' flag survives a save and an open (ProjectFile "playlistTakeLanes")
- juce::String error;
- auto same = false;
- if (const auto back = lynx::ProjectFile::fromJson (lynx::ProjectFile::toJson (song), error); back && back->playlistTracks.size() == song.playlistTracks.size())
- {
- same = true;
- for (std::size_t t = 0; t < song.playlistTracks.size(); ++t)
- same = same && back->playlistTracks[t].takeLane == song.playlistTracks[t].takeLane;
- }
- info << "take lanes after save + open: " << (same ? "same" : "DIFFERENT") << "\n";
- }
- juce::File (prefix + "-file.txt").replaceWithText (info);
- ui.setClipLaunchWorkflow (false);
- return;
- }
- write ("pattern"); // Pattern workflow: nothing of the grid exists yet
- const auto madeBefore = lynx::launcher::Runtime::instances.load();
- offline.editSong ([] (lynx::Song& s) {
- while (s.patterns.size() < 6)
- s.patterns.emplace_back();
- for (int p = 0; p < 6; ++p)
- {
- auto& pattern = s.patterns[(std::size_t) p];
- const char* names[] { "Drums A", "Drums B", "Bass", "Chords", "Lead", "Pad" };
- pattern.name = names[p];
- pattern.lengthTicks = 4 * lynx::ppq;
- }
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 6));
- const char* tracks[] { "Drums", "Bass", "Chords", "Lead", "Vocals", "FX" };
- for (int t = 0; t < 6; ++t)
- s.playlistTracks[(std::size_t) t].name = tracks[t];
- const int placed[][3] { { 0, 0, 0 }, { 0, 1, 1 }, { 0, 2, 0 }, { 0, 3, 1 }, { 1, 0, 2 }, { 1, 2, 2 }, { 2, 1, 3 }, { 2, 2, 3 }, { 3, 2, 4 }, { 3, 3, 4 }, { 4, 3, 5 } };
- for (const auto& c : placed)
- {
- lynx::Clip clip;
- clip.pattern = c[2];
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, c[0], c[1], clip);
- }
- auto& grid = lynx::launcher::ensureGrid (s);
- const char* scenes[] { "Intro", "Verse", "Drop", "Break" };
- grid.scenes.resize (6);
- for (int r = 0; r < 4; ++r)
- grid.scenes[(std::size_t) r].name = scenes[r];
- }, false);
- offline.dispatchPendingMessages();
- write ("pattern-edited"); // the same song as -pattern-after: the workflow must leave no trace
- ui.setClipLaunchWorkflow (true);
- offline.dispatchPendingMessages();
- if (auto* runtime = offline.launcherStateForSnapshot())
- {
- runtime->tracks[0].playing.store (2);
- runtime->tracks[0].progress.store (0.4f);
- runtime->tracks[0].taken.store (true);
- runtime->tracks[1].playing.store (2);
- runtime->tracks[1].progress.store (0.4f);
- runtime->tracks[1].taken.store (true);
- runtime->tracks[2].pending.store (2);
- runtime->tracks[3].taken.store (true);
- }
- write ("both");
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- write ("grid");
- // round 190bv: recording into slots and the Groove Pool. Two tracks armed (round record buttons in their empty
- // slots, their arm buttons lit), one of them recording and one waiting for its start; then a clip through a
- // groove with the pool shown, and the slot menus
- if (auto* gridView = ui.getClipGridForSnapshot())
- {
- offline.setGridTrackArmed (4, true);
- offline.setGridTrackArmed (5, true, false);
- offline.dispatchPendingMessages();
- write ("rec-armed");
- if (auto* runtime = offline.launcherStateForSnapshot())
- {
- runtime->tracks[4].recording.store (1);
- runtime->tracks[4].recordFrom.store (0.0); // (round 190cy: one beat recorded, the counter reads 0.1.0)
- runtime->clockNow.store ((double) lynx::ppq);
- runtime->tracks[5].recordPending.store (1);
- }
- write ("rec-recording");
- if (auto* runtime = offline.launcherStateForSnapshot())
- {
- runtime->tracks[4].recording.store (-1);
- runtime->tracks[5].recordPending.store (-1);
- }
- offline.editSong ([] (lynx::Song& s) {
- const auto& bank = lynx::groove::factoryBank();
- std::uint32_t first = 0;
- for (const auto index : { std::size_t (9), std::size_t (20), std::size_t (27) })
- if (index < bank.size())
- {
- const auto id = lynx::groove::add (s.grooves, bank[index].groove);
- first = first == 0 ? id : first;
- }
- lynx::groove::setClipGroove (s, 0, 0, first);
- }, false);
- offline.dispatchPendingMessages();
- lynx::setClipGridGroovePoolShown (*gridView, true);
- write ("groove-pool");
- saveMenus ({ "Clip slot", "Groove", "Empty slot" },
- { lynx::clipGridSlotMenu (*gridView, 0, 0), [&] {
- juce::PopupMenu found;
- const auto menu = lynx::clipGridSlotMenu (*gridView, 0, 0);
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == lynx::tr ("Groove"))
- found = *it.getItem().subMenu;
- return found;
- }(), lynx::clipGridSlotMenu (*gridView, 4, 1) },
- prefix + "-rec-menus.png");
- lynx::setClipGridGroovePoolShown (*gridView, false);
- // round 190cy: a second record button pressed while recording: the first take ("Vocals 1") plays on, the
- // clicked slot records "Vocals 2" with its counter at 2.0.2 (as Live 12.4.16, live check 190cw shot 03b)
- {
- const auto name = offline.slotRecordingName (4);
- offline.editSong ([&name] (lynx::Song& s) { lynx::session::placeRecordedPattern (s, 4, 0, {}, 8 * lynx::ppq, name); }, false);
- offline.dispatchPendingMessages();
- if (auto* runtime = offline.launcherStateForSnapshot())
- {
- runtime->tracks[4].playing.store (0);
- runtime->tracks[4].progress.store (0.3f);
- runtime->tracks[4].recording.store (1);
- runtime->tracks[4].recordFrom.store (0.0);
- runtime->clockNow.store (8.0 * lynx::ppq + 2.0 * lynx::ppq / 4.0);
- }
- write ("rec-second");
- if (auto* runtime = offline.launcherStateForSnapshot())
- {
- runtime->tracks[4].playing.store (-1);
- runtime->tracks[4].recording.store (-1);
- }
- offline.editSong ([] (lynx::Song& s) {
- if (lynx::session::cut (s, 4, 0) && ! s.patterns.empty())
- s.patterns.pop_back();
- }, false);
- offline.dispatchPendingMessages();
- }
- offline.setGridTrackArmed (4, false);
- offline.setGridTrackArmed (5, false);
- offline.dispatchPendingMessages();
- }
- ui.setClipGridView (lynx::PlaylistArea::GridView::song);
- write ("song");
- ui.setClipLaunchWorkflow (false);
- write ("pattern-after");
- juce::File (prefix + "-counts.txt").replaceWithText ("runtimes before " + juce::String (madeBefore) + ", after " + juce::String (lynx::launcher::Runtime::instances.load()) + "\n");
- }
- // Round 190bu: the Simple workflow's track dock (ui/SimpleDock.h), off-screen
- void runSimpleFxShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto writeImage = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = juce::File (prefix + "-" + name + ".png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- juce::String report;
- const auto line = [&report] (const juce::String& text) { report << text << "\n"; };
- const auto check = [&report] (const juce::String& what, bool ok) { report << (ok ? "OK " : "ERROR ") << what << "\n"; };
- const auto madeBefore = lynx::SimpleWorkflow::instances.load();
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- if (simple == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText ("ERROR no Simple workflow\n");
- return;
- }
- simple->hideChooser();
- // three tracks: a voice, keys with a few chords, a drum kit
- int keysInsert = -1;
- offline.editSong ([&keysInsert] (lynx::Song& s) {
- namespace st = lynx::simpletracks;
- st::Request q;
- q.kind = st::Kind::voice;
- q.name = "Lead vocal";
- st::addTrack (s, q);
- q = {};
- q.kind = st::Kind::instrument;
- q.name = "Keys";
- lynx::ChannelDef keys;
- keys.instrument = lynx::InstrumentKind::synth;
- q.channel = keys;
- lynx::Pattern chords;
- for (int i = 0; i < 4; ++i)
- for (int k : { 60, 64, 67 })
- chords.notes.push_back (lynx::Note { (std::int64_t) i * 4 * lynx::ppq, 4 * lynx::ppq - lynx::ppq / 4, 0, k });
- q.pattern = chords;
- keysInsert = st::addTrack (s, q).insert;
- q = {};
- q.kind = st::Kind::drums;
- for (auto kind : { lynx::InstrumentKind::kick, lynx::InstrumentKind::snare, lynx::InstrumentKind::hat })
- {
- lynx::ChannelDef c;
- c.instrument = kind;
- c.name = kind == lynx::InstrumentKind::kick ? "Kick" : kind == lynx::InstrumentKind::snare ? "Snare" : "Hat";
- q.kit.push_back (c);
- }
- lynx::Pattern beat;
- for (int step = 0; step < 16; step += 2)
- beat.notes.push_back (lynx::Note { (std::int64_t) step * lynx::ticksPerStep, lynx::ticksPerStep, 2, 60 });
- q.pattern = beat;
- st::addTrack (s, q);
- });
- offline.dispatchPendingMessages();
- simple->hideChooser();
- auto& playlist = ui.getPlaylistForSnapshot();
- // the tracks' places in the Playlist
- int voiceTrack = -1, keysTrack = -1, drumsTrack = -1;
- {
- const auto& song = offline.getSong();
- for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
- if (const auto kind = lynx::simpletracks::kindOf (song, t))
- {
- if (*kind == lynx::simpletracks::Kind::audio && voiceTrack < 0)
- voiceTrack = t;
- else if (*kind == lynx::simpletracks::Kind::instrument && keysTrack < 0)
- keysTrack = t;
- else if (*kind == lynx::simpletracks::Kind::drums && drumsTrack < 0)
- drumsTrack = t;
- }
- }
- check ("three Simple tracks (voice, keys, drums)", voiceTrack >= 0 && keysTrack >= 0 && drumsTrack >= 0);
- playlist.selectTrack (keysTrack);
- offline.dispatchPendingMessages();
- auto* dock = simple->dockForSnapshot();
- if (dock == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText (report + "ERROR no dock\n");
- return;
- }
- // the whole window and the dock alone, at 1x and 2x
- const auto shots = [&] (const juce::String& name) {
- offline.dispatchPendingMessages();
- for (float scale : { 1.0f, 2.0f })
- {
- const auto suffix = scale > 1.0f ? juce::String ("@2x") : juce::String();
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, scale), name + suffix);
- writeImage (dock->createComponentSnapshot (dock->getLocalBounds(), true, scale), "dock-" + name + suffix);
- }
- };
- const auto menuShot = [&] (const juce::PopupMenu& menu, const juce::String& title, const juce::String& subTitle, const juce::String& name) {
- juce::StringArray names { title };
- std::vector<juce::PopupMenu> menus { menu };
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == subTitle)
- {
- names.add (subTitle);
- menus.push_back (*it.getItem().subMenu);
- }
- saveMenus (names, menus, prefix + "-" + name + ".png");
- };
- // --- the Instrument tab ---------------------------------------------------------------------------------------
- check ("the dock shows the selected track", dock->shownTrack() == keysTrack && dock->isVisible() && dock->getParentComponent() != nullptr);
- check ("an instrument track opens on its sound", dock->hasInstrumentTabForCheck() && dock->getTab() == lynx::SimpleDock::Tab::instrument);
- const auto channel = dock->channelForCheck();
- line ("sound at first: " + dock->soundNameForCheck() + ", rows in its category: " + juce::String (dock->soundRowsForCheck()));
- shots ("instrument");
- // a click on a row of another category: the track plays that sound, its own settings stay
- const auto before = offline.getSong().channels[(std::size_t) channel];
- dock->showCategoryForSnapshot ((int) lynx::soundlib::Category::pad);
- offline.dispatchPendingMessages();
- const auto padRows = dock->soundRowsForCheck();
- dock->clickSoundForCheck (juce::jmin (2, padRows - 1));
- offline.dispatchPendingMessages();
- {
- const auto& now = offline.getSong().channels[(std::size_t) channel];
- const auto found = lynx::soundlib::find (lynx::soundlib::builtIn(), now);
- check ("a click on a sound puts it on the track's channel (" + dock->soundNameForCheck() + ")",
- padRows > 0 && found >= 0 && lynx::soundlib::builtIn()[(std::size_t) found].category == lynx::soundlib::Category::pad
- && ! lynx::soundlib::sameSound (before, now));
- check ("the channel keeps its name, level and insert", now.name == before.name && now.volume == before.volume && now.mixerTrack == before.mixerTrack);
- double seconds = 0.0;
- const auto heard = offline.auditionSound (now, { 60, 64, 67 }, &seconds);
- check ("the sound's audition renders (" + juce::String (seconds, 2) + " s)", heard && seconds > 1.0);
- }
- shots ("instrument-pad");
- const auto picked = dock->soundNameForCheck();
- dock->stepSoundForCheck (1);
- offline.dispatchPendingMessages();
- const auto stepped = dock->soundNameForCheck();
- dock->stepSoundForCheck (-1);
- offline.dispatchPendingMessages();
- check ("the arrows step through the category (" + picked + " -> " + stepped + " -> back)", stepped != picked && dock->soundNameForCheck() == picked);
- check ("one undo step per sound", offline.canUndo());
- // the user's SoundFont files (an index made here: no file is read)
- {
- std::vector<lynx::sf::IndexedFont> fonts (2);
- fonts[0].path = "/home/me/SoundFonts/Concert Band.sf2";
- fonts[0].name = "Concert Band";
- int program = 0;
- for (const char* name : { "Grand Piano", "Bright Piano", "Electric Piano", "Harpsichord", "Clavinet", "Celesta", "Music Box", "Vibraphone" })
- fonts[0].presets.push_back ({ name, 0, program++ });
- for (const auto& [name, p] : std::initializer_list<std::pair<const char*, int>> { { "Finger Bass", 33 }, { "Picked Bass", 34 }, { "Nylon Guitar", 24 }, { "Strings", 48 }, { "Choir Aahs", 52 }, { "Trumpet", 56 } })
- fonts[0].presets.push_back ({ name, 0, p });
- fonts[0].presets.push_back ({ "Standard Kit", 128, 0 });
- fonts[1].path = "/home/me/SoundFonts/Old Upright.sf2";
- fonts[1].name = "Old Upright";
- fonts[1].presets.push_back ({ "Old Upright", 0, 0 });
- fonts[1].presets.push_back ({ "Old Upright Soft", 0, 1 });
- dock->setFontsForSnapshot (fonts);
- dock->showCategoryForSnapshot ((int) lynx::soundlib::Category::keys);
- offline.dispatchPendingMessages();
- check ("My SoundFonts lists the presets of the user's files by category (Keys: " + juce::String (dock->soundRowsForCheck()) + " of 17)", dock->soundRowsForCheck() == 7);
- dock->clickSoundForCheck (0);
- offline.dispatchPendingMessages();
- const auto& now = offline.getSong().channels[(std::size_t) channel];
- check ("a SoundFont preset becomes the track's sound (" + dock->soundNameForCheck() + ")",
- now.instrument == lynx::InstrumentKind::soundfont && juce::String (now.samplePath).endsWith (".sf2"));
- shots ("instrument-soundfonts");
- }
- // --- the Effects tab ------------------------------------------------------------------------------------------
- playlist.selectTrack (voiceTrack);
- offline.dispatchPendingMessages();
- const auto insert = dock->insertForCheck();
- check ("an audio track has no Instrument tab and opens on its effects",
- dock->shownTrack() == voiceTrack && ! dock->hasInstrumentTabForCheck() && dock->getTab() == lynx::SimpleDock::Tab::effects && insert > 0);
- check ("no effects yet: no cards", dock->cardCountForCheck() == 0);
- shots ("effects-empty");
- menuShot (dock->addMenuForSnapshot(), lynx::tr ("Add an effect"), {}, "menu-add");
- // + adds one-knob effects at the end of the chain
- dock->addOneKnobForCheck (lynx::goals::brighter);
- dock->addOneKnobForCheck (lynx::goals::room);
- dock->addOneKnobForCheck (lynx::goals::level);
- offline.dispatchPendingMessages();
- const auto slotsText = [&offline] (int t) {
- juce::String text;
- const auto rows = lynx::mixerops::effectRows (offline.getSong().mixer[(std::size_t) t].effects); // (the Mixer's slot of each)
- std::size_t at = 0;
- for (const auto& fx : offline.getSong().mixer[(std::size_t) t].effects)
- text << "[slot " << rows[at++] + 1 << " " << lynx::effectInfo (fx.kind).name
- << (lynx::goals::active (fx) ? " = " + juce::String (lynx::goals::name (fx.goal)) + " " + juce::String (juce::roundToInt (fx.goalAmount * 100.0f)) + "%" : juce::String())
- << (fx.enabled ? "" : " off") << "] ";
- return text.trimEnd();
- };
- line ("after + x3: " + slotsText (insert));
- check ("three cards, three one-knob effects", dock->cardCountForCheck() == 3 && dock->oneKnobCardsForCheck() == 3);
- // the knob writes the effect's own parameters
- const auto roomBefore = offline.getSong().mixer[(std::size_t) insert].effects[1];
- dock->turnKnobForCheck (1, 0.8f);
- offline.dispatchPendingMessages();
- {
- const auto& room = offline.getSong().mixer[(std::size_t) insert].effects[1];
- check ("the knob at 80 % writes the mapped parameters", std::abs (room.goalAmount - 0.8f) < 1.0e-6f && lynx::goals::active (room) && ! (room.params == roomBefore.params));
- }
- // ‹ › reorder, × removes
- dock->moveCardForCheck (2, -1);
- offline.dispatchPendingMessages();
- line ("Level moved left: " + slotsText (insert));
- {
- const auto& fx = offline.getSong().mixer[(std::size_t) insert].effects;
- check ("the card moved one place earlier", fx.size() == 3 && fx[1].goal == lynx::goals::level && fx[2].goal == lynx::goals::room);
- }
- dock->removeCardForCheck (0);
- offline.dispatchPendingMessages();
- line ("Brighter removed: " + slotsText (insert));
- check ("the card is gone", dock->cardCountForCheck() == 2 && offline.getSong().mixer[(std::size_t) insert].effects.size() == 2);
- // a hand edit in the full editor: the slot is an ordinary effect again (its card shows Mix)
- offline.editSong ([insert] (lynx::Song& s) {
- auto& slot = s.mixer[(std::size_t) insert].effects[0];
- const auto moved = (std::size_t) lynx::goals::mapping (slot.goal, slot.goalAmount).back().param;
- slot.params[moved] = slot.params[moved] > 0.5f ? 0.2f : 0.9f;
- });
- offline.dispatchPendingMessages();
- check ("a parameter moved by hand makes the card an ordinary effect", dock->cardCountForCheck() == 2 && dock->oneKnobCardsForCheck() == 1);
- dock->turnKnobForCheck (0, 0.5f); // (its knob is the slot's Mix now)
- offline.dispatchPendingMessages();
- check ("an ordinary card's knob is the slot's Mix", std::abs (offline.getSong().mixer[(std::size_t) insert].effects[0].mix - 0.5f) < 1.0e-6f);
- // a preset replaces the chain; Blend is the chain's dry/wet
- if (const auto* preset = lynx::chains::find ("Clear Voice"))
- offline.editSongStructural ([insert, preset] (lynx::Song& s) { lynx::chains::apply (s, insert, *preset); });
- offline.dispatchPendingMessages();
- line ("preset Clear Voice: " + slotsText (insert));
- check ("the preset's chain is on the insert", offline.getSong().mixer[(std::size_t) insert].chainPreset == "Clear Voice" && lynx::chains::unchanged (offline.getSong(), insert)
- && dock->cardCountForCheck() == (int) offline.getSong().mixer[(std::size_t) insert].effects.size());
- shots ("effects-preset");
- menuShot (dock->presetMenuForSnapshot(), lynx::tr ("Preset"), lynx::tr ("Voice"), "menu-preset");
- dock->setBlendForCheck (0.7f);
- dock->addOneKnobForCheck (lynx::goals::echo);
- offline.dispatchPendingMessages();
- check ("Blend 70 % is the insert's chain blend; the preset shows as edited",
- std::abs (offline.getSong().mixer[(std::size_t) insert].chainBlend - 0.7f) < 1.0e-6f && ! lynx::chains::unchanged (offline.getSong(), insert));
- shots ("effects-edited");
- // a user preset: saved to a file, loaded on another track (its slots and Blend; that track's level stays)
- const auto mine = offline.getSong().mixer[(std::size_t) insert];
- const auto saved = lynx::SimpleDock::saveUserPreset (offline, insert, "My voice");
- const auto file = lynx::SimpleDock::userPresetFolder().getChildFile ("My voice.lynxtrack");
- check ("the preset is saved as " + file.getFileName(), saved && file.existsAsFile() && offline.getSong().mixer[(std::size_t) insert].chainPreset == "My voice");
- offline.editSong ([keysInsert] (lynx::Song& s) { s.mixer[(std::size_t) keysInsert].volume = 0.42f; });
- const auto loaded = keysInsert > 0 && lynx::SimpleDock::loadUserPreset (offline, keysInsert, file);
- offline.dispatchPendingMessages();
- {
- const auto& other = offline.getSong().mixer[(std::size_t) keysInsert];
- auto same = loaded && other.effects.size() == mine.effects.size() && std::abs (other.chainBlend - mine.chainBlend) < 1.0e-6f && other.chainPreset == "My voice";
- for (std::size_t i = 0; same && i < mine.effects.size(); ++i)
- same = other.effects[i].kind == mine.effects[i].kind && other.effects[i].goal == mine.effects[i].goal
- && lynx::mixerops::effectRows (other.effects)[i] == lynx::mixerops::effectRows (mine.effects)[i] && std::abs (other.effects[i].goalAmount - mine.effects[i].goalAmount) < 1.0e-6f && lynx::goals::active (other.effects[i]) == lynx::goals::active (mine.effects[i]);
- check ("loaded on the Keys track: the same slots and Blend", same);
- check ("the Keys track keeps its level", std::abs (other.volume - 0.42f) < 1.0e-6f);
- line ("Keys after load: " + slotsText (keysInsert));
- }
- menuShot (dock->presetMenuForSnapshot(), lynx::tr ("Preset"), lynx::tr ("My presets"), "menu-preset-mine");
- file.deleteFile();
- // the drums: effects only (a kit has no single sound to pick)
- playlist.selectTrack (drumsTrack);
- offline.dispatchPendingMessages();
- check ("the Drums track shows its insert's effects, no Instrument tab", dock->shownTrack() == drumsTrack && ! dock->hasInstrumentTabForCheck() && dock->insertForCheck() > 0);
- if (const auto* preset = lynx::chains::find ("Smash Room"))
- offline.editSongStructural ([t = dock->insertForCheck(), preset] (lynx::Song& s) { lynx::chains::apply (s, t, *preset); });
- shots ("effects-drums");
- // the project file keeps all of it
- {
- juce::String error;
- const auto json = lynx::ProjectFile::toJson (offline.getSong());
- const auto back = lynx::ProjectFile::fromJson (json, error);
- auto same = back && back->mixer.size() == offline.getSong().mixer.size();
- for (std::size_t t = 0; same && t < back->mixer.size(); ++t)
- {
- const auto& a = offline.getSong().mixer[t];
- const auto& b = back->mixer[t];
- same = a.effects.size() == b.effects.size() && std::abs (a.chainBlend - b.chainBlend) < 1.0e-6f && a.chainPreset == b.chainPreset;
- for (std::size_t i = 0; same && i < a.effects.size(); ++i)
- same = a.effects[i].kind == b.effects[i].kind && a.effects[i].goal == b.effects[i].goal && a.effects[i].row == b.effects[i].row
- && std::abs (a.effects[i].goalAmount - b.effects[i].goalAmount) < 1.0e-6f;
- }
- check ("saved and loaded as a project: the same chains, knobs, Blend and preset names", same);
- }
- // --- the same plugins in the same slots in FL's layout --------------------------------------------------------
- const auto simpleSong = offline.getSong();
- const auto inSimple = slotsText (insert);
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- offline.dispatchPendingMessages();
- check ("Pattern workflow: the dock is gone", dock->getParentComponent() == nullptr);
- ui.selectTabForSnapshot (3);
- ui.getMixerForSnapshot().selectTrack (insert);
- offline.dispatchPendingMessages();
- for (float scale : { 1.0f, 2.0f })
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, scale), juce::String ("pattern-mixer") + (scale > 1.0f ? "@2x" : ""));
- line ("Simple layout: " + inSimple);
- line ("Pattern layout: " + slotsText (insert));
- check ("the same effects in the same Mixer slots in the Pattern workflow", offline.getSong().mixer == simpleSong.mixer && offline.getSong().channels == simpleSong.channels);
- // an effect added in the Mixer's way shows as a card when the Simple workflow comes back
- offline.editSongStructural ([insert] (lynx::Song& s) { lynx::mixerops::insertEffectAtRow (s, insert, lynx::makeEffectSlot (lynx::EffectKind::chorus), 7); });
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- simple->hideChooser();
- playlist.selectTrack (voiceTrack);
- offline.dispatchPendingMessages();
- check ("back in Simple: the dock shows the insert as it is now, the Mixer's new effect too",
- dock->getParentComponent() != nullptr && dock->cardCountForCheck() == (int) offline.getSong().mixer[(std::size_t) insert].effects.size()
- && lynx::mixerops::effectRows (offline.getSong().mixer[(std::size_t) insert].effects).back() == 7);
- line ("Simple again: " + slotsText (insert));
- shots ("effects-back");
- // hidden with its key, shown again by "+FX"
- simple->toggleDock();
- offline.dispatchPendingMessages();
- check ("Ctrl+Alt+L hides the dock", ! simple->isDockShowing() && ! lynx::SimpleDock::shownSetting);
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, 1.0f), "dock-hidden");
- simple->showEffectsOfInsert (keysInsert);
- offline.dispatchPendingMessages();
- check ("+FX on a track header shows the dock on that track's effects",
- simple->isDockShowing() && dock->shownTrack() == keysTrack && dock->getTab() == lynx::SimpleDock::Tab::effects && dock->insertForCheck() == keysInsert);
- simple->cycleDockTab();
- check ("Shift+Tab goes to the Instrument tab", dock->getTab() == lynx::SimpleDock::Tab::instrument);
- line ("Simple workflow objects: " + juce::String (madeBefore) + " before, " + juce::String (lynx::SimpleWorkflow::instances.load()) + " after");
- line (report.contains ("ERROR ") ? "RESULT ERROR" : "RESULT OK");
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- // --simpleclosetest (round 190fc, 0.1.27 RC blocker B1): every close in the Simple layout crashed (the Simple workflow
- // was destroyed after the Workspace and its destructor called into it). Off-screen, no window: the main window in the
- // Simple layout with everything of it open — Welcome, the first-song tour's card, Start from, a demo song, each dock
- // tab (the Editor tab docks the Piano roll), Finish, Lyrics, the chooser — then destroyed as the app's shutdown does.
- // A second main window goes Simple -> Pattern -> Simple and closes too. Checks: no Simple workflow outlives its main
- // window's destructor body, none is left at all. (Under ASan on Linux the old order is a heap-use-after-free.)
- bool runDonateShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String report;
- bool ok = true;
- const auto line = [&report, &prefix] (const juce::String& text) {
- report << text << "\n";
- juce::File (prefix + "-report.txt").replaceWithText (report); // (written as it goes)
- };
- const auto check = [&line, &ok] (const juce::String& what, bool good) {
- line ((good ? "ok " : "FAIL ") + what);
- ok = ok && good;
- };
- const auto writeImage = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- // a window as the --snapshot route saves one (off the desktop, on the theme's panel colour), at 1x and 2x
- const auto saveAlert = [&] (juce::AlertWindow& w, const juce::String& name) {
- if (w.isOnDesktop())
- w.removeFromDesktop();
- w.setOpaque (true);
- juce::Component frame;
- frame.setSize (w.getWidth(), w.getHeight());
- frame.setOpaque (true);
- frame.addAndMakeVisible (w);
- w.setTopLeftPosition (0, 0);
- writeImage (lynx::shot::paint (frame, lynx::theme::panel), name);
- writeImage (frame.createComponentSnapshot (frame.getLocalBounds(), true, 2.0f), name + "@2x");
- frame.removeChildComponent (&w);
- };
- const auto buttonTexts = [] (juce::AlertWindow& w) {
- if (auto* d = dynamic_cast<lynx::ui::dialog::Dialog*> (&w)) // (round 190jp: LYNX's dialog, its own buttons)
- return d->dialogButtonTexts();
- juce::StringArray texts;
- for (int b = 0; b < w.getNumButtons(); ++b)
- if (auto* button = w.getButton (b))
- texts.add (button->getButtonText());
- return texts;
- };
- check ("the donation page is one constant, on Ko-fi", juce::String (lynx::links::donate).startsWith ("https://ko-fi"));
- line ("donate URL: " + juce::String (lynx::links::donate));
- const auto stateFile = lynx::PluginHost::settingsFolder().getChildFile ("support-note.txt");
- const auto hadState = stateFile.existsAsFile();
- const auto oldState = stateFile.loadFileAsString();
- line ("state file: " + stateFile.getFullPathName() + (hadState ? " (exists; put back at the end)" : ""));
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- ui.setVisible (true);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- // --- Help › Support LYNX SHARE..., right above About, in the three layouts ----------------------------------
- for (auto [style, name] : { std::pair { lynx::layoutstyle::Style::pattern, "pattern" }, { lynx::layoutstyle::Style::clipLaunch, "cliplaunch" },
- { lynx::layoutstyle::Style::simple, "simple" } })
- {
- ui.setLayoutStyle (style);
- settle();
- const auto help = ui.getMenuForSnapshot (ui.getMenuNamesForSnapshot().indexOf (lynx::tr ("Help")));
- juce::StringArray items;
- for (juce::PopupMenu::MenuItemIterator it (help); it.next();)
- if (! it.getItem().isSeparator)
- items.add (it.getItem().text);
- const auto support = items.indexOf (lynx::tr ("Support LYNX SHARE..."));
- const auto about = items.indexOf (lynx::tr ("About LYNX SHARE"));
- check (juce::String ("Help has Support LYNX SHARE... right above About LYNX SHARE (") + name + " layout)",
- support >= 0 && about == support + 1);
- saveMenus ({ lynx::tr ("Help") }, { help }, prefix + "-menu-help-" + name + ".png");
- }
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- settle();
- // --- the Support window -------------------------------------------------------------------------------------
- {
- auto w = lynx::support::makeSupportWindow();
- const auto texts = buttonTexts (*w);
- check ("Support window: Donate on Ko-fi, Close", texts == juce::StringArray { lynx::tr ("Donate on Ko-fi"), lynx::tr ("Close") });
- check ("Support window: Donate on Ko-fi points at the constant",
- dynamic_cast<lynx::ui::dialog::Dialog*> (w.get()) != nullptr
- && static_cast<lynx::ui::dialog::Dialog*> (w.get())->dialogButton (0)->getTooltip() == juce::String (lynx::links::donate));
- check ("Support window title", w->getName() == lynx::tr ("Support LYNX SHARE"));
- saveAlert (*w, "support");
- }
- // --- the About window ---------------------------------------------------------------------------------------
- {
- auto w = lynx::MainComponent::makeAboutWindow();
- const auto texts = buttonTexts (*w);
- check ("About window: Support LYNX SHARE (result 2) and OK", texts == juce::StringArray { lynx::tr ("Support LYNX SHARE"), lynx::tr ("OK") });
- saveAlert (*w, "about");
- }
- // --- Settings › General › Show the support note -------------------------------------------------------------
- {
- auto page = lynx::makeGeneralPage (offline, {}, false);
- bool found = false;
- std::function<void (juce::Component&)> walk = [&] (juce::Component& c) {
- if (auto* t = dynamic_cast<juce::ToggleButton*> (&c); t != nullptr && t->getButtonText() == lynx::tr ("Show the support note"))
- found = t->getToggleState();
- for (auto* child : c.getChildren())
- walk (*child);
- };
- walk (*page);
- check ("Settings > General: \"Show the support note\", ticked by default", found);
- }
- // --- the start-up note's rules, end to end on the saved state ----------------------------------------------
- lynx::supportnote::Moment moment; // (the main window here is off-screen: the moment is set by hand)
- lynx::support::StartupNote note (ui, [&moment] { return moment; }, [] { return 0; });
- const auto state = [] { return lynx::support::loadState(); };
- const auto setState = [] (int launches, int next, bool show) { lynx::support::saveState ({ launches, next, show }); };
- stateFile.deleteFile();
- for (int k = 0; k < 15; ++k)
- note.begin (true);
- note.pollForSnapshot();
- check ("test mode / CI runs: 15 starts, nothing counted, no file, no card", ! stateFile.existsAsFile() && ! note.isCardShowing());
- check ("a first start's defaults: next at start 10, shown", state() == lynx::supportnote::State { 0, 10, true });
- for (int k = 1; k <= 9; ++k)
- {
- note.begin (false);
- note.pollForSnapshot();
- }
- check ("starts 1 to 9: counted, no card", state().launches == 9 && ! note.isCardShowing());
- moment.playing = true;
- note.begin (false); // the 10th start
- note.pollForSnapshot();
- check ("10th start while playing: the card waits", state().launches == 10 && ! note.isCardShowing());
- moment = {};
- moment.dialogOpen = true;
- note.pollForSnapshot();
- check ("... and while a dialog is open", ! note.isCardShowing());
- moment = {};
- note.pollForSnapshot();
- check ("10th start, a quiet moment: the card shows", note.isCardShowing());
- check ("shown: left without an answer it comes back 30 starts later", state().nextAt == 40);
- if (auto* card = note.cardForSnapshot())
- {
- const auto b = card->getBounds();
- check ("the card sits in the bottom-right corner", b.getRight() <= ui.getWidth() - 8 && b.getRight() >= ui.getWidth() - 40
- && b.getBottom() <= ui.getHeight() - 4 && b.getBottom() >= ui.getHeight() - 40);
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, 1.0f), "note-in-window");
- writeImage (card->createComponentSnapshot (card->getLocalBounds(), true, 2.0f), "note@2x");
- // the corner of the window around the card, at 2x
- writeImage (ui.createComponentSnapshot (b.expanded (220, 120).getIntersection (ui.getLocalBounds()), true, 2.0f), "note-corner@2x");
- }
- moment.playing = true;
- note.pollForSnapshot();
- check ("playback starts: the card steps aside", ! note.isCardShowing());
- moment = {};
- // Not now: again after 30 more starts
- setState (10, 10, true);
- note.begin (false); // start 11
- note.pollForSnapshot();
- if (auto* card = note.cardForSnapshot(); card != nullptr && card->buttonForSnapshot (lynx::supportnote::Choice::notNow) != nullptr)
- card->buttonForSnapshot (lynx::supportnote::Choice::notNow)->onClick();
- note.closeCard(); // (the click closes it on the next message turn)
- check ("Not now: next at start 41", state() == lynx::supportnote::State { 11, 41, true });
- for (int k = 12; k <= 40; ++k)
- {
- note.begin (false);
- note.pollForSnapshot();
- if (note.isCardShowing())
- break;
- }
- check ("Not now: starts 12 to 40 without the card", ! note.isCardShowing() && state().launches == 40);
- note.begin (false);
- note.pollForSnapshot();
- check ("Not now: the card again at start 41", note.isCardShowing());
- // Don't show again: never, and Settings shows the box unticked
- if (auto* card = note.cardForSnapshot())
- card->buttonForSnapshot (lynx::supportnote::Choice::never)->onClick();
- note.closeCard();
- check ("Don't show again: off", ! state().show && ! lynx::support::noteEnabled());
- for (int k = 0; k < 200; ++k)
- {
- note.begin (false);
- note.pollForSnapshot();
- }
- check ("Don't show again: 200 more starts, never", ! note.isCardShowing());
- // Support: opens the Support window (on the next message turn) and the note doesn't come back
- setState (20, 10, true);
- note.begin (false);
- note.pollForSnapshot();
- if (auto* card = note.cardForSnapshot())
- card->buttonForSnapshot (lynx::supportnote::Choice::support)->onClick();
- note.closeCard();
- check ("Support: the note has done its job", ! state().show);
- // Settings off: never; on again: counts from now
- setState (5, 10, true);
- lynx::support::setNoteEnabled (false);
- for (int k = 0; k < 100; ++k)
- {
- note.begin (false);
- note.pollForSnapshot();
- }
- check ("Settings off: 100 starts, never", ! note.isCardShowing() && state().launches == 105);
- lynx::support::setNoteEnabled (true);
- check ("Settings on again: next 30 starts later", state() == lynx::supportnote::State { 105, 135, true });
- note.closeCard();
- }
- stateFile.deleteFile();
- if (hadState)
- stateFile.replaceWithText (oldState);
- line (ok ? "result=OK" : "result=FAILED");
- return ok;
- }
- bool runSimpleCloseTest (const juce::String& reportPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String report;
- bool ok = true;
- const auto line = [&report, &reportPath] (const juce::String& text) {
- report << text << "\n";
- juce::File (reportPath).replaceWithText (report); // (written as it goes: a crash still leaves the last step)
- };
- const auto check = [&line, &ok] (const juce::String& what, bool good) {
- line ((good ? "ok " : "FAIL ") + what);
- ok = ok && good;
- };
- const auto aliveBefore = lynx::SimpleWorkflow::alive.load();
- {
- lynx::AudioEngine offline (false);
- {
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- ui.setVisible (true); // (no window: the docked editor and the tour only need their parents visible)
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- settle();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- check ("the Simple workflow is up", simple != nullptr);
- if (simple != nullptr)
- {
- const auto empty = lynx::builtInTemplateIndex ("Empty");
- offline.setSong (empty >= 0 ? lynx::makeNewProject (empty) : lynx::makeNewProject());
- settle();
- simple->showWelcome();
- settle();
- auto* tour = simple->tourForSnapshot();
- check ("Welcome screen shown", tour != nullptr && tour->isWelcomeShowing());
- simple->startOrContinueTour();
- settle();
- simple->doTourStep (lynx::tour::beat);
- settle();
- check ("the tour runs with its card up", simple->tourRunning() && tour != nullptr && tour->cardForSnapshot() != nullptr);
- // a demo song from Start from (the panel stays up over the Playlist)
- if (auto* start = simple->startFromForSnapshot(); start != nullptr && lynx::demos::count > 1)
- {
- offline.setSong (lynx::demos::make (1));
- settle();
- check ("a demo song opened, Start from up", simple->isStartFromShowing() && ! offline.getSong().playlist.empty());
- }
- // the dock on a track, every tab (the Editor tab docks the Piano roll)
- if (auto* dock = simple->dockForSnapshot())
- {
- simple->trackSelected ([] (const lynx::Song& song) { // the first Instrument track (the dock's Keyboard and Editor tabs are for it)
- for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
- if (lynx::simpletracks::kindOf (song, t) == lynx::simpletracks::Kind::instrument)
- return t;
- return 0;
- } (offline.getSong()));
- for (auto tab : { lynx::SimpleDock::Tab::instrument, lynx::SimpleDock::Tab::keyboard, lynx::SimpleDock::Tab::editor,
- lynx::SimpleDock::Tab::effects, lynx::SimpleDock::Tab::editor })
- {
- dock->setTab (tab);
- settle();
- }
- check ("the dock shows", simple->isDockShowing());
- line ("dock tab at the close: " + juce::String ((int) dock->getTab()) + " (2 = Editor, the docked Piano roll)");
- }
- ui.toggleLyrics(); // (Lyrics, then Finish: they share the dock on the right)
- settle();
- simple->showFinish();
- settle();
- check ("Finish open", simple->isFinishShowing());
- simple->showChooser();
- settle();
- line ("Simple workflow objects alive before the close: " + juce::String (lynx::SimpleWorkflow::alive.load() - aliveBefore));
- }
- } // (the main window goes as at shutdown)
- check ("no Simple workflow outlived its main window's destructor body (it reaches the Workspace)",
- lynx::MainComponent::simpleWorkflowAliveAfterTeardown == aliveBefore);
- check ("none left after the close", lynx::SimpleWorkflow::alive.load() == aliveBefore);
- // Simple, then Pattern, then Simple again, and closed
- {
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- ui.setVisible (true);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- offline.dispatchPendingMessages();
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- if (auto* simple = ui.getSimpleWorkflowForSnapshot())
- simple->showWelcome();
- offline.dispatchPendingMessages();
- }
- check ("Simple -> Pattern -> Simple, closed: none outlived the destructor body", lynx::MainComponent::simpleWorkflowAliveAfterTeardown == aliveBefore
- && lynx::SimpleWorkflow::alive.load() == aliveBefore);
- }
- line (ok ? "result=OK" : "result=FAILED");
- return ok;
- }
- void runTour190dvShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- ui.setVisible (true); // (no window: the docked editor and the ring's targets only need their parents visible)
- const auto writeImage = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = juce::File (prefix + "-" + name + ".png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- juce::String report;
- // (written as it goes: a run that stops halfway still leaves its checks)
- const auto line = [&report, &prefix] (const juce::String& text) {
- report << text << "\n";
- juce::File (prefix + "-report.txt").replaceWithText (report);
- };
- const auto check = [&line] (const juce::String& what, bool ok) { line ((ok ? "OK " : "ERROR ") + what); };
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- auto* tour = simple != nullptr ? simple->tourForSnapshot() : nullptr;
- if (tour == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText ("ERROR no Simple workflow / tour\n");
- return;
- }
- check ("no Welcome screen by itself in a --snapshot route (not a real first start)", ! tour->isWelcomeShowing());
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- const auto window = [&] (const juce::String& name, bool twoX = false) {
- settle();
- tour->ringForSnapshot(); // (the ring follows the layout: resolved now, as its timer would)
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, 1.0f), name);
- if (twoX)
- if (auto* card = tour->cardForSnapshot(); card != nullptr && card->getParentComponent() != nullptr)
- writeImage (card->createComponentSnapshot (card->getLocalBounds(), true, 2.0f), name + "-card@2x");
- };
- const auto stepIs = [&] (int step, const juce::String& target) {
- settle();
- const auto ring = tour->ringForSnapshot();
- const auto id = tour->targetIdForSnapshot();
- line ("step " + juce::String (tour->step() + 1) + " (" + lynx::tour::stepId (tour->step()) + "): ring on " + (id.isEmpty() ? juce::String ("-") : id) + " "
- + ring.toString());
- check (juce::String ("the card shows step ") + lynx::tour::stepId (step), tour->isRunning() && tour->step() == step);
- if (target.isNotEmpty())
- check ("the ring is on " + target, id == target && ! ring.isEmpty());
- };
- // --- the Welcome screen (on a new, empty project: the built-in "Empty" template, as File › New can give) -------------
- const auto emptyProject = [] {
- const auto index = lynx::builtInTemplateIndex ("Empty");
- return index >= 0 ? lynx::makeNewProject (index) : lynx::makeNewProject();
- };
- offline.setSong (emptyProject());
- settle();
- check ("the new project is empty for the Simple workflow (it opens on the chooser)", lynx::simpletracks::isEmptySong (offline.getSong()));
- simple->showWelcome();
- settle();
- check ("Help › Welcome screen shows it", tour->isWelcomeShowing());
- window ("welcome");
- if (auto* w = tour->welcomeForSnapshot())
- writeImage (w->createComponentSnapshot (w->getLocalBounds(), true, 2.0f), "welcome@2x");
- tour->clickForSnapshot ("welcome.tour");
- settle();
- check ("Make my first song: the Welcome screen closes, the tour starts, the chooser comes up for the beat",
- ! tour->isWelcomeShowing() && tour->isRunning() && simple->isChooserShowing());
- // --- step 1: the beat ---------------------------------------------------------------------------------------------
- stepIs (lynx::tour::beat, "simple.tile.drums");
- window ("step1-beat", true);
- simple->showStarterPageForSnapshot();
- stepIs (lynx::tour::beat, "simple.starters");
- window ("step1-beat-starters");
- tour->clickForSnapshot ("do");
- settle();
- check ("Do it for me added a starter beat", lynx::tour::hasBeat (offline.getSong()));
- // --- step 2: the key ----------------------------------------------------------------------------------------------
- stepIs (lynx::tour::key, "toolbar.key");
- window ("step2-key", true);
- tour->clickForSnapshot ("do");
- settle();
- check ("Do it for me set A minor", lynx::projectkey::get (offline.getSong()).has_value());
- // --- step 3: an instrument (Add track opens the chooser: the ring moves to its tile) ------------------------------
- stepIs (lynx::tour::instrument, "simple.addTrack");
- window ("step3-instrument", true);
- simple->showChooser();
- stepIs (lynx::tour::instrument, "simple.tile.instrument");
- window ("step3-instrument-chooser");
- tour->clickForSnapshot ("do");
- settle();
- check ("Do it for me added an Instrument track (the chooser closed)", lynx::tour::firstInstrumentTrack (offline.getSong()) >= 0 && ! simple->isChooserShowing());
- // --- step 4: chords -----------------------------------------------------------------------------------------------
- stepIs (lynx::tour::chords, "keyboard.chordPad");
- window ("step4-chords", true);
- tour->clickForSnapshot ("do");
- settle();
- check ("Do it for me wrote four chords (12 notes) on the instrument's pattern", [&] {
- const auto& song = offline.getSong();
- const auto p = lynx::simpletracks::patternOf (song, lynx::tour::firstInstrumentTrack (song));
- return p >= 0 && song.patterns[(std::size_t) p].notes.size() == 12;
- }());
- // --- step 5: a voice or a loop (no "Do it for me": a loop is dropped as a user would) ------------------------------
- stepIs (lynx::tour::loop, "simple.dropLane"); // (round 190jc, SG-18: it rang "+ Add track")
- window ("step5-loop", true);
- {
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190dv-loops");
- dir.deleteRecursively();
- dir.createDirectory();
- const auto wav = dir.getChildFile ("Warm Keys 120 Am.wav");
- const int frames = 192000;
- juce::AudioBuffer<float> audio (1, frames);
- for (int i = 0; i < frames; ++i)
- {
- const auto t = (double) i / 48000.0;
- double v = 0.0;
- for (const auto key : { 57, 60, 64 })
- v += std::sin (2.0 * juce::MathConstants<double>::pi * 440.0 * std::pow (2.0, (key - 69) / 12.0) * t);
- audio.setSample (0, i, (float) (0.1 * v * (1.0 - std::exp (-std::fmod (t, 0.5) * 60.0))));
- }
- {
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- }
- simple->dropFiles ({ wav.getFullPathName() }, 0);
- settle();
- check ("a dropped loop (A minor in its name) follows the key", [&] {
- for (const auto& c : offline.getSong().playlist)
- if (c.kind == lynx::ClipKind::audio)
- return c.followKey;
- return false;
- }());
- }
- // --- step 6: a one-knob effect --------------------------------------------------------------------------------------
- stepIs (lynx::tour::effect, "simple.dock.addEffect");
- window ("step6-effect", true);
- tour->clickForSnapshot ("do");
- settle();
- check ("Do it for me put Room on the instrument track", lynx::tour::hasOneKnob (offline.getSong()));
- // --- step 7: Finish -----------------------------------------------------------------------------------------------
- stepIs (lynx::tour::finish, "simple.finish");
- window ("step7-finish", true);
- tour->clickForSnapshot ("do");
- settle();
- check ("Do it for me opened Finish and chose Balanced", simple->isFinishShowing() && lynx::looks::present (offline.getSong()));
- // --- the end card, Back / Next, close -------------------------------------------------------------------------------
- settle();
- check ("the end card", tour->isRunning() && tour->step() == lynx::tour::stepCount);
- window ("end", true);
- tour->clickForSnapshot ("back");
- settle();
- check ("Back: the Finish step again, shown done (the tour waits for Next)", tour->step() == lynx::tour::finish
- && tour->machineForCheck().shownDone (offline.getSong()));
- window ("back-done", true);
- tour->clickForSnapshot ("next");
- settle();
- check ("Next: the end card again", tour->step() == lynx::tour::stepCount);
- check ("all seven steps done by the song", tour->machineForCheck().state().completed == 0x7fu);
- tour->clickForSnapshot ("close");
- settle();
- check ("closing the end card ends the tour (not continued from Help)", ! tour->isRunning() && ! tour->canContinue()
- && tour->machineForCheck().state().done);
- line ("-- paused tour");
- // --- a paused tour, the Help menu and the chooser's button ---------------------------------------------------------
- offline.setSong (emptyProject());
- settle();
- tour->machineForCheck() = lynx::tour::Machine {};
- simple->startOrContinueTour();
- settle();
- line ("-- do beat");
- simple->doTourStep (lynx::tour::beat);
- settle();
- check ("a new tour on an empty project: the beat done moves it to the key", tour->step() == lynx::tour::key);
- tour->clickForSnapshot ("close");
- settle();
- check ("closing the card pauses the tour (Help continues it)", ! tour->isRunning() && tour->canContinue());
- line ("-- help menu");
- {
- const auto help = ui.getMenuForSnapshot (ui.getMenuNamesForSnapshot().indexOf (lynx::tr ("Help")));
- bool continueItem = false, welcomeItem = false;
- for (juce::PopupMenu::MenuItemIterator it (help); it.next();)
- {
- continueItem = continueItem || it.getItem().text.startsWith (lynx::tr ("Continue the first-song tour (step {0} of {1})", { "2", "7" }));
- welcomeItem = welcomeItem || it.getItem().text == lynx::tr ("Welcome screen...");
- }
- check ("Help: Continue the first-song tour (step 2 of 7) and Welcome screen...", continueItem && welcomeItem);
- saveMenus ({ lynx::tr ("Help") }, { help }, prefix + "-menu-help.png");
- }
- simple->startOrContinueTour();
- settle();
- check ("Help › Continue: back on the key step", tour->isRunning() && tour->step() == lynx::tour::key);
- tour->clickForSnapshot ("skip");
- settle();
- check ("Skip tour ends it", ! tour->isRunning() && ! tour->canContinue());
- offline.setSong (emptyProject());
- settle();
- simple->showChooser();
- window ("chooser");
- line ("-- start from");
- // --- Start from: the three demo songs; a demo opened in Simple -------------------------------------------------------
- if (auto* start = simple->startFromForSnapshot())
- {
- settle();
- writeImage (start->createComponentSnapshot (start->getLocalBounds(), true, 1.0f), "startfrom");
- const auto list = lynx::startfrom::entries();
- int demos = 0;
- for (const auto& e : list)
- demos += e.kind == lynx::startfrom::Entry::Kind::demo && e.playable ? 1 : 0;
- check ("Start from lists three playable demo songs first", demos == 3 && list.size() >= 3 && list[1].demo == 1 && list[2].demo == 2);
- for (int d = 1; d < 3 && d < (int) list.size(); ++d)
- line ("demo " + list[(std::size_t) d].name + ": " + juce::String (list[(std::size_t) d].bpm) + " BPM, " + juce::String (list[(std::size_t) d].bars) + " bars");
- simple->hideStartFrom();
- }
- line ("-- demos");
- for (int d = 1; d < lynx::demos::count; ++d)
- {
- offline.setSong (lynx::demos::make (d));
- settle();
- simple->hideChooser();
- window (juce::String ("demo-") + (d == 1 ? "hiphop" : "pop"));
- // the committed file is the generated song
- const auto file = juce::File::getCurrentWorkingDirectory().getChildFile ("resources/demos").getChildFile (lynx::demos::fileName (d));
- juce::String error;
- const auto loaded = lynx::ProjectFile::load (file, error);
- check ("resources/demos/" + juce::String (lynx::demos::fileName (d)) + " loads and is the generated song",
- loaded.has_value() && lynx::ProjectFile::toJson (*loaded, false) == lynx::ProjectFile::toJson (lynx::demos::make (d), false));
- }
- line (report.contains ("ERROR ") ? "RESULT ERROR" : "RESULT OK");
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- // --patterns190ea (round 190ea): FL keeps at least one pattern; the engine now does too (AudioEngine::publishSong,
- // Song::keepOnePattern). Before, a Song without a pattern crashed the docked Piano roll's listener.
- bool runPatterns190ea (const juce::String& reportPath)
- {
- namespace st = lynx::simpletracks;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- ui.setVisible (true); // (no window: the docked editor only needs its parents visible)
- juce::String report;
- bool ok = true;
- const auto check = [&report, &ok] (const juce::String& what, bool good) {
- report << (good ? "OK " : "ERROR ") << what << "\n";
- ok = ok && good;
- };
- const auto save = [&report, &reportPath] { juce::File (reportPath).replaceWithText (report); };
- const auto settle = [&] { offline.dispatchPendingMessages(); ui.getPianoRollForSnapshot().repaint(); };
- const auto onePattern = [&offline] {
- const auto& s = offline.getSong();
- return s.patterns.size() >= 1 && s.currentPattern >= 0 && s.currentPattern < (int) s.patterns.size();
- };
- // the hand-built songs the engine can be given: none of them has a pattern
- const auto bare = [] {
- lynx::Song s;
- s.mixer = lynx::Song::defaultMixer();
- return s;
- };
- // every way to reach "no pattern" in the current layout
- const auto paths = [&] (const juce::String& where) {
- offline.setSong (bare());
- settle();
- check (where + ": a song without a pattern opens with one empty \"Pattern 1\"",
- onePattern() && offline.getSong().patterns.size() == 1 && offline.getSong().patterns[0].name == "Pattern 1"
- && offline.getSong().patterns[0].notes.empty());
- offline.editSong ([] (lynx::Song& s) { s.patterns.clear(); });
- settle();
- check (where + ": an edit that clears every pattern leaves one", onePattern());
- offline.editSong ([] (lynx::Song& s) {
- s.patterns.resize (2);
- s.patterns[1].notes.push_back ({});
- s.currentPattern = 1;
- });
- settle();
- offline.editSong ([] (lynx::Song& s) { s.removePattern (s.currentPattern); });
- offline.editSong ([] (lynx::Song& s) { s.removePattern (s.currentPattern); });
- settle();
- check (where + ": deleting the last pattern leaves an empty \"Pattern 1\" (FL's invariant)",
- onePattern() && offline.getSong().patterns.size() == 1 && offline.getSong().patterns[0].notes.empty());
- for (int k = 0; k < 6; ++k)
- {
- offline.undo();
- settle();
- }
- check (where + ": undo back over those steps keeps a pattern", onePattern());
- for (int k = 0; k < 6; ++k)
- {
- offline.redo();
- settle();
- }
- check (where + ": redo keeps a pattern", onePattern());
- offline.applyRemote (bare());
- settle();
- check (where + ": a live session's remote song without a pattern gets one", onePattern());
- offline.editSong ([] (lynx::Song& s) { s.currentPattern = 99; });
- settle();
- check (where + ": a current pattern out of range is put back in range", onePattern() && offline.getSong().currentPattern == 0);
- };
- // the Simple layout with the Piano roll docked in the Editor tab (round 190dv's crash)
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- settle();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- check ("the Simple workflow is up", simple != nullptr);
- if (simple == nullptr)
- {
- save();
- return false;
- }
- simple->hideChooser();
- st::Request q;
- q.kind = st::Kind::instrument;
- q.name = "Keys";
- lynx::ChannelDef synth;
- synth.instrument = lynx::InstrumentKind::synth;
- q.channel = synth;
- q.emptyBars = 4;
- st::Result r;
- offline.editSong ([&] (lynx::Song& s) { r = st::addTrack (s, q); });
- settle();
- ui.getPlaylistForSnapshot().selectTrack (r.track);
- simple->trackSelected (r.track);
- settle();
- auto* dock = simple->dockForSnapshot();
- check ("the instrument track's dock has the Editor tab", dock != nullptr && dock->hasPlayTabsForCheck());
- if (dock != nullptr)
- dock->setTab (lynx::SimpleDock::Tab::editor);
- settle();
- check ("the Piano roll is docked in the Editor tab", dock != nullptr && dock->isEditorDocked() && dock->isParentOf (&ui.getPianoRollForSnapshot()));
- paths ("Simple, Editor tab");
- // the Pattern layout with the Piano roll panel, then the Clip-launch layout
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- settle();
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::pianoRoll });
- settle();
- paths ("Pattern layout, Piano roll");
- ui.setLayoutStyle (lynx::layoutstyle::Style::clipLaunch);
- settle();
- paths ("Clip-launch layout");
- report << (ok ? "RESULT OK\n" : "RESULT FAILED\n");
- save();
- return ok;
- }
- // round 190fo: the Simple layout's Sampler track (16 pads) and a folder of stems and MIDI files, off-screen at 1x and
- // 2x, with a text report of the checks (.lynx round trip, kits, typing keys, the folder import)
- void runReabl190foShot (const juce::String& prefix)
- {
- namespace st = lynx::simpletracks;
- namespace sp = lynx::simplepads;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- ui.setVisible (true);
- const auto writeImage = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = juce::File (prefix + "-" + name + ".png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- juce::String report;
- const auto line = [&report] (const juce::String& text) { report << text << "\n"; };
- const auto check = [&report] (const juce::String& what, bool ok) { report << (ok ? "OK " : "ERROR ") << what << "\n"; };
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- if (simple == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText ("ERROR no Simple workflow\n");
- return;
- }
- const auto whole = [&] (const juce::String& name) {
- offline.dispatchPendingMessages();
- for (float scale : { 1.0f, 2.0f })
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, scale), name + (scale > 1.0f ? "@2x" : ""));
- };
- // the chooser: the Sampler tile (16 pads, "On keys..." for one sample over the keys) and Import's "Folder..."
- simple->showChooser();
- whole ("chooser");
- simple->hideChooser();
- // --- test sounds -------------------------------------------------------------------------------------------------
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190fo");
- dir.deleteRecursively();
- dir.createDirectory();
- const auto writeWav = [] (const juce::File& wav, int frames, const std::function<float (int)>& f) {
- juce::AudioBuffer<float> audio (1, frames);
- for (int i = 0; i < frames; ++i)
- audio.setSample (0, i, f (i));
- wav.getParentDirectory().createDirectory();
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- return wav;
- };
- juce::Random rnd (190);
- const auto pi = juce::MathConstants<double>::pi;
- const auto kick = writeWav (dir.getChildFile ("pads/Kick.wav"), 24000, [pi] (int i) {
- const auto t = i / 48000.0;
- return (float) (0.9 * std::sin (2.0 * pi * (50.0 * t + 60.0 * (1.0 - std::exp (-t * 30.0)) / 30.0)) * std::exp (-t * 7.0));
- });
- const auto snare = writeWav (dir.getChildFile ("pads/Snare.wav"), 14400, [&rnd] (int i) { return (float) ((rnd.nextFloat() * 2.0f - 1.0f) * 0.6f * std::exp (-i / 4000.0f)); });
- const auto hat = writeWav (dir.getChildFile ("pads/Hat.wav"), 4800, [&rnd] (int i) { return (float) ((rnd.nextFloat() * 2.0f - 1.0f) * 0.4f * std::exp (-i / 900.0f)); });
- const auto chord = writeWav (dir.getChildFile ("pads/Chord stab.wav"), 48000, [pi] (int i) {
- const auto t = i / 48000.0;
- double v = 0.0;
- for (int k : { 57, 60, 64 })
- v += std::sin (2.0 * pi * 440.0 * std::pow (2.0, (k - 69) / 12.0) * t);
- return (float) (0.2 * v * std::exp (-t * 2.5));
- });
- const auto vox = writeWav (dir.getChildFile ("pads/Vox hey.wav"), 30000, [pi] (int i) {
- const auto t = i / 48000.0;
- return (float) (0.5 * std::sin (2.0 * pi * 220.0 * t + 2.0 * std::sin (2.0 * pi * 660.0 * t)) * std::sin (pi * t / 0.625));
- });
- // --- the Sampler track ---------------------------------------------------------------------------------------------
- check ("the Sampler tile's track was added", simple->addPads());
- offline.dispatchPendingMessages();
- const auto& song0 = offline.getSong();
- int track = -1;
- for (int t = 0; t < (int) song0.playlistTracks.size() && track < 0; ++t)
- if (st::kindOf (song0, t) == st::Kind::pads)
- track = t;
- check ("a Sampler track with 16 pads", track >= 0 && [&] {
- const auto c = sp::padChannels (song0, track);
- return std::all_of (c.begin(), c.end(), [] (int i) { return i >= 0; });
- }());
- auto* dock = simple->dockForSnapshot();
- if (dock == nullptr || track < 0)
- {
- juce::File (prefix + "-report.txt").replaceWithText (report + "ERROR no dock / track\n");
- return;
- }
- simple->trackSelected (track);
- offline.dispatchPendingMessages();
- check ("the dock opens on the Pads tab", dock->hasPadsTabForCheck() && dock->getTab() == lynx::SimpleDock::Tab::pads);
- const auto shots = [&] (const juce::String& name) {
- offline.dispatchPendingMessages();
- for (float scale : { 1.0f, 2.0f })
- {
- const auto suffix = scale > 1.0f ? juce::String ("@2x") : juce::String();
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, scale), name + suffix);
- writeImage (dock->createComponentSnapshot (dock->getLocalBounds(), true, scale), "dock-" + name + suffix);
- }
- };
- shots ("pads-empty");
- const juce::File files[] { kick, snare, hat, hat, chord, vox };
- for (int p = 0; p < 6; ++p)
- dock->padsLoadForCheck (p, files[p]);
- offline.dispatchPendingMessages();
- check ("six pads hold a sound", [&] {
- int n = 0;
- for (int p = 0; p < sp::padCount; ++p)
- n += sp::hasSample (offline.getSong(), track, p) ? 1 : 0;
- return n == 6;
- }());
- // pad 3 = the open hat: one-shot, group 1 with pad 2 (closed hat), a colour; pad 4 = the chord, looped and darker
- dock->padsSelectForCheck (2);
- dock->padsModeForCheck (1);
- dock->padsSelectForCheck (3);
- dock->padsModeForCheck (1);
- offline.editSong ([track] (lynx::Song& s) {
- for (int p : { 2, 3 })
- if (const auto c = sp::padChannel (s, track, p); c >= 0)
- {
- s.channels[(std::size_t) c].simplePad.group = 1;
- s.channels[(std::size_t) c].simplePad.colour = 2;
- sp::apply (s.channels[(std::size_t) c], 4800);
- }
- });
- dock->padsSelectForCheck (4);
- dock->padsModeForCheck (2);
- dock->padsKnobForCheck (2, 0.3f); // tone: a low-pass
- dock->padsKnobForCheck (1, 0.35f); // release
- dock->padsRegionForCheck (0.05f, 0.7f);
- dock->padsNormalizeForCheck();
- dock->padsUpdateForCheck();
- {
- const auto& s = offline.getSong();
- const auto& c = s.channels[(std::size_t) sp::padChannel (s, track, 4)];
- line ("pad 5: mode " + juce::String ((int) c.simplePad.mode) + " tone " + juce::String (c.simplePad.tone, 2) + " cutoff " + juce::String (c.sampler.cutoff, 0)
- + " release " + juce::String (c.sampler.release, 3) + " region " + juce::String (c.sampler.regionStart, 2) + "-" + juce::String (c.sampler.regionEnd, 2)
- + " gain " + juce::String (c.sampler.gainDb, 2) + " dB zones " + juce::String ((int) c.zones.size()));
- check ("pad 5 loops its region, darker, normalized", c.simplePad.mode == 2 && c.zones.size() == 1 && c.zones[0].loopMode == 2 && c.simplePad.tone < -0.3f
- && c.sampler.filterType == 0 && c.sampler.cutoff < 5000.0f && c.sampler.gainDb > 0.5f);
- const auto& h = s.channels[(std::size_t) sp::padChannel (s, track, 3)];
- check ("the hats share a choke group of this insert", h.cutGroup > 1000 && h.cutGroup == s.channels[(std::size_t) sp::padChannel (s, track, 2)].cutGroup);
- }
- shots ("pads");
- dock->padsHitForCheck (0);
- dock->lightPad (2);
- shots ("pads-hit");
- // the typing keys: V plays pad 1, M pad 4, 7 pad 16; Z is not a pad key
- check ("typing keys reach the pads", simple->padChannelForKey ('V') == sp::padChannel (offline.getSong(), track, 0)
- && simple->padChannelForKey ('m') == sp::padChannel (offline.getSong(), track, 3)
- && simple->padChannelForKey ('7') == sp::padChannel (offline.getSong(), track, 15)
- && simple->padChannelForKey ('Z') == -1);
- // drag pad 6 (vox) onto the empty pad 9: it moves; Alt-drag pad 1 onto pad 10: a copy
- dock->padsDragForCheck (5, 8, false);
- dock->padsDragForCheck (0, 9, true);
- check ("a pad moved and a pad copied", ! sp::hasSample (offline.getSong(), track, 5) && sp::hasSample (offline.getSong(), track, 8)
- && sp::hasSample (offline.getSong(), track, 9) && sp::hasSample (offline.getSong(), track, 0));
- dock->padsSelectForCheck (4);
- shots ("pads-moved");
- saveMenus ({ "Pad menu", "Colour", "Copy a value to every pad" }, [&] {
- const auto top = dock->padMenuForSnapshot (4);
- std::vector<juce::PopupMenu> menus { top };
- for (juce::PopupMenu::MenuItemIterator it (top); it.next();)
- if (it.getItem().subMenu != nullptr)
- menus.push_back (*it.getItem().subMenu);
- return menus;
- }(), prefix + "-menu-pad.png");
- // kits: saved, the pads cleared, opened again
- const auto kitFile = lynx::platform::documentsFolder().getChildFile ("LYNX/Sampler kits/Test kit 190fo.lynxkit");
- kitFile.deleteFile();
- check ("the pads saved as a kit", dock->saveKitForCheck ("Test kit 190fo") && kitFile.existsAsFile());
- saveMenus ({ "Kit", "My kits" }, [&] {
- const auto top = dock->kitMenuForSnapshot();
- std::vector<juce::PopupMenu> menus { top };
- for (juce::PopupMenu::MenuItemIterator it (top); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == lynx::tr ("My kits"))
- menus.push_back (*it.getItem().subMenu);
- return menus;
- }(), prefix + "-menu-kit.png");
- const auto before = offline.getSong().channels;
- offline.editSong ([track] (lynx::Song& s) {
- for (int p = 0; p < sp::padCount; ++p)
- sp::clearPad (s, track, p);
- });
- check ("the kit opens the same pads again", dock->openKitForCheck (kitFile) && [&] {
- const auto& now = offline.getSong().channels;
- for (int p = 0; p < sp::padCount; ++p)
- {
- const auto c = sp::padChannel (offline.getSong(), track, p);
- if (c < 0 || now[(std::size_t) c].samplePath != before[(std::size_t) c].samplePath || now[(std::size_t) c].simplePad != before[(std::size_t) c].simplePad
- || now[(std::size_t) c].sampler.release != before[(std::size_t) c].sampler.release || now[(std::size_t) c].zones != before[(std::size_t) c].zones)
- return false;
- }
- return true;
- }());
- {
- const auto renamed = kitFile.getSiblingFile ("Renamed kit 190fo.lynxkit");
- renamed.deleteFile();
- check ("a kit renamed (and a one-letter name refused)", ! lynx::SimpleDock::renameKitForCheck (kitFile, "x")
- && lynx::SimpleDock::renameKitForCheck (kitFile, "Renamed kit 190fo") && renamed.existsAsFile()
- && ! kitFile.exists());
- renamed.deleteFile();
- }
- kitFile.deleteFile();
- // a beat on the pads (the track's pattern) and the .lynx round trip
- offline.editSong ([track] (lynx::Song& s) {
- const auto pattern = [&] {
- for (const auto& c : s.playlist)
- if (c.track == track && c.kind == lynx::ClipKind::pattern)
- return c.pattern;
- return -1;
- }();
- if (pattern < 0)
- return;
- for (int step = 0; step < 16; ++step)
- {
- const int pad = step % 4 == 0 ? 0 : step % 8 == 4 ? 1 : 2;
- lynx::Note n;
- n.channel = sp::padChannel (s, track, pad);
- n.key = sp::padKey;
- n.start = (std::int64_t) step * lynx::ticksPerStep;
- n.length = lynx::ticksPerStep;
- s.patterns[(std::size_t) pattern].notes.push_back (n);
- }
- });
- {
- const auto json = lynx::ProjectFile::toJson (offline.getSong());
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (json, error);
- bool same = back.has_value() && back->channels.size() == offline.getSong().channels.size() && st::kindOf (*back, track) == st::Kind::pads;
- for (std::size_t c = 0; same && c < back->channels.size(); ++c)
- {
- const auto& a = back->channels[c];
- const auto& b = offline.getSong().channels[c];
- same = a.simplePad == b.simplePad && a.zones == b.zones && a.cutGroup == b.cutGroup && a.cutBy == b.cutBy && a.samplePath == b.samplePath
- && a.sampler.regionStart == b.sampler.regionStart && a.sampler.release == b.sampler.release && a.sampler.cutoff == b.sampler.cutoff;
- }
- check ("pads, their modes, groups and loops survive .lynx", same);
- lynx::Song plain = lynx::Song::makeDefault();
- check ("a project without pads writes no pad field", ! lynx::ProjectFile::toJson (plain).contains ("simplePad"));
- }
- ui.getPlaylistForSnapshot().selectTrack (track);
- // --- a folder of stems and MIDI files (the other app's "download stems" naming) --------------------------------------
- const auto stems = dir.getChildFile ("My song stems");
- writeWav (stems.getChildFile ("01_Drums.wav"), 96000, [&rnd] (int i) { return (i % 24000) < 2000 ? (rnd.nextFloat() - 0.5f) * 0.8f : 0.0f; });
- writeWav (stems.getChildFile ("02_Bass.wav"), 96000, [pi] (int i) { return (float) (0.3 * std::sin (2.0 * pi * 55.0 * i / 48000.0)); });
- writeWav (stems.getChildFile ("10_Lead Vox.wav"), 96000, [pi] (int i) { return (float) (0.2 * std::sin (2.0 * pi * 330.0 * i / 48000.0)); });
- {
- juce::MidiMessageSequence seq;
- for (int k = 0; k < 8; ++k)
- {
- seq.addEvent (juce::MidiMessage::noteOn (1, 36 + (k % 4) * 3, (juce::uint8) 100), k * 480.0);
- seq.addEvent (juce::MidiMessage::noteOff (1, 36 + (k % 4) * 3), k * 480.0 + 400.0);
- }
- seq.updateMatchedPairs();
- juce::MidiFile midi;
- midi.setTicksPerQuarterNote (960);
- midi.addTrack (seq);
- for (const auto& name : { "02_Bass.mid", "03_Keys.mid" })
- {
- juce::FileOutputStream out (stems.getChildFile (name));
- midi.writeTo (out);
- }
- }
- const auto tracksBefore = [&] {
- int n = 0;
- for (int t = 0; t < (int) offline.getSong().playlistTracks.size(); ++t)
- n += st::kindOf (offline.getSong(), t).has_value() ? 1 : 0;
- return n;
- }();
- simple->addFilesForCheck ({ stems });
- offline.dispatchPendingMessages();
- {
- const auto& s = offline.getSong();
- juce::StringArray names;
- int muted = 0, count = 0;
- for (int t = 0; t < (int) s.playlistTracks.size(); ++t)
- if (st::kindOf (s, t).has_value())
- {
- ++count;
- if (count > tracksBefore)
- {
- names.add (juce::String::fromUTF8 (s.playlistTracks[(std::size_t) t].name.c_str()) + (s.playlistTracks[(std::size_t) t].muted ? " (muted)" : ""));
- muted += s.playlistTracks[(std::size_t) t].muted ? 1 : 0;
- }
- }
- line ("folder tracks: " + names.joinIntoString (", "));
- check ("the folder gave 5 tracks in number order, named without numbers, the Bass notes muted (its stem plays)",
- names == juce::StringArray { "Drums", "Bass", "Lead Vox", "Bass 2 (muted)", "Keys" } && muted == 1);
- bool atZero = true;
- for (const auto& c : s.playlist)
- if (c.track >= 0 && st::kindOf (s, c.track) == st::Kind::audio)
- atZero = atZero && c.start == 0;
- check ("every stem starts at the song's start", atZero);
- }
- simple->hideChooser();
- whole ("folder-import");
- dir.deleteRecursively();
- line (report.contains ("ERROR ") ? "RESULT ERROR" : "RESULT OK");
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- void runSimple190dsShot (const juce::String& prefix)
- {
- namespace st = lynx::simpletracks;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- ui.setVisible (true); // (no window: the docked editor only needs its parents visible)
- const auto writeImage = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = juce::File (prefix + "-" + name + ".png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- juce::String report;
- const auto line = [&report] (const juce::String& text) { report << text << "\n"; };
- const auto check = [&report] (const juce::String& what, bool ok) { report << (ok ? "OK " : "ERROR ") << what << "\n"; };
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- if (simple == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText ("ERROR no Simple workflow\n");
- return;
- }
- simple->hideChooser();
- auto& playlist = ui.getPlaylistForSnapshot();
- // --- three loops: two with their key in the name, one only in its sound ---------------------------------------
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190ds-loops");
- dir.deleteRecursively();
- dir.createDirectory();
- // a chord loop (two bars at 120 BPM, 48 kHz): each chord's notes with six harmonics, a soft attack per beat
- const auto writeLoop = [&dir] (const juce::String& name, std::vector<std::vector<int>> chords) {
- const int frames = 192000;
- juce::AudioBuffer<float> audio (1, frames);
- audio.clear();
- for (int i = 0; i < frames; ++i)
- {
- const auto& chord = chords[(std::size_t) (i / (frames / (int) chords.size()))];
- const auto t = (double) i / 48000.0;
- const auto beat = std::fmod (t, 0.5);
- double v = 0.0;
- for (const auto key : chord)
- {
- const auto f = 440.0 * std::pow (2.0, (key - 69) / 12.0);
- for (int h = 1; h <= 6; ++h)
- v += std::sin (2.0 * juce::MathConstants<double>::pi * f * h * t) / (h * h);
- }
- audio.setSample (0, i, (float) (0.08 * v * (1.0 - std::exp (-beat * 60.0)) * (0.6 + 0.4 * std::exp (-beat * 3.0))));
- }
- const auto wav = dir.getChildFile (name);
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- return wav.getFullPathName();
- };
- const auto gMinor = writeLoop ("Night Pad 120 Gm.wav", { { 55, 58, 62 }, { 51, 55, 58 }, { 53, 57, 60 }, { 55, 58, 62 } });
- const auto dMinor = writeLoop ("Pluck_120_D_minor.wav", { { 50, 53, 57 }, { 46, 50, 53 }, { 48, 52, 55 }, { 50, 53, 57 } });
- const auto eMinor = writeLoop ("Warm Keys Loop 120 bpm.wav", { { 52, 55, 59, 64 }, { 48, 52, 55, 60 }, { 50, 54, 57, 62 }, { 52, 55, 59, 64 } });
- lynx::SimpleWorkflow::answerForSnapshot = 1; // "Set the project key to G minor?" — yes
- simple->dropFiles ({ gMinor, dMinor, eMinor }, 0);
- lynx::SimpleWorkflow::answerForSnapshot = -1;
- offline.dispatchPendingMessages();
- simple->hideChooser();
- line ("question: " + simple->lastKeyQuestionForCheck());
- check ("the first keyed loop offered its key (G minor)", simple->lastKeyQuestionForCheck().contains ("G minor"));
- {
- const auto& song = offline.getSong();
- const auto key = lynx::projectkey::get (song);
- check ("the project key is G minor", key && key->root == 7 && lynx::projectkey::isMinor (*key));
- std::vector<int> clips;
- for (int i = 0; i < (int) song.playlist.size(); ++i)
- if (song.playlist[(std::size_t) i].kind == lynx::ClipKind::audio)
- clips.push_back (i);
- check ("three loop clips", clips.size() == 3);
- const int expect[] { 0, 5, 3 }; // G minor, D minor (F -> Bb: +5), E minor detected (G -> Bb: +3)
- const int roots[] { 7, 2, 4 };
- const int sources[] { 1, 1, 2 };
- for (std::size_t k = 0; k < clips.size() && k < 3; ++k)
- {
- const auto& c = song.playlist[(std::size_t) clips[k]];
- const auto& sampler = song.channels[(std::size_t) c.channel].sampler;
- line ("loop " + juce::String ((int) k + 1) + ": key " + juce::String (sampler.loopKeyRoot) + (sampler.loopKeyMinor ? "m" : "") + " source "
- + juce::String ((int) sampler.loopKeySource) + " follow " + juce::String (c.followKey ? 1 : 0) + " shift " + juce::String ((int) c.keyShift)
- + " pitch " + juce::String (c.pitch));
- check ("loop " + juce::String ((int) k + 1) + " key, source and move", sampler.loopKeyRoot == roots[k] && sampler.loopKeyMinor
- && sampler.loopKeySource == sources[k] && c.followKey
- && c.keyShift == expect[k] && std::abs (c.pitch - (float) expect[k]) < 1.0e-4f);
- }
- }
- // the key changes: every following loop moves with it (one undo step)
- offline.editSong ([] (lynx::Song& s) { lynx::projectkey::set (s, lynx::projectkey::Key { 9, lynx::projectkey::commonFirst()[1] }); });
- offline.dispatchPendingMessages();
- {
- const auto& song = offline.getSong();
- std::vector<int> shifts;
- for (const auto& c : song.playlist)
- if (c.kind == lynx::ClipKind::audio)
- shifts.push_back (c.keyShift);
- line ("after A minor: " + juce::String (shifts.size() > 2 ? shifts[0] : 99) + " " + juce::String (shifts.size() > 2 ? shifts[1] : 99) + " "
- + juce::String (shifts.size() > 2 ? shifts[2] : 99));
- check ("A minor: the loops move by +2, -5, +5", shifts == std::vector<int> { 2, -5, 5 });
- }
- // the loop tracks in the dock: the switch and what it does
- int loopTrack = -1;
- for (const auto& c : offline.getSong().playlist)
- if (c.kind == lynx::ClipKind::audio && loopTrack < 0)
- loopTrack = c.track;
- playlist.selectTrack (loopTrack);
- offline.dispatchPendingMessages();
- auto* dock = simple->dockForSnapshot();
- if (dock == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText (report + "ERROR no dock\n");
- return;
- }
- simple->trackSelected (loopTrack);
- offline.dispatchPendingMessages();
- const auto shots = [&] (const juce::String& name) {
- offline.dispatchPendingMessages();
- for (float scale : { 1.0f, 2.0f })
- {
- const auto suffix = scale > 1.0f ? juce::String ("@2x") : juce::String();
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, scale), name + suffix);
- writeImage (dock->createComponentSnapshot (dock->getLocalBounds(), true, scale), "dock-" + name + suffix);
- }
- };
- const auto menuShot = [&] (const juce::PopupMenu& menu, const juce::String& title, const juce::String& subTitle, const juce::String& name) {
- juce::StringArray names { title };
- std::vector<juce::PopupMenu> menus { menu };
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text.startsWith (subTitle))
- {
- names.add (subTitle);
- menus.push_back (*it.getItem().subMenu);
- }
- saveMenus (names, menus, prefix + "-" + name + ".png");
- };
- check ("the dock shows the follow switch for the loop track", dock->followShownForCheck());
- shots ("follow-on");
- {
- int clip = -1;
- for (int i = 0; i < (int) offline.getSong().playlist.size() && clip < 0; ++i)
- if (offline.getSong().playlist[(std::size_t) i].kind == lynx::ClipKind::audio)
- clip = i;
- const auto menu = playlist.getClipMenuForSnapshot (clip);
- bool follow = false, keyItem = false;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- follow = follow || (it.getItem().text.startsWith (lynx::tr ("Follow the project key")) && it.getItem().isTicked);
- keyItem = keyItem || it.getItem().text.startsWith (lynx::tr ("Loop key"));
- }
- check ("the clip menu has Follow the project key (ticked) and Loop key", follow && keyItem);
- menuShot (menu, lynx::tr ("Audio clip"), lynx::tr ("Loop key"), "menu-clip-key");
- }
- dock->clickFollowForCheck(); // off: back to its own key
- offline.dispatchPendingMessages();
- {
- float pitch = 99.0f;
- bool following = true;
- for (const auto& c : offline.getSong().playlist)
- if (c.kind == lynx::ClipKind::audio && c.track == loopTrack)
- pitch = c.pitch, following = c.followKey;
- check ("switched off: the loop plays in its own key (pitch 0)", ! following && std::abs (pitch) < 1.0e-6f);
- }
- shots ("follow-off");
- dock->clickFollowForCheck();
- offline.dispatchPendingMessages();
- // --- an instrument track from the tile: a pattern to write into, the Editor tab ------------------------------
- {
- st::Request q;
- q.kind = st::Kind::instrument;
- q.name = "Keys";
- lynx::ChannelDef synth;
- synth.instrument = lynx::InstrumentKind::synth;
- q.channel = synth;
- q.emptyBars = 4;
- st::Result r;
- offline.editSong ([&] (lynx::Song& s) { r = st::addTrack (s, q); });
- offline.dispatchPendingMessages();
- check ("the new Instrument track has an empty 4-bar pattern on it", r.ok() && r.pattern >= 0
- && st::patternOf (offline.getSong(), r.track) == r.pattern
- && offline.getSong().patterns[(std::size_t) r.pattern].notes.empty());
- // a few notes, as the first clicks would write them (A minor: A C E, then G B D)
- offline.editSong ([r] (lynx::Song& s) {
- auto& p = s.patterns[(std::size_t) r.pattern];
- const int keys[] { 57, 60, 64, 67, 71, 74, 69, 72 };
- for (int i = 0; i < 8; ++i)
- {
- lynx::Note n;
- n.channel = r.channels.front();
- n.key = keys[i];
- n.start = (std::int64_t) (i / 3) * lynx::ppq * 2 + (i % 3 == 0 ? 0 : 0);
- n.length = lynx::ppq * 2;
- n.velocity = 0.8f;
- p.notes.push_back (n);
- }
- p.sortNotes();
- });
- offline.dispatchPendingMessages();
- playlist.selectTrack (r.track);
- simple->trackSelected (r.track);
- offline.dispatchPendingMessages();
- check ("the instrument track has the Keyboard and Editor tabs", dock->hasPlayTabsForCheck());
- dock->setTab (lynx::SimpleDock::Tab::editor);
- offline.dispatchPendingMessages();
- check ("the Piano roll is docked in the Editor tab", dock->isEditorDocked());
- check ("on the track's pattern", offline.getSong().currentPattern == r.pattern);
- ui.getPianoRollForSnapshot().scrollToNotes(); // (done asynchronously when it docks)
- shots ("editor");
- dock->clickFoldForCheck (true); // "Only notes in key"
- check ("Only notes in key folds the rows to A minor", ui.getPianoRollForSnapshot().isFoldedToScale());
- ui.getPianoRollForSnapshot().scrollToNotes();
- shots ("editor-in-key");
- dock->clickFoldForCheck (false);
- // --- the keyboard's modes ------------------------------------------------------------------------------
- auto& keyboard = lynx::scalekeys::current();
- const auto saved = keyboard;
- keyboard = {};
- keyboard.lockToKey = true;
- dock->setTab (lynx::SimpleDock::Tab::keyboard);
- if (auto* panel = dock->keyboardPanelForSnapshot())
- {
- lynx::refreshKeyboardPanel (*panel);
- shots ("keys-locked");
- keyboard.lockToKey = false;
- keyboard.mode = lynx::scalekeys::Mode::scaleKeys;
- lynx::refreshKeyboardPanel (*panel);
- shots ("scale-keys");
- keyboard.mode = lynx::scalekeys::Mode::chordPad;
- keyboard.complexity = lynx::scalekeys::Complexity::seventh;
- keyboard.strumMs = 40;
- lynx::refreshKeyboardPanel (*panel);
- shots ("chord-pad");
- }
- check ("the Keyboard tab shows the keyboard panel", dock->keyboardPanelForSnapshot() != nullptr);
- // the same panel as the Touch keyboard window, each mode with a key / pad held
- for (const auto& [mode, name, pressed] : { std::tuple { lynx::scalekeys::Mode::scaleKeys, juce::String ("window-scale-keys"), 4 },
- std::tuple { lynx::scalekeys::Mode::chordPad, juce::String ("window-chord-pad"), 3 } })
- {
- auto panel = lynx::makeKeyboardPanelForSnapshot (offline, mode, pressed, [ch = r.channels.front()] { return ch; });
- panel->setSize (1100, 260);
- for (float scale : { 1.0f, 2.0f })
- writeImage (panel->createComponentSnapshot (panel->getLocalBounds(), true, scale), name + (scale > 1.0f ? "@2x" : ""));
- if (mode == lynx::scalekeys::Mode::chordPad)
- menuShot (lynx::chordPadMenuForSnapshot (*panel, 3), lynx::tr ("Edit chord"), lynx::tr ("Chord type"), "menu-chord-edit");
- }
- // the Chord pad on an FL Studio Mobile chord set (the default set's shape: C Dm Em F G Am B° C)
- {
- const auto set = lynx::scalekeys::parseFlmChordSet (R"({"chords":[{"baseNote":0,"extensions":[],"octave":3,"quality":0},{"baseNote":2,"extensions":[],"octave":3,"quality":1},{"baseNote":4,"extensions":[],"octave":3,"quality":1},{"baseNote":5,"extensions":[],"octave":3,"quality":0},{"baseNote":7,"extensions":[],"octave":3,"quality":0},{"baseNote":9,"extensions":[],"octave":3,"quality":1},{"baseNote":11,"extensions":[],"octave":3,"quality":3},{"baseNote":0,"extensions":[],"octave":4,"quality":0}],"rootNote":0})");
- check ("an FLM chord set reads as 8 chords (B diminished)", set.size() == 8 && set[6].quality == 3);
- offline.editSong ([set] (lynx::Song& s) { s.keyboardChords = set; });
- keyboard.projectChords = true;
- keyboard.complexity = lynx::scalekeys::Complexity::triad;
- auto panel = lynx::makeKeyboardPanelForSnapshot (offline, lynx::scalekeys::Mode::chordPad, 5, [ch = r.channels.front()] { return ch; });
- panel->setSize (1100, 260);
- for (float scale : { 1.0f, 2.0f })
- writeImage (panel->createComponentSnapshot (panel->getLocalBounds(), true, scale), juce::String ("window-chord-set") + (scale > 1.0f ? "@2x" : ""));
- }
- // the typing keys in each mode (A minor; Z = the root)
- {
- const auto& song = offline.getSong();
- lynx::scalekeys::Settings s;
- s.mode = lynx::scalekeys::Mode::scaleKeys;
- juce::String z;
- for (const int typed : { 60, 62, 64, 65, 67, 69, 71, 72, 61 })
- {
- const auto n = lynx::scalekeys::typedNotes (song, s, typed, 60);
- z << (n.empty() ? juce::String ("-") : juce::String (n.front())) << " ";
- }
- line ("Scale keys, typing C D E F G A B C C#: " + z);
- check ("Scale keys: the white typing keys play A minor from A", z.trim() == "69 71 72 74 76 77 79 81 -");
- s.mode = lynx::scalekeys::Mode::chordPad;
- s.projectChords = false;
- const auto pad = lynx::scalekeys::typedNotes (song, s, 60, 60);
- check ("Chord pad: Z plays A minor (A C E)", pad == std::vector<int> { 69, 72, 76 });
- }
- keyboard = saved;
- }
- // --- the project round trip --------------------------------------------------------------------------------
- {
- const auto json = lynx::ProjectFile::toJson (offline.getSong());
- juce::String error;
- const auto back = lynx::ProjectFile::fromJson (json, error);
- bool same = back.has_value() && back->keyboardChords == offline.getSong().keyboardChords && back->playlist.size() == offline.getSong().playlist.size();
- for (std::size_t i = 0; same && i < back->playlist.size(); ++i)
- same = back->playlist[i].followKey == offline.getSong().playlist[i].followKey && back->playlist[i].keyShift == offline.getSong().playlist[i].keyShift
- && back->playlist[i].pitch == offline.getSong().playlist[i].pitch;
- for (std::size_t c = 0; same && c < back->channels.size(); ++c)
- same = back->channels[c].sampler.loopKeyRoot == offline.getSong().channels[c].sampler.loopKeyRoot
- && back->channels[c].sampler.loopKeySource == offline.getSong().channels[c].sampler.loopKeySource;
- check ("follow, key moves, loop keys and the chord set survive .lynx", same);
- }
- dir.deleteRecursively();
- line (report.contains ("ERROR ") ? "RESULT ERROR" : "RESULT OK");
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- void runSimple190dgShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto writeImage = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = juce::File (prefix + "-" + name + ".png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- juce::String report;
- const auto line = [&report] (const juce::String& text) { report << text << "\n"; };
- const auto check = [&report] (const juce::String& what, bool ok) { report << (ok ? "OK " : "ERROR ") << what << "\n"; };
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- if (simple == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText ("ERROR no Simple workflow\n");
- return;
- }
- simple->hideChooser();
- offline.editSong ([] (lynx::Song& s) {
- namespace st = lynx::simpletracks;
- st::Request q;
- q.kind = st::Kind::voice;
- q.name = "Lead vocal";
- st::addTrack (s, q);
- q = {};
- q.kind = st::Kind::instrument;
- q.name = "Keys";
- lynx::ChannelDef keys;
- keys.instrument = lynx::InstrumentKind::synth;
- q.channel = keys;
- st::addTrack (s, q);
- });
- offline.dispatchPendingMessages();
- simple->hideChooser();
- auto& playlist = ui.getPlaylistForSnapshot();
- int voiceTrack = -1, keysTrack = -1;
- {
- const auto& song = offline.getSong();
- for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
- if (const auto kind = lynx::simpletracks::kindOf (song, t))
- {
- if (*kind == lynx::simpletracks::Kind::audio && voiceTrack < 0)
- voiceTrack = t;
- else if (*kind == lynx::simpletracks::Kind::instrument && keysTrack < 0)
- keysTrack = t;
- }
- }
- check ("two Simple tracks (voice, keys)", voiceTrack >= 0 && keysTrack >= 0);
- playlist.selectTrack (voiceTrack);
- offline.dispatchPendingMessages();
- auto* dock = simple->dockForSnapshot();
- if (dock == nullptr)
- {
- juce::File (prefix + "-report.txt").replaceWithText (report + "ERROR no dock\n");
- return;
- }
- const auto shots = [&] (const juce::String& name) {
- offline.dispatchPendingMessages();
- for (float scale : { 1.0f, 2.0f })
- {
- const auto suffix = scale > 1.0f ? juce::String ("@2x") : juce::String();
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, scale), name + suffix);
- writeImage (dock->createComponentSnapshot (dock->getLocalBounds(), true, scale), "dock-" + name + suffix);
- }
- };
- const auto menuShot = [&] (const juce::PopupMenu& menu, const juce::String& title, const juce::String& subTitle, const juce::String& name) {
- juce::StringArray names { title };
- std::vector<juce::PopupMenu> menus { menu };
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == subTitle)
- {
- names.add (subTitle);
- menus.push_back (*it.getItem().subMenu);
- }
- saveMenus (names, menus, prefix + "-" + name + ".png");
- };
- const auto insert = dock->insertForCheck();
- // --- every one-knob effect as a card, each at a knob position of its own -------------------------------------
- const float at[] { 0.0f, 0.55f, 0.40f, 0.70f, 0.30f, 0.60f, 0.45f, 0.35f, 0.80f };
- for (int id = 1; id <= lynx::goals::count; ++id)
- dock->addOneKnobForCheck (id);
- offline.dispatchPendingMessages();
- for (int id = 1; id <= lynx::goals::count; ++id)
- dock->turnKnobForCheck (id - 1, at[id]);
- offline.dispatchPendingMessages();
- check ("eight one-knob cards on the insert", dock->cardCountForCheck() == 8 && dock->oneKnobCardsForCheck() == 8);
- {
- const auto& fx = offline.getSong().mixer[(std::size_t) insert].effects;
- bool turned = fx.size() == 8;
- for (std::size_t i = 0; turned && i < fx.size(); ++i)
- turned = lynx::goals::active (fx[i]) && std::abs (fx[i].goalAmount - at[i + 1]) < 1.0e-6f;
- check ("each knob wrote its effect's parameters", turned);
- }
- shots ("effects-all");
- offline.dispatchPendingMessages();
- for (int card = 0; card < dock->cardCountForCheck(); ++card)
- {
- const auto area = dock->cardBoundsForSnapshot (card);
- const auto name = juce::String (lynx::goals::name (card + 1)).toLowerCase();
- check ("card " + juce::String (card + 1) + " (" + name + ") is on screen", ! area.isEmpty() && dock->getLocalBounds().contains (area));
- for (float scale : { 1.0f, 2.0f })
- writeImage (dock->createComponentSnapshot (area.expanded (4), true, scale), "card-" + name + (scale > 1.0f ? "@2x" : ""));
- }
- // --- a chain preset with Blend --------------------------------------------------------------------------------
- if (const auto* preset = lynx::chains::find ("Canyon"))
- offline.editSongStructural ([insert, preset] (lynx::Song& s) { lynx::chains::apply (s, insert, *preset); });
- offline.dispatchPendingMessages();
- dock->setBlendForCheck (0.6f);
- offline.dispatchPendingMessages();
- check ("preset Canyon with Blend 60 % (shown as edited)", offline.getSong().mixer[(std::size_t) insert].chainPreset == "Canyon"
- && std::abs (offline.getSong().mixer[(std::size_t) insert].chainBlend - 0.6f) < 1.0e-6f
- && ! lynx::chains::unchanged (offline.getSong(), insert));
- shots ("effects-preset-blend");
- // favourites: the track's preset starred; the menu lists it first
- const auto favFile = lynx::SimpleDock::favouritesFile();
- const auto hadFavourites = favFile.existsAsFile();
- const auto oldFavourites = favFile.loadFileAsString();
- lynx::SimpleDock::setFavouritePreset ("Canyon", true);
- lynx::SimpleDock::setFavouritePreset ("Clear Voice", true);
- lynx::SimpleDock::setFavouritePreset ("Canyon", true); // (twice: once in the list)
- check ("two favourites kept, in order", lynx::SimpleDock::favouritePresets() == juce::StringArray { "Canyon", "Clear Voice" });
- {
- bool first = false, toggle = false;
- const auto menu = dock->presetMenuForSnapshot();
- juce::PopupMenu::MenuItemIterator it (menu);
- if (it.next())
- first = it.getItem().subMenu != nullptr && it.getItem().text.contains (lynx::tr ("Favourites"));
- for (juce::PopupMenu::MenuItemIterator all (menu); all.next();)
- toggle = toggle || all.getItem().text == lynx::tr ("Remove \"{0}\" from favourites", { "Canyon" });
- check ("the Preset menu starts with the favourites and offers to unstar the track's preset", first && toggle);
- menuShot (menu, lynx::tr ("Preset"), juce::String::fromUTF8 ("\xe2\x98\x85 ") + lynx::tr ("Favourites"), "menu-preset-favourites");
- }
- lynx::SimpleDock::setFavouritePreset ("Canyon", false);
- check ("unstarred", lynx::SimpleDock::favouritePresets() == juce::StringArray { "Clear Voice" });
- if (hadFavourites)
- favFile.replaceWithText (oldFavourites);
- else
- favFile.deleteFile();
- // --- the sound picker: a search, and the installed plugins -----------------------------------------------------
- playlist.selectTrack (keysTrack);
- offline.dispatchPendingMessages();
- check ("the Keys track opens on its sound", dock->getTab() == lynx::SimpleDock::Tab::instrument);
- dock->showCategoryForSnapshot ((int) lynx::soundlib::Category::bass);
- dock->setSearchForSnapshot ("sub");
- offline.dispatchPendingMessages();
- line ("search \"sub\" in Bass: " + juce::String (dock->soundRowsForCheck()) + " rows");
- check ("a search narrows the category", dock->soundRowsForCheck() > 0 && dock->soundRowsForCheck() < (int) lynx::soundlib::filter (lynx::soundlib::builtIn(), lynx::soundlib::Category::bass).size());
- shots ("picker-search");
- dock->setSearchForSnapshot ({});
- // a made-up list of installed plugins (nothing is scanned or loaded)
- dock->setPluginsForSnapshot ({ { "VST3-demo-1", "Analog Mono", "Example Audio", "VST3", "Instrument|Synth" },
- { "VST3-demo-2", "Grand Upright", "Example Audio", "VST3", "Instrument|Piano" },
- { "VST3-demo-3", "Beat Kit 808", "Sample Lab", "VST3", "Instrument|Drum" },
- { "CLAP-demo-4", "Orchestra Strings", "Sample Lab", "CLAP", "Instrument|Sampler" },
- { "VST3-demo-5", "Wave Table One", "Example Audio", "VST3", "Instrument|Synth" },
- { "VST-demo-6", "Sub Bass Machine", "Low End", "VST", "Synth" },
- { "VST3-demo-7", "Sample Player", "Sample Lab", "VST3", "Instrument|Sampler" } });
- dock->showCategoryForSnapshot ((int) lynx::soundlib::Category::synths);
- offline.dispatchPendingMessages();
- check ("My plugins: the generic synths and samplers in their own category (" + juce::String (dock->soundRowsForCheck()) + " of 7)", dock->soundRowsForCheck() == 3);
- shots ("picker-plugins");
- line (report.contains ("ERROR ") ? "RESULT ERROR" : "RESULT OK");
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- // LYNX --simple190jcshot prefix (round 190jc, design190ia slices 5, 14, 15, 22, 24 + Large controls): the Simple
- // layout's tracks (only real rows, the round "+", M S, type icons, the track-colour volume and clips; muted, soloed,
- // selected), the drop lane idle and lit, the dock (close X, icon tabs, a lone tab, the sound picker, the keyboard's
- // keycaps and octave capsule, effect cards), the pads in all 8 colours (label contrast measured), the chooser,
- // starter beats, Finish, the tour card beside its ring with the beacon (Animations on / off), and Large controls;
- // windows at 1x and 2x, and a text report of the checks
- void runSimple190jcShot (const juce::String& prefix)
- {
- namespace st = lynx::simpletracks;
- namespace sp = lynx::simplepads;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- ui.setVisible (true);
- const auto writeImage = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = juce::File (prefix + "-" + name + ".png");
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- juce::String report;
- const auto line = [&report, &prefix] (const juce::String& text) {
- report << text << "\n";
- juce::File (prefix + "-report.txt").replaceWithText (report);
- };
- const auto check = [&line] (const juce::String& what, bool ok) { line ((ok ? "OK " : "ERROR ") + what); };
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- const auto whole = [&] (const juce::String& name, bool twoX = true) {
- settle();
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, 1.0f), name);
- if (twoX)
- writeImage (ui.createComponentSnapshot (ui.getLocalBounds(), true, 2.0f), name + "@2x");
- };
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- settle();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- auto& playlist = ui.getPlaylistForSnapshot();
- if (simple == nullptr)
- {
- line ("ERROR no Simple workflow");
- return;
- }
- // an empty project: the drop lane alone, the round "+"
- offline.setSong ([] {
- lynx::Song s;
- s.mixer = lynx::Song::defaultMixer();
- return s;
- }());
- settle();
- simple->hideChooser();
- whole ("empty");
- check ("an empty song shows one row (the drop lane), with the round +", st::rowsShown (offline.getSong(), 500) == 1 && ! playlist.simpleAddButtonForSnapshot().isEmpty());
- // --- sounds ------------------------------------------------------------------------------------------------------
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190jc");
- dir.deleteRecursively();
- dir.createDirectory();
- const auto writeWav = [] (const juce::File& wav, int frames, const std::function<float (int)>& f) {
- wav.getParentDirectory().createDirectory();
- juce::AudioBuffer<float> audio (1, frames);
- for (int i = 0; i < frames; ++i)
- audio.setSample (0, i, f (i));
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- return wav;
- };
- const auto pi = juce::MathConstants<double>::pi;
- juce::Random rnd (190);
- const auto loop = writeWav (dir.getChildFile ("Vocal chop 100.wav"), 230400, [pi] (int i) {
- const auto t = i / 48000.0, inBeat = std::fmod (t, 0.6);
- return (float) (0.7 * std::exp (-inBeat * 5.0) * std::sin (2.0 * pi * 220.0 * t + 1.5 * std::sin (2.0 * pi * 440.0 * t)));
- });
- std::vector<juce::File> padSounds;
- const char* padNames[] { "Kick", "Snare", "Hat", "Clap", "Chord stab", "Vox hey", "Perc", "Bass hit" };
- for (int k = 0; k < 8; ++k)
- padSounds.push_back (writeWav (dir.getChildFile (juce::String ("pads/") + padNames[k] + ".wav"), 12000 + 3000 * k, [&rnd, k] (int i) {
- return (float) ((rnd.nextFloat() * 2.0f - 1.0f) * 0.6f * std::exp (-i / (600.0f + 500.0f * (float) k)));
- }));
- // --- tracks: a voice with a loop, keys with chords, drums, a bass take, a Sampler track --------------------------------
- int vocal = -1, keys = -1, drums = -1, bass = -1;
- offline.editSong ([&] (lynx::Song& s) {
- st::Request q;
- q.kind = st::Kind::audio;
- q.name = "Vocal chop";
- q.audioFile = loop.getFullPathName().toStdString();
- q.audioLength = 8 * lynx::ppq;
- q.audioBeats = 8.0f;
- vocal = st::addTrack (s, q).track;
- q = {};
- q.kind = st::Kind::instrument;
- q.name = "Keys";
- lynx::ChannelDef synth;
- synth.instrument = lynx::InstrumentKind::synth;
- q.channel = synth;
- lynx::Pattern chords;
- for (int i = 0; i < 4; ++i)
- for (int k : { 60, 64, 67 })
- chords.notes.push_back (lynx::Note { (std::int64_t) i * 4 * lynx::ppq, 4 * lynx::ppq - lynx::ppq / 4, 0, k });
- q.pattern = chords;
- const auto r = st::addTrack (s, q);
- keys = r.track;
- q = {};
- q.kind = st::Kind::drums;
- q.name = "Drums";
- for (auto kind : { lynx::InstrumentKind::kick, lynx::InstrumentKind::snare, lynx::InstrumentKind::hat })
- {
- lynx::ChannelDef c;
- c.instrument = kind;
- q.kit.push_back (c);
- }
- lynx::Pattern beat;
- for (int step = 0; step < 16; step += 2)
- beat.notes.push_back (lynx::Note { (std::int64_t) step * lynx::ticksPerStep, lynx::ticksPerStep, 2, 60 });
- for (int step : { 0, 8 })
- beat.notes.push_back (lynx::Note { (std::int64_t) step * lynx::ticksPerStep, lynx::ticksPerStep, 0, 60 });
- q.pattern = beat;
- q.fillBars = 4;
- const auto d = st::addTrack (s, q);
- drums = d.track;
- q = {};
- q.kind = st::Kind::bass;
- q.name = "Bass";
- bass = st::addTrack (s, q).track;
- if (r.insert > 0)
- {
- s.mixer[(std::size_t) r.insert].volume = 0.55f;
- s.mixer[(std::size_t) r.insert].pan = -0.4f;
- s.mixer[(std::size_t) r.insert].solo = true;
- }
- if (d.insert > 0)
- s.mixer[(std::size_t) d.insert].muted = true;
- });
- settle();
- check ("the Sampler tile's track was added", simple->addPads());
- settle();
- const auto& song = offline.getSong();
- int pads = -1;
- for (int t = 0; t < (int) song.playlistTracks.size() && pads < 0; ++t)
- if (st::kindOf (song, t) == st::Kind::pads)
- pads = t;
- lynx::ui::WaveformCache::getInstance()->find (loop.getFullPathName(), [&offline, &loop] { return offline.getSampleLibrary().load (loop.getFullPathName()); });
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (30000);
- simple->hideChooser();
- playlist.selectTrack (keys);
- settle();
- const auto rows = st::rowsShown (song, 500);
- line ("tracks: vocal " + juce::String (vocal) + " keys " + juce::String (keys) + " drums " + juce::String (drums) + " bass " + juce::String (bass)
- + " pads " + juce::String (pads) + "; rows shown " + juce::String (rows));
- check ("five tracks + the drop lane are the rows shown (no placeholder rows)", rows == 6);
- whole ("tracks");
- {
- // the Simple Playlist's whole paint (its rows only, no placeholder rows): CPU ms per frame
- juce::Image img (juce::Image::ARGB, juce::jmax (1, playlist.getWidth()), juce::jmax (1, playlist.getHeight()), true);
- std::vector<double> ms;
- for (int f = -3; f < 40; ++f)
- {
- const auto t0 = lynx::threadCpuSeconds();
- {
- juce::Graphics g (img);
- playlist.paintEntireComponent (g, true);
- }
- if (f >= 0)
- ms.push_back (1000.0 * (lynx::threadCpuSeconds() - t0));
- }
- std::sort (ms.begin(), ms.end());
- line ("simple playlist " + juce::String (playlist.getWidth()) + "x" + juce::String (playlist.getHeight()) + " whole paint: median "
- + juce::String (ms[ms.size() / 2], 3) + " ms, p90 " + juce::String (ms[ms.size() * 9 / 10], 3) + " ms");
- }
- playlist.setDropLaneHotForSnapshot (true);
- whole ("droplane-hot", false);
- playlist.setDropLaneHotForSnapshot (false);
- // --- the dock ------------------------------------------------------------------------------------------------------
- auto* dock = simple->dockForSnapshot();
- if (dock == nullptr)
- {
- line ("ERROR no dock");
- return;
- }
- const auto dockShots = [&] (const juce::String& name) {
- settle();
- for (float scale : { 1.0f, 2.0f })
- writeImage (dock->createComponentSnapshot (dock->getLocalBounds(), true, scale), "dock-" + name + (scale > 1.0f ? "@2x" : ""));
- };
- simple->trackSelected (keys);
- dock->setTab (lynx::SimpleDock::Tab::instrument);
- dockShots ("instrument");
- whole ("window-dock-instrument", false);
- dock->showKeyboard();
- dockShots ("keyboard");
- simple->trackSelected (vocal);
- settle();
- check ("an audio track's dock has one tab (drawn as a title)", dock->getTab() == lynx::SimpleDock::Tab::effects);
- dockShots ("audio-lone-tab");
- simple->showEffectsOfInsert (st::insertOf (offline.getSong(), keys));
- dock->addOneKnobForCheck (1);
- dock->addOneKnobForCheck (2);
- dockShots ("effects");
- // --- pads: 8 sounds in the 8 colours --------------------------------------------------------------------------------
- if (pads >= 0)
- {
- simple->trackSelected (pads);
- settle();
- for (int p = 0; p < 8; ++p)
- dock->padsLoadForCheck (p, padSounds[(std::size_t) p]);
- offline.editSong ([pads] (lynx::Song& s) {
- for (int p = 0; p < 8; ++p)
- if (const auto c = sp::padChannel (s, pads, p); c >= 0)
- s.channels[(std::size_t) c].simplePad.colour = (std::uint8_t) (p + 1);
- });
- dock->padsSelectForCheck (4);
- dock->padsUpdateForCheck();
- dockShots ("pads");
- dock->padsHitForCheck (2);
- dockShots ("pads-hit");
- whole ("window-pads", false);
- // the labels' contrast on the 8 colours, unlit and lit (the same colours the page draws)
- static const juce::uint32 palette[] { 0xffe5383b, 0xffe8833a, 0xffe2c044, 0xff5fbf6a, 0xff3fb6b0, 0xff4f8ee0, 0xff9a6fe0, 0xffe06aa8 };
- float worst = 99.0f;
- for (auto argb : palette)
- for (bool lit : { false, true })
- {
- const auto fill = juce::Colour (argb).withMultipliedBrightness (lit ? 1.0f : 0.55f).withMultipliedSaturation (lit ? 1.0f : 0.8f);
- const auto ratio = lynx::ui::simplelook::contrast (lynx::ui::simplelook::inkOn (fill), fill);
- worst = juce::jmin (worst, ratio);
- line ("pad " + juce::String::toHexString ((int) argb).substring (2) + (lit ? " lit " : " unlit") + ": label " + juce::String (ratio, 2) + ":1");
- }
- check ("pad labels >= 4.5:1 on all 8 colours, lit and unlit (worst " + juce::String (worst, 2) + ":1)", worst >= 4.5f);
- }
- // --- chooser, starters, Finish ---------------------------------------------------------------------------------------
- simple->showChooser();
- whole ("chooser");
- simple->showStarterPageForSnapshot();
- whole ("starters");
- simple->hideChooser();
- simple->showFinish();
- whole ("finish");
- simple->hideFinish();
- // --- the tour: the card beside its ring, the beacon with Animations on and off -----------------------------------------
- if (auto* tour = simple->tourForSnapshot())
- {
- simple->showWelcome();
- settle();
- tour->clickForSnapshot ("welcome.tour");
- settle();
- const auto ring = tour->ringForSnapshot();
- const auto card = tour->cardBoundsForSnapshot();
- const auto distance = juce::jmax (0, juce::jmax (card.getY() - ring.getBottom(), ring.getY() - card.getBottom()))
- + juce::jmax (0, juce::jmax (card.getX() - ring.getRight(), ring.getX() - card.getRight()));
- line ("tour step 1: ring " + ring.toString() + " card " + card.toString() + " gap " + juce::String (distance) + " px");
- check ("the card sits beside its ring (<= 24 px)", ! ring.isEmpty() && distance <= 24 && ! card.intersects (ring));
- check ("the beacon pulses after a step change (Animations on)", tour->pulsingForCheck());
- tour->setPulseForSnapshot (0.5f);
- whole ("tour-pulse-on", false);
- lynx::ui::motion::enabled() = false;
- tour->clickForSnapshot ("next");
- settle();
- check ("no pulse timer with Animations off", ! tour->pulsingForCheck());
- tour->setPulseForSnapshot (0.0f);
- whole ("tour-pulse-off", false);
- lynx::ui::motion::enabled() = true;
- tour->clickForSnapshot ("skip");
- settle();
- }
- // --- Large controls ---------------------------------------------------------------------------------------------------
- ui.setSimpleLargeControls (true);
- simple->hideChooser();
- playlist.selectTrack (keys);
- settle();
- whole ("large-tracks", false);
- if (pads >= 0)
- {
- simple->trackSelected (pads);
- dockShots ("large-pads");
- }
- ui.setSimpleLargeControls (false);
- line ("done");
- }
- void runSimpleShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto writeImage = [&prefix] (const juce::Image& image, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- const auto write = [&ui, &writeImage] (const char* name) { writeImage (lynx::shot::snapshot (ui), name); };
- // View › Layout style, with its submenu, as it is with `style` chosen
- const auto viewMenu = [&ui] {
- const auto names = ui.getMenuNamesForSnapshot();
- const auto view = names.indexOf (lynx::tr ("View"));
- return ui.getMenuForSnapshot (juce::jmax (0, view));
- };
- const auto saveStyleMenus = [&] (const juce::String& suffix) {
- const auto view = viewMenu();
- juce::StringArray names { lynx::tr ("View") };
- std::vector<juce::PopupMenu> menus { view };
- for (juce::PopupMenu::MenuItemIterator it (view); it.next();)
- if (it.getItem().subMenu != nullptr && it.getItem().text == lynx::tr ("Layout style"))
- {
- names.add (lynx::tr ("Layout style"));
- menus.push_back (*it.getItem().subMenu);
- }
- saveMenus (names, menus, prefix + "-menu-" + suffix + ".png");
- };
- // Settings › General with `style` selected, and its style list
- const auto saveSettings = [&] (lynx::layoutstyle::Style style, const char* name) {
- lynx::SettingsHooks hooks;
- hooks.getGeneral = [style] {
- lynx::GeneralOptions o;
- o.language = lynx::i18n::current();
- o.layoutStyle = (int) style;
- return o;
- };
- auto page = lynx::makeSettingsPanel (offline, lynx::SettingsPage::general, false, hooks);
- const auto image = lynx::shot::paint (*page, lynx::theme::panel, -1, juce::jmin (page->getHeight(), 420));
- writeImage (image, name);
- std::function<juce::ComboBox* (juce::Component&)> find = [&find] (juce::Component& c) -> juce::ComboBox* {
- if (c.getComponentID() == "layoutStyle")
- return dynamic_cast<juce::ComboBox*> (&c);
- for (auto* child : c.getChildren())
- if (auto* box = find (*child))
- return box;
- return nullptr;
- };
- if (auto* box = find (*page); box != nullptr && box->getRootMenu() != nullptr)
- saveMenus (juce::StringArray { lynx::tr ("Layout style") }, std::vector<juce::PopupMenu> { *box->getRootMenu() },
- prefix + "-" + name + "-list.png");
- };
- const auto madeBefore = lynx::SimpleWorkflow::instances.load();
- ui.selectTabForSnapshot (2); // the Playlist panel, maximized (as --gridshot)
- write ("pattern");
- saveStyleMenus ("pattern");
- saveSettings (lynx::layoutstyle::Style::pattern, "settings-pattern");
- const auto madePattern = lynx::SimpleWorkflow::instances.load();
- ui.setLayoutStyle (lynx::layoutstyle::Style::clipLaunch);
- saveStyleMenus ("cliplaunch");
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- if (auto* simple = ui.getSimpleWorkflowForSnapshot())
- simple->showChooser(); // (an empty project opens on it by itself; the offline project may hold the default song)
- write ("simple"); // the New track chooser (slice S3)
- if (auto* simple = ui.getSimpleWorkflowForSnapshot())
- {
- simple->showStarterPageForSnapshot();
- write ("simple-starter");
- simple->hideChooser();
- write ("simple-closed");
- // round 190p: a loop keeps time. Two files with the same 4.8 s of audio dropped on the empty Simple timeline:
- // "Guitar loop 100.wav" (2 bars at 100 BPM) lasts 2 bars at the project's tempo, "Guitar take.wav" plays at
- // its own speed. Both are undone again, so the shots after this one are as they were.
- {
- const auto folder = juce::File (prefix + "-loops");
- folder.createDirectory();
- juce::StringArray files;
- for (const auto* name : { "Guitar loop 100.wav", "Guitar take.wav" })
- {
- const auto file = folder.getChildFile (name);
- file.deleteFile();
- const auto rate = 44100.0;
- const auto frames = (int) (4.8 * rate);
- juce::AudioBuffer<float> audio (1, frames);
- for (int i = 0; i < frames; ++i)
- {
- const auto t = (double) i / rate, inBeat = std::fmod (t, 0.6); // a plucked note on every beat at 100 BPM
- audio.setSample (0, i, (float) (0.7 * std::exp (-inBeat * 7.0) * std::sin (juce::MathConstants<double>::twoPi * 196.0 * t)));
- }
- if (auto out = file.createOutputStream())
- if (auto writer = std::unique_ptr<juce::AudioFormatWriter> (juce::WavAudioFormat().createWriterFor (out.get(), rate, 1, 16, {}, 0)))
- {
- out.release();
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- files.add (file.getFullPathName());
- }
- simple->dropFiles (files, 0);
- offline.dispatchPendingMessages();
- // the clips' waveforms are analysed in the background and drawn once ready (a live window repaints by
- // itself; one off-screen paint came too early and showed empty clips)
- for (const auto& path : files)
- lynx::ui::WaveformCache::getInstance()->find (path, [&offline, path] { return offline.getSampleLibrary().load (path); });
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (30000);
- offline.dispatchPendingMessages();
- write ("simple-loop");
- const auto& song = offline.getSong();
- juce::String report;
- for (const auto& clip : song.playlist)
- if (clip.kind == lynx::ClipKind::audio)
- report << song.channels[(std::size_t) clip.channel].name << ": " << juce::String ((double) clip.length / lynx::ppq, 3) << " beats, stretch "
- << juce::String (song.channels[(std::size_t) clip.channel].sampler.stretchBeats, 2) << "\n";
- juce::File (prefix + "-loop.txt").replaceWithText ("tempo " + juce::String (song.bpm, 1) + "\n" + report);
- for (int i = 0; i < files.size() && offline.canUndo(); ++i) // (one undo step per dropped file)
- offline.undo();
- offline.dispatchPendingMessages();
- simple->hideChooser();
- }
- // round 190t, slice A: one click on a starter beat adds it, placed for four bars (undone again)
- {
- const auto clipsBefore = offline.getSong().playlist.size();
- const auto tempoBefore = offline.getSong().bpm;
- simple->clickStarterForSnapshot (1);
- offline.dispatchPendingMessages();
- write ("simple-starter-added");
- const auto& song = offline.getSong();
- juce::String report ("tempo " + juce::String (tempoBefore, 1) + " -> " + juce::String (song.bpm, 1) + "\n");
- for (auto i = clipsBefore; i < song.playlist.size(); ++i)
- report << "clip at beat " << juce::String ((double) song.playlist[i].start / lynx::ppq, 2) << ", " << juce::String ((double) song.playlist[i].length / lynx::ppq, 2)
- << " beats, pattern " << song.playlist[i].pattern << ", track " << song.playlist[i].track << "\n";
- juce::File (prefix + "-starter.txt").replaceWithText (report);
- if (song.playlist.size() > clipsBefore && offline.canUndo())
- offline.undo();
- offline.dispatchPendingMessages();
- simple->hideChooser();
- }
- // slice S4: the Simple headers with a few tracks (voice, instrument, drums, an audio file), some levels moved
- offline.editSong ([] (lynx::Song& s) {
- namespace st = lynx::simpletracks;
- st::Request q;
- q.kind = st::Kind::voice;
- q.name = "Lead vocal";
- st::addTrack (s, q);
- q = {};
- q.kind = st::Kind::instrument;
- q.name = "Keys";
- lynx::ChannelDef keys;
- keys.instrument = lynx::InstrumentKind::synth;
- q.channel = keys;
- lynx::Pattern chords;
- for (int i = 0; i < 4; ++i)
- for (int k : { 60, 64, 67 })
- chords.notes.push_back (lynx::Note { (std::int64_t) i * 4 * lynx::ppq, 4 * lynx::ppq - lynx::ppq / 4, 0, k });
- q.pattern = chords;
- const auto r = st::addTrack (s, q);
- q = {};
- q.kind = st::Kind::drums;
- for (auto kind : { lynx::InstrumentKind::kick, lynx::InstrumentKind::snare, lynx::InstrumentKind::hat })
- {
- lynx::ChannelDef c;
- c.instrument = kind;
- c.name = kind == lynx::InstrumentKind::kick ? "Kick" : kind == lynx::InstrumentKind::snare ? "Snare" : "Hat";
- q.kit.push_back (c);
- }
- lynx::Pattern beat;
- const auto hit = [&beat] (int step, int row) { beat.notes.push_back (lynx::Note { (std::int64_t) step * lynx::ticksPerStep, lynx::ticksPerStep, row, 60 }); };
- for (int step = 0; step < 16; step += 2)
- hit (step, 2); // hats on the 8ths, kick on 1 and 3, snare on 2 and 4
- for (int step : { 0, 8 })
- hit (step, 0);
- for (int step : { 4, 12 })
- hit (step, 1);
- q.pattern = beat;
- q.bpm = 96.0;
- st::addTrack (s, q);
- if (r.insert > 0)
- {
- s.mixer[(std::size_t) r.insert].volume = 0.55f;
- s.mixer[(std::size_t) r.insert].pan = -0.4f;
- s.mixer[(std::size_t) r.insert].solo = true;
- }
- });
- offline.dispatchPendingMessages();
- ui.getPlaylistForSnapshot().selectTrack (1);
- write ("simple-tracks");
- // round 190t, slice E: the backup status beside the title tools, in each of its states
- {
- const auto now = juce::Time::currentTimeMillis();
- juce::String states;
- int n = 0;
- for (const auto& text : { lynx::MainComponent::simpleSaveStatusText (true, false, 0, now), lynx::MainComponent::simpleSaveStatusText (true, false, now - 5000, now),
- lynx::MainComponent::simpleSaveStatusText (true, true, now - 125000, now), lynx::MainComponent::simpleSaveStatusText (false, true, 0, now),
- lynx::MainComponent::simpleSaveStatusText (false, false, 0, now) })
- {
- simple->setStatusForSnapshot (text);
- offline.dispatchPendingMessages();
- states << n << ": " << text << "\n";
- // (round 190oo, CS-32: the status is the top bar's since round 190iv: its rows 0..74, not the title band)
- writeImage (lynx::shot::snapshot (ui, ui.getLocalBounds().withHeight (juce::jmin (ui.getHeight(), 74))),
- ("status-" + juce::String (n++)).toRawUTF8());
- }
- juce::File (prefix + "-status.txt").replaceWithText (states);
- simple->setStatusForSnapshot (lynx::MainComponent::simpleSaveStatusText (true, true, now - 125000, now));
- offline.dispatchPendingMessages();
- write ("simple-status");
- }
- // round 190oo (design review 2): the top bar while the transport plays (CS-35: Play shows BandLab's Pause,
- // Back-to-start becomes Stop; the offline engine does not play, so the main window's states are driven), and
- // the LYNX extra O-4 (the project's name centred at the top, "Untitled" while it has none) at this size and at
- // 1280 px, then off again
- {
- const auto topBar = [&ui] { return ui.getLocalBounds().withHeight (juce::jmin (ui.getHeight(), 80)); };
- const auto nameWas = std::exchange (lynx::ui::simplelook::projectNameShown(), false); // (round 190qk: on by default)
- ui.resized();
- ui.transportForSnapshot (true, false);
- writeImage (lynx::shot::snapshot (ui, topBar()), "topbar-playing");
- ui.transportForSnapshot (false, false);
- writeImage (lynx::shot::snapshot (ui, topBar()), "topbar-stopped");
- lynx::ui::simplelook::projectNameShown() = true;
- ui.resized();
- writeImage (lynx::shot::snapshot (ui, topBar()), "topbar-project-name");
- const auto wide = ui.getWidth(), tall = ui.getHeight();
- ui.setSize (1280, tall);
- offline.dispatchPendingMessages();
- writeImage (lynx::shot::snapshot (ui, topBar()), "topbar-project-name-1280");
- ui.setSize (wide, tall);
- lynx::ui::simplelook::projectNameShown() = nameWas;
- ui.resized();
- offline.dispatchPendingMessages();
- }
- // slice S8: the Finish dock, empty, then with a look on the Master (Balanced, Normal, a little Tone)
- simple->showFinish();
- offline.dispatchPendingMessages();
- write ("simple-finish-empty");
- offline.editSongStructural ([] (lynx::Song& s) { lynx::looks::apply (s, lynx::MasterLookSettings { lynx::looks::balanced, 0.5f, { 1.5f, 0.0f, 1.0f }, -3.0f }); });
- offline.dispatchPendingMessages();
- simple->showFinish();
- write ("simple-finish");
- simple->hideFinish();
- }
- saveStyleMenus ("simple");
- saveSettings (lynx::layoutstyle::Style::simple, "settings-simple");
- // round 184a S11: the Key panel (no key, then an A minor riff and its guesses) and its menu
- const auto toolbarShot = [&] (const char* name) {
- writeImage (lynx::shot::snapshot (ui, ui.getLocalBounds().withHeight (juce::jmin (ui.getHeight(), 80))), name);
- };
- toolbarShot ("key-none");
- saveMenus (juce::StringArray { lynx::tr ("Key") }, std::vector<juce::PopupMenu> { ui.getKeyMenuForSnapshot() }, prefix + "-key-menu-empty.png");
- offline.editSong ([] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- if (s.patterns.empty())
- s.patterns.emplace_back();
- int t = 0;
- for (int k : { 57, 60, 64, 67, 69, 67, 64, 60, 57, 59, 60, 62, 64, 62, 60, 59, 57, 57, 64, 45 })
- {
- lynx::Note n;
- n.channel = 0;
- n.key = k;
- n.start = t * lynx::ppq / 2;
- n.length = k == 57 || k == 45 ? lynx::ppq : lynx::ppq / 2;
- s.patterns[0].notes.push_back (n);
- ++t;
- }
- });
- offline.dispatchPendingMessages();
- saveMenus (juce::StringArray { lynx::tr ("Key") }, std::vector<juce::PopupMenu> { ui.getKeyMenuForSnapshot() }, prefix + "-key-menu-guess.png");
- const auto guesses = lynx::keyguess::guess (offline.getSong(), 3);
- if (! guesses.empty())
- offline.editSong ([k = guesses[0].key] (lynx::Song& s) { lynx::projectkey::set (s, k); });
- offline.dispatchPendingMessages();
- toolbarShot ("key-set");
- write ("simple-key");
- juce::String keyCounts;
- for (const auto& g : guesses)
- keyCounts << "guess " << lynx::projectkey::name (g.key) << " " << g.notesInScale << "/" << g.notes << " score " << g.score << "\n";
- offline.editSong ([] (lynx::Song& s) { lynx::projectkey::set (s, std::nullopt); });
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- offline.dispatchPendingMessages();
- toolbarShot ("key-pattern-toolbar");
- write ("pattern-after");
- // round 184a S17: the setup wizard with its Workflow choice — a first start (Pattern selected), then reopened in Simple
- for (int style : { 0, 2 })
- {
- auto wizard = lynx::makeSetupWizardContent (offline, {}, {}, style, {});
- auto image = lynx::shot::paint (*wizard);
- writeImage (image, style == 0 ? "wizard-pattern" : "wizard-simple");
- }
- juce::File (prefix + "-counts.txt").replaceWithText ("simple workflows before " + juce::String (madeBefore) + ", in pattern workflow "
- + juce::String (madePattern) + ", after " + juce::String (lynx::SimpleWorkflow::instances.load())
- + "\nstyle after " + lynx::layoutstyle::id (ui.getLayoutStyle()) + "\n" + keyCounts);
- }
- void runLiveRackShot190hr (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix, &ui, &offline] (const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- const auto writeView = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::paint (c, lynx::theme::panel), out);
- };
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto itemEnabled = [] (const juce::PopupMenu& menu, const juce::String& start) {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (it.getItem().text.startsWith (start))
- return it.getItem().isEnabled ? 1 : 0;
- return -1;
- };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::browser, lynx::workspace::Panel::playlist });
- offline.editSong ([] (lynx::Song& s) {
- if (s.channels.size() < 1)
- s.channels.resize (1);
- s.channels[0].name = "Lead";
- s.channels[0].instrument = lynx::InstrumentKind::synth;
- s.channels[0].mixerTrack = 2;
- if (s.mixer.size() < 4)
- s.mixer.resize (4);
- s.mixer[2].name = "Lead";
- s.mixer[2].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::delay })
- s.mixer[2].effects.push_back (lynx::makeEffectSlot (kind));
- while (s.patterns.size() < 1)
- s.patterns.emplace_back();
- lynx::Note note;
- note.channel = 0;
- note.key = 60;
- s.patterns[0].notes = { note };
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 3));
- s.playlistTracks[1].name = "Lead";
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 1, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- auto* detail = ui.getDetailViewForSnapshot();
- if (detail == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText ("FAIL no detail view\n");
- return;
- }
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- detail->selectCardForCheck (0); // the instrument
- write ("01-devices");
- auto menu = detail->cardMenuForSnapshot (0);
- saveMenus (juce::StringArray { "Instrument" }, std::vector<juce::PopupMenu> { menu }, prefix + "-02-instrument-menu.png");
- check ("instrument menu: Group on, Ungroup off", itemEnabled (menu, lynx::tr ("Group")) == 1 && itemEnabled (menu, lynx::tr ("Ungroup")) == 0);
- // Ctrl+G: the synth into an Instrument Rack (the card becomes the rack's)
- check ("Ctrl+G groups the instrument into an Instrument Rack", detail->groupCardForCheck (0, false));
- const auto& grouped = offline.getSong().channels[0];
- check ("the channel keeps its insert and the rack holds the synth",
- grouped.mixerTrack == 2 && lynx::rack::isRack (grouped) && lynx::rack::rackOf (grouped.patcher)->kind == lynx::RackDoc::Kind::instrument
- && lynx::rack::devices (*lynx::rack::rackOf (grouped.patcher), 0).size() == 1);
- detail->selectCardForCheck (0);
- write ("03-grouped");
- menu = detail->cardMenuForSnapshot (0);
- saveMenus (juce::StringArray { "Instrument Rack" }, std::vector<juce::PopupMenu> { menu }, prefix + "-04-rack-menu.png");
- check ("rack menu: Ungroup on, Save as Live rack preset", itemEnabled (menu, lynx::tr ("Ungroup")) == 1
- && itemEnabled (menu, lynx::tr ("Save as Live rack preset (.adg)...")) == 1);
- check ("Ctrl+Shift+G ungroups it", detail->groupCardForCheck (0, true) && offline.getSong().channels[0].instrument == lynx::InstrumentKind::synth);
- write ("05-ungrouped");
- // a rack's view: Live's Save Preset button at the foot of the strip, the drop area
- offline.editSong ([] (lynx::Song& s) {
- auto rack = lynx::rack::makeRackSlot (lynx::RackDoc::Kind::audioEffect);
- lynx::rack::rackOf (rack.patcher)->showDevices = true;
- s.mixer[3].effects = { rack };
- }, false);
- offline.dispatchPendingMessages();
- {
- auto view = lynx::RackWindows::makeSlotView (offline, 3, 0, true);
- view->setSize (std::max (520, view->preferredWidth (228)), 228);
- writeView (*view, "06-rack-empty");
- lynx::PatchNode fx;
- fx.effect = lynx::makeEffectSlot (lynx::EffectKind::delay);
- const juce::Point<int> inDevices { view->getWidth() - 30, view->getHeight() / 2 };
- check ("an effect dropped on the chain goes in", view->dropNodeForCheck (fx, inDevices));
- lynx::PatchNode synth;
- synth.generator = true;
- synth.channel.instrument = lynx::InstrumentKind::synth;
- check ("an instrument dropped on an Audio Effect Rack is refused", ! view->dropNodeForCheck (synth, inDevices));
- const auto* r = lynx::rack::rackOf (offline.getSong().mixer[3].effects[0].patcher);
- check ("the chain holds one device", r != nullptr && lynx::rack::devices (*r, 0).size() == 1);
- view->setSize (std::max (520, view->preferredWidth (228)), 228);
- writeView (*view, "07-rack-after-drop");
- // the rack as a Live preset and back
- const auto out = lynx::exportLiveRackPreset (offline.getSong().mixer[3].effects[0].patcher, "Shot Rack");
- check ("Save as .adg writes Live's preset form", out.xml.find ("<GroupDevicePreset>") != std::string::npos
- && out.xml.find ("<AudioEffectBranchPreset ") != std::string::npos);
- const auto back = lynx::importLiveDevicePreset (out.bytes);
- check ("the .adg reads back as the rack", back.has_value() && lynx::rack::isRack (back->slot)
- && lynx::rack::rackOf (back->slot.patcher)->chains.size() == 1);
- }
- // Live's own .adg (Core Library, read-only): before round 190hr it opened without chains
- const juce::File live ("C:/ProgramData/Ableton/Live 12 Trial/Resources/Core Library/Racks/Audio Effect Racks/Distortion/Smokey Water.adg");
- const juce::File liveWsl ("/mnt/c/ProgramData/Ableton/Live 12 Trial/Resources/Core Library/Racks/Audio Effect Racks/Distortion/Smokey Water.adg");
- const auto adg = live.existsAsFile() ? live : liveWsl;
- if (adg.existsAsFile())
- {
- juce::MemoryBlock data;
- adg.loadFileAsData (data);
- const auto* bytes = static_cast<const std::uint8_t*> (data.getData());
- auto p = lynx::importLiveDevicePreset (std::vector<std::uint8_t> (bytes, bytes + data.getSize()));
- check ("Live's Smokey Water.adg opens with its chain and devices", p.has_value() && lynx::rack::isRack (p->slot)
- && ! lynx::rack::rackOf (p->slot.patcher)->chains.empty()
- && lynx::rack::devices (*lynx::rack::rackOf (p->slot.patcher), 0).size() >= 3);
- if (p)
- {
- lynx::rack::rackOf (p->slot.patcher)->showDevices = true;
- lynx::rack::rackOf (p->slot.patcher)->showChains = true;
- offline.editSong ([slot = p->slot] (lynx::Song& s) { s.mixer[3].effects = { slot }; }, false);
- offline.dispatchPendingMessages();
- auto view = lynx::RackWindows::makeSlotView (offline, 3, 0, true);
- view->setSize (std::max (520, view->preferredWidth (228)), 228);
- writeView (*view, "08-live-adg-smokey-water");
- }
- }
- else
- checks << "skip Live's Core Library is not on this machine\n";
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runHelixShot190ja (const juce::String& prefix, const juce::String& preset)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1920x1080"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto write = [&prefix, &ui, &offline] (const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- // the Helix channel: Helix's defaults, or a Live Wavetable preset's values through the .als import's own mapping
- lynx::ChannelDef helix;
- helix.instrument = lynx::InstrumentKind::helix;
- helix.name = "Helix";
- if (preset.isNotEmpty())
- {
- juce::MemoryBlock raw;
- juce::File (preset).loadFileAsData (raw);
- juce::MemoryInputStream in (raw, false);
- juce::GZIPDecompressorInputStream gz (&in, false, juce::GZIPDecompressorInputStream::gzipFormat);
- const auto text = juce::File (preset).getFileExtension() == ".adv" ? gz.readEntireStreamAsString() : juce::String();
- lynx::xml::Document doc;
- lynx::alsdev::Notes notes;
- const auto parsed = doc.parse (text.toStdString());
- auto device = parsed ? doc.root().child ("InstrumentVector") : lynx::xml::Element();
- check ("preset read: " + preset, parsed && (bool) device && lynx::alsdev::wavetableToHelix (device, helix, notes));
- helix.name = juce::File (preset).getFileNameWithoutExtension().toStdString();
- }
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- offline.editSong ([&helix] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- helix.mixerTrack = s.channels[0].mixerTrack;
- s.channels[0] = helix;
- while (s.patterns.empty())
- s.patterns.emplace_back();
- lynx::Note note;
- note.channel = 0;
- note.key = 60;
- s.patterns[0].name = "Chords";
- s.patterns[0].notes = { note };
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 2));
- s.playlistTracks[0].name = helix.name;
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 0, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- auto* detail = ui.getDetailViewForSnapshot();
- check ("detail view", detail != nullptr);
- if (detail != nullptr)
- {
- detail->showSelection (0, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- offline.dispatchPendingMessages();
- write ("01-device");
- struct View
- {
- const char* name;
- int modTab, source, osc;
- };
- for (const auto v : { View { "02-matrix", 1, 0, 0 }, View { "03-midi", 2, 0, 0 }, View { "04-mpe", 3, 0, 0 }, View { "05-env2", 0, 1, 0 },
- View { "06-lfo1", 0, 3, 0 }, View { "07-osc2", 0, 0, 1 } })
- {
- check (juce::String ("Helix card shown for ") + v.name, lynx::helixcards::showView (*detail, v.modTab, v.source, v.osc) > 0);
- write (v.name);
- }
- lynx::helixcards::showView (*detail, 0, 0, 0);
- }
- // the Pattern layout: the channel window's page alone
- {
- auto page = lynx::makeHelixEditor (offline, [] (lynx::Song& s) -> lynx::ChannelDef* { return s.channels.empty() ? nullptr : &s.channels[0]; }, 0);
- const auto file = lynx::shot::file (juce::File (prefix + "-10-window.png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (*page), out);
- check ("channel window page", page->getWidth() > 0);
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runHelixShot190oc (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto& bank = lynx::banks::bankOf (lynx::InstrumentKind::helix);
- const auto load = [&] (const juce::String& name) {
- int index = -1;
- for (int b = 0; b < (int) bank.size(); ++b)
- if (juce::String (bank[(std::size_t) b].name) == name)
- index = b;
- check ("preset " + name, index >= 0);
- offline.editSong ([index] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- lynx::ChannelDef c;
- c.instrument = lynx::InstrumentKind::helix;
- c.name = "Helix";
- c.mixerTrack = s.channels[0].mixerTrack;
- if (auto loaded = lynx::banks::withPreset (c, std::max (index, 0)))
- c = *loaded;
- s.channels[0] = c;
- }, false);
- offline.dispatchPendingMessages();
- };
- const auto locate = [] (lynx::Song& s) -> lynx::ChannelDef* { return s.channels.empty() ? nullptr : &s.channels[0]; };
- const auto save = [&prefix, &offline] (juce::Component& c, const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- const auto paintCost = [&checks] (juce::Component& c, const char* what) {
- double best = 1.0e9;
- for (int run = 0; run < 3; ++run)
- {
- juce::Image image (juce::Image::ARGB, c.getWidth(), c.getHeight(), true);
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int f = 0; f < 30; ++f)
- {
- juce::Graphics g (image);
- c.paintEntireComponent (g, false);
- }
- best = std::min (best, (juce::Time::getMillisecondCounterHiRes() - t0) / 30.0);
- }
- checks << "paint " << what << " " << juce::String (best, 3) << " ms per frame (" << c.getWidth() << " x " << c.getHeight() << ")\n";
- };
- // each part of a window alone (the strip, the device), its paint cost
- const auto parts = [&checks] (juce::Component& page) {
- for (int i = 0; i < page.getNumChildComponents(); ++i)
- {
- auto* child = page.getChildComponent (i);
- juce::Image image (juce::Image::ARGB, std::max (1, child->getWidth()), std::max (1, child->getHeight()), true);
- double best = 1.0e9;
- for (int run = 0; run < 3; ++run)
- {
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int f = 0; f < 10; ++f)
- {
- juce::Graphics g (image);
- child->paintEntireComponent (g, false);
- }
- best = std::min (best, (juce::Time::getMillisecondCounterHiRes() - t0) / 10.0);
- }
- checks << " part " << juce::String (best, 3) << " ms " << typeid (*child).name() << " " << child->getBounds().toString() << "\n";
- }
- };
- // the channel window (Pattern layout, LYNX's look): Helix+'s strip with round 4's row
- load ("Grain Swarm");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- check ("window page holds the six strip rows", page->getHeight() >= lynx::helixDeviceHeight + 16 + 446);
- save (*page, "01-window-grain-swarm");
- paintCost (*page, "window (Grain Swarm)");
- }
- load ("Spectral Ensemble");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- save (*page, "02-window-spectral-ensemble");
- paintCost (*page, "window (Spectral Ensemble)");
- parts (*page);
- }
- load ("Frozen Choir");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- save (*page, "03-window-frozen-choir");
- }
- load ("Triple Stack");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- save (*page, "04-window-triple");
- paintCost (*page, "window (Triple Stack)");
- parts (*page);
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runHelixShot190mt (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto& bank = lynx::banks::bankOf (lynx::InstrumentKind::helix);
- const auto load = [&] (const juce::String& name) {
- int index = -1;
- for (int b = 0; b < (int) bank.size(); ++b)
- if (juce::String (bank[(std::size_t) b].name) == name)
- index = b;
- check ("preset " + name, index >= 0);
- offline.editSong ([index] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- lynx::ChannelDef c;
- c.instrument = lynx::InstrumentKind::helix;
- c.name = "Helix";
- c.mixerTrack = s.channels[0].mixerTrack;
- if (auto loaded = lynx::banks::withPreset (c, std::max (index, 0)))
- c = *loaded;
- s.channels[0] = c;
- }, false);
- offline.dispatchPendingMessages();
- };
- const auto locate = [] (lynx::Song& s) -> lynx::ChannelDef* { return s.channels.empty() ? nullptr : &s.channels[0]; };
- const auto save = [&prefix, &offline] (juce::Component& c, const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- const auto paintCost = [&checks] (juce::Component& c, const char* what) {
- double best = 1.0e9;
- for (int run = 0; run < 3; ++run)
- {
- juce::Image image (juce::Image::ARGB, c.getWidth(), c.getHeight(), true);
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int f = 0; f < 30; ++f)
- {
- juce::Graphics g (image);
- c.paintEntireComponent (g, false);
- }
- best = std::min (best, (juce::Time::getMillisecondCounterHiRes() - t0) / 30.0);
- }
- checks << "paint " << what << " " << juce::String (best, 3) << " ms per frame (" << c.getWidth() << " x " << c.getHeight() << ")\n";
- };
- // the channel window (Pattern layout, LYNX's look): Helix+'s strip with round 3's row
- load ("Grain Cloud");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- check ("window page holds the five strip rows", page->getHeight() >= lynx::helixDeviceHeight + 16 + 370);
- save (*page, "01-window-granular");
- paintCost (*page, "window (Grain Cloud)");
- check ("Matrix tab", lynx::helixcards::showView (*page, 1, 0, 0) == 1);
- save (*page, "04-matrix-granular");
- }
- load ("Frozen Choir");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- save (*page, "02-window-spectral");
- }
- load ("Spectral Glass");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- save (*page, "03-window-glass");
- }
- // the same preset as 190ml's first picture (the side by side)
- load ("Triple Stack");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- save (*page, "05-window-triple");
- paintCost (*page, "window (Triple Stack)");
- for (int i = 0; i < page->getNumChildComponents(); ++i) // (each part alone)
- {
- auto* child = page->getChildComponent (i);
- juce::Image image (juce::Image::ARGB, std::max (1, child->getWidth()), std::max (1, child->getHeight()), true);
- double best = 1.0e9;
- for (int run = 0; run < 3; ++run)
- {
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int f = 0; f < 10; ++f)
- {
- juce::Graphics g (image);
- child->paintEntireComponent (g, false);
- }
- best = std::min (best, (juce::Time::getMillisecondCounterHiRes() - t0) / 10.0);
- }
- checks << " part " << juce::String (best, 3) << " ms " << typeid (*child).name() << " " << child->getBounds().toString() << "\n";
- }
- }
- // the Clip-launch layout's Device View card (Live's look) with its Helix+ panel (Granular / Spectral discs)
- load ("Frozen Choir");
- {
- lynx::MainComponent ui (offline, false);
- ui.setSize (2560, 1080);
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- offline.editSong ([] (lynx::Song& s) {
- while (s.patterns.empty())
- s.patterns.emplace_back();
- lynx::Note note;
- note.channel = 0;
- note.key = 60;
- s.patterns[0].name = "Choir";
- s.patterns[0].notes = { note };
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 2));
- s.playlistTracks[0].name = "Helix";
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 0, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- auto* detail = ui.getDetailViewForSnapshot();
- check ("detail view", detail != nullptr);
- if (detail != nullptr)
- {
- detail->showSelection (0, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- offline.dispatchPendingMessages();
- check ("card's Helix+ panel", lynx::helixcards::showPlusInCard (*detail, true) == 1);
- offline.dispatchPendingMessages();
- save (ui, "06-card-plus");
- checks << "detail " << detail->getScreenBounds().translated (-ui.getScreenX(), -ui.getScreenY()).toString() << "\n";
- lynx::helixcards::showPlusInCard (*detail, false);
- }
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runHelixShot190ml (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto& bank = lynx::banks::bankOf (lynx::InstrumentKind::helix);
- const auto load = [&] (const juce::String& name) {
- int index = -1;
- for (int b = 0; b < (int) bank.size(); ++b)
- if (juce::String (bank[(std::size_t) b].name) == name)
- index = b;
- check ("preset " + name, index >= 0);
- offline.editSong ([index] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- lynx::ChannelDef c;
- c.instrument = lynx::InstrumentKind::helix;
- c.name = "Helix";
- c.mixerTrack = s.channels[0].mixerTrack;
- if (auto loaded = lynx::banks::withPreset (c, std::max (index, 0)))
- c = *loaded;
- s.channels[0] = c;
- }, false);
- offline.dispatchPendingMessages();
- };
- const auto locate = [] (lynx::Song& s) -> lynx::ChannelDef* { return s.channels.empty() ? nullptr : &s.channels[0]; };
- const auto save = [&prefix, &offline] (juce::Component& c, const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- const auto paintCost = [&checks] (juce::Component& c, const char* what) {
- double best = 1.0e9;
- for (int run = 0; run < 3; ++run)
- {
- juce::Image image (juce::Image::ARGB, c.getWidth(), c.getHeight(), true);
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int f = 0; f < 30; ++f)
- {
- juce::Graphics g (image);
- c.paintEntireComponent (g, false);
- }
- best = std::min (best, (juce::Time::getMillisecondCounterHiRes() - t0) / 30.0);
- }
- checks << "paint " << what << " " << juce::String (best, 3) << " ms per frame (" << c.getWidth() << " x " << c.getHeight() << ")\n";
- };
- // the channel window (Pattern layout, LYNX's look): Helix+'s strip with Helix+ 2's two rows
- load ("Triple Stack");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- check ("window page holds the four strip rows", page->getHeight() >= lynx::helixDeviceHeight + 16 + 300);
- save (*page, "01-window");
- paintCost (*page, "window");
- // (the slowest parts: each child of the page and of its children, alone)
- std::vector<std::pair<double, juce::String>> parts;
- std::function<void (juce::Component&, int)> walk = [&] (juce::Component& c, int depth) {
- for (auto* child : c.getChildren())
- {
- if (child->getWidth() <= 0 || child->getHeight() <= 0)
- continue;
- juce::Image image (juce::Image::ARGB, child->getWidth(), child->getHeight(), true);
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int f = 0; f < 10; ++f)
- {
- juce::Graphics g (image);
- child->paintEntireComponent (g, false);
- }
- parts.push_back ({ (juce::Time::getMillisecondCounterHiRes() - t0) / 10.0,
- juce::String (depth) + " " + typeid (*child).name() + " " + child->getBounds().toString() });
- if (depth < 2)
- walk (*child, depth + 1);
- }
- };
- walk (*page, 0);
- for (int i = 0; i < page->getNumChildComponents(); ++i) // (the page with one child hidden)
- {
- auto* child = page->getChildComponent (i);
- child->setVisible (false);
- paintCost (*page, (juce::String ("window without child ") + juce::String (i)).toRawUTF8());
- child->setVisible (true);
- }
- paintCost (*page, "window again");
- std::sort (parts.begin(), parts.end(), [] (const auto& x, const auto& y) { return x.first > y.first; });
- for (std::size_t i = 0; i < parts.size() && i < 12; ++i)
- checks << " part " << juce::String (parts[i].first, 3) << " ms " << parts[i].second << "\n";
- check ("Macros tab", lynx::helixcards::showView (*page, 4, 0, 0) == 1);
- save (*page, "02-matrix-macros");
- }
- load ("Vowel Sync");
- {
- auto page = lynx::makeHelixEditor (offline, locate, 0);
- save (*page, "03-window-sample");
- }
- // the table editor on a formula preset's table
- load ("Formula Bell");
- {
- auto editor = lynx::helixcards::makeTableEditor (offline, locate, 0, 0, 0, 20);
- save (*editor, "04-table-draw");
- paintCost (*editor, "table editor (draw)");
- auto harmonics = lynx::helixcards::makeTableEditor (offline, locate, 0, 0, 1, 20);
- save (*harmonics, "05-table-harmonics");
- }
- // the Clip-launch layout's Device View card (Live's look), without and with its Helix+ panel
- load ("Triple Stack");
- {
- lynx::MainComponent ui (offline, false);
- ui.setSize (2560, 1080); // (wide: the card with its panel whole)
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- offline.editSong ([] (lynx::Song& s) {
- while (s.patterns.empty())
- s.patterns.emplace_back();
- lynx::Note note;
- note.channel = 0;
- note.key = 60;
- s.patterns[0].name = "Lead";
- s.patterns[0].notes = { note };
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 2));
- s.playlistTracks[0].name = "Helix";
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 0, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- auto* detail = ui.getDetailViewForSnapshot();
- check ("detail view", detail != nullptr);
- if (detail != nullptr)
- {
- detail->showSelection (0, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- offline.dispatchPendingMessages();
- lynx::helixcards::showPlusInCard (*detail, false);
- save (ui, "06-card");
- check ("card's Helix+ panel", lynx::helixcards::showPlusInCard (*detail, true) == 1);
- offline.dispatchPendingMessages();
- save (ui, "07-card-plus");
- // (where the Device View sits in the picture, for the crops)
- checks << "detail " << detail->getScreenBounds().translated (-ui.getScreenX(), -ui.getScreenY()).toString() << "\n";
- lynx::helixcards::showPlusInCard (*detail, false);
- }
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runHelixShot190mi (const juce::String& prefix, const juce::String& presetName)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto& bank = lynx::banks::bankOf (lynx::InstrumentKind::helix);
- int index = -1;
- for (int b = 0; b < (int) bank.size(); ++b)
- if (juce::String (bank[(std::size_t) b].name) == presetName)
- index = b;
- check ("preset " + presetName, index >= 0);
- offline.editSong ([index] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- lynx::ChannelDef c;
- c.instrument = lynx::InstrumentKind::helix;
- c.mixerTrack = s.channels[0].mixerTrack;
- if (auto loaded = lynx::banks::withPreset (c, std::max (index, 0)))
- c = *loaded;
- s.channels[0] = c;
- }, false);
- offline.dispatchPendingMessages();
- auto page = lynx::makeHelixEditor (offline, [] (lynx::Song& s) -> lynx::ChannelDef* { return s.channels.empty() ? nullptr : &s.channels[0]; }, 0);
- const auto write = [&prefix, &page, &offline] (const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (*page), out);
- };
- check ("window page", page->getWidth() > 0 && page->getHeight() > lynx::helixDeviceHeight + 100);
- check ("Helix panel inside", lynx::helixcards::showView (*page, 0, 0, 0) == 1);
- write ("01-window");
- lynx::helixcards::showView (*page, 0, 3, 0);
- write ("02-lfo1-drawn");
- lynx::helixcards::showView (*page, 1, 0, 0);
- write ("03-matrix");
- // the window's paint cost (device + strip, the Mod Sources page): 60 whole frames off screen, the best of 3 runs
- lynx::helixcards::showView (*page, 0, 0, 0);
- double best = 1.0e9;
- for (int run = 0; run < 3; ++run)
- {
- juce::Image image (juce::Image::ARGB, page->getWidth(), page->getHeight(), true);
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int f = 0; f < 60; ++f)
- {
- juce::Graphics g (image);
- page->paintEntireComponent (g, false);
- }
- best = std::min (best, (juce::Time::getMillisecondCounterHiRes() - t0) / 60.0);
- }
- checks << "paint " << juce::String (best, 3) << " ms per frame (" << page->getWidth() << " x " << page->getHeight() << ")\n";
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runLiveShot190ce (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix, &ui, &offline] (const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- juce::String checks;
- const auto check = [&checks] (const char* what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- // a small library of its own (empty files: only names are shown)
- const auto lib = juce::File (prefix + "-library");
- lib.deleteRecursively();
- for (const auto* path : { "Drums/Kicks/Kick Hard.wav", "Drums/Kicks/Kick Soft.wav", "Drums/Snare Tight.wav", "Drums/Hat Closed.wav",
- "Loops/Break 120.wav", "Loops/Shaker 98.wav", "Textures/Vinyl Noise.wav", "Textures/Rain.wav" })
- lib.getChildFile (path).create();
- auto& browser = ui.getBrowserForSnapshot();
- auto& store = lynx::BrowserComponent::collectionStore();
- store = {};
- const auto item = [&lib] (const char* path) { return lib.getChildFile (path).getFullPathName().toStdString(); };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::browser, lynx::workspace::Panel::playlist });
- offline.editSong ([] (lynx::Song& s) {
- if (s.channels.size() < 2)
- s.channels.resize (2);
- s.channels[0].name = "Bass synth";
- s.channels[0].mixerTrack = 2;
- s.channels[1].mixerTrack = 3;
- if (s.mixer.size() < 4)
- s.mixer.resize (4);
- s.mixer[2].name = "Bass";
- s.mixer[2].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::compressor, lynx::EffectKind::delay })
- {
- lynx::EffectSlot fx;
- fx.kind = kind;
- const auto& info = lynx::effectInfo (kind);
- for (std::size_t k = 0; k < info.params.size() && k < fx.params.size(); ++k)
- fx.params[k] = info.params[k].defaultValue;
- s.mixer[2].effects.push_back (fx);
- }
- s.mixer[2].effects[1].enabled = false; // the compressor: off, at half mix
- s.mixer[2].effects[1].mix = 0.5f;
- while (s.patterns.size() < 2)
- s.patterns.emplace_back();
- s.patterns[0].name = "Bass line";
- lynx::Note note;
- note.channel = 0;
- note.key = 36;
- s.patterns[0].notes = { note };
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 3));
- s.playlistTracks[1].name = "Bass";
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 1, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- auto* detail = ui.getDetailViewForSnapshot();
- if (detail == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText ("FAIL no detail view\n");
- return;
- }
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- detail->selectCardForCheck (2); // the compressor (card 0 is the instrument)
- write ("01-devices"); // the cards' title buttons: hot-swap, save, fold
- saveMenus (juce::StringArray { "Device (effect card)" }, std::vector<juce::PopupMenu> { detail->cardMenuForSnapshot (2) }, prefix + "-02-device-menu.png");
- // hot-swap on for the compressor: the Browser's bar, the Plugin database's effects, the card's button lit
- const auto compressor = lynx::hotswap::targetOfEffect (offline.getSong(), 2, 1);
- browser.beginHotSwap (compressor);
- write ("03-hotswap-effect");
- check ("hot-swap links the compressor", browser.isHotSwapping() && browser.hotSwapTarget() == compressor);
- // a swap through the Browser itself (the row of LYNX's Reverb, then Enter): the slot keeps its place, its off
- // state and its Mix; the link moves to the new device
- {
- browser.showPluginDatabase ("LYNX SHARE", 0); // (the folder of LYNX's own effects, opened as a click would)
- browser.selectRowForSnapshot (lynx::tr (lynx::effectInfo (lynx::EffectKind::reverb).name));
- write ("03a-hotswap-row"); // the candidate's row selected
- check ("swap: Enter on the Reverb row is taken by hot-swap", browser.hotSwapLoadSelected());
- offline.dispatchPendingMessages();
- const auto& slot = offline.getSong().mixer[2].effects[1];
- // (round 190cy: the device comes in with its own on / off state, on, as in Live 12.4.16; the Mix stays)
- check ("swap: reverb in the compressor's place, on (its own state), at 50 % mix", slot.kind == lynx::EffectKind::reverb && slot.enabled && slot.mix == 0.5f);
- check ("swap: three effects as before", offline.getSong().mixer[2].effects.size() == 3);
- check ("swap: the Browser is linked to the new device", browser.isHotSwapping() && browser.hotSwapTarget() == lynx::hotswap::targetOfEffect (offline.getSong(), 2, 1)
- && ! (browser.hotSwapTarget() == compressor));
- write ("03b-hotswap-swapped");
- offline.undo();
- offline.dispatchPendingMessages();
- const auto& back = offline.getSong().mixer[2].effects[1];
- check ("undo: the compressor is back with its instance", back.kind == lynx::EffectKind::compressor && back.instance.id == compressor.instance);
- check ("undo: the Browser is still linked to it", browser.isHotSwapping() && browser.hotSwapTarget() == compressor);
- }
- // round 190cy (Live 12.4.16 live check 190cw shot 02a): hot-swap starts on the device's current preset. The
- // compressor got its settings from a saved preset of LYNX's ("Glue bus", in this run's own settings folder)
- {
- browser.endHotSwap();
- const auto folder = lynx::pluginheader::userFolder (lynx::EffectKind::compressor);
- folder.createDirectory();
- const auto& fx = offline.getSong().mixer[2].effects[1];
- for (const auto* name : { "Glue bus", "Gentle", "Parallel smash" })
- folder.getChildFile (juce::String (name) + ".lynxpreset").replaceWithText (lynx::presets::toText (lynx::EffectKind::compressor, name, fx.params));
- offline.editSong ([] (lynx::Song& s) { s.mixer[2].effects[1].presetName = "Glue bus"; }, false);
- offline.dispatchPendingMessages();
- browser.beginHotSwap (compressor);
- write ("03c-hotswap-current-preset");
- check ("hot-swap starts on the current preset", browser.getSelectedFile() == folder.getChildFile ("Glue bus.lynxpreset"));
- // a preset of the same effect swapped in comes in on (the compressor was off)
- browser.selectRowForSnapshot ("Gentle.lynxpreset");
- check ("swap: the preset row is taken by hot-swap", browser.hotSwapLoadSelected());
- offline.dispatchPendingMessages();
- const auto& now = offline.getSong().mixer[2].effects[1];
- check ("swap: the preset's settings, the device on", now.kind == lynx::EffectKind::compressor && now.presetName == "Gentle" && now.enabled);
- write ("03d-hotswap-preset-swapped");
- offline.undo();
- offline.dispatchPendingMessages();
- check ("undo: the compressor off again", ! offline.getSong().mixer[2].effects[1].enabled);
- browser.endHotSwap();
- check ("hot-swap ended: the preset list goes", ! browser.isHotSwapping());
- browser.beginHotSwap (compressor);
- }
- // linked to the instrument instead
- const auto bass = lynx::hotswap::targetOfChannel (offline.getSong(), 0);
- browser.beginHotSwap (bass);
- detail->selectCardForCheck (0);
- write ("04-hotswap-instrument");
- check ("re-link to the instrument", browser.hotSwapTarget() == bass);
- browser.endHotSwap();
- check ("hot-swap ended", ! browser.isHotSwapping());
- write ("05-hotswap-ended"); // the Browser as it was before
- // the device is deleted while linked: the mode ends by itself
- browser.beginHotSwap (lynx::hotswap::targetOfEffect (offline.getSong(), 2, 2));
- offline.editSong ([] (lynx::Song& s) { s.mixer[2].effects.pop_back(); });
- offline.dispatchPendingMessages();
- check ("deleting the linked device ends hot-swap", ! browser.isHotSwapping());
- offline.undo();
- offline.dispatchPendingMessages();
- // Duplicate (Ctrl+D) of the EQ
- check ("duplicate", detail->duplicateCardForCheck (1));
- offline.dispatchPendingMessages();
- check ("duplicate: four effects, EQ twice", offline.getSong().mixer[2].effects.size() == 4 && offline.getSong().mixer[2].effects[1].kind == lynx::EffectKind::eq
- && offline.getSong().mixer[2].effects[0].instance.id != offline.getSong().mixer[2].effects[1].instance.id);
- write ("06-duplicated");
- // --- collections ---
- browser.showFilterForSnapshot (lib, lynx::browserview::ContentFilter::all);
- ui.waitForBrowserForSnapshot();
- browser.setInCollection (item ("Drums/Kicks/Kick Hard.wav"), 0, true);
- browser.setInCollection (item ("Drums/Snare Tight.wav"), 0, true);
- browser.setInCollection (item ("Loops"), 0, true);
- browser.setTab (lynx::BrowserComponent::starredTab);
- write ("07-starred-only"); // only Starred shown: the tab as it always was
- browser.setInCollection (item ("Drums/Kicks/Kick Hard.wav"), 4, true); // also Blue
- browser.setInCollection (item ("Loops/Break 120.wav"), 4, true);
- browser.setInCollection (item ("Textures/Vinyl Noise.wav"), 3, true);
- browser.setInCollection (item ("Textures/Rain.wav"), 3, true);
- browser.setInCollection (item ("Drums/Hat Closed.wav"), 1, true);
- store.rename (3, "Textures");
- browser.setCollectionShown (1, true);
- browser.setCollectionShown (3, true);
- browser.setCollectionShown (4, true);
- write ("08-collections"); // a heading per collection shown
- check ("collections: four shown", store.shown().size() == 4);
- check ("collections: an item in two", store.mask (item ("Drums/Kicks/Kick Hard.wav")) == 0b10001);
- // round 190cy: the Clip-launch workflow's row menu lists the collections flat, as Live's item menu (shot 05);
- // the Pattern workflow keeps the "Collections" sub-menu
- browser.setLiveItemMenus (false);
- saveMenus (juce::StringArray { "Collections (Pattern workflow: a row's sub-menu)" }, std::vector<juce::PopupMenu> { browser.collectionsMenuForSnapshot (item ("Drums/Kicks/Kick Hard.wav")) },
- prefix + "-09-collections-menu.png");
- browser.setLiveItemMenus (true);
- saveMenus (juce::StringArray { "Collections (Clip-launch workflow: a row's menu)" }, std::vector<juce::PopupMenu> { browser.collectionsMenuForSnapshot (item ("Drums/Kicks/Kick Hard.wav")) },
- prefix + "-09b-collections-flat.png");
- // the key of a hidden collection (6, Purple) labels the row and the collection appears
- check ("hidden collection: not shown before", ! store.isShown (5));
- browser.setInCollection (item ("Textures/Rain.wav"), 5, true);
- check ("hidden collection: its key shows it", store.isShown (5) && store.has (item ("Textures/Rain.wav"), 5));
- write ("08b-hidden-collection-shown");
- saveMenus (juce::StringArray { "Browser options" }, std::vector<juce::PopupMenu> { browser.buildViewMenu() }, prefix + "-10-browser-options.png");
- browser.setTab (lynx::BrowserComponent::allTab);
- write ("11-all-tab-chips"); // the colour chips on the rows of the ALL tab
- browser.setSearchForSnapshot ("textures");
- ui.waitForBrowserForSnapshot();
- write ("12-search-collection-name"); // found by the collection's name
- browser.setSearchForSnapshot ({});
- // the file round trip
- {
- const auto text = store.toText();
- check ("collections: text round trip", lynx::collections::Store::fromText (text) == store);
- }
- store = {};
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- lib.deleteRecursively();
- }
- void runLinkShot190gl (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- ui.setVisible (true);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto writeImage = [&prefix] (const juce::Image& image, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- const auto toolbarShot = [&] (const char* name) {
- ui.tickLinkForSnapshot();
- writeImage (lynx::shot::snapshot (ui, ui.getToolbarBoundsForSnapshot()), name);
- };
- auto& link = offline.getLink();
- auto& transport = offline.getTransport();
- link.deviceStarted (44100.0);
- // the audio callbacks the offline engine has none of: Link's per-block step, in real time
- const auto pump = [&] (double seconds, std::function<bool()> until = {}) {
- const auto end = juce::Time::getMillisecondCounterHiRes() + seconds * 1000.0;
- while (juce::Time::getMillisecondCounterHiRes() < end)
- {
- const auto start = link.beginBlock (transport, 256, 0.0);
- if (start >= 0)
- transport.playing.store (true);
- if (transport.playing.load())
- transport.positionTicks.store (transport.positionTicks.load() + 256 * transport.ticksPerSample());
- juce::Thread::sleep (6);
- if (until && until())
- return true;
- }
- return ! until || until();
- };
- auto peer = lynx::AbletonLink::makeTestPeer (97.0); // the other app in the session (it was there first)
- juce::Thread::sleep (1500); // (a session that started at the same moment as LYNX's could take either tempo)
- using lynx::toolbarlayout::Group;
- // FL's Pattern layout: no Link toggle on a new install
- check ("Pattern layout: the Link toggle is hidden by default", ! ui.getToolbarLayoutForSnapshot().isShown (Group::link));
- toolbarShot ("toolbar-fl-default");
- // shown by hand (Settings › Ableton Link › Show Link Toggle): "Link", off
- auto layout = ui.getToolbarLayoutForSnapshot();
- layout.setShown (Group::link, true);
- ui.setToolbarLayoutForSnapshot (layout);
- toolbarShot ("toolbar-fl-link-off");
- check ("off: the toggle says Link", ui.getLinkToggleForSnapshot().text() == lynx::trc ("@Ableton Link: Link"));
- // on: the session the other peer runs (its tempo, 97 BPM, wins over the project's)
- link.setEnabled (true, offline.getSong().bpm);
- // (a new peer is counted at once; its session's tempo is taken after Link measured it, a moment later)
- const auto joined = pump (8.0, [&] { return link.peers() > 0 && link.startProgress() >= 0.0 && std::abs (link.sessionTempo() - 97.0) < 1e-3; });
- check ("Link on: one peer found", joined && link.peers() == 1);
- check ("Link on: the session's tempo (97 BPM, the first peer's) is the one shown", std::abs (offline.shownTempo() - 97.0) < 1e-3);
- toolbarShot ("toolbar-fl-link-on");
- check ("on with one peer: the toggle says 1 Link", ui.getLinkToggleForSnapshot().text() == lynx::trc ("@Ableton Link: {0} Link").replace ("{0}", "1"));
- check ("stopped with a peer: the position display shows the session's progress", link.startProgress() >= 0.0);
- // the Clip-launch layout: the toggle is shown by default (the reference DAW's "Show Link Toggle": Show)
- ui.setToolbarLayoutForSnapshot (lynx::toolbarlayout::Layout::makeDefault());
- ui.setClipLaunchWorkflow (true);
- check ("Clip-launch layout: the Link toggle is shown by default", ui.getToolbarLayoutForSnapshot().isShown (Group::link));
- pump (0.4);
- toolbarShot ("toolbar-cliplaunch-1link");
- writeImage (lynx::shot::snapshot (ui), "window-cliplaunch");
- // Play: it waits for the session's phase (the play button lit, the progress bar running), then starts
- transport.playing.store (true);
- pump (0.05);
- const auto waited = offline.isLinkWaiting();
- check ("Play with a peer waits for the session's phase", waited);
- toolbarShot ("toolbar-cliplaunch-waiting");
- const auto started = pump (4.0, [&] { return transport.playing.load() && ! offline.isLinkWaiting(); });
- check ("then playback starts on the session's phase", started);
- pump (0.5);
- toolbarShot ("toolbar-cliplaunch-playing");
- check ("playing: no progress bar", link.startProgress() < 0.0);
- // the toggle's drop-down and the Options menu
- saveMenus (juce::StringArray { lynx::trc ("@Ableton Link: Link") }, std::vector<juce::PopupMenu> { ui.getLinkToggleForSnapshot().makeMenu() },
- prefix + "-menu-link.png");
- {
- const auto names = ui.getMenuNamesForSnapshot();
- for (int m = 0; m < names.size(); ++m)
- if (names[m] == lynx::tr ("Options"))
- saveMenus (juce::StringArray { names[m] }, std::vector<juce::PopupMenu> { ui.getMenuForSnapshot (m) }, prefix + "-menu-options.png");
- }
- // Settings › Ableton Link
- {
- lynx::SettingsHooks hooks;
- hooks.linkToggleShown = [] { return true; };
- auto panel = lynx::makeSettingsPanel (offline, lynx::SettingsPage::link, false, hooks);
- panel->setSize (680, 620);
- writeImage (lynx::shot::snapshot (*panel), "settings-link");
- }
- // off: the project's own tempo comes back on the display
- transport.playing.store (false);
- pump (0.1);
- link.setEnabled (false, offline.getSong().bpm);
- pump (0.1);
- toolbarShot ("toolbar-cliplaunch-link-off");
- check ("off: the tempo display shows the project's tempo again", std::abs (offline.shownTempo() - offline.getSong().bpm) < 1e-9);
- const auto stats = link.stats();
- checks << "audio-thread cost of the Link step: mean " << juce::String (stats.meanUs, 2) << " us, max " << juce::String (stats.maxUs, 1)
- << " us over " << (juce::int64) stats.blocks << " blocks\n";
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- // LYNX --communityshot190hp <prefix> (round 190hp): the three community slices off-screen, with checks in
- // prefix-checks.txt — B9 the MIDI Map Mode's "In every project (LYNX)" (the row menu, the Mapping Browser with the
- // global rows, a new project still playing on the mapped CC, Settings' list), B16 the Mixer menu's Mix snapshots
- // (take, recall, Compare A/B, the .lynx round trip), B18 the audio clip menu's "Split at silence..." (the dialog and
- // the Playlist before / after).
- void runCommunityShot190hp (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto plain = [] (juce::String t) { return t.upToFirstOccurrenceOf ("\t", false, false).removeCharacters ("&"); };
- const auto find = [&plain] (const juce::PopupMenu& menu, const juce::String& text) -> const juce::PopupMenu::Item* {
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- if (plain (it.getItem().text) == plain (text))
- return &it.getItem();
- return nullptr;
- };
- const auto click = [&find] (const juce::PopupMenu& menu, const juce::String& text) {
- const auto* item = find (menu, text);
- if (item == nullptr || ! item->isEnabled || item->action == nullptr)
- return false;
- item->action();
- return true;
- };
- using namespace lynx::remotemap;
- ui.setVisible (true);
- // ---- B9: the MIDI Map Mode's mappings for every project ---------------------------------------------------------
- ui.setClipLaunchWorkflow (true);
- offline.editSong ([] (lynx::Song& s) {
- auto& grid = lynx::launcher::ensureGrid (s);
- grid.scenes.resize (4);
- assignMidi (s, Target::of (lynx::RemoteAction::play), { 0, 118, -1 });
- assignMidi (s, Target::of (lynx::RemoteAction::stop), { 0, 117, -1 });
- assignMidi (s, Target::sceneLaunch (0), { 0, lynx::linkNoteBase + 44, -1 });
- assignMidi (s, Target::slot (0, 0), { 0, lynx::linkNoteBase + 36, -1 });
- assignMidi (s, Target::parameter ({ lynx::AutomationTargetKind::mixerVolume, 0, 0, 0 }), { 0, 7, -1 });
- }, false);
- offline.dispatchPendingMessages();
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist, lynx::workspace::Panel::browser });
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- ui.setMapMode (Mode::midi);
- auto* list = ui.mappingBrowserForSnapshot();
- if (list == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText (checks + "FAIL no Mapping Browser\n");
- return;
- }
- list->setMode (Mode::midi);
- ui.resized();
- const auto rowOf = [&] (const Target& t) {
- const auto rows = list->rowsShown();
- for (int r = 0; r < (int) rows.size(); ++r)
- if (rows[(std::size_t) r].target == t)
- return r;
- return -1;
- };
- const auto everyProject = lynx::tr ("In every project (LYNX)");
- {
- const auto slotMenu = list->rowMenu (rowOf (Target::slot (0, 0)));
- const auto* item = find (slotMenu, everyProject);
- check ("row menu: a clip slot cannot be for every project (greyed)", item != nullptr && ! item->isEnabled);
- const auto playRow = rowOf (Target::of (lynx::RemoteAction::play));
- list->selectRow (playRow);
- const auto playMenu = list->rowMenu (playRow);
- const auto* p = find (playMenu, everyProject);
- check ("row menu: Play can, unticked", p != nullptr && p->isEnabled && ! p->isTicked);
- saveMenus (juce::StringArray { "Row" }, std::vector<juce::PopupMenu> { playMenu }, prefix + "-b9-01-row-menu.png");
- check ("Play goes to every project", click (playMenu, everyProject) && offline.getMidiPrefs().globalMappings.size() == 1);
- }
- check ("Stop goes too", click (list->rowMenu (rowOf (Target::of (lynx::RemoteAction::stop))), everyProject));
- check ("the Master volume link goes too (FL's global links)",
- click (list->rowMenu (rowOf (Target::parameter ({ lynx::AutomationTargetKind::mixerVolume, 0, 0, 0 }))), everyProject)
- && offline.getMidiPrefs().globalLinks.size() == 1 && offline.getSong().midiLinks.empty());
- list->setMode (Mode::midi);
- const auto shown = list->rowsShown();
- check ("Mapping Browser: 2 project rows, then 3 global ones (" + juce::String ((int) shown.size()) + ")",
- shown.size() == 5 && ! shown[0].global && ! shown[1].global && shown[2].global && shown[4].global);
- {
- const auto rowMenu = list->rowMenu (2); // (round 190rf: kept while its item is read; ASan, heap-use-after-free)
- const auto* ticked = find (rowMenu, everyProject);
- check ("a global row's item is ticked", ticked != nullptr && ticked->isTicked);
- }
- write (*list, "b9-02-mapping-browser-global");
- // a new project: the global mappings are there and act (CC 118 plays, CC 117 stops)
- offline.setSong (lynx::Song::makeDefault());
- offline.dispatchPendingMessages();
- list->setMode (Mode::midi);
- const auto fresh = list->rowsShown();
- check ("new project: the 3 global rows (" + juce::String ((int) fresh.size()) + ")", fresh.size() == 3 && fresh[0].global);
- write (*list, "b9-03-new-project-browser");
- ui.setMapMode (Mode::off);
- offline.injectControllerForTest (118, 0, 127);
- offline.dispatchPendingMessages();
- check ("new project: CC 118 plays", offline.getTransport().playing.load());
- offline.injectControllerForTest (118, 0, 0);
- offline.injectControllerForTest (117, 0, 127);
- offline.dispatchPendingMessages();
- check ("new project: CC 117 stops", ! offline.getTransport().playing.load());
- offline.injectControllerForTest (7, 0, 0);
- offline.dispatchPendingMessages();
- check ("new project: CC 7 moves the Master", offline.currentTargetValue ({ lynx::AutomationTargetKind::mixerVolume, 0, 0, 0 }) < 0.01f);
- // the Pattern layout: they act there too, and Settings › MIDI lists them
- ui.setClipLaunchWorkflow (false);
- offline.injectControllerForTest (117, 0, 0);
- offline.injectControllerForTest (118, 0, 127);
- offline.dispatchPendingMessages();
- check ("Pattern layout: CC 118 plays", offline.getTransport().playing.load());
- offline.stop();
- // back into one project, then cleared (the settings of this test engine are never written)
- ui.setClipLaunchWorkflow (true);
- ui.setMapMode (Mode::midi);
- list->setMode (Mode::midi);
- check ("back into this project", click (list->rowMenu (rowOf (Target::of (lynx::RemoteAction::play))), everyProject)
- && offline.getMidiPrefs().globalMappings.size() == 1 && offline.getSong().remoteMappings.size() == 1);
- ui.setMapMode (Mode::off);
- ui.setClipLaunchWorkflow (false);
- // ---- B16: Mix snapshots ----------------------------------------------------------------------------------------
- offline.setSong (lynx::Song::makeDefault());
- offline.dispatchPendingMessages();
- offline.editSong ([] (lynx::Song& s) {
- const char* names[] { "Master", "Drums", "Bass", "Keys", "Vox", "Reverb" };
- for (int i = 1; i < 6 && i < (int) s.mixer.size(); ++i)
- s.mixer[(std::size_t) i].name = names[i];
- s.mixer[1].volume = 0.7f;
- s.mixer[4].pan = -0.3f;
- s.setRoute (4, 5, true, 0.5f);
- });
- juce::PopupMenu mixerMenu;
- lynx::mixeroptions::addItems (mixerMenu, offline, false);
- const auto* snaps = find (mixerMenu, lynx::tr ("Mix snapshots (LYNX)"));
- check ("Mixer menu: Mix snapshots (LYNX)", snaps != nullptr && snaps->subMenu != nullptr);
- check ("Take snapshot", click (lynx::mixeroptions::snapshotsMenu (offline), lynx::tr ("Take snapshot")) && offline.getSong().mixSnapshots.size() == 1);
- offline.editSong ([] (lynx::Song& s) {
- s.mixer[1].volume = 0.4f;
- s.mixer[4].pan = 0.6f;
- s.mixer[3].muted = true;
- s.setRoute (4, 5, false);
- });
- check ("Take snapshot again", click (lynx::mixeroptions::snapshotsMenu (offline), lynx::tr ("Take snapshot")) && offline.getSong().mixSnapshots.size() == 2);
- {
- const auto menu = lynx::mixeroptions::snapshotsMenu (offline);
- const auto* first = find (menu, juce::String ("Snapshot 1 (B)"));
- check ("snapshot 1 listed as B", first != nullptr && first->subMenu != nullptr && ! first->isTicked);
- const auto* second = find (menu, juce::String ("Snapshot 2 (A)"));
- check ("snapshot 2 ticked: the mix is it", second != nullptr && second->isTicked);
- saveMenus (juce::StringArray { "Mixer", "Mix snapshots (LYNX)", "Snapshot 1" },
- std::vector<juce::PopupMenu> { mixerMenu, menu, first != nullptr ? *first->subMenu : juce::PopupMenu() }, prefix + "-b16-01-menus.png");
- check ("Recall snapshot 1", first != nullptr && click (*first->subMenu, lynx::tr ("Recall")));
- }
- const auto& m = offline.getSong().mixer;
- check ("recalled: fader, pan, mute, send", m[1].volume == 0.7f && m[4].pan == -0.3f && ! m[3].muted && offline.getSong().routes (4, 5));
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::mixer });
- ui.resized();
- offline.dispatchPendingMessages();
- write (ui, "b16-02-mixer-recalled");
- check ("Compare A/B", click (lynx::mixeroptions::snapshotsMenu (offline), lynx::tr ("Compare A/B: back to \"{0}\"", { "Snapshot 2" }))
- && m[1].volume == 0.4f && m[3].muted);
- offline.undo();
- check ("one undo step: back to snapshot 1", m[1].volume == 0.7f);
- {
- const auto file = juce::File (prefix + "-b16-snapshots.lynx");
- juce::String error;
- const auto saved = lynx::ProjectFile::save (offline.getSong(), file, error);
- const auto back = lynx::ProjectFile::load (file, error);
- check ("saved and loaded: the snapshots and A/B", saved && back && back->mixSnapshots == offline.getSong().mixSnapshots
- && back->mixSnapshotCurrent == offline.getSong().mixSnapshotCurrent
- && back->mixSnapshotPrevious == offline.getSong().mixSnapshotPrevious);
- file.deleteFile();
- }
- // ---- B18: Split at silence -------------------------------------------------------------------------------------
- {
- // a "vocal take": 0.5 s silence, three phrases with pauses of 0.6 s and 0.15 s, quiet hiss in the gaps
- const double rate = 44100.0;
- juce::AudioBuffer<float> buffer (1, (int) (rate * 4.0));
- buffer.clear();
- juce::Random noise (190);
- for (int i = 0; i < buffer.getNumSamples(); ++i)
- {
- const auto t = i / rate;
- const auto phrase = (t >= 0.5 && t < 1.4) || (t >= 2.0 && t < 2.6) || (t >= 2.75 && t < 3.3);
- buffer.setSample (0, i, phrase ? (float) (0.4 * std::sin (juce::MathConstants<double>::twoPi * 180.0 * t) * (0.6 + 0.4 * std::sin (6.0 * t)))
- : (noise.nextFloat() - 0.5f) * 0.0004f);
- }
- const auto wav = juce::File (prefix + "-b18-take.wav");
- wav.deleteFile();
- juce::WavAudioFormat format;
- if (auto out = std::unique_ptr<juce::AudioFormatWriter> (format.createWriterFor (wav.createOutputStream().release(), rate, 1, 16, {}, 0)))
- out->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- auto song = lynx::Song::makeDefault();
- song.channels.push_back ({});
- song.channels.back().name = "Vocal take";
- song.channels.back().instrument = lynx::InstrumentKind::audioClip;
- song.channels.back().samplePath = wav.getFullPathName().toStdString();
- lynx::Clip c;
- c.kind = lynx::ClipKind::audio;
- c.channel = (int) song.channels.size() - 1;
- c.track = 1;
- c.start = 4 * lynx::ppq;
- c.length = (std::int64_t) std::llround (4.0 * song.bpm / 60.0 * lynx::ppq); // (the whole file at the song tempo)
- song.playlist.push_back (c);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- ui.resized();
- auto& playlist = ui.getPlaylistForSnapshot();
- const auto index = (int) offline.getSong().playlist.size() - 1;
- const auto menu = playlist.getClipMenuForSnapshot (index);
- const auto* item = find (menu, lynx::tr ("Split at silence..."));
- const auto* splitHere = find (menu, lynx::tr ("Split here"));
- check ("clip menu: Split at silence... in LYNX extras, enabled", item != nullptr && item->isEnabled && splitHere != nullptr);
- savePng (columnMenuImage (menu), prefix + "-b18-01-clip-menu.png");
- {
- auto dialog = playlist.makeSplitSilenceDialogForSnapshot (index);
- write (*dialog, "b18-02-dialog");
- }
- offline.dispatchPendingMessages();
- write (ui, "b18-03-playlist-before");
- juce::String why;
- const auto made = playlist.splitClipsAtSilence ({ index }, lynx::PlaylistComponent::splitSilenceOptions(), &why);
- offline.dispatchPendingMessages();
- const auto& clips = offline.getSong().playlist;
- std::vector<const lynx::Clip*> audio;
- for (const auto& x : clips)
- if (x.kind == lynx::ClipKind::audio)
- audio.push_back (&x);
- std::sort (audio.begin(), audio.end(), [] (const lynx::Clip* a, const lynx::Clip* b) { return a->start < b->start; });
- const auto secondsAt = [&] (std::int64_t ticks) { return (double) (ticks - 4 * lynx::ppq) / lynx::ppq * 60.0 / offline.getSong().bpm; };
- check ("split into 2 clips (the 0.15 s pause stays inside): " + juce::String (made) + ", " + why, made == 2 && audio.size() == 2);
- if (audio.size() == 2)
- check ("the clips start at the phrases less the pre-roll, end after them: " + juce::String (secondsAt (audio[0]->start), 3) + "-"
- + juce::String (secondsAt (audio[0]->end()), 3) + ", " + juce::String (secondsAt (audio[1]->start), 3) + "-" + juce::String (secondsAt (audio[1]->end()), 3),
- std::abs (secondsAt (audio[0]->start) - 0.49) < 0.02 && std::abs (secondsAt (audio[0]->end()) - 1.45) < 0.02
- && std::abs (secondsAt (audio[1]->start) - 1.99) < 0.02 && std::abs (secondsAt (audio[1]->end()) - 3.35) < 0.02
- && audio[1]->offset - audio[0]->offset == audio[1]->start - audio[0]->start);
- write (ui, "b18-04-playlist-after");
- offline.undo();
- check ("one undo step", offline.getSong().playlist.size() == clips.size() && std::count_if (offline.getSong().playlist.begin(), offline.getSong().playlist.end(),
- [] (const lynx::Clip& x) { return x.kind == lynx::ClipKind::audio; }) == 1);
- lynx::stripsilence::Options loud;
- loud.thresholdDb = -1.0f;
- check ("all below the threshold: nothing split", playlist.splitClipsAtSilence ({ index }, loud, &why) == 0);
- wav.deleteFile();
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runMapShot190ef (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- using namespace lynx::remotemap;
- ui.setVisible (true);
- // the Pattern layout first: Ctrl+M stays FL's metronome there and no map mode starts
- {
- const auto before = offline.getTransport().metronome.load();
- ui.keyPressed (juce::KeyPress ('M', juce::ModifierKeys::ctrlModifier, 0));
- check ("Pattern layout: Ctrl+M is the metronome, no map mode", ui.getMapMode() == Mode::off && offline.getTransport().metronome.load() != before);
- ui.keyPressed (juce::KeyPress ('M', juce::ModifierKeys::ctrlModifier, 0));
- ui.setMapMode (Mode::midi);
- check ("Pattern layout: setMapMode stays off", ui.getMapMode() == Mode::off);
- }
- ui.setClipLaunchWorkflow (true);
- offline.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() < 6)
- s.mixer.resize (6);
- const char* inserts[] { "Master", "Drums", "Bass", "Keys", "Vox", "Reverb" };
- for (int i = 1; i < 6; ++i)
- s.mixer[(std::size_t) i].name = inserts[i];
- const int channels = (int) s.channels.size();
- s.channels.resize ((std::size_t) channels + 3);
- const char* names[] { "Drum kit", "Bass synth", "Keys" };
- for (int k = 0; k < 3; ++k)
- {
- auto& ch = s.channels[(std::size_t) (channels + k)];
- ch.name = names[k];
- ch.instrument = k == 0 ? lynx::InstrumentKind::sampler : lynx::InstrumentKind::synth;
- ch.mixerTrack = k + 1;
- }
- s.mixer[2].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::compressor })
- {
- lynx::EffectSlot fx;
- fx.kind = kind;
- const auto& info = lynx::effectInfo (kind);
- for (std::size_t k = 0; k < info.params.size() && k < fx.params.size(); ++k)
- fx.params[k] = info.params[k].defaultValue;
- s.mixer[2].effects.push_back (fx);
- }
- while (s.patterns.size() < 3)
- s.patterns.emplace_back();
- const char* patterns[] { "Beat", "Bassline", "Chords" };
- for (int p = 0; p < 3; ++p)
- {
- auto& pattern = s.patterns[(std::size_t) p];
- pattern.name = patterns[p];
- lynx::Note n;
- n.channel = channels + p;
- n.key = 48 + p * 5;
- pattern.notes = { n };
- pattern.lengthTicks = 4 * lynx::ppq;
- }
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 8));
- const char* tracks[] { "Drums", "Bass", "Keys", "Vox" };
- for (int t = 0; t < 4; ++t)
- s.playlistTracks[(std::size_t) t].name = tracks[t];
- for (int t = 0; t < 3; ++t)
- for (int r = 0; r < 3; ++r)
- {
- lynx::Clip clip;
- clip.pattern = t;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, t, r, clip);
- }
- auto& grid = lynx::launcher::ensureGrid (s);
- const char* scenes[] { "Intro", "Verse", "Drop" };
- grid.scenes.resize (4);
- for (int r = 0; r < 3; ++r)
- grid.scenes[(std::size_t) r].name = scenes[r];
- // some mappings, as the lesson's pictures show them (pads on slots and scenes, knobs on volume and pan)
- assignMidi (s, Target::slot (0, 0), { 0, lynx::linkNoteBase + 36, -1 });
- assignMidi (s, Target::slot (1, 0), { 0, lynx::linkNoteBase + 37, -1 });
- assignMidi (s, Target::sceneLaunch (1), { 0, lynx::linkNoteBase + 44, -1 });
- assignMidi (s, Target::parameter ({ lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 }), { 0, 17, -1 });
- assignMidi (s, Target::parameter ({ lynx::AutomationTargetKind::mixerPan, 1, 0, 0 }), { 0, 16, -1 });
- assignMidi (s, Target::of (lynx::RemoteAction::play), { 0, 118, -1 });
- setRange (s, rows (s, Mode::midi)[0], 0.0f, 0.85f);
- assignKey (s, Target::slot (0, 1), 'A');
- assignKey (s, Target::slot (1, 1), 'S');
- assignKey (s, Target::sceneLaunch (2), '3');
- assignKey (s, Target::parameter ({ lynx::AutomationTargetKind::mixerVolume, 2, 0, 0 }), 'V');
- }, false);
- offline.dispatchPendingMessages();
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist, lynx::workspace::Panel::browser }); // (no floating Channel Rack over the grid)
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- offline.dispatchPendingMessages();
- ui.resized();
- if (auto* detail = ui.getDetailViewForSnapshot())
- {
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- }
- ui.resized();
- offline.dispatchPendingMessages();
- write (ui, "00-clip-launch-before");
- // Ctrl+M in the Clip-launch layout: MIDI Map Mode (the metronome stays as it was)
- const auto metronome = offline.getTransport().metronome.load();
- ui.keyPressed (juce::KeyPress ('M', juce::ModifierKeys::ctrlModifier, 0));
- check ("Clip-launch layout: Ctrl+M starts MIDI Map Mode", ui.getMapMode() == Mode::midi && offline.getTransport().metronome.load() == metronome);
- auto* overlay = ui.mapOverlayForSnapshot();
- auto* list = ui.mappingBrowserForSnapshot();
- if (overlay == nullptr || list == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText (checks + "FAIL no overlay\n");
- return;
- }
- overlay->refresh();
- const auto& spots = overlay->spots();
- const auto count = [&] (lynx::RemoteAction a) { return (int) std::count_if (spots.begin(), spots.end(), [a] (const lynx::mapmode::Spot& p) { return p.target.action == a; }); };
- const auto params = [&] (lynx::AutomationTargetKind k) {
- return (int) std::count_if (spots.begin(), spots.end(), [k] (const lynx::mapmode::Spot& p) { return p.target.action == lynx::RemoteAction::parameter && p.target.param.kind == k; });
- };
- check ("overlay: clip slots (" + juce::String (count (lynx::RemoteAction::clipSlot)) + ")", count (lynx::RemoteAction::clipSlot) >= 12);
- check ("overlay: scene launch buttons (" + juce::String (count (lynx::RemoteAction::sceneLaunch)) + ")", count (lynx::RemoteAction::sceneLaunch) >= 4);
- check ("overlay: track stop buttons", count (lynx::RemoteAction::trackStop) >= 4);
- check ("overlay: Stop all clips, Session Record", count (lynx::RemoteAction::stopAllClips) == 1 && count (lynx::RemoteAction::sessionRecord) == 1);
- check ("overlay: transport play / stop / record / metronome", count (lynx::RemoteAction::play) == 1 && count (lynx::RemoteAction::stop) == 1
- && count (lynx::RemoteAction::record) == 1 && count (lynx::RemoteAction::metronome) == 1);
- check ("overlay: tempo", params (lynx::AutomationTargetKind::tempo) == 1);
- check ("overlay: mixer volume / pan (" + juce::String (params (lynx::AutomationTargetKind::mixerVolume)) + " / " + juce::String (params (lynx::AutomationTargetKind::mixerPan)) + ")",
- params (lynx::AutomationTargetKind::mixerVolume) >= 3 && params (lynx::AutomationTargetKind::mixerPan) >= 3);
- check ("overlay: device knobs (" + juce::String (params (lynx::AutomationTargetKind::effectParam)) + ")", params (lynx::AutomationTargetKind::effectParam) >= 2);
- // a click on Keys' first slot selects it; a MIDI control assigns it (as the engine's catch would)
- for (const auto& spot : spots)
- if (spot.target == Target::slot (2, 0))
- {
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const auto now = juce::Time::getCurrentTime();
- const auto at = spot.area.getCentre().toFloat();
- overlay->mouseDown (juce::MouseEvent (source, at, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- overlay, overlay, now, at, now, 1, false));
- break;
- }
- if (spots.empty())
- {
- juce::File (prefix + "-checks.txt").replaceWithText (checks + "FAIL no spots\n");
- return;
- }
- check ("a click selects the slot", overlay->selection() == std::optional<Target> (Target::slot (2, 0)));
- check ("the overlay takes clicks only on elements", overlay->hitTest (spots.front().area.getCentreX(), spots.front().area.getCentreY()) && ! overlay->hitTest (2, ui.getHeight() - 2));
- check ("a pad assigns it", overlay->assignMidi ({ 0, lynx::linkNoteBase + 38, -1 }) && midiOf (offline.getSong(), Target::slot (2, 0)).number == lynx::linkNoteBase + 38);
- check ("the same pad again on track 0 is refused", ! (overlay->select (Target::slot (0, 2)), overlay->assignMidi ({ 0, lynx::linkNoteBase + 36, -1 })));
- overlay->select (Target::slot (2, 0));
- list->setMode (Mode::midi);
- list->selectRow (0);
- ui.resized();
- overlay->refresh();
- write (ui, "01-midi-map-mode");
- check ("Mapping Browser rows (MIDI): " + juce::String ((int) list->rowsShown().size()), list->rowsShown().size() == 7);
- write (*list, "02-mapping-browser-midi");
- saveMenus (juce::StringArray { "Row" }, std::vector<juce::PopupMenu> { list->rowMenu (0) }, prefix + "-03-row-menu.png");
- // Ctrl+K: Key Map Mode; a key assigns the selected element
- ui.keyPressed (juce::KeyPress ('K', juce::ModifierKeys::ctrlModifier, 0));
- check ("Ctrl+K switches to Key Map Mode", ui.getMapMode() == Mode::key && offline.getMapMode() == Mode::key);
- overlay->select (Target::sceneLaunch (0));
- ui.keyPressed (juce::KeyPress ('1', {}, '1'));
- check ("a key assigns the selected scene", keyOf (offline.getSong(), Target::sceneLaunch (0)).key == '1');
- overlay->select (Target::sceneLaunch (1));
- ui.keyPressed (juce::KeyPress ('A', {}, 'a'));
- check ("a key already on a slot is refused for a scene", ! keyOf (offline.getSong(), Target::sceneLaunch (1)).found);
- overlay->refresh();
- write (ui, "04-key-map-mode");
- write (*list, "05-mapping-browser-key");
- {
- // round 190em: Min / Max in the parameter's unit, Path "<track> | Mixer", Name "Track Volume" / "Slot n"
- const lynx::remotemap::Target volume = Target::parameter ({ lynx::AutomationTargetKind::mixerVolume, 2, 0, 0 });
- const auto [path, name] = lynx::mapmode::describe (offline, volume);
- check ("browser: volume row Path / Name = " + path + " / " + name, path == "Bass | Mixer" && name == "Track Volume");
- check ("browser: volume Min / Max = " + lynx::mapmode::rangeText (offline, volume, 0.0f) + " / " + lynx::mapmode::rangeText (offline, volume, 1.0f),
- lynx::mapmode::rangeText (offline, volume, 0.0f) == juce::String::fromUTF8 ("\xe2\x88\x92\xe2\x88\x9e dB")
- && lynx::mapmode::rangeText (offline, volume, 1.0f).endsWith (" dB"));
- const lynx::remotemap::Target pan = Target::parameter ({ lynx::AutomationTargetKind::mixerPan, 1, 0, 0 });
- check ("browser: pan Min / Max = " + lynx::mapmode::rangeText (offline, pan, 0.25f) + " / " + lynx::mapmode::rangeText (offline, pan, 0.5f),
- lynx::mapmode::rangeText (offline, pan, 0.25f) == "50L" && lynx::mapmode::rangeText (offline, pan, 0.5f) == "C"
- && lynx::mapmode::rangeText (offline, pan, 1.0f) == "100R");
- const auto typed = lynx::mapmode::rangeValueOf (offline, volume, "0 dB");
- check ("browser: typing 0 dB", typed.has_value() && std::abs (lynx::mapmode::rangeText (offline, volume, *typed).getDoubleValue()) < 0.15);
- check ("browser: typing 50L", lynx::mapmode::rangeValueOf (offline, pan, "50L") == std::optional<float> (0.25f));
- check ("browser: Key column = " + lynx::mapmode::listKeyText ('V') + ", " + lynx::mapmode::listKeyText ('3'),
- lynx::mapmode::listKeyText ('V') == "Key v" && lynx::mapmode::listKeyText ('3') == "Key 3");
- check ("browser: slot row Name = " + lynx::mapmode::describe (offline, Target::slot (0, 2)).second,
- lynx::mapmode::describe (offline, Target::slot (0, 2)) == std::pair<juce::String, juce::String> ("Drums", "Slot 3"));
- }
- // off again: the key mapping on a parameter toggles it between Min and Max
- ui.keyPressed (juce::KeyPress ('K', juce::ModifierKeys::ctrlModifier, 0));
- check ("Ctrl+K again ends it", ui.getMapMode() == Mode::off && ! overlay->isVisible() && ! list->isVisible());
- const lynx::AutomationTarget keysVolume { lynx::AutomationTargetKind::mixerVolume, 2, 0, 0 };
- // (round 190em, Live 12.4.16: the first press goes to Min, then Max, then Min)
- ui.keyPressed (juce::KeyPress ('V', {}, 'v'));
- check ("the mapped key V moves Bass's volume to Min first", std::abs (offline.currentTargetValue (keysVolume)) < 0.01f);
- ui.keyStateChanged (false); // (V is not down any more: its release)
- ui.keyPressed (juce::KeyPress ('V', {}, 'v'));
- check ("again: to Max", std::abs (offline.currentTargetValue (keysVolume) - 1.0f) < 0.01f);
- ui.keyStateChanged (false);
- ui.keyPressed (juce::KeyPress ('V', {}, 'v'));
- check ("again: to Min", std::abs (offline.currentTargetValue (keysVolume)) < 0.01f);
- ui.keyStateChanged (false);
- // the title bar switches
- ui.setMapMode (Mode::midi);
- write (ui, "06-switches-midi-on");
- ui.setMapMode (Mode::off);
- ui.setClipLaunchWorkflow (false);
- check ("leaving the Clip-launch layout ends the map mode", ui.getMapMode() == Mode::off);
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runSceneShot190ef (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = false;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- offline.editSong ([] (lynx::Song& s) {
- const int channels = (int) s.channels.size();
- s.channels.resize ((std::size_t) channels + 3);
- const char* names[] { "Drum kit", "Bass synth", "Keys" };
- for (int k = 0; k < 3; ++k)
- {
- auto& ch = s.channels[(std::size_t) (channels + k)];
- ch.name = names[k];
- ch.instrument = k == 0 ? lynx::InstrumentKind::sampler : lynx::InstrumentKind::synth;
- }
- while (s.patterns.size() < 3)
- s.patterns.emplace_back();
- const char* patterns[] { "Beat", "Bassline", "Chords" };
- for (int p = 0; p < 3; ++p)
- {
- auto& pattern = s.patterns[(std::size_t) p];
- pattern.name = patterns[p];
- lynx::Note n;
- n.channel = channels + p;
- n.key = 48 + p * 5;
- pattern.notes = { n };
- pattern.lengthTicks = 4 * lynx::ppq;
- }
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 6));
- const char* tracks[] { "Drums", "Bass", "Keys" };
- const std::uint32_t colours[] { 0xFFE0533Bu, 0xFF3B8BE0u, 0xFF46C27Au };
- for (int t = 0; t < 3; ++t)
- {
- s.playlistTracks[(std::size_t) t].name = tracks[t];
- s.playlistTracks[(std::size_t) t].colour = colours[t];
- }
- for (int t = 0; t < 3; ++t)
- for (int r = 0; r < 3; ++r)
- if (! (t == 2 && r == 0))
- {
- lynx::Clip clip;
- clip.pattern = t;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, t, r, clip);
- }
- auto& grid = lynx::launcher::ensureGrid (s);
- grid.scenes.resize (4);
- const char* scenes[] { "Intro", "Verse", "Drop" };
- for (int r = 0; r < 3; ++r)
- grid.scenes[(std::size_t) r].name = scenes[r];
- lynx::session::setSceneTempo (s, 1, 128.0);
- lynx::session::setSceneSignature (s, 1, 3, 4); // (as the live check's "Verse": 3 / 4)
- lynx::session::setSceneSignature (s, 2, 6, 8); // (round 190em: a denominator of its own)
- grid.scenes[2].colour = 0xFF8E5BD6u;
- }, false);
- offline.dispatchPendingMessages();
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- offline.dispatchPendingMessages();
- ui.resized();
- auto* gridView = ui.getClipGridForSnapshot();
- if (gridView == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText ("FAIL no grid\n");
- return;
- }
- lynx::clipGridSceneTempoShown() = true;
- lynx::refreshClipGrid (*gridView);
- lynx::selectClipGridScene (*gridView, 1);
- write (*gridView, "01-scene-fields");
- {
- // round 190em: a plain scene's launch triangle in Live's dark grey (#1E1E1E), scene 4 (row 3)
- const auto image = lynx::shot::snapshot (*gridView);
- int dark = 0;
- for (int y = 0; y < image.getHeight(); ++y)
- for (int x = image.getWidth() - 240; x < image.getWidth() - 180; ++x)
- if (const auto p = image.getPixelAt (x, y); y > 3 * 24 + 26 && y < 4 * 24 + 26 && std::abs (p.getRed() - 0x1e) <= 2
- && std::abs (p.getGreen() - 0x1e) <= 2 && std::abs (p.getBlue() - 0x1e) <= 2)
- ++dark;
- check ("plain scene triangle in Live's #1E1E1E (" + juce::String (dark) + " px)", dark >= 20);
- }
- saveMenus (juce::StringArray { "Scene menu (Verse)" }, std::vector<juce::PopupMenu> { lynx::clipGridSceneMenu (*gridView, 1) }, prefix + "-02-scene-menu.png");
- saveMenus (juce::StringArray { "Scene tempo field", "Scene time signature field" },
- std::vector<juce::PopupMenu> { lynx::clipGridSceneFieldMenu (*gridView, 1, 1), lynx::clipGridSceneFieldMenu (*gridView, 2, 2) },
- prefix + "-03-field-menus.png");
- saveMenus (juce::StringArray { "Column title (Bass)" }, std::vector<juce::PopupMenu> { lynx::clipGridHeaderMenu (*gridView, 1) }, prefix + "-04-title-menu.png");
- const auto clipsIn = [&offline] (int row) {
- int n = 0;
- if (const auto& g = offline.getSong().clipGrid)
- for (int t = 0; t < 8; ++t)
- n += lynx::launcher::clipAt (*g, t, row) != nullptr ? 1 : 0;
- return n;
- };
- const auto before = clipsIn (1);
- const auto dup = lynx::duplicateClipGridScene (*gridView, 1);
- offline.dispatchPendingMessages();
- const auto& scenesNow = offline.getSong().clipGrid->scenes;
- check ("duplicate: Verse's copy is row 2, with its clips and tempo", dup == 2 && clipsIn (2) == before && scenesNow.size() > 2
- && scenesNow[2].name == "Verse" && scenesNow[2].tempo == 128.0);
- write (*gridView, "05-scene-duplicated");
- const auto cap = lynx::captureClipGridScene (*gridView, 3, { 0, 2, 1 }); // Drums row 0, Bass row 2, Keys row 1
- offline.dispatchPendingMessages();
- check ("capture: a new row 4 with the three playing clips", cap == 4 && clipsIn (4) == 3);
- {
- const auto& sc = offline.getSong().clipGrid->scenes;
- check ("capture while playing: the new scene is plain (no name, fields off)", sc.size() > 4 && sc[4] == lynx::ClipGridScene {});
- }
- write (*gridView, "06-scene-captured");
- // round 190em: nothing plays: an empty scene like the selected one (name, tempo, signature), selected
- const auto empty = lynx::captureClipGridScene (*gridView, 1, { -1, -1 });
- offline.dispatchPendingMessages();
- {
- const auto& sc = offline.getSong().clipGrid->scenes;
- check ("capture with nothing playing: an empty row 2 named Verse, 128 BPM, 3 / 4", empty == 2 && clipsIn (2) == 0 && sc[2].name == "Verse"
- && sc[2].tempo == 128.0 && sc[2].beatsPerBar == 3 && sc[2].beatUnit == 4);
- }
- write (*gridView, "06b-scene-captured-stopped");
- // round 190em: Capture and Insert while clips play: playback moves to the new row (the runtime view shows what
- // the player reports once the published song holds the moved slots)
- {
- const auto rowsBefore = offline.getSong().clipGrid->scenes.size();
- lynx::selectClipGridScene (*gridView, 0);
- const auto at = lynx::captureClipGridScene (*gridView, 0, { 0, 0, -1 });
- offline.dispatchPendingMessages();
- const auto& g = *offline.getSong().clipGrid;
- check ("capture while playing: row 1 holds the moved playing slots", at == 1 && g.scenes.size() == rowsBefore + 1
- && clipsIn (1) == 2 && clipsIn (0) == 2 && g.scenes[1] == lynx::ClipGridScene {});
- if (auto* runtime = offline.launcherStateForSnapshot())
- for (int t = 0; t < 2; ++t)
- runtime->tracks[(std::size_t) t].playing.store (1);
- lynx::refreshClipGrid (*gridView);
- write (*gridView, "09-capture-playing-moves");
- if (auto* runtime = offline.launcherStateForSnapshot())
- for (int t = 0; t < 2; ++t)
- runtime->tracks[(std::size_t) t].playing.store (-1);
- }
- // round 190em: the fields as "n / d", a selected field, Del = Return to Default
- lynx::clipGridSceneTempoShown() = true;
- lynx::refreshClipGrid (*gridView);
- {
- const auto& sc = offline.getSong().clipGrid->scenes;
- int verse = -1;
- for (int r = 0; r < (int) sc.size() && verse < 0; ++r)
- if (sc[(std::size_t) r].name == "Verse" && sc[(std::size_t) r].tempo > 0.0)
- verse = r;
- lynx::selectClipGridSceneField (*gridView, verse, 1);
- write (*gridView, "10-field-selected");
- gridView->keyPressed (juce::KeyPress (juce::KeyPress::deleteKey));
- offline.dispatchPendingMessages();
- const auto& after = offline.getSong().clipGrid->scenes;
- check ("Del on a selected tempo field returns it to default (scene kept)", verse >= 0 && after.size() == sc.size()
- && after[(std::size_t) verse].tempo == 0.0 && after[(std::size_t) verse].beatsPerBar == 3);
- write (*gridView, "11-field-returned-to-default");
- }
- // round 190em: Capture MIDI to the armed track (Bass), the selected scene's slot, the tempo from the phrase
- {
- offline.stop();
- offline.setGridTrackArmed (1, true, true);
- lynx::selectClipGridScene (*gridView, 0);
- int empty = 0;
- while (lynx::launcher::clipAt (*offline.getSong().clipGrid, 1, empty) != nullptr)
- ++empty;
- const auto now = juce::Time::getMillisecondCounterHiRes();
- const auto beat = 60000.0 / 148.0;
- for (int i = 0; i < 8; ++i)
- {
- const auto at = now - 9.0 * beat + i * beat;
- offline.logPlayedNoteForTest (at, 0, 60 + (i % 4) * 2, 0.8f, true);
- offline.logPlayedNoteForTest (at + beat * 0.5, 0, 60 + (i % 4) * 2, 0.8f, false);
- }
- int placed = -1;
- bool into = true;
- const auto r = offline.captureMidiToSlot (1, empty, placed, into);
- offline.dispatchPendingMessages();
- check ("Capture MIDI: 8 notes into Bass row " + juce::String (placed) + ", tempo " + juce::String (offline.getSong().bpm, 2),
- r.notes == 8 && placed == empty && ! into && std::abs (offline.getSong().bpm - 148.0) < 0.5 && offline.getTransport().playing.load());
- const auto& capturedGrid = *offline.getSong().clipGrid;
- const auto* capturedClip = lynx::launcher::clipAt (capturedGrid, 1, placed);
- const auto* slot = capturedClip != nullptr ? &capturedGrid.slots[(std::size_t) capturedClip->gridSlot] : nullptr;
- check ("Capture MIDI: the clip has no name of its own (blank label, as Live)", slot != nullptr && slot->name.empty() && slot->blankName);
- if (auto* runtime = offline.launcherStateForSnapshot())
- runtime->tracks[1].playing.store (placed);
- lynx::refreshClipGrid (*gridView);
- write (*gridView, "12-capture-midi");
- if (auto* runtime = offline.launcherStateForSnapshot())
- runtime->tracks[1].playing.store (-1);
- offline.stop();
- }
- write (ui, "07-window");
- lynx::clipGridSceneTempoShown() = false;
- lynx::refreshClipGrid (*gridView);
- write (*gridView, "08-fields-off");
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runDrawShot190ef (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- ui.setVisible (true);
- ui.setClipLaunchWorkflow (true);
- ui.setClipGridView (lynx::PlaylistArea::GridView::song);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- lynx::autolanes::setShown (true);
- offline.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() < 4)
- s.mixer.resize (4);
- s.mixer[1].name = "Bass";
- s.mixer[2].name = "Pad";
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 6));
- s.playlistTracks[0].name = "Bass";
- s.playlistTracks[0].mode = lynx::PlaylistTrackMode::audio;
- s.playlistTracks[0].mixerTrack = 1;
- s.playlistTracks[1].name = "Pad";
- s.playlistTracks[1].mode = lynx::PlaylistTrackMode::audio;
- s.playlistTracks[1].mixerTrack = 2;
- }, false);
- lynx::createAutomationLane (offline, { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 }, 0);
- lynx::createAutomationLane (offline, { lynx::AutomationTargetKind::mixerPan, 2, 0, 0 }, 1);
- offline.editSong ([] (lynx::Song& s) {
- for (int t = 0; t < 2; ++t)
- if (! s.playlistTracks[(std::size_t) t].lanes.empty())
- s.playlistTracks[(std::size_t) t].lanes[0].height = 110;
- }, false);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- playlist.setViewForSnapshot (180.0, 0, 0);
- ui.resized();
- offline.dispatchPendingMessages();
- const auto& song = offline.getSong();
- const auto laneA = song.playlistTracks[0].lanes.empty() ? -1 : song.playlistTracks[0].lanes[0].automation;
- const auto laneB = song.playlistTracks[1].lanes.empty() ? -1 : song.playlistTracks[1].lanes[0].automation;
- check ("two lanes made", laneA >= 0 && laneB >= 0);
- if (laneA < 0 || laneB < 0)
- {
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- return;
- }
- write (ui, "00-lanes-before");
- const auto before = song.automations[(std::size_t) laneA].points;
- // a drag through the Playlist's own handlers (the events a real mouse sends)
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const auto now = juce::Time::getCurrentTime();
- const auto stroke = [&] (int track, const std::vector<juce::Point<float>>& path, juce::ModifierKeys extra) {
- const juce::ModifierKeys mods (juce::ModifierKeys::leftButtonModifier | extra.getRawFlags());
- const auto event = [&] (juce::Point<float> p, juce::ModifierKeys m, bool dragged) {
- return juce::MouseEvent (source, p, m, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &playlist, &playlist, now, path.front(), now, 1, dragged);
- };
- juce::ignoreUnused (track);
- // (the engine joins the edits of one press into one undo step while a button is down)
- const auto held = juce::ModifierKeys::currentModifiers;
- juce::ModifierKeys::currentModifiers = mods;
- playlist.mouseDown (event (path.front(), mods, false));
- for (std::size_t i = 1; i < path.size(); ++i)
- playlist.mouseDrag (event (path[i], mods, true));
- juce::ModifierKeys::currentModifiers = held;
- playlist.mouseUp (event (path.back(), extra, true));
- };
- const auto bodyA = playlist.laneBodyForSnapshot (0, 0), bodyB = playlist.laneBodyForSnapshot (1, 0);
- const auto bar = (double) (4 * lynx::ppq);
- const auto x = [&] (double bars) { return (float) playlist.xOfTickForSnapshot (bars * bar); };
- const auto y = [] (juce::Rectangle<float> body, float v) { return body.getBottom() - v * body.getHeight(); };
- lynx::drawmode::set (true);
- // steps: a rise over bar 1 and a fall over bar 2, at the Playlist's grid (Line, at this zoom)
- std::vector<juce::Point<float>> steps;
- for (int k = 0; k <= 16; ++k)
- steps.push_back ({ x (1.0 + k / 16.0) + 2.0f, y (bodyA, 0.15f + 0.05f * (float) k) });
- for (int k = 0; k <= 16; ++k)
- steps.push_back ({ x (2.0 + k / 16.0) + 2.0f, y (bodyA, 0.95f - 0.05f * (float) k) });
- stroke (0, steps, {});
- const auto& afterSteps = offline.getSong().automations[(std::size_t) laneA].points;
- check ("Draw Mode drag made steps (" + juce::String ((int) afterSteps.size()) + " points)", afterSteps.size() > before.size() + 4);
- bool unchangedOutside = true;
- for (double t = 0.0; t < 6.0 * bar; t += 37.0)
- if ((t < bar - 1.0 || t > 3.1 * bar) && std::abs (lynx::automationCurveAt (before, t) - lynx::automationCurveAt (afterSteps, t)) > 1.0e-4f)
- unchangedOutside = false;
- check ("the curve outside the drawn bars is unchanged", unchangedOutside);
- {
- // flat inside each drawn cell: the values in a cell's first and last tick are the same
- int flatCells = 0, cells = 0;
- for (double t = bar; t < 3.0 * bar; t += lynx::ppq / 4.0)
- {
- ++cells;
- if (std::abs (lynx::automationCurveAt (afterSteps, t + 1.0) - lynx::automationCurveAt (afterSteps, t + lynx::ppq / 4.0 - 1.0)) < 1.0e-5f)
- ++flatCells;
- }
- check ("each sixteenth inside bars 2-3 is flat (" + juce::String (flatCells) + " / " + juce::String (cells) + ")", flatCells == cells);
- }
- // freehand: Alt (no grid) on the pad's pan lane, a wave over bars 1-4
- const auto panBefore = offline.getSong().automations[(std::size_t) laneB].points;
- // (off-screen every press has the same mouse-down time, which the undo history uses to join one press's edits:
- // an edit with no button down in between separates the two strokes, as a real second press does)
- offline.editSong ([] (lynx::Song&) {});
- std::vector<juce::Point<float>> wave;
- for (int k = 0; k <= 60; ++k)
- wave.push_back ({ x (1.0 + 3.0 * k / 60.0), y (bodyB, 0.5f + 0.4f * std::sin ((float) k * 0.3f)) });
- stroke (1, wave, juce::ModifierKeys (juce::ModifierKeys::altModifier));
- const auto& pan = offline.getSong().automations[(std::size_t) laneB].points;
- check ("Alt drag drew freehand (" + juce::String ((int) pan.size()) + " points)", pan.size() > 30);
- playlist.repaint();
- write (ui, "01-draw-mode-steps-and-freehand");
- if (auto* parent = playlist.getParentComponent())
- write (*parent, "01b-playlist");
- // one stroke is one undo step
- offline.undo();
- check ("one undo takes the whole freehand stroke back", offline.getSong().automations[(std::size_t) laneB].points == panBefore);
- // Draw Mode off: the same press adds one point, as before
- lynx::drawmode::set (false);
- const auto countOff = offline.getSong().automations[(std::size_t) laneA].points.size();
- stroke (0, { { x (4.5), y (bodyA, 0.8f) } }, {});
- check ("Draw Mode off: a press adds one point", offline.getSong().automations[(std::size_t) laneA].points.size() == countOff + 1);
- // the Options menu (Clip-launch layout) with the switch
- lynx::drawmode::set (true);
- {
- const auto names = ui.getMenuNamesForSnapshot();
- const auto index = names.indexOf (TRANS ("Options"));
- if (index >= 0)
- saveMenus (juce::StringArray { "Options" }, std::vector<juce::PopupMenu> { ui.getMenuForSnapshot (index) }, prefix + "-02-options-menu.png");
- check ("Options menu found", index >= 0);
- }
- lynx::drawmode::set (false);
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runClipEnvShot190gi (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- // two files: a sustained pad (4 s, a slow swell, for the envelope over its waveform) and a one-bar loop of clicks
- const auto writeWav = [] (const juce::File& file, int seconds, const std::function<float (int, double)>& fn) {
- const double rate = 48000.0;
- juce::AudioBuffer<float> buffer (2, (int) (rate * seconds));
- for (int ch = 0; ch < 2; ++ch)
- for (int i = 0; i < buffer.getNumSamples(); ++i)
- buffer.setSample (ch, i, fn (i, rate));
- file.deleteFile();
- if (auto out = std::unique_ptr<juce::FileOutputStream> (file.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 2, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- return file;
- };
- const auto pad = writeWav (juce::File (prefix + "-pad.wav"), 4, [] (int i, double rate) {
- const auto t = i / rate;
- return (float) (0.45 * (std::sin (juce::MathConstants<double>::twoPi * 220.0 * t) + 0.5 * std::sin (juce::MathConstants<double>::twoPi * 331.0 * t))
- * (0.7 + 0.3 * std::sin (juce::MathConstants<double>::twoPi * 1.5 * t)));
- });
- const auto loop = writeWav (juce::File (prefix + "-loop.wav"), 2, [] (int i, double) {
- const auto k = i % 12000;
- const auto hit = i / 12000;
- return k < 3000 ? (float) (std::sin (k * (hit % 4 == 0 ? 0.05 : 0.3)) * std::exp (-k / 500.0) * 0.8) : 0.0f;
- });
- ui.setVisible (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::playlist });
- offline.editSong ([&] (lynx::Song& s) {
- const auto add = [&s] (const char* name, const juce::File& file) {
- lynx::ChannelDef ch;
- ch.name = name;
- ch.instrument = lynx::InstrumentKind::audioClip;
- ch.samplePath = file.getFullPathName().toStdString();
- s.channels.push_back (ch);
- return (int) s.channels.size() - 1;
- };
- const auto padChannel = add ("Pad", pad), loopChannel = add ("Loop", loop);
- s.playlist.clear();
- lynx::Clip a;
- a.kind = lynx::ClipKind::audio;
- a.channel = padChannel;
- a.length = 8 * lynx::ppq;
- a.track = 0;
- s.playlist.push_back (a);
- a.track = 1;
- s.playlist.push_back (a);
- lynx::Clip b = a;
- b.channel = loopChannel;
- b.track = 2;
- b.length = 4 * lynx::ppq;
- s.playlist.push_back (b);
- // the first clip: a volume envelope (a swell, a dip, FL's curve modes on two segments)
- auto& e = lynx::clipenv::own (s, s.playlist[0]);
- e.shown = lynx::clipenv::volumeLane;
- e.volume = { { 0, 0.15f, 0.0f, 0 }, { lynx::ppq * 2, 1.0f, -0.6f, 0 }, { lynx::ppq * 4, 1.0f, 0.0f, 0 },
- { lynx::ppq * 5, 0.45f, 0.0f, 2 }, { lynx::ppq * 6, 0.9f, 0.0f, 0 }, { lynx::ppq * 8, 0.9f, 0.0f, 0 } };
- // the second: its pan lane shown (only pan made)
- lynx::clipenv::show (s, s.playlist[1], lynx::clipenv::panLane);
- auto& p = lynx::clipenv::own (s, s.playlist[1]);
- p.pan = { { 0, 0.5f, 0.0f, 0 }, { lynx::ppq * 2, 0.1f, 0.0f, 0 }, { lynx::ppq * 4, 0.9f, 0.0f, 0 }, { lynx::ppq * 6, 0.5f, 0.0f, 0 } };
- if (s.playlistTracks.size() < 3)
- s.playlistTracks.resize (3);
- for (int t = 0; t < 3; ++t)
- s.playlistTracks[(std::size_t) t].height = 96;
- }, false);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- playlist.setViewForSnapshot (360.0, 0, 0);
- ui.resized();
- offline.dispatchPendingMessages();
- (void) lynx::shot::snapshot (ui); // (a paint starts the waveform analyses; the shot waits for them)
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- offline.dispatchPendingMessages();
- write (ui, "01-playlist-envelopes");
- // the clip menu: LYNX's extras with Clip envelope ›, Auto-warp, Quantize audio (Auto-warp run from it on the loop)
- {
- const auto menu = playlist.getClipMenuForSnapshot (2);
- const juce::PopupMenu* envelopeMenu = nullptr;
- bool autoWarp = false, quantize = false;
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- if (it.getItem().text == lynx::tr ("Clip envelope") && it.getItem().subMenu != nullptr)
- envelopeMenu = it.getItem().subMenu.get();
- autoWarp = autoWarp || (it.getItem().text == lynx::tr ("Auto-warp") && it.getItem().isEnabled);
- quantize = quantize || (it.getItem().text == lynx::tr ("Quantize audio") && it.getItem().isEnabled);
- }
- check ("clip menu: Clip envelope submenu, Auto-warp, Quantize audio", envelopeMenu != nullptr && autoWarp && quantize);
- saveMenus (juce::StringArray { lynx::tr ("Audio clip"), lynx::tr ("Clip envelope") },
- std::vector<juce::PopupMenu> { menu, envelopeMenu != nullptr ? *envelopeMenu : juce::PopupMenu() }, prefix + "-02-clip-menu.png");
- check ("Auto-warp from the clip menu places markers", clickMenuItem (menu, lynx::tr ("Auto-warp")));
- offline.dispatchPendingMessages();
- const auto& s = offline.getSong();
- const auto& loopClip = s.playlist[2];
- check ("the loop's channel is warped", s.channels[(std::size_t) loopClip.channel].sampler.warp.size() >= 2
- && s.channels[(std::size_t) loopClip.channel].sampler.keepPitch);
- // the first clip's menu: Show volume envelope ticked
- const auto first = playlist.getClipMenuForSnapshot (0);
- bool ticked = false;
- for (juce::PopupMenu::MenuItemIterator it (first); it.next();)
- if (it.getItem().text == lynx::tr ("Clip envelope") && it.getItem().subMenu != nullptr)
- for (juce::PopupMenu::MenuItemIterator sub (*it.getItem().subMenu); sub.next();)
- ticked = ticked || (sub.getItem().text == lynx::tr ("Show volume envelope") && sub.getItem().isTicked);
- check ("Show volume envelope is ticked on the first clip", ticked);
- }
- // gestures through the Playlist's own handlers
- auto source = juce::Desktop::getInstance().getMainMouseSource();
- const auto now = juce::Time::getCurrentTime();
- const auto press = [&] (juce::Point<float> from, juce::Point<float> to, juce::ModifierKeys button, juce::ModifierKeys extra) {
- const juce::ModifierKeys mods (button.getRawFlags() | extra.getRawFlags());
- const auto event = [&] (juce::Point<float> p, juce::ModifierKeys m, bool dragged) {
- return juce::MouseEvent (source, p, m, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &playlist, &playlist, now, from, now, 1, dragged);
- };
- const auto held = juce::ModifierKeys::currentModifiers;
- juce::ModifierKeys::currentModifiers = mods;
- playlist.mouseDown (event (from, mods, false));
- if (to != from)
- playlist.mouseDrag (event (to, mods, true));
- juce::ModifierKeys::currentModifiers = held;
- playlist.mouseUp (event (to, extra, to != from));
- };
- const auto x = [&] (double beats) { return (float) playlist.xOfTickForSnapshot (beats * lynx::ppq); };
- {
- const auto body = playlist.curveBodyForSnapshot (0);
- const auto points = offline.getSong().clipEnvelopes[(std::size_t) offline.getSong().playlist[0].envelope].volume.size();
- // [RMB] in the curve's area adds a point there (FL's in-Playlist automation editing, round 165)
- press ({ x (7.0), body.getBottom() - 0.3f * body.getHeight() }, { x (7.0), body.getBottom() - 0.3f * body.getHeight() },
- juce::ModifierKeys::rightButtonModifier, {});
- offline.dispatchPendingMessages();
- const auto& s = offline.getSong();
- const auto* e = lynx::clipenv::of (s, s.playlist[0]);
- check ("[RMB] on the clip's volume lane adds a point", e != nullptr && e->volume.size() == points + 1
- && std::abs (lynx::automationCurveAt (e->volume, 7.0 * lynx::ppq) - 0.3f) < 0.05f);
- // drag that point up with the Pencil
- press ({ x (7.0), body.getBottom() - 0.3f * body.getHeight() }, { x (7.0), body.getBottom() - 0.7f * body.getHeight() },
- juce::ModifierKeys::leftButtonModifier, {});
- offline.dispatchPendingMessages();
- const auto* moved = lynx::clipenv::of (offline.getSong(), offline.getSong().playlist[0]);
- check ("dragging the point moves it", moved != nullptr && std::abs (lynx::automationCurveAt (moved->volume, 7.0 * lynx::ppq) - 0.7f) < 0.05f);
- check ("the edits are undoable", offline.canUndo());
- }
- write (ui, "03-playlist-edited");
- {
- // warp: a double-click on the loop clip's flag strip adds a marker; Alt + drag on its line (mid clip) moves it
- const auto bounds = playlist.clipBoundsForSnapshot (2);
- const auto channelOf = [&] { return offline.getSong().playlist[2].channel; };
- const auto markers = [&] { return offline.getSong().channels[(std::size_t) channelOf()].sampler.warp; };
- const auto before = markers().size();
- const juce::Point<float> strip { x (1.5), (float) bounds.getY() + 13.0f + 3.0f };
- playlist.mouseDoubleClick (juce::MouseEvent (source, strip, juce::ModifierKeys::leftButtonModifier, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &playlist, &playlist,
- now, strip, now, 2, false));
- offline.dispatchPendingMessages();
- check ("a double-click on the flag strip adds a warp marker", markers().size() == before + 1);
- if (markers().size() != before + 1)
- checks << " (strip seconds " << playlist.warpStripSecondsForSnapshot (2, strip.toInt()) << ", played markers "
- << (int) playlist.warpMarkerCountForSnapshot (2) << ", file seconds " << playlist.clipFileSecondsForSnapshot (2)
- << ", channel markers " << (int) before << ", clip at " << bounds.toString() << ", strip " << strip.toString() << ")\n";
- int added = -1;
- for (int k = 0; k < (int) markers().size(); ++k)
- if (std::abs (markers()[(std::size_t) k].beats - 1.5) < 0.05)
- added = k;
- check ("the marker sits on the beat it was added on", added > 0);
- if (added > 0)
- {
- const juce::Point<float> line { x (1.5), (float) bounds.getCentreY() + 10.0f };
- press (line, line.translated (x (1.75) - x (1.5), 0.0f), juce::ModifierKeys::leftButtonModifier, juce::ModifierKeys::altModifier);
- offline.dispatchPendingMessages();
- check ("Alt + drag on a marker's line moves it", added < (int) markers().size() && std::abs (markers()[(std::size_t) added].beats - 1.75) < 0.05);
- }
- }
- write (ui, "04-playlist-warp");
- // the Clip-launch layout: the Clip View's Envelopes tab of a grid audio clip
- offline.editSong ([&] (lynx::Song& s) {
- auto clip = s.playlist[0];
- clip.start = 0;
- lynx::launcher::setClip (s, 0, 0, clip);
- lynx::launcher::ensureGrid (s).scenes.resize (std::max<std::size_t> (1, lynx::launcher::ensureGrid (s).scenes.size()));
- }, false);
- offline.dispatchPendingMessages();
- const auto shootPanel = [&] (const char* name, bool envelopes, std::uint8_t lane) {
- auto panel = lynx::makeClipAudioPanel (offline, 0, 0);
- if (panel == nullptr)
- return false;
- panel->setSize (1100, 300);
- for (auto* child : panel->getChildren())
- if (auto* b = dynamic_cast<juce::TextButton*> (child); b != nullptr && b->getButtonText() == (envelopes ? lynx::tr ("Envelopes") : lynx::tr ("Sample")))
- if (b->onClick)
- b->onClick();
- if (lane != 0)
- offline.editSong ([lane] (lynx::Song& s) {
- if (s.clipGrid)
- if (auto* c = const_cast<lynx::Clip*> (lynx::launcher::clipAt (*s.clipGrid, 0, 0)); c != nullptr)
- lynx::clipenv::show (s, *c, lane);
- }, false);
- offline.dispatchPendingMessages();
- write (*panel, name);
- return true;
- };
- check ("Clip View: Sample tab", shootPanel ("05-clipview-sample", false, 0));
- check ("Clip View: Envelopes tab, Clip > Gain", shootPanel ("06-clipview-envelopes-gain", true, lynx::clipenv::volumeLane));
- check ("Clip View: Envelopes tab, Mixer > Track Panning", shootPanel ("07-clipview-envelopes-pan", true, lynx::clipenv::panLane));
- {
- const auto* c = offline.getSong().clipGrid ? lynx::launcher::clipAt (*offline.getSong().clipGrid, 0, 0) : nullptr;
- check ("the grid clip keeps the volume envelope", c != nullptr && lynx::clipenv::activeOf (offline.getSong(), *c) != nullptr);
- }
- shootPanel ("08-clipview-sample-again", false, 0); // (the tab choice back to Sample for the next run)
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runGapsShot190kf (const juce::String& prefix, const juce::String& wavPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- // the probe's file, else a LYNX-made stand-in (8.42 s of a decaying 220 Hz tone every half second, 44.1 kHz)
- auto wav = juce::File (wavPath);
- if (! wav.existsAsFile())
- {
- wav = juce::File (prefix + "-probe.wav");
- wav.deleteFile();
- const double rate = 44100.0;
- juce::AudioBuffer<float> buffer (1, (int) (rate * 8.421));
- for (int k = 0; k < buffer.getNumSamples(); ++k)
- {
- const auto t = std::fmod (k / rate, 0.5);
- buffer.setSample (0, k, (float) (0.5 * std::exp (-t * 6.0) * std::sin (2.0 * juce::MathConstants<double>::pi * 220.0 * k / rate)));
- }
- if (auto out = std::unique_ptr<juce::FileOutputStream> (wav.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- }
- double seconds = 0.0;
- {
- juce::AudioFormatManager formats;
- formats.registerBasicFormats();
- if (std::unique_ptr<juce::AudioFormatReader> r (formats.createReaderFor (wav)); r != nullptr && r->sampleRate > 0.0)
- seconds = (double) r->lengthInSamples / r->sampleRate;
- }
- check ("probe file " + wav.getFileName() + " " + juce::String (seconds, 3) + " s", seconds > 1.0);
- const auto beats = seconds * 2.0; // (warped at 120 BPM, its own tempo)
- offline.editSong ([&] (lynx::Song& s) {
- s.bpm = 120.0;
- lynx::ChannelDef ch;
- ch.name = "warped";
- ch.instrument = lynx::InstrumentKind::audioClip;
- ch.samplePath = wav.getFullPathName().toStdString();
- ch.sampler.keepPitch = true;
- ch.sampler.stretchMethod = lynx::StretchMethod::complex;
- ch.sampler.stretchBeats = (float) beats;
- ch.sampler.warp = { { 0.0, 0.0 }, { seconds * 0.3, beats * 0.25 }, { seconds * 0.55, beats * 0.5 }, { seconds, beats } };
- s.channels.push_back (ch);
- const auto c = (int) s.channels.size() - 1;
- lynx::Clip audio;
- audio.kind = lynx::ClipKind::audio;
- audio.channel = c;
- audio.offset = 2 * lynx::ppq; // (Loop Position 1.3, Length 2.0.0 → 3.3, Start 1.4: the probe set's)
- audio.length = 8 * lynx::ppq;
- lynx::launcher::setClip (s, 0, 0, audio);
- lynx::launcher::ensureGrid (s).scenes.resize (1);
- auto& grid = *s.clipGrid;
- for (auto& g : grid.clips)
- if (g.gridSlot >= 0)
- {
- grid.slots[(std::size_t) g.gridSlot].loop = true;
- grid.slots[(std::size_t) g.gridSlot].startMarker = lynx::ppq;
- }
- }, false);
- offline.dispatchPendingMessages();
- const auto editorOf = [] (juce::Component& panel) -> juce::Component* {
- for (auto* child : panel.getChildren())
- if (child->isVisible() && child->getWidth() > 400 && dynamic_cast<juce::Button*> (child) == nullptr)
- return child;
- return nullptr;
- };
- const auto write = [&] (juce::Component& panel, const char* name) {
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (panel), out);
- };
- const auto slotOf = [&] (auto&& fn) {
- offline.editSong ([&] (lynx::Song& s) {
- for (auto& g : s.clipGrid->clips)
- if (g.gridSlot >= 0)
- fn (g, s.clipGrid->slots[(std::size_t) g.gridSlot]);
- }, false);
- offline.dispatchPendingMessages();
- };
- {
- auto panel = lynx::makeClipAudioPanel (offline, 0, 0);
- check ("the Clip View panel", panel != nullptr);
- if (panel == nullptr)
- return;
- panel->setSize (1390, 670);
- if (auto* e = editorOf (*panel)) // (the Clip-launch layout's beat-time view; off-screen there is no layout)
- lynx::setAudioEditorBeatTimeForSnapshot (*e, 1);
- write (*panel, "01-loop-on-start-marker");
- // perf (round gaps190kf): the sample editor painted 40 times with the warp time line (a grid clip's editor)
- // and without it (the same channel's editor panel, no grid clip) — ms per full paint
- {
- const auto timeIt = [] (juce::Component& c) {
- juce::Image image (juce::Image::ARGB, c.getWidth(), c.getHeight(), true);
- const auto t0 = juce::Time::getMillisecondCounterHiRes();
- for (int k = 0; k < 40; ++k)
- {
- juce::Graphics g (image);
- c.paintEntireComponent (g, false);
- }
- return (juce::Time::getMillisecondCounterHiRes() - t0) / 40.0;
- };
- if (auto* withLane = editorOf (*panel))
- {
- auto plain = lynx::makeAudioEditorPanel (offline, (int) offline.getSong().channels.size() - 1, -1, true);
- plain->setSize (withLane->getWidth(), withLane->getHeight());
- lynx::setAudioEditorBeatTimeForSnapshot (*plain, 1);
- offline.dispatchPendingMessages();
- timeIt (*withLane);
- timeIt (*plain);
- double a = 0.0, b = 0.0;
- for (int round = 0; round < 3; ++round)
- {
- a += timeIt (*withLane) / 3.0;
- b += timeIt (*plain) / 3.0;
- }
- check ("paint ms: with the warp time line " + juce::String (a, 3) + ", without " + juce::String (b, 3), true);
- }
- }
- auto* editor = editorOf (*panel);
- check ("its sample editor", editor != nullptr);
- if (editor != nullptr)
- {
- lynx::selectAudioEditorBraceForSnapshot (*editor, true);
- write (*panel, "02-brace-selected");
- lynx::selectAudioEditorBraceForSnapshot (*editor, false);
- lynx::holdAudioEditorBraceForSnapshot (*editor, 2, 12 * lynx::ppq); // (the loop's end dragged to 4.1)
- write (*panel, "03-loop-end-held-at-4.1");
- lynx::holdAudioEditorBraceForSnapshot (*editor, 0, 0);
- }
- }
- slotOf ([] (lynx::Clip& c, lynx::ClipGridSlot& slot) {
- slot.loop = false;
- slot.startMarker = 0;
- c.offset = 0;
- c.length = (std::int64_t) std::llround (10.0 * lynx::ppq);
- });
- {
- auto panel = lynx::makeClipAudioPanel (offline, 0, 0);
- if (panel != nullptr)
- {
- panel->setSize (1390, 670);
- if (auto* e = editorOf (*panel))
- lynx::setAudioEditorBeatTimeForSnapshot (*e, 1);
- write (*panel, "04-loop-off-start-end");
- }
- }
- offline.editSong ([&] (lynx::Song& s) { lynx::clipsample::setWarp (s, (int) s.channels.size() - 1, false, seconds); }, false);
- offline.dispatchPendingMessages();
- {
- auto panel = lynx::makeClipAudioPanel (offline, 0, 0);
- if (panel != nullptr)
- {
- panel->setSize (1390, 670);
- if (auto* e = editorOf (*panel))
- lynx::setAudioEditorBeatTimeForSnapshot (*e, 1);
- write (*panel, "05-unwarped-seconds");
- }
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runLiveFactsShot190gx (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- // a 1 kHz sine, 20 s at 48 kHz (Live's 190gu clip-envelope stimulus), −9 dBFS
- const auto wav = juce::File (prefix + "-sine1k.wav");
- wav.deleteFile();
- {
- const double rate = 48000.0;
- juce::AudioBuffer<float> buffer (2, (int) (rate * 20.0));
- for (int k = 0; k < buffer.getNumSamples(); ++k)
- for (int ch = 0; ch < 2; ++ch)
- buffer.setSample (ch, k, (float) (0.3535 * std::sin (2.0 * juce::MathConstants<double>::pi * 1000.0 * k / rate)));
- if (auto out = std::unique_ptr<juce::FileOutputStream> (wav.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 2, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- }
- offline.editSong ([&wav] (lynx::Song& s) {
- s.bpm = 120.0;
- lynx::ChannelDef ch;
- ch.name = "sine1k";
- ch.instrument = lynx::InstrumentKind::audioClip;
- ch.samplePath = wav.getFullPathName().toStdString();
- s.channels.push_back (ch);
- const auto c = (int) s.channels.size() - 1;
- lynx::clipsample::setWarp (s, c, true, 20.0);
- lynx::warpmodes::setMode (s, c, (int) lynx::StretchMethod::beats);
- lynx::Clip audio;
- audio.kind = lynx::ClipKind::audio;
- audio.channel = c;
- audio.length = 40 * lynx::ppq;
- // Live's Clip Gain staircase of the 190gu render (−1 … 1 in 0.1 steps, 2 beats each), as LYNX lane values
- lynx::ClipEnvelope e;
- for (int k = 0; k <= 20; ++k)
- {
- const auto v = lynx::clipenv::fromLive (lynx::clipenv::volumeLane, -1.0 + 0.1 * k);
- for (const auto at : { 2 * k, 2 * k + 2 })
- {
- lynx::AutomationPoint p;
- p.tick = (std::int64_t) at * lynx::ppq;
- p.value = v;
- e.volume.push_back (p);
- }
- }
- e.shown = lynx::clipenv::volumeLane;
- s.clipEnvelopes.push_back (e);
- audio.envelope = (int) s.clipEnvelopes.size() - 1;
- lynx::launcher::setClip (s, 0, 0, audio);
- lynx::launcher::ensureGrid (s).scenes.resize (1);
- }, false);
- offline.dispatchPendingMessages();
- const auto channelOf = [&] {
- const auto* c = lynx::warpmodes::gridAudioClip (const_cast<lynx::Song&> (offline.getSong()), 0, 0);
- return c != nullptr ? c->channel : -1;
- };
- const auto shoot = [&] (const char* name, int w, int h, int tab) {
- auto panel = lynx::makeClipAudioPanel (offline, 0, 0);
- if (panel == nullptr)
- return std::unique_ptr<juce::Component>();
- panel->setSize (w, h);
- if (tab != 0)
- for (auto* child : panel->getChildren())
- if (auto* b = dynamic_cast<juce::TextButton*> (child); b != nullptr && b->getButtonText() == (tab == 2 ? lynx::tr ("Envelopes") : lynx::tr ("Sample")))
- if (b->onClick)
- b->onClick();
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (*panel), out);
- return panel;
- };
- const auto visibleText = [] (juce::Component& panel, const juce::String& text) {
- for (auto* child : panel.getChildren())
- if (auto* b = dynamic_cast<juce::TextButton*> (child); b != nullptr && b->getButtonText() == text)
- return b->isVisible();
- return false;
- };
- const auto setMode = [&] (int method) {
- offline.editSong ([&] (lynx::Song& s) { lynx::warpmodes::setMode (s, channelOf(), method); }, false);
- offline.dispatchPendingMessages();
- };
- check ("01 Beats (Preserve label + chooser, loop icon + Transient Envelope)", shoot ("01-audio-beats", 900, 250, 1) != nullptr);
- setMode ((int) lynx::StretchMethod::tones);
- check ("02 Tones (Grain Size 30.00)", shoot ("02-audio-tones", 900, 250, 1) != nullptr);
- setMode ((int) lynx::StretchMethod::texture);
- check ("03 Texture (Grain Size 65.00, Flux only when it plays)", shoot ("03-audio-texture", 900, 250, 1) != nullptr);
- { // (round 190ik: Complex Pro plays, its Formants and Envelope show)
- offline.editSong ([&] (lynx::Song& s) { lynx::warpmodes::setComplexPro (s, channelOf()); }, false);
- offline.dispatchPendingMessages();
- check ("04 Complex Pro (Formants 100.00, Envelope 128)", shoot ("04-audio-complex-pro", 900, 250, 1) != nullptr);
- offline.editSong ([&] (lynx::Song& s) { lynx::warpmodes::setWarpLaw (s, channelOf(), 0); }, false);
- offline.dispatchPendingMessages();
- check ("04b Complex Pro of a project saved before 0.1.30 (law chooser, no Formants / Envelope)",
- shoot ("04b-audio-complex-pro-classic", 900, 250, 1) != nullptr);
- offline.editSong ([&] (lynx::Song& s) { lynx::warpmodes::setWarpLaw (s, channelOf(), 1); }, false);
- offline.dispatchPendingMessages();
- }
- setMode ((int) lynx::StretchMethod::beats);
- {
- auto panel = shoot ("05-envelopes-clip-gain-staircase", 1390, 420, 2);
- check ("05 Envelopes tab shown on a warped clip", panel != nullptr && visibleText (*panel, lynx::tr ("Envelopes")));
- }
- offline.editSong ([&] (lynx::Song& s) { lynx::clipsample::setWarp (s, channelOf(), false, 20.0); }, false);
- offline.dispatchPendingMessages();
- {
- auto panel = shoot ("06-unwarped-sample-only", 1390, 420, 2);
- check ("06 an unwarped clip has no Envelopes tab (Live)", panel != nullptr && ! visibleText (*panel, lynx::tr ("Envelopes"))
- && visibleText (*panel, lynx::tr ("Sample")));
- }
- // the law: Live's staircase values round trip through the lane values
- bool law = true;
- for (int k = 0; k <= 20; ++k)
- {
- const auto L = -1.0 + 0.1 * k;
- law = law && std::abs (lynx::clipenv::toLive (lynx::clipenv::volumeLane, lynx::clipenv::fromLive (lynx::clipenv::volumeLane, L)) - L) < 2.0e-3;
- }
- check ("Clip Gain values round trip (Live → lane → Live)", law);
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runDvShot190hr (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = true;
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::clipLaunch);
- offline.editSong ([] (lynx::Song& s) {
- const int ch = (int) s.channels.size();
- s.channels.resize ((std::size_t) ch + 1);
- s.channels[(std::size_t) ch].name = "Keys";
- s.channels[(std::size_t) ch].instrument = lynx::InstrumentKind::synth;
- while (s.patterns.empty())
- s.patterns.emplace_back();
- auto& p = s.patterns[0];
- p.name = "Riff";
- p.notes.clear();
- const int keys[] { 62, 65, 69, 72, 64, 67 };
- for (int i = 0; i < 6; ++i)
- {
- lynx::Note n;
- n.channel = ch;
- n.key = keys[i];
- n.start = i * lynx::ppq / 2 + (i % 2 ? 37 : -0) + 11; // a little off the 1/16 grid
- n.length = lynx::ppq / 3;
- p.notes.push_back (n);
- }
- p.lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 3));
- s.playlistTracks[0].name = "Keys";
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- const auto id = lynx::launcher::setClip (s, 0, 0, clip);
- lynx::launcher::setClip (s, 0, 1, clip);
- auto& grid = lynx::launcher::ensureGrid (s);
- grid.scenes.resize (3);
- if (id >= 0)
- {
- auto& slot = grid.slots[(std::size_t) id];
- slot.name = "Riff";
- slot.startMarker = 2 * lynx::ppq; // Start 1. 3. 1 inside the loop 1. 1. 1 + 1 bar
- slot.ownScale = true;
- slot.scaleRoot = 2; // D, the scale list's first (Major)
- slot.scaleIndex = (std::int16_t) lynx::projectkey::commonFirst().front();
- slot.follow.enabled = true;
- slot.follow.a = lynx::FollowKind::next;
- slot.follow.b = lynx::FollowKind::jump;
- slot.follow.jumpB = 1;
- slot.follow.chanceA = 70;
- slot.follow.chanceB = 30;
- slot.follow.linked = true;
- slot.follow.iterations = 2;
- }
- }, false);
- offline.dispatchPendingMessages();
- ui.resized();
- auto* detail = ui.getDetailViewForSnapshot();
- if (detail == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText ("FAIL no detail view\n");
- return;
- }
- detail->showSelection (0, 0);
- detail->setPage (lynx::DetailView::Page::clip);
- offline.dispatchPendingMessages();
- ui.resized();
- write (ui, "01-clip-view-midi");
- write (*detail, "01b-detail-alone");
- auto& roll = ui.getPianoRollForSnapshot();
- check ("the docked editor uses the reference's grid (" + roll.liveGridTextForCheck() + ")", roll.liveGridOn() && roll.liveGridTextForCheck().isNotEmpty());
- check ("Start marker inside the loop kept by the launcher (lead 2 beats)", lynx::launcher::startLead (offline.getSong().clipGrid->slots[0], 4 * lynx::ppq) == 2.0 * lynx::ppq);
- {
- std::vector<juce::PopupMenu> menus { roll.liveGridMenu() };
- saveMenus (juce::StringArray { "Grid" }, menus, prefix + "-02-grid-menu.png");
- }
- roll.liveGrid.fixed = true;
- roll.liveGrid.fixedIndex = lynx::livegrid::defaultFixed;
- roll.resized();
- const auto sixteenth = roll.gridStepForCheck();
- roll.runAction ("pianoRoll.liveGridNarrower");
- const auto narrower = roll.gridStepForCheck();
- roll.runAction ("pianoRoll.liveGridTriplet");
- const auto triplet = roll.gridStepForCheck();
- check ("fixed 1/16 = 240 ticks, Ctrl+1 -> 1/32 = 120, Ctrl+3 -> 1/32T = 80 (" + juce::String (sixteenth) + ", " + juce::String (narrower) + ", " + juce::String (triplet) + ")",
- sixteenth == lynx::ppq / 4 && narrower == lynx::ppq / 8 && triplet == lynx::ppq / 12);
- write (roll, "03-editor-grid-1-32T");
- roll.runAction ("pianoRoll.liveGridTriplet");
- roll.runAction ("pianoRoll.liveGridWider");
- const auto before = offline.getSong().patterns[0].notes;
- roll.runAction ("pianoRoll.liveQuantize"); // (Live 12: Edit › Quantize, the Quantize tool's settings: Grid = 1/16 here)
- offline.dispatchPendingMessages();
- {
- const auto& after = offline.getSong().patterns[0].notes;
- bool onGrid = ! after.empty();
- for (const auto& n : after)
- onGrid = onGrid && n.start % (lynx::ppq / 4) == 0;
- check ("Ctrl+U quantized every note start onto the editor's 1/16 grid", onGrid && after.size() == before.size() && after != before);
- }
- roll.runAction ("pianoRoll.liveQuantizeSettings"); // (Live 12: Quantize Settings… opens the MIDI Tools' Quantize tool)
- offline.dispatchPendingMessages();
- check ("Ctrl+Shift+U shows the MIDI Tools' Quantize tool", detail->midiToolsForSnapshot().getTool() == lynx::MidiToolsPanel::quantize
- && detail->midiToolsForSnapshot().isVisible());
- ui.resized();
- write (*detail, "04-after-quantize-tool");
- // an audio clip transposed +30 st 25 ct (Live's ±48 st)
- const auto wav = juce::File (prefix + "-tone.wav");
- wav.deleteFile();
- {
- const double rate = 48000.0;
- juce::AudioBuffer<float> buffer (1, (int) (rate * 2.0));
- for (int k = 0; k < buffer.getNumSamples(); ++k)
- buffer.setSample (0, k, (float) (0.5 * std::sin (k * 0.05)));
- if (auto out = std::unique_ptr<juce::FileOutputStream> (wav.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- }
- offline.editSong ([&wav] (lynx::Song& s) {
- lynx::ChannelDef ch;
- ch.name = "Tone";
- ch.instrument = lynx::InstrumentKind::audioClip;
- ch.samplePath = wav.getFullPathName().toStdString();
- s.channels.push_back (ch);
- lynx::Clip audio;
- audio.kind = lynx::ClipKind::audio;
- audio.channel = (int) s.channels.size() - 1;
- audio.length = 4 * lynx::ppq;
- audio.pitch = 30.25f;
- lynx::launcher::setClip (s, 1, 0, audio);
- }, false);
- offline.dispatchPendingMessages();
- if (auto panel = lynx::makeClipAudioPanel (offline, 1, 0))
- {
- panel->setSize (900, 250);
- write (*panel, "06-audio-transpose-30");
- check ("audio clip transpose +30.25 st kept", std::abs (lynx::launcher::clipAt (*offline.getSong().clipGrid, 1, 0)->pitch - 30.25f) < 1e-4f);
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runWarpShot190fm (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- // a one-bar loop of clicks (2 s at 48 kHz) for the audio clips
- const auto wav = juce::File (prefix + "-loop.wav");
- wav.deleteFile();
- {
- const double rate = 48000.0;
- juce::AudioBuffer<float> buffer (2, (int) (rate * 2.0));
- buffer.clear();
- for (int hit = 0; hit < 8; ++hit)
- for (int k = 0; k < 3000; ++k)
- for (int ch = 0; ch < 2; ++ch)
- buffer.setSample (ch, hit * 12000 + k, (float) (std::sin (k * (hit % 4 == 0 ? 0.05 : 0.3)) * std::exp (-k / 500.0) * 0.8));
- if (auto out = std::unique_ptr<juce::FileOutputStream> (wav.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 2, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- }
- offline.editSong ([&wav] (lynx::Song& s) {
- lynx::ChannelDef ch;
- ch.name = "Loop";
- ch.instrument = lynx::InstrumentKind::audioClip;
- ch.samplePath = wav.getFullPathName().toStdString();
- s.channels.push_back (ch);
- const auto c = (int) s.channels.size() - 1;
- lynx::clipsample::setWarp (s, c, true, 2.0);
- lynx::warpmodes::setMode (s, c, (int) lynx::StretchMethod::beats); // (keeps the pitch: Beats, not Re-Pitch)
- lynx::Clip audio;
- audio.kind = lynx::ClipKind::audio;
- audio.channel = c;
- audio.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 0, 0, audio);
- lynx::launcher::setClip (s, 0, 1, audio); // (a second clip on the same channel: O16)
- lynx::launcher::ensureGrid (s).scenes.resize (2);
- }, false);
- offline.dispatchPendingMessages();
- const auto shoot = [&] (const char* name) {
- auto panel = lynx::makeClipAudioPanel (offline, 0, 0);
- if (panel == nullptr)
- return false;
- panel->setSize (900, 250);
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (*panel), out);
- return true;
- };
- const auto channelOf = [&] (int scene) {
- const auto* c = lynx::warpmodes::gridAudioClip (const_cast<lynx::Song&> (offline.getSong()), 0, scene);
- return c != nullptr ? c->channel : -1;
- };
- const auto beatsOn = [&] { const auto& sm = offline.getSong().channels[(std::size_t) channelOf (0)].sampler; return sm.keepPitch && sm.stretchMethod == lynx::StretchMethod::beats; };
- check ("01 Beats panel (defaults: Transients, Back-and-Forth, 100)", beatsOn() && shoot ("01-beats-defaults"));
- offline.editSong ([&] (lynx::Song& s) {
- const auto c = lynx::warpmodes::ownChannelForGridClip (s, 0, 0);
- lynx::warpmodes::setPreserve (s, c, 3);
- lynx::warpmodes::setLoopMode (s, c, 0);
- lynx::warpmodes::setEnvelope (s, c, 40.0);
- }, false);
- offline.dispatchPendingMessages();
- check ("O16: the first clip moved to its own channel, the second kept the old one", channelOf (0) != channelOf (1) && channelOf (0) >= 0 && channelOf (1) >= 0);
- check ("02 Beats panel (1/8, Loop Off, 40)", beatsOn() && shoot ("02-beats-set"));
- offline.editSong ([&] (lynx::Song& s) { lynx::warpmodes::setMode (s, channelOf (0), (int) lynx::StretchMethod::tones); }, false);
- offline.dispatchPendingMessages();
- check ("03 Tones panel (Grain Size 30)", shoot ("03-tones"));
- offline.editSong ([&] (lynx::Song& s) {
- lynx::warpmodes::setMode (s, channelOf (0), (int) lynx::StretchMethod::texture);
- lynx::warpmodes::setGrain (s, channelOf (0), 120.0);
- }, false);
- offline.dispatchPendingMessages();
- check ("04 Texture panel (Grain Size 120)", shoot ("04-texture"));
- check ("Texture grain kept 120, Tones grain still 30", offline.getSong().channels[(std::size_t) channelOf (0)].sampler.warpModes.textureGrain == 120.0f
- && offline.getSong().channels[(std::size_t) channelOf (0)].sampler.warpModes.tonesGrain == 30.0f);
- offline.editSong ([&] (lynx::Song& s) { lynx::warpmodes::setMode (s, channelOf (0), (int) lynx::StretchMethod::complex); }, false);
- offline.dispatchPendingMessages();
- check ("05 Complex panel (no settings row)", shoot ("05-complex"));
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- // LYNX --livelook190jnshot prefix [set.als]: round 190jn off screen (design190ia slices 13 CL-D, 17 CL-E, 18 CL-H,
- // 19 CL-F, 25 CL-I: the Clip-launch layout in Ableton Live's look) — the Session mixer (selected, armed, muted,
- // soloed, I/O on and off, peak pills), the Device View (cards, a card off and one folded, the hot-swap link, a Drum
- // Rack's pads, an Instrument Rack's macros), the Clip View (MIDI and audio, three detail heights), the Info View with a
- // hovered control and the status strip; with a Live set: its Arrangement in 19 px lanes, the 38 px option and a tall
- // audio lane; every view once more in the classic LYNX look (View › Classic LYNX look). prefix-checks.txt
- void runLiveLook190jnShot (const juce::String& prefix, const juce::String& set)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
- juce::String checks;
- const auto flush = [&] { juce::File (lynx::shot::file (juce::File (prefix + "-checks.txt"))).replaceWithText (checks); };
- const auto check = [&] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; flush(); };
- const auto line = [&] (const juce::String& what) { checks << " " << what << "\n"; flush(); };
- const auto write = [&prefix] (juce::Component& c, const juce::String& name) { savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png"); };
- const auto area = [&prefix] (juce::Component& c, juce::Rectangle<int> r, const juce::String& name) { saveArea (c, r, prefix + "-" + name + ".png"); };
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1920x1080"), "x", "");
- const auto w = juce::jlimit (800, 3840, size[0].getIntValue()), h = juce::jlimit (450, 2160, size[1].getIntValue());
- const auto classicBefore = lynx::clipGridClassicLook();
- const auto tallBefore = lynx::playlistTallLiveLanes();
- lynx::clipGridClassicLook() = false;
- lynx::playlistTallLiveLanes() = false;
- lynx::DetailView::infoViewShown = true;
- // ---- A. a synthetic set (round 190dr's, with a Drum Rack and an audio loop) -----------------------------------
- const auto wav = juce::File (prefix + "-loop.wav");
- wav.deleteFile();
- {
- const double rate = 48000.0;
- juce::AudioBuffer<float> buffer (2, (int) (rate * 4.0));
- buffer.clear();
- for (int hit = 0; hit < 16; ++hit)
- for (int k = 0; k < 9000 && hit * 12000 + k < buffer.getNumSamples(); ++k)
- for (int ch = 0; ch < 2; ++ch)
- buffer.setSample (ch, hit * 12000 + k, (float) (std::sin (k * (hit % 4 == 0 ? 0.05 : 0.3)) * std::exp (-k / 2500.0) * 0.8));
- if (auto out = std::unique_ptr<juce::FileOutputStream> (wav.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 2, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- }
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (w, h);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = true;
- lynx::DetailView::devicesPage = true;
- lynx::DetailView::preferredHeight = 228;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::browser, lynx::workspace::Panel::playlist });
- ui.getPlaylistForSnapshot().addAudioClipAtPlayhead (wav);
- settle();
- int audioChannel = -1;
- const auto selectedChannel = offline.getSelectedChannel();
- offline.editSong ([&audioChannel, selectedChannel] (lynx::Song& s) {
- lynx::Clip audio;
- if (! s.playlist.empty())
- {
- audio = s.playlist.front();
- audioChannel = audio.channel;
- s.playlist.clear();
- }
- const int channels = (int) s.channels.size();
- s.channels.resize ((std::size_t) channels + 3);
- const char* names[] { "Drum kit", "Bass synth", "Keys" };
- for (int k = 0; k < 3; ++k)
- {
- auto& ch = s.channels[(std::size_t) (channels + k)];
- ch.name = names[k];
- ch.instrument = k == 0 ? lynx::InstrumentKind::patcher : lynx::InstrumentKind::synth;
- ch.mixerTrack = k + 1;
- }
- // the Drum kit: a Drum Rack with Live's 909 pad names, its two first macros mapped
- {
- auto& kit = s.channels[(std::size_t) channels].patcher;
- kit = lynx::rack::makeDrumRack();
- const char* pads[] { "Bass Drum", "Rim Shot", "Snare Drum", "Hand Clap", "Snare Drum", "Closed Hi Hat", "Snare Drum", "Bass Drum",
- "Low Tom", "Mid Tom", "Open Hi Hat", "Hi Tom", "Crash", "Crash", "Ride", "Ride" };
- for (int p = 0; p < 16; ++p)
- {
- lynx::PatchNode n;
- n.generator = true;
- n.channel.instrument = lynx::InstrumentKind::sampler;
- n.channel.name = pads[p];
- lynx::rack::addPad (kit, 36 + p, pads[p], n);
- }
- if (auto* r = lynx::rack::rackOf (kit))
- {
- r->name = "909 Core Kit";
- r->showMacros = true;
- r->showPads = true;
- r->shownMacros = 8;
- r->macros[0].name = "Low Gain";
- r->macros[1].name = "Mid Gain";
- }
- for (int m = 0; m < 2; ++m)
- {
- lynx::RackMapping map;
- map.target = lynx::RackMapping::Target::chainVolume;
- map.chain = m;
- lynx::rack::map (kit, m, map);
- }
- lynx::rack::compile (kit);
- }
- if (audioChannel >= 0)
- s.channels[(std::size_t) audioChannel].mixerTrack = 5;
- if (s.mixer.size() < 8)
- s.mixer.resize (8);
- const char* inserts[] { "Master", "Drums", "Bass", "Keys", "Vox", "Loop", "Reverb", "Delay" };
- for (int i = 1; i < 8; ++i)
- s.mixer[(std::size_t) i].name = inserts[i];
- s.mixer[1].volume = lynx::sessionmixer::positionForDb (-3.0);
- s.mixer[2].pan = 0.3f;
- s.mixer[2].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::compressor, lynx::EffectKind::delay, lynx::EffectKind::reverb })
- {
- lynx::EffectSlot fx;
- fx.kind = kind;
- const auto& info = lynx::effectInfo (kind);
- for (std::size_t k = 0; k < info.params.size() && k < fx.params.size(); ++k)
- fx.params[k] = info.params[k].defaultValue;
- s.mixer[2].effects.push_back (fx);
- }
- s.mixer[2].effects[2].enabled = false; // (the Delay off: Live dims a device that is off)
- s.mixer[3].muted = true; // the Keys' activator off
- s.mixer[4].inputChannel = 0;
- s.mixer[4].inputStereo = true;
- s.mixer[4].monitor = lynx::InputMonitor::automatic;
- s.mixer[5].solo = false; // (soloed later: Live greys every activator while a track is soloed)
- for (auto [from, to, level] : std::initializer_list<std::tuple<int, int, float>> { { 1, 6, 0.35f }, { 2, 6, 0.6f }, { 3, 6, 0.8f }, { 2, 7, 0.25f }, { 4, 7, 0.5f } })
- {
- lynx::MixerSend send;
- send.target = to;
- send.level = lynx::faderGain (level);
- s.mixer[(std::size_t) from].sends.push_back (send);
- }
- while (s.patterns.size() < 3)
- s.patterns.emplace_back();
- const char* patterns[] { "Beat", "Bassline", "Chords" };
- for (int p = 0; p < 3; ++p)
- {
- auto& pattern = s.patterns[(std::size_t) p];
- pattern.name = patterns[p];
- pattern.notes.clear();
- for (int k = 0; k < 6; ++k)
- {
- lynx::Note n;
- n.channel = channels + p;
- n.key = (p == 0 ? 36 : 48) + (k * 5) % 12 + p * 2;
- n.start = (std::int64_t) k * lynx::ppq / 2;
- n.length = lynx::ppq / 2;
- n.velocity = 0.55f + 0.07f * (float) k;
- pattern.notes.push_back (n);
- }
- pattern.lengthTicks = 4 * lynx::ppq;
- }
- // a "Lead" clip on the FX track for the Clip View's MIDI shot: notes of the rack's selected channel (the docked
- // Piano roll edits its notes) in the Piano roll's opening rows
- {
- const auto kick = juce::jlimit (0, channels - 1, selectedChannel); // (the docked Piano roll edits the selected channel's notes)
- lynx::Pattern lead;
- lead.name = "Lead";
- for (int k = 0; k < 6; ++k)
- {
- lynx::Note n;
- n.channel = kick;
- n.key = 79 + (k * 5) % 6; // (G6 .. C7 in FL's names, C5 = 60: the rows the docked Piano roll opens on)
- n.start = (std::int64_t) k * lynx::ppq / 2;
- n.length = lynx::ppq / 2;
- n.velocity = 0.55f + 0.07f * (float) k;
- lead.notes.push_back (n);
- }
- lead.lengthTicks = 4 * lynx::ppq;
- s.patterns.push_back (lead);
- }
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 8));
- const char* tracks[] { "Drums", "Bass", "Keys", "Vox", "Loop", "FX" };
- const std::uint32_t colours[] { 0xff9bc48d, 0xffd2e498, 0xffa595b5, 0xffcdf1f8, 0xfff7f47c, 0xffc6928b }; // (Live's palette)
- for (int t = 0; t < 6; ++t)
- {
- s.playlistTracks[(std::size_t) t].name = tracks[t];
- s.playlistTracks[(std::size_t) t].colour = colours[t];
- }
- s.playlistTracks[3].mode = lynx::PlaylistTrackMode::audio;
- s.playlistTracks[3].mixerTrack = 4;
- for (int t = 0; t < 3; ++t)
- for (int r = 0; r < 3; ++r)
- if (! (t == 2 && r == 0))
- {
- lynx::Clip clip;
- clip.pattern = t;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, t, r, clip);
- }
- {
- lynx::Clip lead;
- lead.pattern = (int) s.patterns.size() - 1;
- lead.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 5, 0, lead);
- }
- if (audioChannel >= 0)
- {
- lynx::clipsample::setWarp (s, audioChannel, true, 4.0);
- audio.track = 4;
- audio.start = 0;
- lynx::launcher::setClip (s, 4, 0, audio);
- lynx::launcher::setClip (s, 4, 1, audio);
- }
- auto& grid = lynx::launcher::ensureGrid (s);
- const char* scenes[] { "Intro", "Verse", "Drop" };
- grid.scenes.resize (5);
- for (int r = 0; r < 3; ++r)
- grid.scenes[(std::size_t) r].name = scenes[r];
- }, false);
- settle();
- offline.setGridTrackArmed (3, true);
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- settle();
- ui.resized();
- auto* gridView = ui.getClipGridForSnapshot();
- auto* mixer = gridView != nullptr ? lynx::clipGridMixer (*gridView) : nullptr;
- auto* detail = ui.getDetailViewForSnapshot();
- if (gridView == nullptr || mixer == nullptr || detail == nullptr)
- {
- check ("a grid, a Session mixer and a detail view", false);
- return;
- }
- check ("the Live look is on (Clip-launch, classic off)", lynx::theme::livelook::active());
- const auto meters = [&] {
- mixer->tick();
- const float peaks[] { 0.9f, 0.5f, 0.7f, 0.0f, 0.3f, 0.45f, 0.2f, 0.12f };
- for (int i = 0; i < 8; ++i)
- mixer->setMeterForSnapshot (i, peaks[i], peaks[i] * 0.85f, peaks[i] * 1.1f, peaks[i], i == 1 ? 1.2f : peaks[i] * 1.15f);
- };
- if (auto* runtime = offline.launcherStateForSnapshot())
- {
- runtime->tracks[0].playing.store (1);
- runtime->tracks[0].progress.store (0.3f);
- runtime->tracks[1].playing.store (1);
- runtime->tracks[1].progress.store (0.3f);
- runtime->tracks[4].playing.store (0);
- runtime->tracks[4].progress.store (0.5f);
- runtime->running.store (true);
- }
- lynx::selectClipGridSlotForSnapshot (*gridView, 1, 1); // (the Bass track selected: its strip #464646)
- settle();
- meters();
- gridView->resized();
- write (ui, "13-window");
- write (*gridView, "13-grid-mixer");
- area (*gridView, mixer->getBoundsInParent(), "13-mixer");
- using Part = lynx::SessionMixerComponent::Part;
- check ("mixer: the Drums strip has a peak pill in Live's look", ! mixer->partBounds (0, Part::peak).isEmpty());
- check ("mixer: the Drums peak pill reads the clipped peak", mixer->loudestPeak (1) >= 1.0f);
- line ("mixer: activator " + mixer->partBounds (0, Part::activator).toString() + ", solo " + mixer->partBounds (0, Part::solo).toString()
- + ", arm " + mixer->partBounds (0, Part::arm).toString() + ", pan " + mixer->partBounds (0, Part::pan).toString()
- + ", volume " + mixer->partBounds (0, Part::volume).toString() + ", peak " + mixer->partBounds (0, Part::peak).toString());
- check ("mixer: the activator is Live's 21-23 px square", juce::jlimit (21, 23, mixer->partBounds (0, Part::activator).getWidth()) == mixer->partBounds (0, Part::activator).getWidth());
- mixer->setHoverForSnapshot ({ 1, Part::solo, 0 });
- area (*gridView, mixer->getBoundsInParent(), "13-mixer-hover-solo");
- mixer->setHoverForSnapshot ({});
- // the I/O section off (View › Mixer › I/O)
- offline.editSong ([] (lynx::Song& s) { lynx::launcher::ensureGrid (s).mixerView.io = false; }, false);
- settle();
- gridView->resized();
- meters();
- area (*gridView, mixer->getBoundsInParent(), "13-mixer-io-off");
- // a track soloed: Live greys every active activator (#757575, captured in shots/ref/live-mixer-solo-deactivated.png)
- offline.editSong ([] (lynx::Song& s) { s.mixer[5].solo = true; }, false);
- settle();
- meters();
- area (*gridView, mixer->getBoundsInParent(), "13-mixer-soloing");
- offline.editSong ([] (lynx::Song& s) { s.mixer[5].solo = false; }, false);
- settle();
- offline.editSong ([] (lynx::Song& s) { lynx::launcher::ensureGrid (s).mixerView.io = true; }, false);
- settle();
- gridView->resized();
- // ---- 19 + 25: the Device View of the Bass track (EQ, Compressor, Delay off, Reverb folded), the Info View ----
- detail->showSelection (1, 1);
- detail->setPage (lynx::DetailView::Page::devices);
- settle();
- ui.resized();
- settle();
- const auto cards = detail->cardCountForCheck();
- line ("device view: " + juce::String (cards) + " cards, insert " + juce::String (detail->chainInsertForCheck()));
- if (cards >= 5)
- detail->toggleFoldForCheck (4);
- detail->selectCardForCheck (1);
- meters();
- // the Info View with a hovered control: the Bass strip's activator, as the hint timer would give it
- {
- lynx::ui::Hint hint; // (the mixer's hint is its tooltip, read at the mouse: off screen its text for the part)
- hint.text = mixer->tipForSnapshot ({ 1, Part::activator, 0 });
- detail->setInfoHint (hint);
- line ("info view: title '" + detail->infoViewForSnapshot().getTitleText() + "', body '" + detail->infoViewForSnapshot().getBodyText() + "'");
- check ("info view: the hovered activator's hint shows", detail->infoViewForSnapshot().getBodyText().isNotEmpty());
- }
- write (ui, "19-window-devices");
- write (*detail, "19-detail-devices");
- area (*detail, detail->getLocalBounds().withTrimmedTop (detail->getHeight() - lynx::DetailView::stripHeight), "25-status-strip");
- area (*detail, detail->getLocalBounds().withWidth (260), "25-info-view");
- check ("device view: four effect cards and the instrument", cards >= 5);
- check ("device view: the folded card stays folded", cards < 5 || detail->isFoldedForCheck (4));
- // the hot-swap link on the selected card (Q)
- ui.runActionForSnapshot ("view.hotSwap");
- settle();
- write (*detail, "19-detail-hotswap");
- ui.runActionForSnapshot ("view.hotSwap");
- settle();
- // the Drum Rack (the Drums track's instrument)
- detail->showSelection (0, 1);
- settle();
- detail->selectCardForCheck (0);
- write (*detail, "19-detail-drumrack");
- // an Instrument Rack (Keys grouped: Ctrl+G on the instrument card)
- detail->showSelection (2, 1);
- settle();
- check ("device view: the Keys instrument grouped into an Instrument Rack", detail->groupCardForCheck (0, false));
- settle();
- write (*detail, "19-detail-instrumentrack");
- // the Info View off (its (i) button), then back
- detail->toggleInfoView();
- write (*detail, "25-detail-info-off");
- detail->toggleInfoView();
- // ---- 17: the Clip View: a MIDI clip, then the audio clip at three detail heights --------------------------
- detail->showSelection (5, 0); // (the FX track's Lead clip)
- detail->setPage (lynx::DetailView::Page::clip);
- settle();
- ui.resized();
- settle();
- write (ui, "17-window-clip-midi");
- write (*detail, "17-detail-clip-midi");
- // Launch (folded at first, as Live shows it) and Pitch & Time open, the column scrolled to them
- detail->clipSectionsForSnapshot (true, true, true, 0);
- write (*detail, "17-detail-clip-midi-launch-open");
- detail->clipSectionsForSnapshot (true, true, true, 160);
- write (*detail, "17-detail-clip-midi-scrolled");
- detail->clipSectionsForSnapshot (true, false, true, 0);
- detail->showSelection (4, 0);
- settle();
- for (const auto height : { 190, 260, 350 })
- {
- lynx::DetailView::preferredHeight = height;
- ui.resized();
- if (auto* parent = detail->getParentComponent()) // (the Playlist area lays its docked detail view out)
- parent->resized();
- settle();
- write (*detail, "17-detail-clip-audio-" + juce::String (height));
- check ("audio box at " + juce::String (height) + " px: the detail view is that high", detail->getHeight() == height);
- }
- lynx::DetailView::preferredHeight = 228;
- ui.resized();
- if (auto* parent = detail->getParentComponent())
- parent->resized();
- settle();
- write (ui, "17-window-clip-audio");
- // ---- the same views in the classic LYNX look (View › Classic LYNX look in the Clip-launch layout) --------
- lynx::clipGridClassicLook() = true;
- lynx::refreshClipGrid (*gridView);
- ui.getPlaylistForSnapshot().liveLanesChanged();
- ui.resized();
- detail->resized();
- settle();
- check ("classic look: the Live look is off", ! lynx::theme::livelook::active());
- write (ui, "classic-window-clip-audio");
- detail->setPage (lynx::DetailView::Page::devices);
- detail->showSelection (1, 1);
- settle();
- meters();
- write (ui, "classic-window-devices");
- lynx::clipGridClassicLook() = false;
- lynx::refreshClipGrid (*gridView);
- ui.getPlaylistForSnapshot().liveLanesChanged();
- ui.resized();
- settle();
- // ---- 18: the synthetic set's Arrangement (Song view) ------------------------------------------------------
- offline.editSong ([audioChannel] (lynx::Song& s) {
- for (int t = 0; t < 3; ++t)
- for (int bar = 0; bar < 8; bar += 2)
- {
- lynx::Clip clip;
- clip.pattern = t;
- clip.track = t;
- clip.start = (std::int64_t) bar * 4 * lynx::ppq + (t == 2 ? 4 * lynx::ppq : 0);
- clip.length = 4 * lynx::ppq * (t == 1 ? 2 : 1);
- if (! (t == 1 && bar % 4 != 0))
- s.playlist.push_back (clip);
- }
- if (audioChannel >= 0)
- for (int bar = 0; bar < 8; bar += 2)
- {
- lynx::Clip audio;
- audio.channel = audioChannel;
- audio.track = 4;
- audio.start = (std::int64_t) bar * 4 * lynx::ppq;
- audio.length = 8 * lynx::ppq;
- audio.kind = lynx::ClipKind::audio;
- s.playlist.push_back (audio);
- }
- }, false);
- settle();
- ui.setClipGridView (lynx::PlaylistArea::GridView::song);
- settle();
- ui.resized();
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (30000);
- settle();
- ui.getPlaylistForSnapshot().repaint();
- write (ui, "18-synthetic-arrangement-19");
- lynx::playlistTallLiveLanes() = true;
- ui.getPlaylistForSnapshot().liveLanesChanged();
- settle();
- write (ui, "18-synthetic-arrangement-38");
- lynx::playlistTallLiveLanes() = false;
- ui.getPlaylistForSnapshot().liveLanesChanged();
- settle();
- }
- // ---- B. the Live set (its Arrangement with real audio) ----------------------------------------------------------
- if (set.isNotEmpty() && juce::File (set).existsAsFile())
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (w, h);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = true;
- lynx::DetailView::devicesPage = true;
- ui.selectTabForSnapshot (2);
- ui.setClipLaunchWorkflow (true); // (first: the import takes Live's colour table in this layout, CL-6)
- settle();
- ui.openFile (juce::File (set));
- settle();
- ui.setClipGridView (lynx::PlaylistArea::GridView::song);
- settle();
- ui.resized();
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (60000);
- settle();
- const auto& song = offline.getSong();
- line ("set: " + juce::String ((int) song.playlist.size()) + " Arrangement clips, " + juce::String ((int) song.playlistTracks.size()) + " tracks");
- int drums = -1;
- for (int t = 0; t < (int) song.playlistTracks.size() && drums < 0; ++t)
- if (juce::String::fromUTF8 (song.playlistTracks[(std::size_t) t].name.c_str()).containsIgnoreCase ("drum"))
- drums = t;
- if (drums >= 0)
- line ("set: Drums track colour #" + juce::String::toHexString ((int) (song.playlistTracks[(std::size_t) drums].colour & 0xffffff)).paddedLeft ('0', 6));
- check ("set: the Drums track has Live's colour #9BC48D (CL-6)", drums >= 0 && (song.playlistTracks[(std::size_t) drums].colour & 0xffffff) == 0x9bc48d);
- write (ui, "18-als-arrangement-19");
- // the set's Session mixer (the coordinator's 190jn follow-up: every Patience track has its strip)
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- settle();
- ui.resized();
- settle();
- if (auto* gridView = ui.getClipGridForSnapshot())
- if (auto* mixer = lynx::clipGridMixer (*gridView))
- {
- int strips = 0;
- for (int t = 0; t < 64; ++t)
- strips += mixer->partBounds (t, lynx::SessionMixerComponent::Part::volume).isEmpty() ? 0 : 1;
- line ("set: Session mixer strips with a volume: " + juce::String (strips) + ", mixer " + mixer->getBounds().toString()
- + ", grid " + gridView->getBounds().toString());
- write (ui, "13-als-window");
- area (*gridView, mixer->getBoundsInParent(), "13-als-mixer");
- }
- ui.setClipGridView (lynx::PlaylistArea::GridView::song);
- settle();
- write (ui.getPlaylistForSnapshot(), "18-als-playlist-19");
- lynx::playlistTallLiveLanes() = true;
- ui.getPlaylistForSnapshot().liveLanesChanged();
- settle();
- write (ui, "18-als-arrangement-38");
- // a tall audio lane (live-arrangement-audiolane.png: Vocal Main at ~250 px)
- int vocal = -1;
- for (int t = 0; t < (int) song.playlistTracks.size() && vocal < 0; ++t)
- if (juce::String::fromUTF8 (song.playlistTracks[(std::size_t) t].name.c_str()).containsIgnoreCase ("vocal"))
- vocal = t;
- if (vocal >= 0)
- {
- offline.editSong ([vocal] (lynx::Song& s) { s.playlistTracks[(std::size_t) vocal].height = 250; }, false);
- lynx::playlistTallLiveLanes() = false;
- ui.getPlaylistForSnapshot().liveLanesChanged();
- settle();
- write (ui, "18-als-audiolane");
- }
- line ("set: Vocal track " + juce::String (vocal));
- lynx::clipGridClassicLook() = true;
- ui.getPlaylistForSnapshot().liveLanesChanged();
- settle();
- write (ui, "classic-als-arrangement");
- lynx::clipGridClassicLook() = false;
- }
- lynx::clipGridClassicLook() = classicBefore;
- lynx::playlistTallLiveLanes() = tallBefore;
- wav.deleteFile();
- line ("done");
- }
- // LYNX --fllook190joshot prefix project.flp: round 190jo off screen (design190ia slices 12 FM-S6, 21 FM-S4, 23 FW-S4)
- void runFllook190joShot (const juce::String& prefix, const juce::String& project)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
- lynx::ui::motion::enabled() = false; // (hover states drawn at once, no fade)
- juce::String checks;
- const auto flush = [&] { juce::File (lynx::shot::file (juce::File (prefix + "-checks.txt"))).replaceWithText (checks); };
- const auto check = [&] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; flush(); };
- const auto line = [&] (const juce::String& what) { checks << " " << what << "\n"; flush(); };
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1920, 1080);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- const auto area = [&] (juce::Rectangle<int> r, const juce::String& name) { saveArea (ui, r, prefix + "-" + name + ".png"); };
- ui.selectTabForSnapshot (2);
- if (project.isNotEmpty())
- {
- ui.openFile (juce::File (project));
- settle();
- }
- check ("the project opened", ! offline.getSong().channels.empty());
- const auto bar = [&ui] { return ui.getLocalBounds().withHeight (juce::jmin (ui.getHeight(), 90)); };
- const std::pair<int, int> sizes[] { { 1920, 1080 }, { 1600, 900 }, { 1366, 768 }, { 1280, 800 } };
- // ---- slice 12: the Pattern toolbar ------------------------------------------------------------------------------
- for (const auto& [w, h] : sizes)
- {
- ui.setSize (w, h);
- settle();
- area (bar(), "tb-" + juce::String (w));
- int tiles = 0;
- for (auto* c : ui.getChildren())
- if (auto* b = dynamic_cast<lynx::IconButton*> (c); b != nullptr && b->isVisible() && b->getLook() == lynx::IconButton::Look::flTile)
- ++tiles;
- line ("toolbar " + juce::String (w) + ": " + juce::String (tiles) + " tiled buttons");
- }
- ui.setSize (1920, 1080);
- settle();
- std::vector<lynx::IconButton*> tiled;
- for (auto* c : ui.getChildren())
- if (auto* b = dynamic_cast<lynx::IconButton*> (c); b != nullptr && b->isVisible() && b->getLook() == lynx::IconButton::Look::flTile)
- tiled.push_back (b);
- check ("the Pattern toolbar's buttons are FL tiles (" + juce::String ((int) tiled.size()) + ")", tiled.size() >= 25);
- std::vector<bool> lit;
- for (auto* b : tiled)
- lit.push_back (b->getToggleState());
- area (bar(), "tb-states-idle");
- for (const auto& [state, name] : { std::pair<juce::Button::ButtonState, const char*> { juce::Button::buttonOver, "hover" }, { juce::Button::buttonDown, "pressed" } })
- {
- for (auto* b : tiled)
- b->setState (state);
- area (bar(), juce::String ("tb-states-") + name);
- for (auto* b : tiled)
- b->setState (juce::Button::buttonNormal);
- }
- for (auto* b : tiled)
- b->setToggleState (true, juce::dontSendNotification);
- area (bar(), "tb-states-on");
- for (auto* b : tiled)
- b->setState (juce::Button::buttonOver);
- area (bar(), "tb-states-on-hover");
- for (std::size_t k = 0; k < tiled.size(); ++k)
- {
- tiled[k]->setState (juce::Button::buttonNormal);
- tiled[k]->setToggleState (lit[k], juce::dontSendNotification);
- tiled[k]->setEnabled (false);
- }
- area (bar(), "tb-states-disabled");
- for (auto* b : tiled)
- b->setEnabled (true);
- // one switch and one plain button under the mouse, as FL's capture (its audio editor button lit)
- if (auto* metronome = dynamic_cast<lynx::IconButton*> (ui.toolbarPartForSnapshot ("metronome")))
- {
- metronome->setState (juce::Button::buttonOver);
- area (bar(), "tb-hover-switch");
- metronome->setState (juce::Button::buttonNormal);
- }
- // the time panel in B:S:T at bar 3, step 05, tick 12 (FL: "3:05:12"), the tempo, and the hint bar
- {
- auto& transport = offline.getTransport();
- const auto& song = offline.getSong();
- transport.positionTicks.store ((double) (2 * song.barTicks()) + 4.0 * lynx::ticksPerStep + lynx::ticksPerStep / 2.0);
- ui.transportTickForSnapshot();
- auto* time = ui.toolbarPartForSnapshot ("position");
- auto* tempo = ui.toolbarPartForSnapshot ("tempo");
- if (time != nullptr && tempo != nullptr)
- {
- area (time->getBounds().getUnion (tempo->getBounds()).expanded (8, 6), "tb-time");
- if (auto* hs = dynamic_cast<lynx::ui::HintSource*> (time))
- line ("time panel: " + hs->hintAt ({}).value);
- check ("the time panel reads FL's B:S:T (3:05:12)", dynamic_cast<lynx::ui::HintSource*> (time) != nullptr
- && dynamic_cast<lynx::ui::HintSource*> (time)->hintAt ({}).value == "3:05:12");
- }
- transport.positionTicks.store (0.0);
- ui.transportTickForSnapshot();
- }
- const auto hintColumn = juce::Rectangle<int> (0, 0, 360, 80);
- if (auto* knob = dynamic_cast<lynx::ui::HintSource*> (ui.toolbarPartForSnapshot ("masterVolume")))
- {
- ui.setHintForSnapshot (knob->hintAt ({}));
- area (hintColumn, "tb-hint-knob");
- }
- if (auto* rec = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot ("record")))
- {
- ui.setHintForSnapshot ({ rec->getTooltip().upToFirstOccurrenceOf ("\n", false, false), {}, false, true });
- area (hintColumn, "tb-hint-button");
- }
- ui.setHintForSnapshot ({});
- area (hintColumn, "tb-menu");
- // ---- slice 21: the Piano roll ----------------------------------------------------------------------------------
- ui.selectTabForSnapshot (1);
- settle();
- saveSnapshot (ui, prefix + "-pr.png");
- auto& roll = ui.getPianoRollForSnapshot();
- line ("piano roll rows: " + juce::String (roll.rowHeight) + " px");
- check ("FL's 18 px rows by default", roll.rowHeight == 18);
- const auto keysBefore = lynx::PianoRollComponent::keyStyle; // (round 190oo: FL's keys are the default)
- lynx::PianoRollComponent::keyStyle = lynx::pianokeys::Style::piano;
- roll.repaint();
- saveSnapshot (ui, prefix + "-pr-pianokeys.png");
- lynx::PianoRollComponent::keyStyle = keysBefore;
- lynx::notenames::everyKey.store (true);
- roll.repaint();
- saveSnapshot (ui, prefix + "-pr-allnames.png");
- lynx::notenames::everyKey.store (false);
- roll.repaint();
- ui.setHintForSnapshot (roll.hoverForSnapshot());
- saveSnapshot (ui, prefix + "-pr-hover.png");
- ui.setHintForSnapshot ({});
- {
- // FL's ghost capture: "Synth Bass" (no notes of its own in this pattern) over the other channels' notes
- const auto& song = offline.getSong();
- int bass = -1;
- for (int c = 0; c < (int) song.channels.size() && bass < 0; ++c)
- if (juce::String (song.channels[(std::size_t) c].name).equalsIgnoreCase ("Synth Bass"))
- bass = c;
- const auto kept = offline.getSelectedChannel();
- if (bass >= 0)
- {
- offline.setSelectedChannel (bass);
- settle();
- roll.rowHeight = 18;
- roll.repaint();
- saveSnapshot (ui, prefix + "-pr-ghosts.png");
- offline.setSelectedChannel (kept);
- settle();
- }
- check ("Synth Bass found for the ghosts", bass >= 0);
- }
- {
- // the note label against the note over the velocity range of each note colour group (WCAG)
- float worst = 99.0f;
- for (int group = 0; group < 16; ++group)
- for (float v = 0.0f; v <= 1.0001f; v += 0.05f)
- {
- const auto fill = lynx::theme::noteGroupColour (group, v);
- const auto label = fill.getPerceivedBrightness() > 0.5f ? lynx::theme::colour::bg0 : lynx::theme::colour::textPrimary;
- worst = juce::jmin (worst, lynx::theme::contrast (label, fill));
- }
- line ("note label contrast, worst of 16 colour groups x velocity 0..1: " + juce::String (worst, 2) + ":1");
- const auto red = lynx::theme::noteGroupColour (0, 0.78f);
- line ("default note " + red.toDisplayString (false) + " label " + juce::String (lynx::theme::contrast (lynx::theme::colour::bg0, red), 2) + ":1");
- check ("note labels >= 4.5:1 on the default red notes", lynx::theme::contrast (lynx::theme::colour::bg0, red) >= 4.5f);
- }
- ui.selectTabForSnapshot (2);
- settle();
- // ---- slice 23: the audio editor in Edison's layout -------------------------------------------------------------
- {
- const juce::File breaker ("C:\\Program Files\\Image-Line\\FL Studio 2026\\Data\\Patches\\Packs\\Loops\\DL Breaker.wav");
- const auto wav = breaker.existsAsFile() ? breaker : juce::File (juce::SystemStats::getEnvironmentVariable ("LYNX_190JO_WAV", ""));
- check ("FL's DL Breaker.wav", wav.existsAsFile());
- if (wav.existsAsFile())
- if (auto editor = lynx::makeAudioEditorForFileSnapshot (offline, wav))
- {
- for (const auto& [w, h] : { std::pair { 1120, 600 }, std::pair { 960, 520 } })
- {
- editor->setSize (w, h);
- saveSnapshot (*editor, prefix + "-ed-breaker-" + juce::String (w) + ".png");
- }
- editor->setSize (760, 320); // (the compact form: a short dock)
- saveSnapshot (*editor, prefix + "-ed-compact.png");
- }
- const auto at = lynx::addEdisonSlot (offline, 1);
- settle();
- if (at >= 0)
- if (auto slot = lynx::makeEdisonSlotEditor (offline, 1, at))
- {
- slot->setSize (1120, 630);
- saveSnapshot (*slot, prefix + "-ed-slot.png");
- }
- check ("an Edison slot editor", at >= 0);
- const auto& song = offline.getSong();
- int sampled = -1;
- for (int c = 0; c < (int) song.channels.size() && sampled < 0; ++c)
- if (! song.channels[(std::size_t) c].samplePath.empty())
- sampled = c;
- if (sampled >= 0)
- if (auto panel = lynx::makeAudioEditorPanel (offline, sampled, -1))
- {
- panel->setSize (1100, 300);
- saveSnapshot (*panel, prefix + "-ed-panel.png");
- }
- }
- lynx::ui::motion::enabled() = true;
- }
- // Round 190kc (see --cliplaunch190kcshot above): the Patience set in the Clip-launch layout
- void runClipLaunch190kcShot (const juce::String& prefix, const juce::String& set)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
- juce::String checks;
- const auto flush = [&] { juce::File (lynx::shot::file (juce::File (prefix + "-checks.txt"))).replaceWithText (checks); };
- const auto check = [&] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; flush(); };
- const auto line = [&] (const juce::String& what) { checks << " " << what << "\n"; flush(); };
- const auto write = [&prefix] (juce::Component& c, const juce::String& name) { savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png"); };
- const auto area = [&prefix] (juce::Component& c, juce::Rectangle<int> r, const juce::String& name) { saveArea (c, r, prefix + "-" + name + ".png"); };
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1920x1080"), "x", "");
- const auto w = juce::jlimit (800, 3840, size[0].getIntValue()), h = juce::jlimit (450, 2160, size[1].getIntValue());
- const auto classicBefore = lynx::clipGridClassicLook();
- lynx::clipGridClassicLook() = false;
- if (set.isEmpty() || ! juce::File (set).existsAsFile())
- {
- check ("the Live set given", false);
- return;
- }
- using Part = lynx::SessionMixerComponent::Part;
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (w, h);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- ui.setVisible (true);
- lynx::DetailView::shownSetting = true;
- lynx::DetailView::devicesPage = true;
- ui.selectTabForSnapshot (2);
- ui.setClipLaunchWorkflow (true);
- settle();
- ui.openFile (juce::File (set));
- settle();
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- settle();
- ui.resized();
- settle();
- auto* gridView = ui.getClipGridForSnapshot();
- auto* mixer = gridView != nullptr ? lynx::clipGridMixer (*gridView) : nullptr;
- if (gridView == nullptr || mixer == nullptr)
- {
- check ("a clip grid with its Session mixer", false);
- return;
- }
- const auto& song = offline.getSong();
- const auto returns = lynx::sessionmixer::returnsOf (song);
- line ("returns: " + juce::String ((int) returns.size()) + ", return strips " + juce::String (mixer->returnColumnCount()));
- check ("the set's two returns are Live return tracks (A Reverb, B Delay)",
- returns.size() == 2 && lynx::sessionmixer::returnTitle (song, returns[0]) == "A Reverb" && lynx::sessionmixer::returnTitle (song, returns[1]) == "B Delay");
- check ("two return strips beside the tracks", mixer->returnColumnCount() == 2);
- check ("every track shows a Sends row per return (the sends at -inf)",
- mixer->sendTargets() == returns && ! mixer->partBounds (0, Part::send, 1).isEmpty());
- const auto retA = lynx::SessionMixerComponent::returnColumn (0);
- check ("a return strip: Sends, volume, activator, Solo, no Arm",
- ! mixer->partBounds (retA, Part::send, 1).isEmpty() && ! mixer->partBounds (retA, Part::activator).isEmpty()
- && ! mixer->partBounds (retA, Part::solo).isEmpty() && mixer->partBounds (retA, Part::arm).isEmpty());
- check ("the Main strip: a Pre / Post toggle per return", ! mixer->partBounds (-2, Part::post, 0).isEmpty() && ! mixer->partBounds (-2, Part::post, 1).isEmpty());
- line ("Post A " + mixer->partBounds (-2, Part::post, 0).toString() + ", Post B " + mixer->partBounds (-2, Part::post, 1).toString()
- + ", return A activator " + mixer->partBounds (retA, Part::activator).toString());
- write (ui, "window");
- area (*gridView, mixer->getBoundsInParent(), "mixer");
- area (*gridView, { 0, 0, gridView->getWidth(), 240 }, "grid-top");
- area (*gridView, mixer->getBoundsInParent().withTrimmedLeft (mixer->getWidth() - 260), "mixer-returns");
- // a return's send to the other one, switched on; Pre on return B
- offline.editSong ([&returns] (lynx::Song& s) {
- lynx::sessionmixer::setSendEnabled (s, returns[0], returns[1], true);
- lynx::sessionmixer::setPre (s, returns[1], true);
- });
- settle();
- area (*gridView, mixer->getBoundsInParent(), "mixer-sendon-pre");
- area (*gridView, mixer->getBoundsInParent().withTrimmedLeft (mixer->getWidth() - 260), "mixer-returns-sendon-pre");
- check ("return A's send to B switched on, B Pre", lynx::sessionmixer::sendEnabled (song, returns[0], returns[1]) && lynx::sessionmixer::isPre (song, returns[1]));
- saveMenus (juce::StringArray { "Return send" }, std::vector<juce::PopupMenu> { mixer->sendMenu ({ lynx::SessionMixerComponent::returnColumn (1), Part::send, 0 }) },
- prefix + "-menu-send.png");
- offline.editSong ([&returns] (lynx::Song& s) {
- lynx::sessionmixer::setSendEnabled (s, returns[0], returns[1], false);
- lynx::sessionmixer::setPre (s, returns[1], false);
- });
- // the crossfader section: track 1 on A, track 2 on B, the crossfader a little towards A
- const auto i0 = lynx::sessionmixer::stripOf (song, 0).insert, i1 = lynx::sessionmixer::stripOf (song, 1).insert;
- offline.editSong ([i0, i1] (lynx::Song& s) {
- lynx::launcher::ensureGrid (s).mixerView.crossfader = true;
- if (i0 > 0)
- s.mixer[(std::size_t) i0].crossfade = lynx::CrossfadeAssign::a;
- if (i1 > 0)
- s.mixer[(std::size_t) i1].crossfade = lynx::CrossfadeAssign::b;
- s.crossfader = -0.3f;
- });
- settle();
- gridView->resized(); // (the menu item does this: the grid gives the mixer its new height)
- settle();
- check ("the Crossfader section: A / B on a track, the crossfader on Main",
- ! mixer->partBounds (0, Part::xfadeA).isEmpty() && ! mixer->partBounds (0, Part::xfadeB).isEmpty() && ! mixer->partBounds (-2, Part::crossfader).isEmpty());
- line ("A " + mixer->partBounds (0, Part::xfadeA).toString() + ", B " + mixer->partBounds (0, Part::xfadeB).toString() + ", crossfader "
- + mixer->partBounds (-2, Part::crossfader).toString());
- area (*gridView, mixer->getBoundsInParent(), "mixer-crossfader");
- area (*gridView, mixer->getBoundsInParent().withTrimmedLeft (mixer->getWidth() - 260), "mixer-returns-crossfader");
- saveMenus (juce::StringArray { "Crossfader" }, std::vector<juce::PopupMenu> { mixer->crossfaderMenu() }, prefix + "-menu-curve.png");
- lynx::clipGridClassicLook() = true;
- lynx::refreshClipGrid (*gridView);
- ui.resized();
- settle();
- area (*gridView, mixer->getBoundsInParent(), "classic-mixer-crossfader");
- write (ui, "classic-window");
- lynx::clipGridClassicLook() = false;
- lynx::refreshClipGrid (*gridView);
- ui.resized();
- settle();
- // the map modes: a key on a slot, a scene, Scene Down, the crossfader's left position
- using namespace lynx::remotemap;
- offline.editSong ([] (lynx::Song& s) {
- assignKey (s, Target::slot (0, 0), 'Q');
- assignKey (s, Target::sceneLaunch (0), 'W');
- assignKey (s, Target::of (lynx::RemoteAction::sceneDown), 'J');
- assignKey (s, Target::of (lynx::RemoteAction::crossfaderLeft), 'Z');
- });
- for (const auto mode : { Mode::key, Mode::midi })
- {
- ui.setMapMode (mode);
- settle();
- if (auto* overlay = ui.mapOverlayForSnapshot())
- {
- overlay->refresh();
- const auto& spots = overlay->spots();
- const auto count = [&spots] (lynx::RemoteAction a) { return (int) std::count_if (spots.begin(), spots.end(), [a] (const auto& sp) { return sp.target.action == a; }); };
- line (juce::String (mode == Mode::key ? "key" : "midi") + " map: " + juce::String ((int) spots.size()) + " spots; relative strip "
- + juce::String (count (lynx::RemoteAction::sceneUp) + count (lynx::RemoteAction::sceneDown) + count (lynx::RemoteAction::launchSelectedScene)
- + count (lynx::RemoteAction::cancelLaunch))
- + ", per-track launch " + juce::String (count (lynx::RemoteAction::launchSelectedClip)) + ", crossfader positions "
- + juce::String (count (lynx::RemoteAction::crossfaderLeft) + count (lynx::RemoteAction::crossfaderCentre) + count (lynx::RemoteAction::crossfaderRight)));
- check (juce::String (mode == Mode::key ? "Key" : "MIDI") + " Map Mode: the relative strip and the crossfader's three positions are mappable",
- count (lynx::RemoteAction::sceneUp) == 1 && count (lynx::RemoteAction::sceneDown) == 1 && count (lynx::RemoteAction::launchSelectedScene) == 1
- && count (lynx::RemoteAction::cancelLaunch) == 1 && count (lynx::RemoteAction::launchSelectedClip) >= 4
- && count (lynx::RemoteAction::crossfaderLeft) == 1 && count (lynx::RemoteAction::crossfaderRight) == 1);
- }
- write (ui, mode == Mode::key ? "keymap" : "midimap");
- }
- ui.setMapMode (Mode::off);
- settle();
- // grooves on clips: a groove of LYNX's bank on the first MIDI clip and on an audio clip; the Clip View's Commit
- int midiTrack = -1, midiScene = -1, audioTrack = -1, audioScene = -1;
- if (song.clipGrid)
- for (const auto& c : song.clipGrid->clips)
- {
- const auto scene = c.gridSlot >= 0 && c.gridSlot < (int) song.clipGrid->slots.size() ? song.clipGrid->slots[(std::size_t) c.gridSlot].scene : -1;
- if (c.kind == lynx::ClipKind::pattern && midiTrack < 0)
- midiTrack = c.track, midiScene = scene;
- if (c.kind == lynx::ClipKind::audio && audioTrack < 0)
- audioTrack = c.track, audioScene = scene;
- }
- line ("MIDI clip " + juce::String (midiTrack) + "/" + juce::String (midiScene) + ", audio clip " + juce::String (audioTrack) + "/" + juce::String (audioScene));
- std::uint32_t grooveId = 0;
- offline.editSong ([&grooveId, midiTrack, midiScene, audioTrack, audioScene] (lynx::Song& s) {
- auto g = lynx::groove::factoryBank().front().groove;
- g.timing = 1.0f;
- grooveId = lynx::groove::add (s.grooves, g);
- lynx::groove::setClipGroove (s, midiTrack, midiScene, grooveId);
- lynx::groove::setClipGroove (s, audioTrack, audioScene, grooveId);
- });
- settle();
- if (auto* detail = ui.getDetailViewForSnapshot(); detail != nullptr && midiTrack >= 0 && audioTrack >= 0)
- {
- detail->showSelection (midiTrack, midiScene);
- detail->setPage (lynx::DetailView::Page::clip);
- settle();
- write (*detail, "clip-midi-groove");
- detail->showSelection (audioTrack, audioScene);
- detail->setPage (lynx::DetailView::Page::clip);
- settle();
- write (*detail, "clip-audio-groove");
- const auto* audio = lynx::launcher::clipAt (*song.clipGrid, audioTrack, audioScene);
- const auto sample = audio != nullptr && audio->channel >= 0 ? offline.getSampleLibrary().load (juce::String::fromUTF8 (song.channels[(std::size_t) audio->channel].samplePath.c_str()))
- : nullptr;
- check ("the audio clip's file loads", sample != nullptr);
- if (sample != nullptr && audio != nullptr)
- {
- const auto hits = lynx::grooveaudio::hitsOf (song, *audio, *sample);
- {
- const auto all = lynx::clipwarp::attacks (*sample);
- const auto& sm = song.channels[(std::size_t) audio->channel].sampler;
- line ("audio file: " + juce::String ((int) sample->frames()) + " frames at " + juce::String (sample->sampleRate) + " Hz, "
- + juce::String ((int) all.size()) + " attacks (first " + juce::String (all.empty() ? -1.0 : all.front(), 3) + " s); clip offset "
- + juce::String (audio->offset) + " length " + juce::String (audio->length) + " stretch " + juce::String (audio->stretch, 3)
- + "; warp " + juce::String ((int) sm.warp.size()) + " markers, keepPitch " + juce::String ((int) sm.keepPitch)
- + ", first content beat " + juce::String (all.empty() ? 0.0 : lynx::grooveaudio::contentBeat (sm, all.front(), song.bpm), 3));
- }
- const auto pool = song.grooves.grooves.size();
- offline.editSong ([&] (lynx::Song& s) {
- if (const auto* c = lynx::launcher::clipAt (*s.clipGrid, audioTrack, audioScene))
- if (auto g = lynx::grooveaudio::extract (s, *c, *sample, lynx::GrooveBase::sixteenth, "Vocal groove"); ! g.points.empty())
- lynx::groove::add (s.grooves, std::move (g));
- });
- line ("audio clip: " + juce::String ((int) hits.size()) + " attacks; pool " + juce::String ((int) pool) + " -> " + juce::String ((int) song.grooves.grooves.size()));
- check ("Extract Groove from the audio clip adds a groove", song.grooves.grooves.size() == pool + 1);
- int placed = -1;
- offline.editSong ([&] (lynx::Song& s) { placed = lynx::grooveaudio::commit (s, audioTrack, audioScene, *sample); });
- auto gridCopy = *song.clipGrid;
- const auto* slot = lynx::launcher::settingsAt (gridCopy, audioTrack, audioScene);
- line ("commit on audio: " + juce::String (placed) + " warp markers");
- check ("Commit on the audio clip writes warp markers and sets its groove to None", placed > 0 && slot != nullptr && slot->groove == 0);
- }
- }
- lynx::clipGridClassicLook() = classicBefore;
- line ("done");
- }
- // LYNX --capfix190jjshot prefix project.flp set.als: round 190jj off screen (capture190ji's "Change in LYNX" lines) —
- // the Simple capsule idle / playing / count-in / recording with the master meter, the pads at rest and pressed, the
- // keys held in the track's colour, the drop lane's ghosts; Live's control bar idle / playing / recording / punch;
- // FL's C-11 picker drop ghost with the drag image, the drop, and the picker's playing mark; prefix-checks.txt
- void runCapfix190jjShot (const juce::String& prefix, const juce::String& project, const juce::String& set)
- {
- namespace st = lynx::simpletracks;
- namespace sp = lynx::simplepads;
- using Look = lynx::toolbarlayout::Look;
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
- juce::String checks;
- const auto flush = [&] { juce::File (lynx::shot::file (juce::File (prefix + "-checks.txt"))).replaceWithText (checks); };
- const auto check = [&] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; flush(); };
- const auto line = [&] (const juce::String& what) { checks << " " << what << "\n"; flush(); };
- const auto write = [&prefix] (juce::Component& c, const juce::String& name) { savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png"); };
- const auto area = [&prefix] (juce::Component& c, juce::Rectangle<int> r, const juce::String& name) { saveArea (c, r, prefix + "-" + name + ".png"); };
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1920x1080"), "x", "");
- const auto w = juce::jlimit (800, 3840, size[0].getIntValue()), h = juce::jlimit (450, 2160, size[1].getIntValue());
- // ---- A. Simple ----------------------------------------------------------------------------------------------------
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (w, h);
- const auto settle = [&] {
- for (int k = 0; k < 3; ++k)
- offline.dispatchPendingMessages();
- };
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- settle();
- auto* simple = ui.getSimpleWorkflowForSnapshot();
- auto& playlist = ui.getPlaylistForSnapshot();
- if (simple == nullptr)
- {
- check ("a Simple workflow", false);
- return;
- }
- offline.setSong ([] {
- lynx::Song s;
- s.mixer = lynx::Song::defaultMixer();
- s.bpm = 120.0;
- return s;
- }());
- settle();
- simple->hideChooser();
- const auto dir = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-190jj");
- dir.deleteRecursively();
- dir.createDirectory();
- const auto writeWav = [] (const juce::File& wav, int frames, const std::function<float (int)>& f) {
- wav.getParentDirectory().createDirectory();
- juce::AudioBuffer<float> audio (1, frames);
- for (int i = 0; i < frames; ++i)
- audio.setSample (0, i, f (i));
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* wr = format.createWriterFor (out.get(), 48000.0, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (wr);
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- }
- return wav;
- };
- const auto pi = juce::MathConstants<double>::pi;
- juce::Random rnd (190);
- // a 4-bar loop at 120 bpm (8 s), as BandLab's "TRAP_160_Piano1_Bm_4bars" is four bars
- const auto loop = writeWav (dir.getChildFile ("TRAP_120_Piano1_Bm_4bars.wav"), 384000, [pi] (int i) {
- const auto t = i / 48000.0, inBeat = std::fmod (t, 0.5);
- return (float) (0.6 * std::exp (-inBeat * 6.0) * std::sin (2.0 * pi * 247.0 * t));
- });
- std::vector<juce::File> padSounds;
- const char* padNames[] { "Kick", "Snare", "Hat", "Clap", "Stab", "Vox", "Perc", "Bass" };
- for (int k = 0; k < 8; ++k)
- padSounds.push_back (writeWav (dir.getChildFile (juce::String ("pads/") + padNames[k] + ".wav"), 12000 + 3000 * k, [&rnd, k] (int i) {
- return (float) ((rnd.nextFloat() * 2.0f - 1.0f) * 0.6f * std::exp (-i / (600.0f + 500.0f * (float) k)));
- }));
- int vocal = -1, keys = -1;
- offline.editSong ([&] (lynx::Song& s) {
- st::Request q;
- q.kind = st::Kind::audio;
- q.name = "Piano loop";
- q.audioFile = loop.getFullPathName().toStdString();
- q.audioLength = 16 * lynx::ppq;
- q.audioBeats = 16.0f;
- vocal = st::addTrack (s, q).track;
- q = {};
- q.kind = st::Kind::instrument;
- q.name = "Instrument";
- lynx::ChannelDef synth;
- synth.instrument = lynx::InstrumentKind::synth;
- q.channel = synth;
- keys = st::addTrack (s, q).track;
- });
- settle();
- check ("the Sampler (pads) track was added", simple->addPads());
- settle();
- const auto& song = offline.getSong();
- int pads = -1;
- for (int t = 0; t < (int) song.playlistTracks.size() && pads < 0; ++t)
- if (st::kindOf (song, t) == st::Kind::pads)
- pads = t;
- simple->hideChooser();
- playlist.selectTrack (keys);
- settle();
- // 1. the transport capsule (+ tempo, key, master) in its four states
- const auto bar = [&ui] {
- juce::Rectangle<int> r;
- for (const auto* name : { "play", "stop", "record", "position", "metronome", "tempo", "signature", "key", "masterVolume", "masterPitch" })
- if (auto* c = ui.toolbarPartForSnapshot (name); c != nullptr && c->isVisible())
- r = r.isEmpty() ? c->getBounds() : r.getUnion (c->getBounds());
- return r.expanded (8, 6);
- };
- auto& transport = offline.getTransport();
- auto* tempo = ui.toolbarPartForSnapshot ("tempo");
- auto* stopButton = dynamic_cast<lynx::IconButton*> (ui.toolbarPartForSnapshot ("stop"));
- auto* playButton = dynamic_cast<lynx::IconButton*> (ui.toolbarPartForSnapshot ("play"));
- auto* master = dynamic_cast<lynx::toolbar::MasterKnob*> (ui.toolbarPartForSnapshot ("masterVolume"));
- ui.transportTickForSnapshot();
- area (ui, bar(), "simple-bar-idle");
- check ("idle: Play shows Play, the second button Back-to-start", playButton != nullptr && playButton->getIcon() == lynx::Icon::play
- && stopButton != nullptr && stopButton->getIcon() == lynx::Icon::toStart);
- transport.positionTicks.store ((double) (2 * song.barTicks()) + 0.3 * lynx::ppq);
- transport.playing.store (true);
- if (master != nullptr)
- master->meterForSnapshot ({ 0.62f, 0.57f });
- ui.transportTickForSnapshot();
- area (ui, bar(), "simple-bar-playing");
- check ("playing: Pause and Stop (BandLab)", playButton != nullptr && playButton->getIcon() == lynx::Icon::pause && stopButton->getIcon() == lynx::Icon::stop);
- transport.playing.store (false);
- transport.positionTicks.store (0.0);
- offline.setRecording (true);
- transport.countIn.store (0.85 * (double) song.barTicks()); // (-1.7 s of a 2 s bar at 120 bpm)
- ui.transportTickForSnapshot();
- area (ui, bar(), "simple-bar-countin");
- check ("count-in: tempo greyed, Pause shown", tempo != nullptr && ! tempo->isEnabled() && playButton->getIcon() == lynx::Icon::pause);
- transport.countIn.store (0.0);
- transport.playing.store (true);
- transport.positionTicks.store (0.45 * (double) song.barTicks());
- ui.transportTickForSnapshot();
- area (ui, bar(), "simple-bar-recording");
- line ("record start kept: " + juce::String (ui.simpleRecordStartForCheck(), 1) + " ticks");
- check ("recording: the take's start is kept (the count-in's target, 0)", ui.simpleRecordStartForCheck() == 0.0);
- auto* rec = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot ("record"));
- const auto litA = rec != nullptr && rec->getToggleState();
- juce::Thread::sleep (260);
- ui.transportTickForSnapshot();
- const auto litB = rec != nullptr && rec->getToggleState();
- check ("recording: Record steady (lit 260 ms apart, no blink in Simple)", litA && litB);
- transport.seekRequest.store (-1.0);
- ui.stopForCheck();
- line ("seek after Stop: " + juce::String (transport.seekRequest.load(), 1));
- check ("Stop after a take goes back to where it started", transport.seekRequest.load() == 0.0);
- offline.setRecording (false);
- transport.playing.store (false);
- ui.transportTickForSnapshot();
- check ("stopped: tempo enabled again", tempo != nullptr && tempo->isEnabled());
- if (master != nullptr)
- {
- area (ui, master->getBounds().expanded (6, 4), "simple-master-idle");
- master->meterForSnapshot ({ 0.62f, 0.57f });
- area (ui, master->getBounds().expanded (6, 4), "simple-master-playing");
- master->meterForSnapshot ({ 0.0f, 0.0f });
- }
- // 2. the dock: pads at rest and pressed, keys held
- if (auto* dock = simple->dockForSnapshot(); dock != nullptr && pads >= 0)
- {
- simple->trackSelected (pads);
- settle();
- for (int p = 0; p < 8; ++p)
- dock->padsLoadForCheck (p, padSounds[(std::size_t) p]);
- offline.editSong ([pads] (lynx::Song& s) {
- for (int p = 0; p < 8; ++p)
- if (const auto c = sp::padChannel (s, pads, p); c >= 0)
- s.channels[(std::size_t) c].simplePad.colour = (std::uint8_t) (p + 1);
- });
- dock->padsSelectForCheck (0);
- dock->padsUpdateForCheck();
- settle();
- write (*dock, "dock-pads-rest");
- dock->padsPressForSnapshot (3, 1.0f);
- dock->padsPressForSnapshot (5, 0.5f);
- write (*dock, "dock-pads-pressed");
- dock->padsPressForSnapshot (3, 0.0f);
- dock->padsPressForSnapshot (5, 0.0f);
- simple->trackSelected (keys);
- settle();
- dock->showKeyboard();
- settle();
- if (auto* kb = dock->keyboardForSnapshot())
- {
- lynx::keyboardPressForSnapshot (*kb);
- write (*dock, "dock-keys-held");
- }
- }
- // 3. the drop lane while the loop is dragged (the Browser's file drag)
- simple->hideChooser();
- playlist.selectTrack (vocal);
- settle();
- const auto lane = st::nextEmptyTrack (offline.getSong());
- const juce::var drag (juce::String ("lynx-arquivo|") + loop.getFullPathName());
- const auto x = (int) playlist.xOfTickForSnapshot (9.0 * (double) song.barTicks()) + 6;
- playlist.dragOverForSnapshot (drag, { x, playlist.trackRowForSnapshot (lane).getCentreY() });
- write (playlist, "simple-drop-lane");
- check ("over the lane: a ghost, no reason", ! playlist.dropGhostAreaForCheck().isEmpty() && playlist.dropGhostReasonForCheck().isEmpty());
- playlist.dragOverForSnapshot (drag, { x, playlist.trackRowForSnapshot (vocal).getCentreY() });
- write (playlist, "simple-drop-audio-track");
- check ("over an audio track: no reason", playlist.dropGhostReasonForCheck().isEmpty());
- playlist.dragOverForSnapshot (drag, { x, playlist.trackRowForSnapshot (pads).getCentreY() });
- write (playlist, "simple-drop-refused");
- check ("over the Sampler track: red, with the reason", playlist.dropGhostReasonForCheck().isNotEmpty());
- playlist.dragOverForSnapshot (drag, { x, playlist.trackRowForSnapshot (keys).getCentreY() });
- check ("over an instrument track: red, with the reason", playlist.dropGhostReasonForCheck().isNotEmpty());
- playlist.dragOverForSnapshot (drag, { x, playlist.trackRowForSnapshot (lane).getBottom() + 60 });
- write (playlist, "simple-drop-below");
- check ("below the lane: only the tag", playlist.dropGhostTagOnlyForCheck());
- playlist.dragOverForSnapshot ({}, {});
- check ("after the drag: nothing left to paint", playlist.dropGhostAreaForCheck().isEmpty());
- const auto clipsBefore = offline.getSong().playlist.size();
- playlist.filesDropped ({ loop.getFullPathName() }, x, playlist.trackRowForSnapshot (pads).getCentreY());
- settle();
- check ("a loop dropped on the Sampler track is refused", offline.getSong().playlist.size() == clipsBefore);
- write (ui, "simple-window");
- dir.deleteRecursively();
- }
- // ---- B. Clip-launch: Live's control bar ----------------------------------------------------------------------------
- if (set.isNotEmpty())
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (w, h);
- ui.openFile (juce::File (set));
- offline.dispatchPendingMessages();
- ui.setLayoutStyle (lynx::layoutstyle::Style::clipLaunch, false);
- offline.dispatchPendingMessages();
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- offline.dispatchPendingMessages();
- const auto centre = [&ui] {
- juce::Rectangle<int> r;
- for (const auto* name : { "backToArrangement", "position", "play", "stop", "record", "overdub", "capture", "sessionRecord", "punch" })
- if (auto* c = ui.toolbarPartForSnapshot (name); c != nullptr && c->isVisible())
- r = r.isEmpty() ? c->getBounds() : r.getUnion (c->getBounds());
- return r.expanded (8, 8);
- };
- auto& transport = offline.getTransport();
- ui.transportTickForSnapshot();
- area (ui, centre(), "live-bar-idle");
- transport.playing.store (true);
- ui.transportTickForSnapshot();
- area (ui, centre(), "live-bar-playing");
- offline.setRecording (true);
- ui.transportTickForSnapshot();
- area (ui, centre(), "live-bar-recording");
- auto* rec = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot ("record"));
- const auto litA = rec != nullptr && rec->getToggleState();
- juce::Thread::sleep (260);
- ui.transportTickForSnapshot();
- check ("Live look: Record steady while recording (no blink)", litA && rec->getToggleState());
- if (auto* punch = dynamic_cast<juce::Button*> (ui.toolbarPartForSnapshot ("punch")))
- {
- punch->setToggleState (true, juce::dontSendNotification);
- area (ui, centre(), "live-bar-punch-lit");
- punch->setToggleState (false, juce::dontSendNotification);
- }
- offline.setRecording (false);
- transport.playing.store (false);
- ui.transportTickForSnapshot();
- }
- // ---- C. Pattern (FL): C-11 drop ghost + drag image, the drop, the picker's playing mark ----------------------------------
- if (project.isNotEmpty())
- {
- lynx::layoutstyle::setCurrent (lynx::layoutstyle::Style::pattern); // (the style is global: A and B changed it)
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (w, h);
- ui.openFile (juce::File (project));
- offline.dispatchPendingMessages();
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern, false);
- ui.selectTabForSnapshot (2);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- auto& picker = ui.getPickerForSnapshot();
- const auto& song = offline.getSong();
- write (playlist, "warmup");
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (60000);
- offline.dispatchPendingMessages();
- juce::File (lynx::shot::file (juce::File (prefix + "-warmup.png"))).deleteFile();
- int synthBass = 0;
- for (int p = 0; p < (int) song.patterns.size(); ++p)
- if (juce::String::fromUTF8 (song.patterns[(std::size_t) p].name.c_str()).equalsIgnoreCase ("Synth Bass"))
- {
- synthBass = p;
- break;
- }
- // an empty track low in the view (FL's capture: Track 43 / 47, past the song's tracks)
- // (an unnamed track past the song's own, as FL's Track 43 / 47)
- const auto target = (int) song.playlistTracks.size() + 2;
- for (int first = juce::jmax (0, target - 30); first <= target; ++first) // (the row in the lower part of the view)
- {
- playlist.setViewForSnapshot (15.6, 0, first);
- if (playlist.trackRowForSnapshot (target).getBottom() < playlist.getHeight() - 40)
- break;
- }
- offline.dispatchPendingMessages();
- const auto row = playlist.trackRowForSnapshot (target);
- const auto mouse = juce::Point<int> ((int) playlist.xOfTickForSnapshot (9.1 * (double) song.barTicks()), row.getCentreY());
- const juce::var drag (lynx::PlaylistComponent::pickerDragDescription (lynx::ClipKind::pattern, { synthBass }));
- playlist.dragOverForSnapshot (drag, mouse);
- {
- // the window as the drag shows it: the ghost in the row, the entry's picture below right of the mouse
- auto image = lynx::shot::snapshot (ui);
- const auto scale = (float) image.getWidth() / (float) juce::jmax (1, ui.getWidth());
- const auto listRow = picker.listRowOfPattern (synthBass);
- if (listRow >= 0)
- {
- const auto entry = picker.dragImageOf (listRow);
- const auto at = ui.getLocalPoint (&playlist, mouse) + lynx::PatternPicker::dragImageOffset();
- juce::Graphics g (image);
- g.addTransform (juce::AffineTransform::scale (scale));
- g.drawImageAt (entry, at.x, at.y);
- g.setColour (juce::Colours::white);
- juce::Path arrow; // (the mouse pointer, so the pair reads as FL's film still)
- arrow.startNewSubPath ((float) ui.getLocalPoint (&playlist, mouse).x, (float) ui.getLocalPoint (&playlist, mouse).y);
- arrow.lineTo (arrow.getCurrentPosition() + juce::Point<float> (0.0f, 16.0f));
- arrow.lineTo (arrow.getCurrentPosition() + juce::Point<float> (4.0f, -4.0f));
- arrow.lineTo (arrow.getCurrentPosition() + juce::Point<float> (7.0f, 0.0f));
- arrow.closeSubPath();
- g.fillPath (arrow);
- g.setColour (juce::Colours::black);
- g.strokePath (arrow, juce::PathStrokeType (1.0f));
- }
- savePng (image, prefix + "-fl-c11-drag.png");
- }
- const auto ghost = playlist.dropGhostAreaForCheck();
- line ("ghost " + ghost.toString() + ", row " + row.toString() + ", mouse " + mouse.toString());
- check ("C-11: the ghost lies in the row under the mouse", ! ghost.isEmpty() && ghost.getY() >= row.getY() - 2 && ghost.getBottom() <= row.getBottom() + 2);
- const auto first = (int) offline.getSong().playlist.size();
- playlist.dropForSnapshot (drag, mouse);
- offline.dispatchPendingMessages();
- const auto& dropped = offline.getSong(); // (an edit publishes a new Song: read it again; the Playlist sorts its clips)
- int onRow = 0, at = -1;
- for (int c = 0; c < (int) dropped.playlist.size(); ++c)
- if (dropped.playlist[(std::size_t) c].track == target)
- {
- ++onRow;
- at = c;
- }
- line ("clips " + juce::String (first) + " -> " + juce::String ((int) dropped.playlist.size()) + ", on the row " + juce::String (onRow));
- check ("C-11: the drop places one clip on the row", (int) dropped.playlist.size() == first + 1 && onRow == 1);
- check ("C-11: the dropped clip is selected", at >= 0 && playlist.isClipSelectedForCheck (at));
- check ("C-11: nothing of the ghost is left", playlist.dropGhostAreaForCheck().isEmpty());
- write (ui, "fl-c11-dropped");
- // the picker's playing mark: Synth Bass plays in the first bars; then another pattern selected
- offline.getTransport().positionTicks.store (0.5 * (double) offline.getSong().barTicks());
- offline.getTransport().playing.store (true);
- offline.getTransport().songMode = true;
- playlist.frameStepForSnapshot();
- playlist.frameStepForSnapshot();
- write (picker, "fl-picker-playing");
- line ("playing patterns: " + juce::String ((int) picker.playingForCheck().size()));
- const auto other = juce::jmin ((int) offline.getSong().patterns.size() - 1, 7);
- offline.editSong ([other] (lynx::Song& s) { s.currentPattern = other; }, false);
- offline.dispatchPendingMessages();
- playlist.frameStepForSnapshot();
- write (picker, "fl-picker-playing-other-selected");
- check ("DC-3: the mark follows what plays, not the selection",
- std::find (picker.playingForCheck().begin(), picker.playingForCheck().end(), other) == picker.playingForCheck().end()
- || std::count_if (offline.getSong().playlist.begin(), offline.getSong().playlist.end(), [&] (const lynx::Clip& c) {
- return c.kind == lynx::ClipKind::pattern && c.pattern == other && (double) c.start <= 0.5 * (double) offline.getSong().barTicks()
- && (double) c.end() > 0.5 * (double) offline.getSong().barTicks();
- }) > 0);
- offline.getTransport().playing.store (false);
- playlist.frameStepForSnapshot();
- write (picker, "fl-picker-stopped");
- check ("DC-3: no mark once stopped", picker.playingForCheck().empty());
- }
- line ("done");
- }
- void runDetails190imShot (const juce::String& prefix, const juce::String& project, const juce::String& set)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true); // (the live frame steps run off-screen)
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto line = [&checks] (const juce::String& what) { checks << " " << what << "\n"; };
- const auto write = [&prefix] (juce::Component& c, const juce::String& name) { savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png"); };
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1920x1080"), "x", "");
- {
- // ---- Pattern layout, the FL demo
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- if (project.isNotEmpty())
- ui.openFile (juce::File (project));
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2);
- auto& playlist = ui.getPlaylistForSnapshot();
- offline.dispatchPendingMessages();
- const auto settle = [&] {
- write (playlist, "warmup");
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (60000);
- offline.dispatchPendingMessages();
- juce::File (prefix + "-warmup.png").deleteFile();
- };
- const auto& song = offline.getSong();
- offline.editSong ([] (lynx::Song& s) { for (auto& t : s.playlistTracks) t.height = 50; }, false);
- offline.dispatchPendingMessages();
- const auto toolbar = ui.getToolbarBoundsForSnapshot();
- // R1: the automation clip with the most points in view, its second point dragged, its first segment bent
- int autoClip = -1;
- for (int c = 0; c < (int) song.playlist.size(); ++c)
- if (const auto& clip = song.playlist[(std::size_t) c]; clip.kind == lynx::ClipKind::automation && clip.automation >= 0
- && clip.automation < (int) song.automations.size() && song.automations[(std::size_t) clip.automation].points.size() >= 3
- && (autoClip < 0 || song.automations[(std::size_t) clip.automation].points.size() > song.automations[(std::size_t) song.playlist[(std::size_t) autoClip].automation].points.size()))
- autoClip = c;
- check ("R1: an automation clip with points in the project", autoClip >= 0);
- if (autoClip >= 0)
- {
- const auto& clip = song.playlist[(std::size_t) autoClip];
- const auto bar = (int) (clip.start / song.barTicks());
- playlist.setViewForSnapshot (39.75, juce::jmax (0, bar - 2), juce::jmax (0, clip.track - 3));
- settle();
- const auto point = playlist.dragHintForSnapshot (autoClip, 1, false);
- line ("point drag hint: " + point.text + " | " + point.value);
- check ("R1: a dragged automation-clip point shows its value (DE-117)", point.value.isNotEmpty());
- ui.setHintForSnapshot (point);
- saveArea (ui, toolbar, prefix + "-r1-hint-point.png");
- write (ui, "r1-window-point");
- int bent = 0; // (a segment that is bent, when the clip has one)
- const auto& points = song.automations[(std::size_t) clip.automation].points;
- for (int k = 0; k + 1 < (int) points.size(); ++k)
- if (points[(std::size_t) k].tension != 0.0f)
- {
- bent = k;
- break;
- }
- const auto tension = playlist.dragHintForSnapshot (autoClip, bent, true);
- line ("tension drag hint: " + tension.text + " | " + tension.value);
- check ("R1: a bent segment shows its tension (DE-118)", tension.value.startsWith (lynx::tr ("Tension: {0}", { "" }).upToFirstOccurrenceOf (" ", false, false).trimEnd()));
- ui.setHintForSnapshot (tension);
- saveArea (ui, toolbar, prefix + "-r1-hint-tension.png");
- const auto body = playlist.curveBodyForSnapshot (autoClip);
- const auto hoverX = juce::jlimit (playlist.headerWidthForSnapshot() + 20, playlist.getWidth() - 40, (int) body.getX() + 80);
- const auto hover = playlist.hintAt ({ hoverX, (int) body.getCentreY() });
- line ("hover hint: " + hover.text + " | " + hover.value);
- check ("R1: hovering the curve shows the value at the mouse (DE-119)", hover.value.contains (" "));
- ui.setHintForSnapshot (hover);
- saveArea (ui, toolbar, prefix + "-r1-hint-hover.png");
- }
- // R5: playing at bar 33 (FL's fl-playing.png), the meters fed so the activity strips show their steps
- playlist.setViewForSnapshot (39.75, 20, 24);
- settle();
- offline.getTransport().positionTicks.store ((double) (32 * song.barTicks()));
- offline.getTransport().playing.store (true);
- const auto feed = [&offline] {
- const float levels[] { 1.0f, 0.3f, 0.08f, 0.02f };
- for (int k = 1; k < lynx::maxMixerTracks; ++k)
- offline.getMeters().accumulate (k, levels[k % 4], levels[k % 4]);
- };
- feed();
- playlist.frameStepForSnapshot();
- feed();
- playlist.frameStepForSnapshot();
- write (ui, "r5-playing");
- write (ui.getPickerForSnapshot(), "r5-picker-playing");
- const auto px = (int) playlist.xOfTickForSnapshot (32.0 * (double) song.barTicks());
- saveArea (playlist, { px - 40, lynx::PlaylistComponent::headerHeight, 60, 120 }, prefix + "-r5-playhead.png");
- saveArea (playlist, { 0, lynx::PlaylistComponent::toolbarHeight, playlist.getWidth(), lynx::PlaylistComponent::overviewHeight }, prefix + "-r5-overview.png");
- saveArea (playlist, { 0, lynx::PlaylistComponent::headerHeight, playlist.headerWidthForSnapshot() + 4, playlist.getHeight() - lynx::PlaylistComponent::headerHeight }, prefix + "-r5-headers.png");
- lynx::ui::motion::enabled() = false;
- playlist.frameStepForSnapshot();
- saveArea (playlist, { px - 40, lynx::PlaylistComponent::headerHeight, 60, 120 }, prefix + "-r5-playhead-noanim.png");
- lynx::ui::motion::enabled() = true;
- playlist.frameStepForSnapshot();
- // a drop preview: two patterns dragged from the Picker (issue #177's description) over track 4, bar 36
- const auto row = playlist.trackRowForSnapshot (27);
- playlist.dragOverForSnapshot (juce::var ("lynx-picker|0|0,1"), { (int) playlist.xOfTickForSnapshot (35.6 * (double) song.barTicks()), row.getCentreY() });
- write (ui, "r5-drop-preview");
- playlist.dragOverForSnapshot ({}, {});
- offline.getTransport().playing.store (false);
- playlist.frameStepForSnapshot();
- write (ui, "r5-stopped");
- write (ui.getPickerForSnapshot(), "r5-picker-stopped");
- saveArea (playlist, { 0, lynx::PlaylistComponent::toolbarHeight, playlist.getWidth(), lynx::PlaylistComponent::overviewHeight }, prefix + "-r5-overview-stopped.png");
- // R15: a scroll by hand while playing — Pattern layout: Follow goes on (off by default); the option on: it pauses
- auto& globals = lynx::EditorGlobals::get();
- const auto scrollWhilePlaying = [&] {
- offline.getTransport().playing.store (true);
- playlist.frameStepForSnapshot();
- playlist.setScrollTickForSnapshot (playlist.scrollTicksForSnapshot() + 4.0 * (double) song.barTicks());
- playlist.frameStepForSnapshot();
- const auto paused = playlist.followPausedForSnapshot();
- offline.getTransport().playing.store (false);
- playlist.frameStepForSnapshot();
- return paused;
- };
- check ("R15: Pattern layout (option off by default): no pause", ! globals.followPausing() && ! scrollWhilePlaying());
- globals.followPausesOnEdit = 1;
- check ("R15: option on: a scroll while playing pauses Follow", scrollWhilePlaying());
- check ("R15: a stop lifts the pause", ! playlist.followPausedForSnapshot());
- globals.followPausesOnEdit = -1;
- }
- {
- // ---- R11: the Sampler's handles (a 1 s tone, loop points on)
- lynx::AudioEngine engine (false);
- const auto tone = juce::File (prefix).getParentDirectory().getChildFile ("details190im-tone.wav");
- {
- juce::AudioBuffer<float> buffer (1, 44100);
- for (int i = 0; i < buffer.getNumSamples(); ++i)
- buffer.setSample (0, i, (float) (0.6 * std::sin (juce::MathConstants<double>::twoPi * 110.0 * i / 44100.0) * (1.0 - i / 44100.0)));
- tone.deleteFile();
- juce::WavAudioFormat wav;
- if (auto out = std::unique_ptr<juce::AudioFormatWriter> (wav.createWriterFor (tone.createOutputStream().release(), 44100.0, 1, 16, {}, 0)))
- out->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- engine.editSong ([&] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- lynx::audioclips::loadSampleInto (s.channels[0], tone.getFullPathName().toStdString(), "Tone");
- });
- const auto sampler = [&engine] { return engine.getSong().channels[0].sampler; };
- auto frame = lynx::makeChannelFrame (engine, 0, 0);
- frame->setSize (frame->getWidth() > 0 ? frame->getWidth() : 700, frame->getHeight() > 0 ? frame->getHeight() : 720);
- frame->createComponentSnapshot (frame->getLocalBounds());
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (8000);
- auto& f = *frame;
- lynx::samplerPageTurn (f, "useLoops", 1.0);
- lynx::samplerPageTurn (f, "loopStart", 11025.0);
- lynx::samplerPageTurn (f, "loopEnd", 22050.0);
- lynx::samplerPageTurn (f, "smpStart", 0.0);
- savePng (f.createComponentSnapshot (f.getLocalBounds()), prefix + "-r11-sampler-before.png");
- for (const auto* h : { "Start", "LoopStart", "LoopEnd" })
- line (juce::String ("press on the drawn ") + h + " handle takes: " + lynx::samplerPageQuery (f, juce::String ("handleAt") + h));
- check ("R11: a press on the loop start line takes the loop start", lynx::samplerPageQuery (f, "handleAtLoopStart") == "loopStart");
- check ("R11: a press on the loop end line takes the loop end", lynx::samplerPageQuery (f, "handleAtLoopEnd") == "loopEnd");
- check ("R11: a press on the Start marker takes the start", lynx::samplerPageQuery (f, "handleAtStart") == "start");
- lynx::samplerPageTurn (f, "dragLoopEnd", 0.75);
- check ("R11: the loop end dragged to 3/4", std::abs ((double) sampler().loopEnd - 0.75 * 44099.0) < 2.0);
- lynx::samplerPageTurn (f, "dragLoopStart", 0.375, true);
- check ("R11: Shift drags the whole loop", sampler().loopStart > 16000 && sampler().loopEnd - sampler().loopStart > 22000);
- line ("loop after the drags: " + juce::String (sampler().loopStart) + " - " + juce::String (sampler().loopEnd));
- lynx::samplerPageTurn (f, "dragStart", 0.2);
- check ("R11: the Start marker dragged to 20 %", std::abs (sampler().startOffset - 0.2f) < 0.01f);
- savePng (f.createComponentSnapshot (f.getLocalBounds()), prefix + "-r11-sampler-after.png");
- tone.deleteFile();
- }
- if (set.isNotEmpty())
- {
- // ---- Clip-launch layout, the Live set
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- ui.setVisible (true);
- ui.selectTabForSnapshot (2);
- ui.setClipLaunchWorkflow (true);
- offline.dispatchPendingMessages();
- ui.openFile (juce::File (set));
- offline.dispatchPendingMessages();
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- offline.dispatchPendingMessages();
- ui.resized();
- auto* gridView = ui.getClipGridForSnapshot();
- auto* runtime = offline.launcherStateForSnapshot();
- const auto& song = offline.getSong();
- check ("grid and launcher", gridView != nullptr && runtime != nullptr && song.clipGrid.has_value());
- if (gridView == nullptr || runtime == nullptr || ! song.clipGrid.has_value())
- {
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- return;
- }
- auto& grid = *gridView;
- gridView->resized();
- const auto firstClip = [&song] (int track, lynx::ClipKind kind) {
- for (int r = 0; r < 64; ++r)
- if (const auto* c = lynx::launcher::clipAt (*song.clipGrid, track, r); c != nullptr && c->kind == kind)
- return r;
- return -1;
- };
- const auto bigCrop = [&] (const juce::String& name, juce::Rectangle<int> area) { saveArea (grid, area, prefix + "-" + name + ".png"); };
- // R6: track 0 plays a one-shot (Loop off), track 1 loops in its 2nd pass, track 2's clip has a follow action
- int rows[3] { -1, -1, -1 };
- for (int t = 0; t < 3; ++t)
- for (const auto kind : { lynx::ClipKind::audio, lynx::ClipKind::pattern })
- if (rows[t] < 0)
- rows[t] = firstClip (t, kind);
- offline.editSong ([&rows] (lynx::Song& s) {
- if (rows[0] >= 0)
- lynx::launcher::settingsAt (*s.clipGrid, 0, rows[0])->loop = false;
- if (rows[2] >= 0)
- {
- auto& f = lynx::launcher::settingsAt (*s.clipGrid, 2, rows[2])->follow;
- f.enabled = true;
- f.a = lynx::FollowKind::next;
- }
- }, false);
- offline.dispatchPendingMessages();
- runtime->running.store (true);
- for (int t = 0; t < 2; ++t)
- if (rows[t] >= 0)
- {
- const auto length = (double) lynx::launcher::clipAt (*song.clipGrid, t, rows[t])->length;
- runtime->tracks[(std::size_t) t].playing.store (rows[t]);
- runtime->tracks[(std::size_t) t].progress.store (0.4f);
- runtime->tracks[(std::size_t) t].anchor.store (0.0);
- runtime->clockNow.store (length * 1.4);
- }
- lynx::tickClipGridForSnapshot (grid);
- grid.repaint();
- write (grid, "r6-grid-playing");
- bigCrop ("r6-status-oneshot", lynx::clipGridCellForSnapshot (grid, 1, 0, 0).getUnion (lynx::clipGridCellForSnapshot (grid, 1, 1, 0)));
- if (rows[2] >= 0)
- {
- const auto cell = lynx::clipGridCellForSnapshot (grid, 0, 2, rows[2]);
- bigCrop ("r6-follow-stripes", cell);
- }
- // the queued scene's pulse, both phases, then the next scene selected
- const auto scene = juce::jmax (0, rows[1]);
- lynx::setClipGridBlinkPhaseForSnapshot (1);
- lynx::launchClipGridSceneForSnapshot (grid, scene);
- grid.repaint();
- bigCrop ("r6-scene-queued-lit", lynx::clipGridCellForSnapshot (grid, 2, 0, scene));
- lynx::setClipGridBlinkPhaseForSnapshot (0);
- grid.repaint();
- bigCrop ("r6-scene-queued-dark", lynx::clipGridCellForSnapshot (grid, 2, 0, scene));
- lynx::setClipGridBlinkPhaseForSnapshot (-1);
- const auto [selected, sceneSelected] = lynx::clipGridSceneSelectionForSnapshot (grid);
- check ("R6: after a scene launch the scene below is selected (DL-6)", selected == juce::jmin (scene + 1, (int) song.clipGrid->scenes.size() - 1) && sceneSelected);
- write (grid, "r6-grid-scene-launched");
- // the hints of each part
- const auto hintAt = [&] (const juce::String& what, juce::Point<int> p) {
- const auto [text, value] = lynx::clipGridHintForSnapshot (grid, p);
- line ("hint " + what + ": " + text + " | " + value);
- return text;
- };
- const auto slot = lynx::clipGridCellForSnapshot (grid, 0, 1, juce::jmax (0, rows[1]));
- const auto launchHint = hintAt ("clip launch button", { slot.getX() + 7, slot.getCentreY() });
- hintAt ("clip", { slot.getCentreX(), slot.getCentreY() });
- hintAt ("stop button", { lynx::clipGridCellForSnapshot (grid, 1, 1, 0).getX() + 7, lynx::clipGridCellForSnapshot (grid, 1, 1, 0).getCentreY() });
- hintAt ("status", { lynx::clipGridCellForSnapshot (grid, 1, 1, 0).getCentreX(), lynx::clipGridCellForSnapshot (grid, 1, 1, 0).getCentreY() });
- const auto sceneCell = lynx::clipGridCellForSnapshot (grid, 2, 0, 0);
- hintAt ("scene launch button", { sceneCell.getX() + 6, sceneCell.getCentreY() });
- hintAt ("scene", { sceneCell.getCentreX(), sceneCell.getCentreY() });
- check ("R6: the grid's parts have hints (DL-21)", launchHint.isNotEmpty());
- ui.setHintForSnapshot ({ launchHint, {}, false, false });
- saveArea (ui, ui.getToolbarBoundsForSnapshot(), prefix + "-r6-hint-launch.png");
- // R12: 0 on the selected clip deactivates it (greyed), again activates it; the scene column's font
- lynx::selectClipGridSlotForSnapshot (grid, 1, juce::jmax (0, rows[1]));
- grid.grabKeyboardFocus();
- const auto activeNow = [&] { const auto* s = lynx::launcher::settingsAt (*const_cast<lynx::Song&> (song).clipGrid, 1, juce::jmax (0, rows[1])); return s == nullptr || s->active; };
- check ("R12: 0 is taken by the grid", lynx::clipGridKeyForSnapshot (grid, juce::KeyPress ('0')));
- offline.dispatchPendingMessages();
- check ("R12: 0 deactivates the selected clip", ! activeNow());
- for (auto& v : runtime->tracks)
- v.playing.store (-1);
- grid.repaint();
- write (grid, "r12-clip-deactivated");
- bigCrop ("r12-clip-deactivated-cell", slot);
- lynx::clipGridKeyForSnapshot (grid, juce::KeyPress ('0'));
- offline.dispatchPendingMessages();
- check ("R12: 0 again activates it", activeNow());
- bigCrop ("r12-scene-column", lynx::clipGridCellForSnapshot (grid, 2, 0, 0).getUnion (lynx::clipGridCellForSnapshot (grid, 2, 0, juce::jmin (7, (int) song.clipGrid->scenes.size() - 1))));
- // R13: the Clip View of a launched MIDI clip: the Piano roll's playhead at the clip's position
- int midiTrack = -1, midiRow = -1;
- for (int t = 0; t < 16 && midiTrack < 0; ++t)
- if (const auto r = firstClip (t, lynx::ClipKind::pattern); r >= 0)
- {
- midiTrack = t;
- midiRow = r;
- }
- check ("R13: the set has a MIDI clip", midiTrack >= 0);
- if (auto* detail = ui.getDetailViewForSnapshot(); detail != nullptr && midiTrack >= 0)
- {
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- lynx::DetailView::shownSetting = true;
- detail->showSelection (midiTrack, midiRow);
- detail->setPage (lynx::DetailView::Page::clip);
- offline.dispatchPendingMessages();
- ui.resized();
- const auto& clip = *lynx::launcher::clipAt (*song.clipGrid, midiTrack, midiRow);
- runtime->running.store (true);
- runtime->tracks[(std::size_t) midiTrack].playing.store (midiRow);
- runtime->tracks[(std::size_t) midiTrack].anchor.store (0.0);
- runtime->clockNow.store ((double) clip.length * 2.3);
- offline.getTransport().playing.store (true);
- auto& roll = ui.getPianoRollForSnapshot();
- roll.frameStepForSnapshot();
- const auto expect = (double) clip.offset + 0.3 * (double) clip.length;
- line ("piano roll playhead " + juce::String (roll.playheadForSnapshot(), 1) + ", the launched clip at " + juce::String (expect, 1));
- check ("R13: the docked Piano roll shows the launched clip's position (DL-74)", std::abs (roll.playheadForSnapshot() - expect) < (double) lynx::ppq);
- write (ui, "r13-clipview-midi");
- offline.getTransport().playing.store (false);
- runtime->tracks[(std::size_t) midiTrack].playing.store (-1);
- roll.frameStepForSnapshot();
- }
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runDesign190igShot (const juce::String& prefix, const juce::String& project)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1920x1080"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png");
- };
- if (project.isNotEmpty())
- ui.openFile (juce::File (project));
- offline.dispatchPendingMessages();
- ui.selectTabForSnapshot (2); // the Playlist, maximized
- auto& playlist = ui.getPlaylistForSnapshot();
- offline.dispatchPendingMessages();
- const auto settle = [&] { // (the waveforms are analysed in the background on the first paint)
- write (playlist, "warmup");
- lynx::ui::WaveformCache::getInstance()->waitUntilIdle (60000);
- offline.dispatchPendingMessages();
- juce::File (prefix + "-warmup.png").deleteFile();
- };
- const auto heights = [&] (int h) {
- offline.editSong ([h] (lynx::Song& s) {
- for (auto& t : s.playlistTracks)
- t.height = h;
- }, false);
- offline.dispatchPendingMessages();
- };
- // FL's default view (shots/ref/fl-playlist.png): 26 px tracks, bar 21 at the left, 15.6 px a bar, CUTS at the top
- heights (26);
- playlist.setViewForSnapshot (15.6, 20, 0);
- playlist.setScrollYForSnapshot (19 * 26);
- settle();
- write (ui, "01-default");
- write (playlist, "01-default-playlist");
- // FL's "Zoom level 17" (shots/ref/fl-playlist-zoom-audioclips.png): 50 px tracks, 39.75 px a bar, Saw Bass at the top
- heights (50);
- playlist.setViewForSnapshot (39.75, 20, 0);
- playlist.setScrollYForSnapshot (24 * 50 + 4);
- settle();
- write (ui, "02-zoom17");
- write (playlist, "02-zoom17-playlist");
- // playing (shots/ref/fl-playing.png): the playhead at bar 33, the activity column lit for the tracks that sound
- offline.getTransport().positionTicks.store ((double) (32 * offline.getSong().barTicks()));
- offline.getTransport().playing.store (true);
- playlist.frameStepForSnapshot();
- playlist.frameStepForSnapshot();
- write (ui, "03-playing");
- offline.getTransport().playing.store (false);
- playlist.frameStepForSnapshot();
- heights (26);
- playlist.setViewForSnapshot (15.6, 0, 0);
- playlist.setScrollYForSnapshot (0);
- write (ui, "04-default-start");
- // round 190jd (live check 190iw Q4): FL's grid levels at its Ctrl+wheel steps — bars only at 9.9 px a beat, beat
- // lines from 11.5, half-beat lines from 21.5 (shots/q4-fl-zoom-levels-ruler-grid.png), at bar 9 like FL's shot
- heights (32);
- for (const auto beat : { 9.9, 11.5, 18.4, 21.5 })
- {
- playlist.setViewForSnapshot (beat * 4.0, 8, 0);
- playlist.setScrollYForSnapshot (0);
- write (playlist, ("05-grid-" + juce::String (beat, 1) + "px-beat").toRawUTF8());
- }
- // round 190jd: NEW automation clips from the first channel's volume and pan knobs take FL's colours by parameter
- // (#8C5F5F, #7F8C5E; shots/q4-fl-new-automation-clip-zoom2.png); the editor windows they open are closed again
- if (! offline.getSong().channels.empty())
- {
- // (the channels of FL's capture: Synth Bass pan + volume, Grv Kick 27 volume + pan; else the first channel)
- const auto channelNamed = [&offline] (const char* name) {
- const auto& channels = offline.getSong().channels;
- for (int c = 0; c < (int) channels.size(); ++c)
- if (juce::String (channels[(std::size_t) c].name).startsWithIgnoreCase (name))
- return c;
- return 0;
- };
- juce::String report;
- offline.editSong ([] (lynx::Song& s) { s.loopStart = s.loopEnd = 0; }, false);
- offline.getTransport().positionTicks.store (0.0);
- const auto before = offline.getSong().automations.size();
- for (const auto& [name, kind] : { std::pair { "Synth Bass", lynx::AutomationTargetKind::channelPan },
- std::pair { "Grv Kick", lynx::AutomationTargetKind::channelVolume },
- std::pair { "Synth Bass", lynx::AutomationTargetKind::channelVolume },
- std::pair { "Grv Kick", lynx::AutomationTargetKind::channelPan } })
- {
- lynx::AutomationTarget t;
- t.kind = kind;
- t.index = channelNamed (name);
- lynx::createAutomationClip (offline, t);
- offline.dispatchPendingMessages();
- }
- lynx::closeAutomationEditors();
- offline.dispatchPendingMessages();
- int first = -1;
- for (std::size_t a = before; a < offline.getSong().automations.size(); ++a)
- {
- const auto& au = offline.getSong().automations[a];
- for (const auto& c : offline.getSong().playlist)
- if (c.kind == lynx::ClipKind::automation && c.automation == (int) a)
- {
- first = first < 0 ? c.track : std::min (first, c.track);
- report << "new clip '" << au.name << "' track " << (c.track + 1) << " colour #"
- << juce::String::toHexString ((int) (au.colour & 0xFFFFFF)).paddedLeft ('0', 6).toUpperCase() << "\n";
- }
- }
- report << "automations " << (int) before << " -> " << (int) offline.getSong().automations.size() << "\n";
- juce::File (prefix + "-190jd-automation.txt").replaceWithText (report);
- heights (50);
- playlist.setViewForSnapshot (39.75, 0, 0);
- playlist.setScrollYForSnapshot (std::max (0, first - 1) * 50);
- write (playlist, "06-new-automation-clips");
- }
- // round 190jd (live check 190iw Q7, shots/q7-fl-countin-sheet.png): a 1-bar count-in — the time display reads
- // "REC IN 4" on its first beat and "REC IN 1" on its last, Play shows its Pause glyph, Record stays lit
- for (const auto beatsLeft : { 4, 1 })
- {
- offline.getTransport().countIn.store ((double) beatsLeft * lynx::ppq - 1.0);
- ui.tickLinkForSnapshot();
- ui.transportForSnapshot (true, true);
- write (ui, ("07-countin-" + juce::String (beatsLeft)).toRawUTF8());
- }
- offline.getTransport().countIn.store (0.0);
- }
- void runDesign190igS4Shot (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- const auto write = [&prefix] (juce::Component& c, const juce::String& name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- ui.setVisible (true);
- ui.selectTabForSnapshot (2);
- ui.setClipLaunchWorkflow (true); // (first: an .als opened in the Clip-launch layout takes Live's own colours)
- offline.dispatchPendingMessages();
- if (projectPath.isNotEmpty())
- {
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- }
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- offline.dispatchPendingMessages();
- ui.resized();
- auto* gridView = ui.getClipGridForSnapshot();
- auto* runtime = offline.launcherStateForSnapshot();
- const auto& song = offline.getSong();
- if (gridView == nullptr || ! song.clipGrid)
- {
- juce::File (prefix + "-checks.txt").replaceWithText ("FAIL no grid\n");
- return;
- }
- if (! song.mixer.empty())
- checks << "first mixer colours:";
- for (std::size_t m = 1; m < std::min<std::size_t> (song.mixer.size(), 6); ++m)
- checks << " " << juce::String::toHexString ((int) (song.mixer[m].colour & 0xffffff)).paddedLeft ('0', 6);
- checks << "\n";
- gridView->resized();
- write (ui, "01-window-idle");
- write (*gridView, "02-grid-idle");
- if (runtime == nullptr)
- {
- check ("a launcher runtime exists", false);
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- return;
- }
- // the frame strip: the first five tracks; the scene each plays or waits for, by the clips the set has
- const auto& grid = *song.clipGrid;
- const auto rowWithClip = [&grid] (int track, int from) {
- for (int r = from; r < 64; ++r)
- if (lynx::launcher::clipAt (grid, track, r) != nullptr)
- return r;
- return -1;
- };
- const auto reset = [&] {
- for (auto& v : runtime->tracks)
- {
- v.playing.store (-1);
- v.pending.store (-1);
- v.stopping.store (false);
- v.recording.store (-1);
- v.recordPending.store (-1);
- v.progress.store (0.0f);
- }
- runtime->running.store (true);
- };
- const auto bar = (double) song.barTicks();
- const auto state = [&] (const juce::String& name) {
- gridView->repaint();
- write (*gridView, name);
- };
- // playing (Live frame 1): tracks 0..3 play their first clip, a third of the way into its second loop
- reset();
- for (int t = 0; t < 4; ++t)
- if (const auto r = rowWithClip (t, 0); r >= 0)
- {
- runtime->tracks[(std::size_t) t].playing.store (r);
- runtime->tracks[(std::size_t) t].progress.store (0.33f);
- const auto length = (double) lynx::launcher::clipAt (grid, t, r)->length;
- runtime->tracks[(std::size_t) t].anchor.store (0.0);
- runtime->clockNow.store (length * 1.33);
- }
- state ("10-playing");
- // queued (Live frames 2 and 3): the same, and each track's next clip waits for its start; both blink phases
- for (int t = 0; t < 4; ++t)
- if (const auto r = runtime->tracks[(std::size_t) t].playing.load(); r >= 0)
- if (const auto next = rowWithClip (t, r + 1); next >= 0)
- runtime->tracks[(std::size_t) t].pending.store (next);
- lynx::setClipGridBlinkPhaseForSnapshot (0);
- state ("11-queued-dark");
- lynx::setClipGridBlinkPhaseForSnapshot (1);
- state ("12-queued-lit");
- // Animations off: the lit green, steady
- lynx::ui::motion::enabled() = false;
- lynx::setClipGridBlinkPhaseForSnapshot (-1);
- state ("13-queued-animations-off");
- lynx::ui::motion::enabled() = true;
- // a stop waiting (both phases)
- reset();
- for (int t = 0; t < 4; ++t)
- if (const auto r = rowWithClip (t, 0); r >= 0)
- {
- runtime->tracks[(std::size_t) t].playing.store (r);
- runtime->tracks[(std::size_t) t].progress.store (0.5f);
- runtime->tracks[(std::size_t) t].stopping.store (t % 2 == 0);
- }
- lynx::setClipGridBlinkPhaseForSnapshot (0);
- state ("14-stopping-dark");
- lynx::setClipGridBlinkPhaseForSnapshot (1);
- state ("15-stopping-lit");
- // recording into an empty slot of track 1 (the counter one beat in) and a launch waiting on an empty slot (a stop)
- reset();
- {
- int empty = -1;
- for (int r = 0; r < 16 && empty < 0; ++r)
- if (lynx::launcher::clipAt (grid, 1, r) == nullptr)
- empty = r;
- if (empty >= 0)
- {
- runtime->tracks[1].recording.store (empty);
- runtime->tracks[1].recordFrom.store (0.0);
- runtime->clockNow.store ((double) lynx::ppq);
- }
- check ("recording: an empty slot on track 2", empty >= 0);
- }
- state ("16-recording");
- // the status pie at 25 / 50 / 75 % in the second loop
- for (const auto [name, p] : { std::pair ("17-pie-25", 0.25f), std::pair ("18-pie-50", 0.5f), std::pair ("19-pie-75", 0.75f) })
- {
- reset();
- for (int t = 0; t < 4; ++t)
- if (const auto r = rowWithClip (t, 0); r >= 0)
- {
- const auto length = (double) lynx::launcher::clipAt (grid, t, r)->length;
- runtime->tracks[(std::size_t) t].playing.store (r);
- runtime->tracks[(std::size_t) t].progress.store (p);
- runtime->tracks[(std::size_t) t].anchor.store (0.0);
- runtime->clockNow.store (length * (1.0 + (double) p));
- }
- state (name);
- }
- juce::ignoreUnused (bar);
- // round 181a's look, the option (View › Classic LYNX look for the clip grid)
- reset();
- for (int t = 0; t < 4; ++t)
- if (const auto r = rowWithClip (t, 0); r >= 0)
- runtime->tracks[(std::size_t) t].playing.store (r);
- lynx::clipGridClassicLook() = true;
- lynx::refreshClipGrid (*gridView);
- state ("20-classic-look-option");
- lynx::clipGridClassicLook() = false;
- lynx::refreshClipGrid (*gridView);
- lynx::setClipGridBlinkPhaseForSnapshot (-1);
- reset();
- runtime->running.store (false);
- write (ui, "21-window-after");
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- ui.setClipLaunchWorkflow (false);
- }
- void runLiveShot190dr (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- juce::String checks;
- const auto check = [&checks] (const juce::String& what, bool ok) { checks << (ok ? "ok " : "FAIL ") << what << "\n"; };
- // a two-bar loop of clicks for the audio clip
- const auto wav = juce::File (prefix + "-loop.wav");
- wav.deleteFile();
- {
- const double rate = 48000.0;
- juce::AudioBuffer<float> buffer (2, (int) (rate * 4.0));
- buffer.clear();
- for (int hit = 0; hit < 16; ++hit)
- for (int k = 0; k < 3000 && hit * 12000 + k < buffer.getNumSamples(); ++k)
- for (int ch = 0; ch < 2; ++ch)
- buffer.setSample (ch, hit * 12000 + k, (float) (std::sin (k * (hit % 4 == 0 ? 0.05 : 0.3)) * std::exp (-k / 500.0) * 0.8));
- if (auto out = std::unique_ptr<juce::FileOutputStream> (wav.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 2, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- }
- ui.setVisible (true);
- lynx::DetailView::shownSetting = true;
- lynx::DetailView::devicesPage = false;
- ui.setClipLaunchWorkflow (true);
- ui.showPanelsForSnapshot ({ lynx::workspace::Panel::browser, lynx::workspace::Panel::playlist });
- ui.getPlaylistForSnapshot().addAudioClipAtPlayhead (wav);
- offline.dispatchPendingMessages();
- int audioChannel = -1;
- offline.editSong ([&audioChannel] (lynx::Song& s) {
- lynx::Clip audio;
- if (! s.playlist.empty())
- {
- audio = s.playlist.front();
- audioChannel = audio.channel;
- s.playlist.clear();
- }
- const int channels = (int) s.channels.size();
- s.channels.resize ((std::size_t) channels + 3);
- const char* names[] { "Drum kit", "Bass synth", "Keys" };
- for (int k = 0; k < 3; ++k)
- {
- auto& ch = s.channels[(std::size_t) (channels + k)];
- ch.name = names[k];
- ch.instrument = k == 0 ? lynx::InstrumentKind::sampler : lynx::InstrumentKind::synth;
- ch.mixerTrack = k + 1;
- }
- if (audioChannel >= 0)
- s.channels[(std::size_t) audioChannel].mixerTrack = 5;
- if (s.mixer.size() < 8)
- s.mixer.resize (8);
- const char* inserts[] { "Master", "Drums", "Bass", "Keys", "Vox", "Loop", "Reverb", "Delay" };
- for (int i = 1; i < 8; ++i)
- s.mixer[(std::size_t) i].name = inserts[i];
- s.mixer[1].volume = lynx::sessionmixer::positionForDb (-3.0);
- s.mixer[2].pan = 0.3f;
- s.mixer[2].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::compressor, lynx::EffectKind::delay })
- {
- lynx::EffectSlot fx;
- fx.kind = kind;
- const auto& info = lynx::effectInfo (kind);
- for (std::size_t k = 0; k < info.params.size() && k < fx.params.size(); ++k)
- fx.params[k] = info.params[k].defaultValue;
- s.mixer[2].effects.push_back (fx);
- }
- s.mixer[3].muted = true; // the Keys' activator off
- s.mixer[4].inputChannel = 0;
- s.mixer[4].inputStereo = true;
- s.mixer[4].monitor = lynx::InputMonitor::automatic;
- s.mixer[4].effects.clear();
- {
- lynx::EffectSlot fx;
- fx.kind = lynx::EffectKind::reverb;
- s.mixer[4].effects.push_back (fx);
- }
- s.mixer[5].solo = true;
- for (auto [from, to, level] : std::initializer_list<std::tuple<int, int, float>> { { 1, 6, 0.35f }, { 2, 6, 0.6f }, { 3, 6, 0.8f }, { 2, 7, 0.25f }, { 4, 7, 0.5f } })
- {
- lynx::MixerSend send;
- send.target = to;
- send.level = lynx::faderGain (level);
- s.mixer[(std::size_t) from].sends.push_back (send);
- }
- while (s.patterns.size() < 3)
- s.patterns.emplace_back();
- const char* patterns[] { "Beat", "Bassline", "Chords" };
- for (int p = 0; p < 3; ++p)
- {
- auto& pattern = s.patterns[(std::size_t) p];
- pattern.name = patterns[p];
- lynx::Note n;
- n.channel = channels + p;
- n.key = 48 + p * 5;
- pattern.notes = { n };
- pattern.lengthTicks = 4 * lynx::ppq;
- }
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 8));
- const char* tracks[] { "Drums", "Bass", "Keys", "Vox", "Loop", "FX" };
- for (int t = 0; t < 6; ++t)
- s.playlistTracks[(std::size_t) t].name = tracks[t];
- s.playlistTracks[3].mode = lynx::PlaylistTrackMode::audio;
- s.playlistTracks[3].mixerTrack = 4;
- for (int t = 0; t < 3; ++t)
- for (int r = 0; r < 3; ++r)
- if (! (t == 2 && r == 0))
- {
- lynx::Clip clip;
- clip.pattern = t;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, t, r, clip);
- }
- if (audioChannel >= 0)
- {
- lynx::clipsample::setWarp (s, audioChannel, true, 4.0); // (Warp on, as a dropped loop in Live)
- audio.track = 4;
- audio.start = 0;
- lynx::launcher::setClip (s, 4, 0, audio);
- lynx::launcher::setClip (s, 4, 1, audio);
- }
- auto& grid = lynx::launcher::ensureGrid (s);
- const char* scenes[] { "Intro", "Verse", "Drop" };
- grid.scenes.resize (5);
- for (int r = 0; r < 3; ++r)
- grid.scenes[(std::size_t) r].name = scenes[r];
- }, false);
- offline.dispatchPendingMessages();
- offline.setGridTrackArmed (3, true);
- ui.setClipGridView (lynx::PlaylistArea::GridView::grid);
- offline.dispatchPendingMessages();
- ui.resized();
- auto* gridView = ui.getClipGridForSnapshot();
- auto* mixer = gridView != nullptr ? lynx::clipGridMixer (*gridView) : nullptr;
- auto* detail = ui.getDetailViewForSnapshot();
- if (gridView == nullptr || mixer == nullptr || detail == nullptr)
- {
- juce::File (prefix + "-checks.txt").replaceWithText ("FAIL no grid, mixer or detail view\n");
- return;
- }
- // the meters: a level per insert, as a playing song leaves them (offscreen nothing plays), two ticks
- const auto levels = [&] {
- for (int k = 0; k < 2; ++k)
- {
- const float peaks[] { 0.9f, 0.5f, 0.7f, 0.0f, 0.3f, 0.45f, 0.2f, 0.12f };
- for (int i = 0; i < 8; ++i)
- offline.getMeters().accumulate (i, peaks[i], peaks[i] * 0.85f);
- mixer->tick();
- }
- };
- if (auto* runtime = offline.launcherStateForSnapshot())
- {
- runtime->tracks[0].playing.store (1);
- runtime->tracks[0].progress.store (0.3f);
- runtime->tracks[1].playing.store (1);
- runtime->tracks[1].progress.store (0.3f);
- runtime->tracks[4].playing.store (0);
- runtime->tracks[4].progress.store (0.5f);
- runtime->running.store (true);
- }
- levels();
- gridView->resized();
- write (ui, "01-session-mixer");
- write (*gridView, "01b-grid-alone");
- using Part = lynx::SessionMixerComponent::Part;
- check ("mixer: Sends rows are the two buses (Reverb 6, Delay 7)", mixer->sendTargets() == std::vector<int> { 6, 7 });
- check ("mixer: the arm buttons moved into the Volume section", mixer->armsShown());
- check ("mixer: Drums strip has activator, solo, arm, pan, volume", ! mixer->partBounds (0, Part::activator).isEmpty() && ! mixer->partBounds (0, Part::solo).isEmpty()
- && ! mixer->partBounds (0, Part::arm).isEmpty() && ! mixer->partBounds (0, Part::pan).isEmpty()
- && ! mixer->partBounds (0, Part::volume).isEmpty());
- check ("mixer: Vox strip (audio track) has Audio From, its channel, Monitor and Audio To", ! mixer->partBounds (3, Part::inType).isEmpty()
- && ! mixer->partBounds (3, Part::inChannel).isEmpty()
- && ! mixer->partBounds (3, Part::monAuto).isEmpty()
- && ! mixer->partBounds (3, Part::output).isEmpty());
- check ("mixer: Bass strip (instrument) shows MIDI From, no Monitor", mixer->partBounds (1, Part::monIn).isEmpty() && ! mixer->partBounds (1, Part::output).isEmpty());
- check ("mixer: FX strip (no clips) has no activator but an arm", mixer->partBounds (5, Part::activator).isEmpty() && ! mixer->partBounds (5, Part::arm).isEmpty());
- check ("mixer: Main strip has volume and pan, no activator", ! mixer->partBounds (-2, Part::volume).isEmpty() && mixer->partBounds (-2, Part::activator).isEmpty());
- {
- const auto hit = mixer->hitAt (mixer->partBounds (2, Part::solo).getCentre());
- check ("mixer: a click on the Keys' S is its solo", hit.column == 2 && hit.part == Part::solo);
- const auto send = mixer->hitAt (mixer->partBounds (1, Part::send, 1).getCentre());
- check ("mixer: the Bass' second knob is its send to Delay", send.column == 1 && send.part == Part::send && send.row == 1);
- }
- {
- juce::PopupMenu menu;
- mixer->addViewItems (menu);
- saveMenus (juce::StringArray { "Mixer (footer button)" }, std::vector<juce::PopupMenu> { menu }, prefix + "-02-mixer-view-menu.png");
- }
- offline.editSong ([] (lynx::Song& s) { lynx::launcher::ensureGrid (s).mixerView.trackOptions = true; }, false);
- offline.dispatchPendingMessages();
- gridView->resized();
- levels();
- write (*gridView, "03-mixer-track-options");
- offline.editSong ([] (lynx::Song& s) {
- auto& v = lynx::launcher::ensureGrid (s).mixerView;
- v.trackOptions = v.io = v.sends = false;
- }, false);
- offline.dispatchPendingMessages();
- gridView->resized();
- levels();
- write (*gridView, "04-mixer-volume-only");
- offline.editSong ([] (lynx::Song& s) { lynx::launcher::ensureGrid (s).mixerView.shown = false; }, false);
- offline.dispatchPendingMessages();
- gridView->resized();
- write (*gridView, "05-mixer-hidden");
- check ("mixer hidden: the arm buttons are back in the status row", ! mixer->armsShown() && mixer->getHeight() == 0);
- offline.editSong ([] (lynx::Song& s) { lynx::launcher::ensureGrid (s).mixerView = {}; }, false);
- offline.dispatchPendingMessages();
- gridView->resized();
- // the Clip page of the Loop clip (track 4, scene 0) while it plays: Warp on, the Set buttons lit, the title
- detail->showSelection (4, 0);
- detail->setPage (lynx::DetailView::Page::clip);
- offline.editSong ([] (lynx::Song&) {}, false); // (a change message: the Clip panel reads the playing state)
- offline.dispatchPendingMessages();
- write (ui, "06-clip-audio-warp-on");
- // round 190ig (round 190ia CL-20a, the BPM row bug): the Audio box at Live's 190 px, 260 px and 350 px detail
- // heights, in Re-Pitch (no settings rows) and in Beats (three rows: the most a mode shows)
- if (audioChannel >= 0)
- {
- const auto heightBefore = lynx::DetailView::preferredHeight;
- for (const auto beats : { false, true })
- {
- offline.editSong ([audioChannel, beats] (lynx::Song& s) {
- auto& sampler = s.channels[(std::size_t) audioChannel].sampler;
- sampler.keepPitch = beats;
- sampler.stretchMethod = beats ? lynx::StretchMethod::beats : sampler.stretchMethod;
- }, false);
- offline.dispatchPendingMessages();
- for (const auto h : { 190, 260, 350 })
- {
- lynx::DetailView::preferredHeight = h;
- ui.resized();
- if (auto* area = detail->getParentComponent()) // (the Playlist area lays its docked detail view out)
- area->resized();
- offline.dispatchPendingMessages();
- write (ui, (juce::String ("06h-audio-box-") + (beats ? "beats-" : "repitch-") + juce::String (h)).toRawUTF8());
- check ("audio box at " + juce::String (h) + " px: the detail view is that high", detail->getHeight() == h);
- }
- }
- offline.editSong ([audioChannel] (lynx::Song& s) { s.channels[(std::size_t) audioChannel].sampler.keepPitch = false; }, false);
- offline.dispatchPendingMessages();
- lynx::DetailView::preferredHeight = heightBefore;
- ui.resized();
- if (auto* area = detail->getParentComponent())
- area->resized();
- offline.dispatchPendingMessages();
- }
- if (audioChannel >= 0)
- {
- const auto beforeLength = lynx::launcher::clipAt (*offline.getSong().clipGrid, 4, 0)->length;
- offline.editSong ([audioChannel] (lynx::Song& s) { lynx::clipsample::setWarp (s, audioChannel, false, 4.0); });
- offline.dispatchPendingMessages();
- write (ui, "07-clip-audio-warp-off");
- check ("warp off: the channel plays at its own speed", ! lynx::clipsample::isWarped (offline.getSong().channels[(std::size_t) audioChannel].sampler));
- offline.undo();
- offline.dispatchPendingMessages();
- check ("warp: undo gives the clip back as it was", lynx::launcher::clipAt (*offline.getSong().clipGrid, 4, 0)->length == beforeLength
- && lynx::clipsample::isWarped (offline.getSong().channels[(std::size_t) audioChannel].sampler));
- // Set (start) at the play position, half way: one undo step
- const auto clipBefore = *lynx::launcher::clipAt (*offline.getSong().clipGrid, 4, 0);
- offline.editSong ([] (lynx::Song& s) {
- for (auto& c : s.clipGrid->clips)
- if (c.track == 4 && c.gridSlot >= 0 && s.clipGrid->slots[(std::size_t) c.gridSlot].scene == 0)
- lynx::clipsample::setStartAt (c, lynx::clipsample::playPosition (c, 0.5f));
- });
- const auto& after = *lynx::launcher::clipAt (*offline.getSong().clipGrid, 4, 0);
- check ("set start: the clip starts half way and ends where it did", after.offset == clipBefore.offset + clipBefore.length / 2
- && after.offset + after.length == clipBefore.offset + clipBefore.length);
- offline.undo();
- offline.dispatchPendingMessages();
- }
- // a MIDI clip's Clip page too (the Set buttons are there for every clip), playing through a groove of the pool
- offline.editSong ([] (lynx::Song& s) {
- const auto& bank = lynx::groove::factoryBank();
- if (bank.size() > 9)
- lynx::groove::setClipGroove (s, 0, 1, lynx::groove::add (s.grooves, bank[9].groove));
- }, false);
- detail->showSelection (0, 1);
- offline.editSong ([] (lynx::Song&) {}, false);
- offline.dispatchPendingMessages();
- write (ui, "08-clip-midi-set-buttons");
- // the Device View of Bass (insert 2): its compressor dragged onto Keys (insert 3), then Ctrl-dragged onto Vox
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- offline.dispatchPendingMessages();
- write (ui, "09-devices-bass-before");
- lynx::setClipGridDeviceDropForSnapshot (*gridView, 2);
- write (ui, "10-device-dragged-over-keys");
- lynx::setClipGridDeviceDropForSnapshot (*gridView, -1);
- int fromId = 0;
- {
- const auto& s = offline.getSong();
- fromId = (int) (s.mixer[2].effects[1].instance.id & 0x7fffffff);
- }
- offline.editSongStructural ([] (lynx::Song& s) { lynx::detailchain::moveEffectToInsert (s, 2, 1, 3, false); });
- offline.dispatchPendingMessages();
- check ("drag to Keys: the compressor moved (same device)", offline.getSong().mixer[2].effects.size() == 2 && offline.getSong().mixer[3].effects.size() == 1
- && (int) (offline.getSong().mixer[3].effects[0].instance.id & 0x7fffffff) == fromId);
- detail->showSelection (2, 1);
- offline.dispatchPendingMessages();
- write (ui, "11-devices-keys-after-move");
- offline.editSongStructural ([] (lynx::Song& s) { lynx::detailchain::moveEffectToInsert (s, 2, 0, 4, true); });
- offline.dispatchPendingMessages();
- check ("Ctrl-drag to Vox: a copy of the EQ after its reverb, Bass keeps its own", offline.getSong().mixer[4].effects.size() == 2
- && offline.getSong().mixer[4].effects[1].kind == lynx::EffectKind::eq
- && offline.getSong().mixer[2].effects[0].kind == lynx::EffectKind::eq);
- offline.undo();
- offline.undo();
- offline.dispatchPendingMessages();
- check ("undo twice: Bass has its three devices again, Keys none", offline.getSong().mixer[2].effects.size() == 3 && offline.getSong().mixer[3].effects.empty()
- && offline.getSong().mixer[4].effects.size() == 1);
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- wav.deleteFile();
- }
- void runWarpShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1600, 900);
- const auto write = [&prefix] (juce::Component& c, const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (c), out);
- };
- // a two-bar loop of clicks, a little off the grid (what Quantize is for)
- const auto wav = juce::File (prefix + "-loop.wav");
- wav.deleteFile();
- {
- const double rate = 44100.0;
- juce::AudioBuffer<float> buffer (1, (int) (rate * 4.0));
- buffer.clear();
- for (int hit = 0; hit < 8; ++hit)
- {
- const auto at = (int) ((hit * 0.5 + (hit % 3) * 0.035) * rate);
- for (int k = 0; k < 4000 && at + k < buffer.getNumSamples(); ++k)
- buffer.setSample (0, at + k, (float) (std::sin (k * (hit % 2 ? 0.25 : 0.06)) * std::exp (-k / 700.0) * 0.8));
- }
- if (auto out = std::unique_ptr<juce::FileOutputStream> (wav.createOutputStream()))
- if (auto* writer = juce::WavAudioFormat().createWriterFor (out.get(), rate, 1, 16, {}, 0))
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> owned (writer);
- owned->writeFromAudioSampleBuffer (buffer, 0, buffer.getNumSamples());
- }
- }
- ui.setVisible (true);
- lynx::DetailView::shownSetting = true;
- ui.selectTabForSnapshot (2);
- ui.setLayoutStyle (lynx::layoutstyle::Style::clipLaunch);
- lynx::autolanes::setShown (true);
- ui.getPlaylistForSnapshot().addAudioClipAtPlayhead (wav);
- offline.dispatchPendingMessages();
- int channel = -1;
- offline.editSong ([&channel] (lynx::Song& s) {
- if (s.playlist.empty())
- return;
- auto audio = s.playlist.front();
- channel = audio.channel;
- audio.track = 1;
- s.playlist.front() = audio;
- for (int k = 1; k < 3; ++k)
- {
- auto more = audio;
- more.start = audio.start + k * 8 * lynx::ppq;
- s.playlist.push_back (more);
- }
- while (s.patterns.size() < 1)
- s.patterns.emplace_back();
- for (int t = 2; t < 5; ++t)
- for (int k = 0; k < 4; ++k)
- {
- lynx::Clip c;
- c.pattern = 0;
- c.track = t;
- c.start = k * 4 * lynx::ppq;
- c.length = 4 * lynx::ppq;
- s.playlist.push_back (c);
- }
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 6));
- s.playlistTracks[1].name = "Loop";
- s.playlistTracks[2].name = "Drums";
- s.playlistTracks[3].name = "Kick";
- s.playlistTracks[4].name = "Hats";
- s.playlistTracks[4].folded = true;
- lynx::noteedit::groupWithAbove (s, 3);
- lynx::noteedit::groupWithAbove (s, 4);
- lynx::arrange::makeGroupBus (s, 3);
- lynx::autolanes::addLane (s, 1, { lynx::AutomationTargetKind::tempo, 0, 0, 0 }, "Tempo", lynx::valueFromTempo (s.bpm));
- if (! s.automations.empty())
- s.automations.back().points = { { 0, lynx::valueFromTempo (120.0), 0.0f }, { 8 * lynx::ppq, lynx::valueFromTempo (120.0), 0.0f },
- { 12 * lynx::ppq, lynx::valueFromTempo (180.0), 0.0f }, { 16 * lynx::ppq, lynx::valueFromTempo (140.0), 0.0f } };
- s.addMarker ({ 4 * lynx::ppq, "Verse", 0, 0 });
- s.addMarker ({ 8 * lynx::ppq, {}, 3, 4 });
- s.addMarker ({ 14 * lynx::ppq, {}, 4, 4 });
- s.loopStart = 4 * lynx::ppq;
- s.loopEnd = 12 * lynx::ppq;
- s.loopOff = true;
- s.tempoViewLow = 60.0; // the tempo lane's range
- s.tempoViewHigh = 200.0;
- std::stable_sort (s.playlist.begin(), s.playlist.end(), [] (const lynx::Clip& a, const lynx::Clip& b) { return a.start < b.start; });
- // the same audio in the clip grid, for the Clip page
- lynx::Clip slot = audio;
- slot.start = 0;
- slot.pitch = -2.25f;
- slot.gain = 0.7f;
- lynx::launcher::setClip (s, 1, 0, slot);
- // a few warp markers, as Quantize leaves them
- if (channel >= 0 && channel < (int) s.channels.size())
- {
- auto& sampler = s.channels[(std::size_t) channel].sampler;
- lynx::warpedit::ensureMarkers (sampler, 4.0, s.bpm);
- std::vector<double> attacks;
- for (int hit = 1; hit < 8; ++hit)
- attacks.push_back (hit * 0.5 + (hit % 3) * 0.035);
- lynx::warptools::quantize (sampler, attacks, 0.0, 4.0, 0.5, 1.0);
- lynx::warpedit::syncLength (sampler, 4.0);
- }
- }, false);
- offline.dispatchPendingMessages();
- ui.resized();
- write (ui, "arrangement-loop-off");
- offline.editSong ([] (lynx::Song& s) { s.loopOff = false; }, false);
- offline.dispatchPendingMessages();
- write (ui, "arrangement-loop-on");
- juce::String facts;
- {
- const auto& s = offline.getSong();
- facts << "channel " << channel << ", warp markers " << (channel >= 0 ? (int) s.channels[(std::size_t) channel].sampler.warp.size() : -1)
- << ", group bus insert " << lynx::arrange::groupBus (s, 3) << ", folded track 4: " << (lynx::arrange::isFolded (s, 4) ? 1 : 0) << "\n";
- }
- if (auto* detail = ui.getDetailViewForSnapshot())
- {
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::clip);
- offline.dispatchPendingMessages();
- write (ui, "clip-audio");
- }
- if (channel >= 0)
- if (auto editor = lynx::makeAudioEditorPanel (offline, channel, 0, true))
- {
- editor->setSize (1120, 600);
- write (*editor, "audio-editor-warp");
- // round 190cy (Live 12.4.16 live check 190cw shot 09): a plain drag of marker 3 holds it two sixteenths
- // later (its audio goes there); Shift + drag slides the audio under it. Round 190db: the Clip-launch
- // workflow draws the warped clip in beats, so the held drag shows the audio stretched around the marker
- // (plain) or slid under it, its attack later (Shift, to the right as in Live's shot)
- const auto& w = offline.getSong().channels[(std::size_t) channel].sampler.warp;
- if (w.size() > 4)
- {
- lynx::holdAudioEditorWarpDragForSnapshot (*editor, 3, w[3].beats + 0.5, false);
- write (*editor, "audio-editor-drag-stretch");
- lynx::holdAudioEditorWarpDragForSnapshot (*editor, 3, w[3].seconds - 0.12, true);
- write (*editor, "audio-editor-drag-slide");
- }
- // the same clip in file time (the Pattern workflow's view, or "Show the audio in beats" off)
- if (auto inFileTime = lynx::makeAudioEditorPanel (offline, channel, 0, true))
- {
- inFileTime->setSize (1120, 600);
- lynx::setAudioEditorBeatTimeForSnapshot (*inFileTime, 0);
- write (*inFileTime, "audio-editor-file-time");
- if (w.size() > 4)
- {
- lynx::holdAudioEditorWarpDragForSnapshot (*inFileTime, 3, w[3].beats + 0.5, false);
- write (*inFileTime, "audio-editor-file-time-drag");
- }
- }
- }
- // round 190cy (Live 12.4.16 live check 190cw shot 02): ÷2 from the editor of the first Playlist clip halves that
- // clip's length with the markers' beats; ÷2 on the grid clip's Clip page halves the grid clip
- {
- const auto lengthOf = [&offline] (int index) { return index < (int) offline.getSong().playlist.size() ? offline.getSong().playlist[(std::size_t) index].length : -1; };
- const auto gridLength = [&offline] {
- const auto& s = offline.getSong();
- const auto* c = s.clipGrid ? lynx::launcher::clipAt (*s.clipGrid, 1, 0) : nullptr;
- return c != nullptr ? c->length : (std::int64_t) -1;
- };
- const auto first = [&offline] {
- const auto& s = offline.getSong();
- for (int i = 0; i < (int) s.playlist.size(); ++i)
- if (s.playlist[(std::size_t) i].kind == lynx::ClipKind::audio)
- return i;
- return -1;
- }();
- facts << "halve: playlist clip " << first << " length " << lengthOf (first);
- if (first >= 0)
- if (auto editor = lynx::makeAudioEditorPanel (offline, offline.getSong().playlist[(std::size_t) first].channel, first, true))
- {
- lynx::scaleAudioEditorTempoForSnapshot (*editor, 0.5);
- offline.dispatchPendingMessages();
- }
- facts << " -> " << lengthOf (first) << "; grid clip length " << gridLength();
- if (channel >= 0)
- if (auto editor = lynx::makeAudioEditorPanel (offline, channel, -1, true))
- {
- lynx::setAudioEditorGridClip (*editor, 1, 0);
- lynx::scaleAudioEditorTempoForSnapshot (*editor, 0.5);
- offline.dispatchPendingMessages();
- }
- facts << " -> " << gridLength() << "\n";
- ui.resized();
- write (ui, "arrangement-halved");
- // Duplicate Time over beats 4-8 holding the locator "Verse" (beat 4): a second "Verse" at beat 8
- offline.editSong ([] (lynx::Song& s) { lynx::arrange::duplicateTime (s, 4 * lynx::ppq, 8 * lynx::ppq); });
- offline.dispatchPendingMessages();
- int verses = 0;
- for (const auto& m : offline.getSong().markers())
- verses += m.name == "Verse" ? 1 : 0;
- facts << "duplicate time: locators named Verse " << verses << "\n";
- write (ui, "arrangement-duplicated-time");
- }
- juce::File (prefix + "-facts.txt").replaceWithText (facts);
- lynx::autolanes::setShown (false);
- }
- void runMtShot190fm (const juce::String& prefix)
- {
- lynx::AudioEngine offline (false);
- offline.editSong ([] (lynx::Song& s) {
- if (s.patterns.empty())
- s.patterns.emplace_back();
- s.patterns[0].notes.clear();
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.currentPattern = 0;
- }, false);
- lynx::MidiToolsPanel panel (offline, [] {
- lynx::MidiToolsPanel::Target t;
- t.pattern = 0;
- t.grid = lynx::ppq / 4;
- t.channel = 0;
- t.length = 4 * lynx::ppq; // one bar, no time selection
- return t;
- });
- panel.setSize (lynx::MidiToolsPanel::panelWidth, lynx::MidiToolsPanel::panelHeight);
- panel.setSection (lynx::MidiToolsPanel::generateSection);
- panel.setGenerateShotSettingsForSnapshot();
- const auto write = [&prefix] (const juce::Image& image, const juce::String& name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (image, out);
- };
- std::vector<juce::Image> images;
- juce::String checks;
- for (int g = 0; g < lynx::midigen::Settings::toolCount; ++g)
- {
- panel.setGenerator (g);
- const auto name = juce::String (lynx::midigen::toolName (g)).toLowerCase();
- images.push_back (lynx::shot::paint (panel, lynx::theme::colour::bg2));
- write (images.back(), "generate-" + name);
- panel.generateNow();
- offline.dispatchPendingMessages();
- const auto made = (int) offline.getSong().patterns[0].notes.size();
- offline.undo();
- offline.dispatchPendingMessages();
- const auto after = (int) offline.getSong().patterns[0].notes.size();
- checks << name << ": generated " << made << " notes, after undo " << after << (made > 0 && after == 0 ? " OK" : " FAIL") << "\n";
- }
- // the five side by side (6 px apart, on the window's background)
- const auto gap = juce::roundToInt (6.0f * lynx::shot::scale());
- int width = gap, height = 0;
- for (const auto& image : images)
- {
- width += image.getWidth() + gap;
- height = std::max (height, image.getHeight());
- }
- juce::Image strip (juce::Image::RGB, width, height + 2 * gap, true);
- {
- juce::Graphics g (strip);
- g.fillAll (lynx::theme::colour::bg0);
- int x = gap;
- for (const auto& image : images)
- {
- g.drawImageAt (image, x, gap);
- x += image.getWidth() + gap;
- }
- }
- write (strip, "generate-panels");
- checks << "settings saved with the project: " << (offline.getSong().midiGenerate.stacksOptions.sequence.size() == 2 ? "OK" : "FAIL") << "\n";
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- // Round 190hy: see --mpeshot190hy
- void runMpeShot190hy (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix, &ui] (const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- ui.setVisible (true); // (not on the desktop: only so the Clip page sees itself shown and docks the Piano roll)
- offline.editSong ([] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- s.channels[0].name = "MPE lead";
- s.channels[0].mixerTrack = 1;
- if (s.mixer.size() < 2)
- s.mixer.resize (2);
- while (s.patterns.empty())
- s.patterns.emplace_back();
- auto& p = s.patterns[0];
- p.name = "MPE take";
- p.notes.clear();
- // four notes as an MPE controller plays them: a slide up an octave, a vibrato, a fall, a held chord tone
- const auto note = [&p] (std::int64_t start, std::int64_t length, int key, lynx::NoteCurves c, float modX = 0.5f) {
- lynx::Note n;
- n.channel = 0;
- n.start = start;
- n.length = length;
- n.key = key;
- n.modX = modX;
- n.curves = std::move (c);
- p.notes.push_back (n);
- };
- const auto beat = (float) lynx::ppq;
- lynx::NoteCurves glide;
- glide.lane (lynx::NoteCurveLane::pitch) = { { 0.0f, 0.0f }, { beat * 0.5f, 0.0f }, { beat * 1.5f, 1200.0f }, { beat * 2.0f, 1200.0f } };
- glide.lane (lynx::NoteCurveLane::timbre) = { { 0.0f, 0.3f }, { beat * 2.0f, 0.85f } };
- glide.lane (lynx::NoteCurveLane::pressure) = { { 0.0f, 0.2f }, { beat * 0.4f, 0.9f }, { beat * 1.6f, 0.7f }, { beat * 2.0f, 0.0f } };
- note (0, 2 * lynx::ppq, 60, glide, 0.3f);
- lynx::NoteCurves vibrato;
- for (int k = 0; k <= 24; ++k)
- vibrato.lane (lynx::NoteCurveLane::pitch).push_back ({ beat * 0.0833f * (float) k, k < 4 ? 0.0f : 40.0f * std::sin ((float) k * 1.5708f) });
- vibrato.lane (lynx::NoteCurveLane::pressure) = { { 0.0f, 0.5f }, { beat * 1.0f, 0.95f }, { beat * 2.0f, 0.4f } };
- note (2 * lynx::ppq, 2 * lynx::ppq, 67, vibrato);
- lynx::NoteCurves fall;
- fall.lane (lynx::NoteCurveLane::pitch) = { { 0.0f, 0.0f }, { beat * 0.75f, 0.0f }, { beat * 1.0f, -500.0f } };
- fall.lane (lynx::NoteCurveLane::timbre) = { { 0.0f, 0.6f }, { beat * 1.0f, 0.2f } };
- note (4 * lynx::ppq, lynx::ppq, 72, fall, 0.6f);
- note (5 * lynx::ppq, 3 * lynx::ppq, 64, {}); // (a note without curves: its own values, dashed)
- p.lengthTicks = 8 * lynx::ppq;
- }, false);
- offline.dispatchPendingMessages();
- juce::String checks;
- auto& roll = ui.getPianoRollForSnapshot();
- ui.selectTabForSnapshot (1);
- roll.selectMidiToolResult ({ 0 });
- roll.scrollToNotes();
- for (const auto& [lane, name] : { std::pair { lynx::PianoRollComponent::laneMpePitch, "pitch" },
- { lynx::PianoRollComponent::laneMpeSlide, "slide" },
- { lynx::PianoRollComponent::laneMpePressure, "pressure" } })
- {
- roll.setLaneForSnapshot (lane);
- offline.dispatchPendingMessages();
- write (name);
- checks << "lane " << name << ": areas " << (int) roll.mpeLaneAreasForTests().size() << "\n";
- }
- roll.setLaneForSnapshot (lynx::PianoRollComponent::laneVelocity);
- int curved = 0;
- for (const auto& n : offline.getSong().patterns[0].notes)
- curved += n.curves.has() ? 1 : 0;
- checks << "notes with curves: " << curved << " of " << (int) offline.getSong().patterns[0].notes.size() << "\n";
- // the Clip-launch layout: the clip's Notes tab, then its MPE tab (Live 11+'s note expression lanes)
- ui.selectTabForSnapshot (2);
- lynx::DetailView::shownSetting = true;
- lynx::DetailView::devicesPage = false;
- ui.setClipLaunchWorkflow (true);
- offline.editSong ([] (lynx::Song& s) {
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 8 * lynx::ppq;
- lynx::launcher::setClip (s, 0, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- if (auto* detail = ui.getDetailViewForSnapshot())
- {
- detail->showSelection (0, 0);
- detail->setPage (lynx::DetailView::Page::clip);
- detail->setClipTab (false);
- offline.dispatchPendingMessages();
- roll.scrollToNotes();
- write ("clip-notes");
- checks << "clip notes tab: mpe view " << (roll.isMpeView() ? 1 : 0) << "\n";
- detail->setMpeTab();
- offline.dispatchPendingMessages();
- roll.selectMidiToolResult ({ 0 });
- roll.scrollToNotes();
- write ("clip-mpe");
- checks << "clip MPE tab: mpe view " << (roll.isMpeView() ? 1 : 0) << ", lanes " << (int) roll.mpeLaneAreasForTests().size() << "\n";
- // round 190jd (Live 12.4's MPE tab): the value ghost point on note 1's Pressure line, the "Show Lane:" menu,
- // then all four lanes shown (Slide, Pressure, Velocity, Release Velocity)
- checks << "ghost on the Pressure line: '" << roll.hoverMpeLineForSnapshot (lynx::PianoRollComponent::laneMpePressure, (double) lynx::ppq) << "'\n";
- write ("clip-mpe-ghost190jd");
- roll.hoverMpeLineForSnapshot (0, 0.0);
- saveMenus (juce::StringArray { "MPE tab: Show Lane" }, std::vector<juce::PopupMenu> { roll.getMpeLaneMenuForSnapshot() },
- prefix + "-clip-mpe-showlane190jd.png");
- roll.setMpeLanesForSnapshot (lynx::mpetab::allLanes);
- offline.dispatchPendingMessages();
- write ("clip-mpe-lanes4-190jd");
- checks << "four lanes: " << (int) roll.mpeLaneAreasForTests().size() << "\n";
- roll.setMpeLanesForSnapshot (lynx::mpetab::defaultLanes);
- detail->setClipTab (false);
- offline.dispatchPendingMessages();
- checks << "back to Notes: mpe view " << (roll.isMpeView() ? 1 : 0) << "\n";
- }
- else
- checks << "no detail view\n";
- lynx::shot::file (juce::File (prefix + "-checks.txt")).replaceWithText (checks);
- }
- // round 190kk: Live's Erosion / Vinyl Distortion / Corpus imported, their LYNX engines on the Device View
- void runMeldShot190ko (const juce::String& prefix, const juce::String& meld, const juce::String& time, const juce::String& resonator)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- juce::String checks;
- // a Live device preset (.adv, gzip) → its device element's text
- const auto deviceOf = [] (const juce::String& path, lynx::xml::Document& doc) {
- juce::MemoryBlock raw;
- juce::File (path).loadFileAsData (raw);
- juce::MemoryInputStream in (raw, false);
- juce::GZIPDecompressorInputStream gz (&in, false, juce::GZIPDecompressorInputStream::gzipFormat);
- const auto text = gz.readEntireStreamAsString();
- if (! doc.parse (text.toStdString()))
- return lynx::xml::Element();
- const auto kids = doc.root().children();
- return kids.empty() ? lynx::xml::Element() : kids.front();
- };
- lynx::ChannelDef braid;
- braid.instrument = lynx::InstrumentKind::braid;
- braid.name = "Meld";
- {
- lynx::xml::Document doc;
- lynx::alsdev::Notes notes;
- const auto d = deviceOf (meld, doc);
- const auto ok = (bool) d && lynx::alsdev::meldToBraid (d, braid, notes);
- checks << (ok ? "ok " : "FAIL ") << "Meld -> Braid: " << meld << "\n";
- braid.name = juce::File (meld).getFileNameWithoutExtension().toStdString();
- }
- std::vector<lynx::EffectSlot> slots;
- for (const auto& path : { time, resonator })
- {
- lynx::xml::Document doc;
- const auto d = deviceOf (path, doc);
- if (const auto t = d ? lynx::alsdev::effectFromLiveDevice (d) : std::nullopt)
- {
- slots.push_back (t->slot);
- checks << "ok " << t->from << " -> " << t->to << ": " << path << "\n";
- }
- else
- checks << "FAIL NOT TRANSLATED: " << path << "\n";
- }
- offline.editSong ([&slots, &braid] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- braid.mixerTrack = 2;
- s.channels[0] = braid;
- if (s.mixer.size() < 3)
- s.mixer.resize (3);
- s.mixer[2].name = braid.name;
- s.mixer[2].effects = slots;
- while (s.patterns.empty())
- s.patterns.emplace_back();
- s.patterns[0].name = "Chords";
- s.patterns[0].notes.clear();
- for (const int key : { 48, 52, 55 })
- {
- lynx::Note note;
- note.channel = 0;
- note.start = 0;
- note.length = 2 * lynx::ppq;
- note.key = key;
- s.patterns[0].notes.push_back (note);
- }
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 2));
- s.playlistTracks[1].name = braid.name;
- }, false);
- offline.dispatchPendingMessages();
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.selectTabForSnapshot (2);
- ui.setClipLaunchWorkflow (true);
- offline.editSong ([] (lynx::Song& s) {
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 1, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- if (auto* detail = ui.getDetailViewForSnapshot())
- {
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- offline.dispatchPendingMessages();
- const auto file = lynx::shot::file (juce::File (prefix + "-devices.png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- checks << "cards " << detail->cardCountForCheck() << ", insert " << detail->chainInsertForCheck() << "\n";
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runLiveDevShot190kk (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto par = [] (const char* name, double v) { return juce::String ("<") + name + "><Manual Value=\"" + juce::String (v) + "\" /></" + name + ">"; };
- // the Core Library presets' values (Erosion "Fizzle", Vinyl Distortion "Crack" with Tracing on, Corpus "Pipe Resonator" closed)
- const juce::String erosion = "<Erosion2 Id=\"1\"><On><Manual Value=\"true\" /></On>" + par ("Amount", 0.9) + par ("Frequency", 16000) +
- par ("FilterWidth", 1.734) + par ("NoiseBlend", 1) + par ("StereoWidth", 1) + "</Erosion2>";
- const juce::String vinyl = "<Vinyl Id=\"1\"><On><Manual Value=\"true\" /></On><Band1On><Manual Value=\"true\" /></Band1On>" + par ("Gain1", 0.5) +
- par ("BandFreq1", 7500) + par ("BandQ1", 3) + "<Band2On><Manual Value=\"false\" /></Band2On>" + par ("Gain2", 0.35) +
- par ("BandFreq2", 5366) + par ("BandQ2", 0.32) + par ("Drive", 1) + par ("SoftHard", 0) + par ("NormalMono", 0) +
- par ("CracleDensity", 50) + par ("CracleVolume", 1) + "</Vinyl>";
- juce::String corpus = "<Corpus Id=\"1\"><On><Manual Value=\"true\" /></On><FilterOn><Manual Value=\"false\" /></FilterOn>";
- for (const auto& [k, v] : std::initializer_list<std::pair<const char*, double>> { { "ResonanceType", 5 }, { "ResonatorQuality", 3 },
- { "Frequency", 0.4603 }, { "Decay", 0.6032 }, { "FreqDamping", 0 }, { "AmpFreq", 0 }, { "Inharmonics", 0 }, { "Radius", 0.8642 },
- { "TubeOpening", 1 }, { "Ratio", 0.5 }, { "ExcitationX", 0.5 }, { "ListeningXL", 0.1 }, { "ListeningXR", 0.9 }, { "Detune", 0.047 },
- { "Drive", 0.405 }, { "Bleed", 0 }, { "DryWet", 0.696 }, { "StereoWidth", 1 }, { "FilterMidFreq", 1000 }, { "FilterBandWidth", 4 } })
- corpus += par (k, v);
- corpus += "</Corpus>";
- std::vector<lynx::EffectSlot> slots;
- juce::String checks;
- for (const auto& text : { erosion, vinyl, corpus })
- {
- lynx::xml::Document doc;
- doc.parse (text.toStdString());
- if (const auto t = lynx::alsdev::effectFromLiveDevice (doc.root()))
- {
- slots.push_back (t->slot);
- checks << t->from << " -> " << t->to << "\n";
- }
- else
- checks << "NOT TRANSLATED\n";
- }
- offline.editSong ([&slots] (lynx::Song& s) {
- if (s.channels.empty())
- s.channels.resize (1);
- s.channels[0].name = "Drums";
- s.channels[0].mixerTrack = 2;
- if (s.mixer.size() < 3)
- s.mixer.resize (3);
- s.mixer[2].name = "Drums";
- s.mixer[2].effects = slots;
- while (s.patterns.empty())
- s.patterns.emplace_back();
- s.patterns[0].name = "Beat";
- s.patterns[0].notes.clear();
- for (int n = 0; n < 4; ++n)
- {
- lynx::Note note;
- note.channel = 0;
- note.start = n * lynx::ppq;
- note.key = 36;
- s.patterns[0].notes.push_back (note);
- }
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 2));
- s.playlistTracks[1].name = "Drums";
- }, false);
- offline.dispatchPendingMessages();
- ui.setVisible (true);
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.selectTabForSnapshot (2);
- ui.setClipLaunchWorkflow (true);
- offline.editSong ([] (lynx::Song& s) {
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 1, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- if (auto* detail = ui.getDetailViewForSnapshot())
- {
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- const auto file = lynx::shot::file (juce::File (prefix + "-devices.png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- checks << "cards " << detail->cardCountForCheck() << ", insert " << detail->chainInsertForCheck() << "\n";
- }
- juce::File (prefix + "-checks.txt").replaceWithText (checks);
- }
- void runDetailShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- const auto write = [&prefix, &ui] (const char* name) {
- const auto file = lynx::shot::file (juce::File (prefix + "-" + name + ".png"));
- file.deleteFile();
- juce::FileOutputStream out (file);
- juce::PNGImageFormat().writeImageToStream (lynx::shot::snapshot (ui), out);
- };
- ui.setVisible (true); // (not on the desktop: only so the Clip page sees itself shown and docks the Piano roll)
- lynx::DetailView::shownSetting = lynx::DetailView::devicesPage = true;
- ui.selectTabForSnapshot (2); // the Playlist panel, maximized
- offline.editSong ([] (lynx::Song& s) {
- if (s.channels.size() < 2)
- s.channels.resize (2);
- s.channels[0].name = "Bass synth";
- s.channels[0].mixerTrack = 2;
- s.channels[1].mixerTrack = 3;
- if (s.mixer.size() < 4)
- s.mixer.resize (4);
- s.mixer[2].name = "Bass";
- s.mixer[2].effects.clear();
- for (auto kind : { lynx::EffectKind::eq, lynx::EffectKind::compressor, lynx::EffectKind::reverb, lynx::EffectKind::delay })
- {
- lynx::EffectSlot fx;
- fx.kind = kind;
- const auto& info = lynx::effectInfo (kind);
- for (std::size_t k = 0; k < info.params.size() && k < fx.params.size(); ++k)
- fx.params[k] = info.params[k].defaultValue;
- fx.enabled = kind != lynx::EffectKind::compressor; // one switched off
- s.mixer[2].effects.push_back (fx);
- }
- while (s.patterns.size() < 2)
- s.patterns.emplace_back();
- s.patterns[0].name = "Bass line";
- s.patterns[0].notes.clear();
- for (int n = 0; n < 4; ++n)
- {
- lynx::Note note;
- note.channel = 0;
- note.start = n * lynx::ppq;
- note.key = 36 + (n % 2) * 7;
- s.patterns[0].notes.push_back (note);
- }
- s.patterns[0].lengthTicks = 4 * lynx::ppq;
- lynx::PatternEvents lane; // a volume swell for the Envelopes tab (slice 3)
- lane.target = lynx::AutomationTarget { lynx::AutomationTargetKind::channelVolume, 0 };
- for (int e = 0; e < 16; ++e)
- lane.events.push_back ({ e * lynx::ppq / 4, 0.3f + 0.6f * (float) e / 15.0f });
- s.patterns[0].events = { lane };
- s.playlistTracks.resize (std::max<std::size_t> (s.playlistTracks.size(), 3));
- s.playlistTracks[1].name = "Bass";
- }, false);
- offline.dispatchPendingMessages();
- write ("pattern"); // Pattern workflow: no detail view exists
- ui.setClipLaunchWorkflow (true);
- offline.editSong ([] (lynx::Song& s) {
- lynx::Clip clip;
- clip.pattern = 0;
- clip.length = 4 * lynx::ppq;
- lynx::launcher::setClip (s, 1, 0, clip);
- }, false);
- offline.dispatchPendingMessages();
- juce::String counts;
- if (auto* detail = ui.getDetailViewForSnapshot())
- {
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::devices);
- write ("devices");
- counts << "cards " << detail->cardCountForCheck() << ", insert " << detail->chainInsertForCheck() << ", channel " << detail->chainChannelForCheck() << "\n";
- detail->toggleFoldForCheck (3); // the reverb (card 0 is the instrument)
- write ("folded");
- counts << "folded card 3: " << (detail->isFoldedForCheck (3) ? 1 : 0) << "\n";
- detail->showSelection (2, 0); // an empty track
- write ("empty-track");
- detail->showSelection (1, 0);
- detail->setPage (lynx::DetailView::Page::clip);
- offline.dispatchPendingMessages();
- ui.getPianoRollForSnapshot().scrollToNotes(); // (the app does it on the message loop, which this shot doesn't run)
- write ("clip"); // slice 2: the Piano roll docked here
- {
- // round 190s: the Transform panel with each MIDI tool, then Arpeggiate applied (and undone again)
- auto& tools = detail->midiToolsForSnapshot();
- for (int t = 0; t < lynx::MidiToolsPanel::toolCount; ++t)
- {
- tools.setTool (t);
- write (("clip-mt-" + juce::String (lynx::MidiToolsPanel::toolName (t)).toLowerCase()).toRawUTF8());
- }
- // round 190aa: the pages again with the settings of the Live shots they are compared with
- tools.setAuto (false);
- tools.setLiveShotSettingsForSnapshot();
- for (int t : { (int) lynx::MidiToolsPanel::chop, (int) lynx::MidiToolsPanel::quantize, (int) lynx::MidiToolsPanel::timeWarp })
- {
- tools.setTool (t);
- write (("clip-mt-" + juce::String (lynx::MidiToolsPanel::toolName (t)).toLowerCase() + "-set").toRawUTF8());
- }
- tools.setAuto (true);
- tools.setTool (lynx::MidiToolsPanel::arpeggiate);
- tools.transformNow();
- offline.dispatchPendingMessages();
- write ("clip-mt-applied");
- counts << "midi tools: arpeggiate made " << (int) offline.getSong().patterns[0].notes.size() << " notes of 4\n";
- offline.undo();
- offline.dispatchPendingMessages();
- counts << "midi tools: undo gives " << (int) offline.getSong().patterns[0].notes.size() << " notes\n";
- }
- counts << "piano roll docked: " << (ui.getPianoRollForSnapshot().getParentComponent() != nullptr
- && ui.getPianoRollForSnapshot().getParentComponent()->getParentComponent() == detail ? 1 : 0) << "\n";
- detail->setClipTab (true); // slice 3: the pattern's events in the Envelopes tab
- offline.dispatchPendingMessages();
- write ("envelopes");
- detail->setClipTab (false);
- detail->setPage (lynx::DetailView::Page::devices);
- // round 183c-card: an Audio Effect Rack in the chain draws as its own card (the rack's view, Rand / Map in its
- // title bar), as Live's Device View shows a rack
- offline.editSong ([] (lynx::Song& s) { s.mixer[2].effects.insert (s.mixer[2].effects.begin() + 1, shotRack()); }, false);
- offline.dispatchPendingMessages();
- detail->showSelection (2, 0);
- detail->showSelection (1, 0);
- write ("devices-rack");
- counts << "rack card: cards " << detail->cardCountForCheck() << "\n";
- offline.editSong ([] (lynx::Song& s) { s.mixer[2].effects.erase (s.mixer[2].effects.begin() + 1); }, false);
- offline.dispatchPendingMessages();
- counts << "piano roll back in its panel: " << (ui.getPianoRollForSnapshot().getParentComponent() != nullptr
- && ui.getPianoRollForSnapshot().getParentComponent()->getParentComponent() != detail ? 1 : 0) << "\n";
- }
- else
- counts << "no detail view\n";
- ui.setClipLaunchWorkflow (false);
- offline.dispatchPendingMessages();
- write ("pattern-after");
- juce::File (prefix + "-counts.txt").replaceWithText (counts);
- }
- void runPerfShot (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- {
- lynx::MainComponent ui (offline, false);
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1600x900"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- if (projectPath.isNotEmpty())
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages();
- // LYNX_PERFSHOT_PREPARE=1: Tools › Macros › Prepare for performance mode first (16 one-bar columns)
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_PERFSHOT_PREPARE", {}) == "1")
- offline.editSong ([] (lynx::Song& s) { lynx::perf::prepareForPerformance (s, 16, 4 * lynx::ppq); }, false);
- offline.editSong ([] (lynx::Song& s) { s.performanceMode = true; s.mode = lynx::PlayMode::song; }, false);
- offline.dispatchPendingMessages();
- // what the Player would publish: on each of the first tracks with zone clips, one clip playing (part way)
- // and on every other one the next clip waiting for its sync point
- const auto& song = offline.getSong();
- auto& live = offline.performanceStateForSnapshot();
- const auto zone = lynx::perf::zoneClips (song);
- int lastTrack = -1, launched = 0;
- for (const auto index : zone)
- {
- const auto& c = song.playlist[(std::size_t) index];
- if (c.track == lastTrack || c.track >= lynx::perf::maxTracks)
- continue;
- lastTrack = c.track;
- std::int64_t clips[64];
- const auto n = lynx::perf::trackZoneClips (song, zone, c.track, clips, 64);
- auto& view = live.tracks[(std::size_t) c.track];
- view.playing.store (clips[(std::size_t) ((launched % 3) % n)]);
- view.progress.store (0.2f + 0.15f * (float) (launched % 5));
- if (launched % 2 == 1 && n > 1)
- view.pending.store (clips[(std::size_t) ((launched % 3 + 1) % n)]);
- ++launched;
- }
- live.anyPlaying.store (launched > 0);
- ui.selectTabForSnapshot (2);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- savePng (lynx::shot::snapshot (playlist), prefix + "-playlist-song.png");
- playlist.runAction ("playlist.zoomPerformance"); // as FL opens these demos: the zone fills the view
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist.png");
- savePng (lynx::shot::snapshot (playlist), prefix + "-playlist-only.png");
- // patcherize: the first insert with effects (all of them) and the first channel that can be
- auto patched = offline.getSong();
- for (int t = 0; t < (int) patched.mixer.size(); ++t)
- if (lynx::patcherize::slotsForAll (patched, t).size() > 1)
- {
- lynx::patcherize::patcherizeSlots (patched, t, 0, true);
- break;
- }
- for (int c = 0; c < (int) patched.channels.size(); ++c)
- if (lynx::patcherize::patcherizeChannel (patched, c))
- break;
- juce::String error;
- lynx::ProjectFile::save (patched, juce::File (prefix + "-patcherized.lynx"), error);
- }
- }
- void runPatcherShot (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- lynx::AudioEngine offline (false);
- {
- lynx::MainComponent ui (offline, false);
- ui.setSize (1280, 720);
- if (projectPath.isNotEmpty())
- ui.openFile (juce::File (projectPath));
- else
- {
- auto song = lynx::Song::makeDefault();
- song.mixer.resize (4);
- auto slot = lynx::makeEffectSlot (lynx::EffectKind::patcher);
- slot.patcher.wires.clear();
- for (auto [kind, x, y] : { std::tuple { lynx::EffectKind::frequencySplitter, 200.0f, 60.0f }, { lynx::EffectKind::reverb, 420.0f, 0.0f },
- { lynx::EffectKind::fruityDelay3, 420.0f, 120.0f }, { lynx::EffectKind::peakController, 200.0f, 260.0f } })
- {
- lynx::PatchNode n;
- n.effect = lynx::makeEffectSlot (kind);
- n.x = x;
- n.y = y;
- slot.patcher.nodes.push_back (n);
- }
- { // round 165c: a Hardware Insert node (its editor opens from the node)
- lynx::PatchNode n;
- n.effect = lynx::makeEffectSlot (lynx::EffectKind::hardwareInsert);
- n.x = 420.0f, n.y = 260.0f;
- slot.patcher.nodes.push_back (n);
- }
- auto wire = [&] (int from, int fromPort, int to, int toPort, float gain = 1.0f, lynx::PatchWire::Kind kind = lynx::PatchWire::Kind::audio) {
- lynx::PatchWire w;
- w.kind = kind;
- w.from = from, w.fromPort = fromPort, w.to = to, w.toPort = toPort, w.gain = gain;
- slot.patcher.wires.push_back (w);
- };
- wire (lynx::patchFromHost, 0, 0, 0);
- wire (0, 1, 1, 0);
- wire (0, 3, 2, 0, 0.5f);
- wire (1, 0, lynx::patchToHost, 0);
- wire (2, 0, lynx::patchToHost, 0);
- wire (lynx::patchFromHost, 1, 3, 0);
- wire (3, 1, 2, 2, 1.0f, lynx::PatchWire::Kind::control);
- wire (0, 2, lynx::patchToHost, 1, 0.7f);
- // round 171b (issue #65): a Surface knob on the reverb's parameter input 1, the reverb's parameter 0 out to
- // the delay's parameter input 2 (FL's Inputs / Outputs › Parameters)
- {
- lynx::SurfaceControl knob;
- knob.name = "Knob 1";
- knob.value = 0.6f;
- slot.patcher.surface = { knob };
- slot.patcher.surfaceX = 200.0f, slot.patcher.surfaceY = 380.0f;
- lynx::patcher::setParamInput (slot.patcher, 1, 1, true, "Reverb - 2");
- lynx::patcher::setParamOutput (slot.patcher, 1, 0, true);
- lynx::patcher::setParamInput (slot.patcher, 2, 2, true, "Delay - 3");
- wire (lynx::patchSurface, 0, 1, 1, 1.0f, lynx::PatchWire::Kind::control);
- wire (1, lynx::patchParamOutput (0), 2, 2, 1.0f, lynx::PatchWire::Kind::control);
- }
- slot.patcher.outputTracks = { 3 };
- slot.patcher.inputX = -20.0f;
- slot.patcher.outputX = 660.0f;
- song.mixer[1].effects = { slot };
- lynx::ChannelDef ch;
- ch.name = "Patcher";
- ch.instrument = lynx::InstrumentKind::patcher;
- lynx::PatchNode synth, chorus;
- synth.generator = true;
- synth.channel.instrument = lynx::InstrumentKind::synth;
- synth.channel.name = "Synth";
- synth.x = 220.0f;
- chorus.effect = lynx::makeEffectSlot (lynx::EffectKind::chorus);
- chorus.x = 420.0f;
- // round 162: a MIDI Out node between the "MIDI port 5" pin and "To LYNX" MIDI port 3, an Envelope Controller
- // on the notes moving the chorus
- lynx::PatchNode midiOut, envelope;
- midiOut.generator = envelope.generator = true;
- midiOut.channel.instrument = lynx::InstrumentKind::midiOut;
- midiOut.channel.name = "MIDI Out";
- lynx::midictl::writeMidiOut (midiOut.channel.pluginState, { 3, 0, 0, -1, -1 });
- midiOut.x = 220.0f, midiOut.y = 160.0f;
- envelope.channel.instrument = lynx::InstrumentKind::controller;
- envelope.channel.name = "Envelope Controller";
- envelope.channel.controllerState = lynx::writeEnvelopeController (lynx::defaultEnvelopeController());
- envelope.x = 220.0f, envelope.y = 260.0f;
- lynx::PatchNode osc; // round 164f: an FL engine node (its editor opens from the node)
- osc.generator = true;
- osc.channel = lynx::natives::makeChannel (lynx::InstrumentKind::threeosc, lynx::flStudioAccess()).value_or (lynx::ChannelDef {});
- osc.channel.instrument = lynx::InstrumentKind::threeosc;
- osc.channel.name = "3x Osc";
- osc.x = 420.0f, osc.y = 260.0f;
- // round 165c: Keyboard Controller, SoundFont player, Granulizer and Dashboard nodes (their editors open from the node)
- lynx::PatchNode keys, soundfont, granulizer, dashboard;
- keys.generator = soundfont.generator = granulizer.generator = dashboard.generator = true;
- keys.channel.instrument = lynx::InstrumentKind::controller;
- keys.channel.name = "Keyboard Controller";
- {
- lynx::KeyboardControllerData ramp;
- for (std::size_t k = 0; k < ramp.keys.size(); ++k)
- ramp.keys[k] = (float) k / (float) (ramp.keys.size() - 1);
- lynx::writeKeyboardController (ramp, keys.channel.controllerState);
- }
- soundfont.channel = lynx::sf::makeChannel();
- granulizer.channel = lynx::natives::makeChannel (lynx::InstrumentKind::granulizer, lynx::flStudioAccess()).value_or (lynx::ChannelDef {});
- granulizer.channel.instrument = lynx::InstrumentKind::granulizer;
- granulizer.channel.name = "Fruity Granulizer";
- dashboard.channel.instrument = lynx::InstrumentKind::dashboard;
- dashboard.channel.name = "Dashboard";
- dashboard.channel.patcher.surface = lynx::surface::starterControls();
- keys.x = 20.0f, keys.y = 440.0f;
- soundfont.x = 220.0f, soundfont.y = 440.0f;
- granulizer.x = 420.0f, granulizer.y = 440.0f;
- dashboard.x = 20.0f, dashboard.y = 540.0f;
- // and a Layer node playing the SoundFont and Granulizer nodes on its Children pin (crossfaded)
- lynx::PatchNode layerNode;
- layerNode.generator = true;
- layerNode.channel.instrument = lynx::InstrumentKind::layer;
- layerNode.channel.name = "Layer";
- layerNode.channel.layer.crossfade = true;
- layerNode.channel.layer.fade = 0.35f;
- layerNode.x = 220.0f, layerNode.y = 540.0f;
- ch.patcher.nodes = { synth, chorus, midiOut, envelope, osc, keys, soundfont, granulizer, dashboard, layerNode };
- lynx::PatchWire notes, a, b, portIn, portOut, envNotes, envControl;
- notes.kind = lynx::PatchWire::Kind::midi, notes.to = 0;
- a.from = 0, a.to = 1;
- b.from = 1;
- portIn.kind = lynx::PatchWire::Kind::midi, portIn.fromPort = lynx::patchMidiPortPin (5), portIn.to = 2;
- portOut.kind = lynx::PatchWire::Kind::midi, portOut.from = 2, portOut.to = lynx::patchToHost, portOut.toPort = 3;
- envNotes.kind = lynx::PatchWire::Kind::midi, envNotes.to = 3;
- envControl.kind = lynx::PatchWire::Kind::control, envControl.from = 3, envControl.to = 1, envControl.toPort = 0;
- lynx::PatchWire oscNotes, oscOut;
- oscNotes.kind = lynx::PatchWire::Kind::midi, oscNotes.to = 4;
- oscOut.from = 4;
- lynx::PatchWire layerNotes, layerToFont, layerToGrains, fontOut, grainsOut;
- layerNotes.kind = layerToFont.kind = layerToGrains.kind = lynx::PatchWire::Kind::midi;
- layerNotes.to = 9;
- layerToFont.from = 9, layerToFont.to = 6;
- layerToGrains.from = 9, layerToGrains.to = 7;
- fontOut.from = 6;
- grainsOut.from = 7;
- ch.patcher.wires = { notes, a, b, portIn, portOut, envNotes, envControl, oscNotes, oscOut, layerNotes, layerToFont, layerToGrains, fontOut, grainsOut };
- ch.patcher.fromMidiPorts = { 1, 5 };
- ch.patcher.toMidiPorts = { 3 };
- ch.patcher.outputX = 640.0f;
- song.channels.push_back (ch);
- // LYNX_PATCHERSHOT_SAVE=file.lynx: the demo as a project (a GUI check of the same Patchers, round 164f)
- if (const auto save = juce::SystemStats::getEnvironmentVariable ("LYNX_PATCHERSHOT_SAVE", {}); save.isNotEmpty())
- {
- if (! song.patterns.empty())
- for (int k = 0; k < 4; ++k)
- song.patterns[0].notes.push_back ({ (std::int64_t) k * lynx::ppq, lynx::ppq / 2, (int) song.channels.size() - 1, 60 + 4 * k, 0.8f });
- juce::String error;
- lynx::ProjectFile::save (song, juce::File (save), error);
- // round 171b: the saved Patchers come back the same (parameter ports, event cables, published)
- juce::String report;
- if (const auto loaded = lynx::ProjectFile::load (juce::File (save), error))
- {
- const auto same = loaded->mixer.size() > 1 && ! loaded->mixer[1].effects.empty()
- && loaded->mixer[1].effects[0].patcher == song.mixer[1].effects[0].patcher;
- const auto& d = loaded->mixer.size() > 1 && ! loaded->mixer[1].effects.empty() ? loaded->mixer[1].effects[0].patcher : lynx::PatcherDoc {};
- report << "patcher round trip: " << (same ? "OK" : "DIFFERENT") << "\n";
- if (! same && loaded->mixer.size() > 1 && ! loaded->mixer[1].effects.empty())
- {
- const auto& a = song.mixer[1].effects[0].patcher;
- report << "wires " << (a.wires == d.wires ? "same" : "differ") << ", published " << (a.published == d.published ? "same" : "differ")
- << ", surface " << (a.surface == d.surface ? "same" : "differ") << "\n";
- for (std::size_t n = 0; n < std::min (a.nodes.size(), d.nodes.size()); ++n)
- if (! (a.nodes[n] == d.nodes[n]))
- report << "node " << (int) n << " differs: ports " << (a.nodes[n].paramIns == d.nodes[n].paramIns && a.nodes[n].paramOuts == d.nodes[n].paramOuts ? "same" : "differ")
- << ", effect " << (a.nodes[n].effect == d.nodes[n].effect ? "same" : "differ") << ", xy "
- << (a.nodes[n].x == d.nodes[n].x && a.nodes[n].y == d.nodes[n].y ? "same" : "differ") << "\n";
- }
- for (int n = 0; n < (int) d.nodes.size(); ++n)
- report << "node " << n << " paramIns " << (int) d.nodes[(std::size_t) n].paramIns.size() << " paramOuts "
- << (int) d.nodes[(std::size_t) n].paramOuts.size() << "\n";
- for (const auto& w : d.wires)
- if (w.kind == lynx::PatchWire::Kind::control)
- report << "control " << w.from << ":" << w.fromPort << " -> " << w.to << ":" << w.toPort << "\n";
- for (const auto& p : d.published)
- report << "published " << p.node << ":" << p.param << " " << juce::String::fromUTF8 (p.name.c_str()) << "\n";
- }
- else
- report << "patcher round trip: load failed: " << error << "\n";
- juce::File (prefix + "-roundtrip.txt").replaceWithText (report);
- }
- offline.setSong (std::move (song));
- }
- offline.dispatchPendingMessages();
- const auto& song = offline.getSong();
- auto shootOpen = [&] (const juce::String& name) {
- for (int k = 0; k < juce::TopLevelWindow::getNumTopLevelWindows(); ++k)
- if (auto* w = dynamic_cast<juce::DocumentWindow*> (juce::TopLevelWindow::getTopLevelWindow (k)))
- if (w->getName().startsWith (lynx::tr ("Patcher")) && w->getContentComponent() != nullptr)
- {
- auto* c = w->getContentComponent();
- savePng (lynx::shot::snapshot (*c), prefix + name);
- delete w;
- return;
- }
- };
- int shots = 0;
- for (int t = 0; t < (int) song.mixer.size() && shots < 12; ++t)
- for (int s = 0; s < (int) song.mixer[(std::size_t) t].effects.size(); ++s)
- if (song.mixer[(std::size_t) t].effects[(std::size_t) s].kind == lynx::EffectKind::patcher)
- {
- lynx::PatcherWindows::openSlot (offline, t, s);
- shootOpen ("-insert" + juce::String (t) + "-slot" + juce::String (s) + ".png");
- // each built-in node's editor, as a double-click opens it (round 165c)
- lynx::PatcherWindows::shootNodeEditors (offline, false, t, s, [&] (const juce::Image& image, int n) {
- savePng (image, prefix + "-insert" + juce::String (t) + "-slot" + juce::String (s) + "-node" + juce::String (n) + ".png");
- });
- ++shots;
- if (shots == 1) // its menus (round 162)
- lynx::PatcherWindows::shootMenus (offline, false, t, s, [&] (const juce::Image& image, const juce::String& name) {
- savePng (image, prefix + "-menu-" + name + ".png");
- });
- }
- for (int c = 0; c < (int) song.channels.size(); ++c)
- if (song.channels[(std::size_t) c].instrument == lynx::InstrumentKind::patcher)
- {
- lynx::PatcherWindows::openChannel (offline, c);
- shootOpen ("-channel" + juce::String (c) + ".png");
- // each node's editor, as a double-click opens it (round 164f; every built-in node since round 165c)
- lynx::PatcherWindows::shootNodeEditors (offline, true, c, 0, [&] (const juce::Image& image, int n) {
- savePng (image, prefix + "-channel" + juce::String (c) + "-node" + juce::String (n) + ".png");
- });
- lynx::PatcherWindows::shootMenus (offline, true, c, 0, [&] (const juce::Image& image, const juce::String& name) {
- savePng (image, prefix + "-channel" + juce::String (c) + "-menu-" + name + ".png");
- });
- }
- }
- }
- // Issue #64: FL's letter keys in a plugin menu (quickpick::showMenu), checked on the real menu windows
- struct TypeAheadTest final : private juce::Timer
- {
- juce::File out;
- juce::StringArray log;
- int step = 0, picked = 0;
- bool ok = true, menuShown = false;
- std::unique_ptr<juce::DocumentWindow> owner;
- juce::PopupMenu pending;
- static juce::String highlighted()
- {
- if (auto* window = juce::Component::getCurrentlyModalComponent())
- for (auto* child : window->getChildren())
- if (auto* h = child->getAccessibilityHandler(); h != nullptr && h->hasFocus (false))
- return h->getTitle();
- return "(none)";
- }
- static void press (const juce::KeyPress& key)
- {
- if (auto* window = juce::Component::getCurrentlyModalComponent())
- if (auto* peer = window->getPeer())
- peer->handleKeyPress (key);
- }
- void expect (const juce::String& what, const juce::String& got, const juce::String& wanted)
- {
- const auto good = got == wanted;
- ok = ok && good;
- log.add ((good ? "ok " : "FAIL ") + what + ": " + got + (good ? juce::String() : " (wanted " + wanted + ")"));
- }
- void start()
- {
- juce::PopupMenu menu, sub;
- auto item = [this] (juce::PopupMenu& m, int id, const char* text, bool enabled = true) {
- m.addItem (text, enabled, false, [this, id] { picked = id; });
- };
- menu.addSectionHeader ("LYNX SHARE");
- item (menu, 1, "Echoform");
- item (menu, 2, "EQ");
- item (menu, 3, "Halo");
- menu.addSectionHeader ("Misc");
- item (menu, 4, "Effector");
- item (menu, 5, "Exciter (unavailable)", false);
- item (sub, 10, "Delay");
- item (sub, 11, "Edison");
- item (sub, 12, "Eventide");
- menu.addSubMenu ("Tree", sub);
- // the menu belongs to a window in the foreground, as when the user right-clicks a mixer slot (JUCE closes a
- // menu of a background process at once)
- owner = std::make_unique<juce::DocumentWindow> ("LYNX type-ahead test", juce::Colours::black, 0);
- owner->setBounds (200, 200, 300, 200);
- owner->setVisible (true);
- lynx::forceForegroundForTest (*owner);
- pending = menu; // shown once the window is up and active (X11 maps and activates it asynchronously)
- startTimer (300);
- }
- void timerCallback() override
- {
- const auto e = juce::KeyPress ('e', {}, 'e');
- if (step == 0 && owner != nullptr && ! menuShown)
- {
- menuShown = true;
- lynx::forceForegroundForTest (*owner);
- lynx::quickpick::showMenu (pending, juce::PopupMenu::Options().withTargetComponent (owner.get()), {});
- return;
- }
- switch (step++)
- {
- case 0: expect ("menu open", juce::String ((int) (juce::Component::getCurrentlyModalComponent() != nullptr)), "1"); break;
- case 1: press (e); expect ("e", highlighted(), "Echoform"); break;
- case 2: press (e); expect ("e again", highlighted(), "EQ"); break;
- case 3: press (juce::KeyPress ('E', juce::ModifierKeys::shiftModifier, 'E')); expect ("E (shift)", highlighted(), "Effector"); break;
- case 4: press (e); expect ("e wraps (skips the disabled one)", highlighted(), "Echoform"); break;
- case 5: press (juce::KeyPress ('m', {}, 'm')); expect ("m (only a heading starts with it: no move)", highlighted(), "Echoform"); break;
- case 6: press (juce::KeyPress (juce::KeyPress::downKey)); expect ("down arrow", highlighted(), "EQ"); break;
- case 7: press (e); expect ("e after the arrow", highlighted(), "Effector"); break;
- case 8: press (juce::KeyPress ('t', {}, 't')); expect ("t", highlighted(), "Tree"); break;
- case 9: press (juce::KeyPress (juce::KeyPress::rightKey)); break; // opens the submenu (it takes the keys)
- case 10: press (e); expect ("e in the submenu", highlighted(), "Edison"); break;
- case 11: press (e); expect ("e again in the submenu", highlighted(), "Eventide"); break;
- case 12: expect ("nothing picked by the letters", juce::String (picked), "0"); press (juce::KeyPress (juce::KeyPress::returnKey)); break;
- case 13: break;
- default:
- expect ("Enter closed the menu", juce::String ((int) (juce::Component::getCurrentlyModalComponent() == nullptr)), "1");
- expect ("Enter picked", juce::String (picked), "12");
- stopTimer();
- owner.reset();
- log.add (ok ? "result=OK" : "result=FAIL");
- out.replaceWithText (log.joinIntoString ("\n") + "\n");
- juce::JUCEApplication::getInstance()->setApplicationReturnValue (ok ? 0 : 1);
- juce::JUCEApplication::quit();
- return;
- }
- }
- };
- std::unique_ptr<TypeAheadTest> typeAheadTest;
- struct ChooserTest final : private juce::Timer
- {
- juce::File out, file;
- juce::StringArray log;
- std::unique_ptr<juce::FileChooser> chooser;
- double started = 0;
- bool shot = false, done = false;
- void start()
- {
- log.add ("LYNX_FILE_DIALOG=" + juce::SystemStats::getEnvironmentVariable ("LYNX_FILE_DIALOG", {}));
- log.add ("native=" + juce::String ((int) lynx::ui::filechooser::nativeDialogs()));
- chooser = lynx::ui::makeFileChooser ("Open audio file", file.getParentDirectory(), "*.wav;*.flac");
- started = juce::Time::getMillisecondCounterHiRes();
- lynx::ui::launchChooser (chooser, juce::FileBrowserComponent::openMode | juce::FileBrowserComponent::canSelectFiles,
- [this] (const juce::FileChooser& fc) { finish (fc.getResult()); });
- startTimer (200);
- }
- static juce::FileChooserDialogBox* builtInDialog()
- {
- for (int i = 0; i < juce::Desktop::getInstance().getNumComponents(); ++i)
- if (auto* box = dynamic_cast<juce::FileChooserDialogBox*> (juce::Desktop::getInstance().getComponent (i)); box != nullptr && box->isShowing())
- return box;
- return nullptr;
- }
- static juce::FileBrowserComponent* findBrowser (juce::Component& c)
- {
- if (auto* b = dynamic_cast<juce::FileBrowserComponent*> (&c))
- return b;
- for (auto* child : c.getChildren())
- if (auto* b = findBrowser (*child))
- return b;
- return nullptr;
- }
- void timerCallback() override
- {
- if (done)
- return;
- if (auto* box = builtInDialog(); box != nullptr && ! shot)
- {
- shot = true;
- log.add ("built-in dialog shown after " + juce::String (juce::roundToInt (juce::Time::getMillisecondCounterHiRes() - started)) + " ms");
- const auto image = lynx::shot::snapshot (*box);
- juce::FileOutputStream png (out.getSiblingFile (out.getFileName() + ".png"));
- if (png.openedOk())
- {
- png.setPosition (0), png.truncate();
- juce::PNGImageFormat().writeImageToStream (image, png);
- }
- if (auto* browser = findBrowser (*box))
- {
- browser->setRoot (file.getParentDirectory());
- browser->setFileName (file.getFileName());
- log.add ("typed " + file.getFileName());
- box->exitModalState (1);
- }
- else
- log.add ("no file browser in the dialog");
- }
- if (juce::Time::getMillisecondCounterHiRes() - started > 30000.0)
- finish ({}, "timeout");
- }
- void finish (const juce::File& result, const juce::String& why = {})
- {
- if (done)
- return;
- done = true;
- stopTimer();
- log.add ("callback after " + juce::String (juce::roundToInt (juce::Time::getMillisecondCounterHiRes() - started)) + " ms: "
- + (why.isNotEmpty() ? why : result.getFullPathName().isEmpty() ? juce::String ("(no file)") : result.getFullPathName()));
- log.add ("native now=" + juce::String ((int) lynx::ui::filechooser::nativeDialogs()));
- const auto ok = result == file && result.existsAsFile();
- log.add (ok ? "result=OK" : "result=FAIL");
- out.replaceWithText (log.joinIntoString ("\n") + "\n");
- juce::JUCEApplication::getInstance()->setApplicationReturnValue (ok ? 0 : 1);
- juce::MessageManager::callAsync ([] { juce::JUCEApplication::quit(); });
- }
- };
- std::unique_ptr<ChooserTest> chooserTest;
- void runChooserTest (const juce::File& out, const juce::File& file)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- chooserTest = std::make_unique<ChooserTest>();
- chooserTest->out = out;
- chooserTest->file = file;
- chooserTest->start();
- }
- void runTypeAheadTest (const juce::File& out)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- typeAheadTest = std::make_unique<TypeAheadTest>();
- typeAheadTest->out = out;
- typeAheadTest->start();
- }
- void runStabilityShot (const juce::String& folder)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::File dir (folder);
- dir.createDirectory();
- {
- lynx::AudioEngine offline (false);
- const auto save = [&dir] (std::unique_ptr<juce::Component> c, const juce::String& name) {
- juce::Component frame;
- frame.setSize (c->getWidth(), c->getHeight());
- frame.setOpaque (true);
- if (c->isOnDesktop()) // (an AlertWindow: never shown, so it takes no foreground)
- c->removeFromDesktop();
- frame.addAndMakeVisible (*c);
- c->setTopLeftPosition (0, 0);
- const auto image = lynx::shot::paint (frame, lynx::theme::panel);
- const auto file = dir.getChildFile (name);
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (image, *out);
- };
- save (lynx::PluginWindows::makeCrashPromptPanel ("Serum", false), "crash-prompt.png");
- save (lynx::PluginWindows::makeCrashPromptPanel ("Serum", true), "crash-prompt-onload.png");
- save (lynx::PluginWindows::makeCrashNoticePanel ("Serum", true), "crash-notice.png");
- save (lynx::makePluginManagerPanel (offline, false), "plugin-manager.png");
- save (lynx::makePluginMonitorPanel (offline), "plugin-monitor.png");
- }
- setApplicationReturnValue (0);
- quit();
- }
- void runDetails190ihShot (const juce::String& prefix)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- juce::String report;
- auto line = [&report] (const juce::String& t) { report << t << "\n"; };
- {
- // R2: Gross Beat on Insert 1 — the first time slot and a half-beat volume gate, as in FL's capture ("Empty",
- // "1/2 Bt Gate")
- lynx::AudioEngine offline (false);
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (2);
- song.bpm = 150.0;
- auto gb = lynx::makeEffectSlot (lynx::EffectKind::grossBeat);
- const auto names = lynx::grossbeat::slotNames (gb.state, true);
- int gate = 0;
- for (int k = 0; k < (int) names.size(); ++k)
- if (names[(std::size_t) k] == "Gate 1/2 beat") // (LYNX's factory slot for FL's "1/2 Bt Gate")
- gate = k;
- gb.params[0] = lynx::grossbeat::paramFromRaw (0, 0);
- gb.params[1] = lynx::grossbeat::paramFromRaw (1, gate);
- song.mixer[1].effects.push_back (gb);
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- // the real effect played to beat 2.9 of its bar: its published outputs go where the rack writes them
- auto run = lynx::makeEffect (gb);
- run->prepare (48000.0);
- const auto tps = 150.0 / 60.0 * lynx::ppq / 48000.0;
- std::vector<float> l (480, 0.3f), r (480, 0.3f);
- std::size_t done = 0;
- auto block = [&] (lynx::EffectParams& params) {
- run->setSongPosition ((double) done * tps);
- run->process (l.data(), r.data(), 480, params, 150.0);
- done += 480;
- };
- auto publish = [&] (bool playing) {
- const auto key = (std::size_t) (1 * lynx::maxEffectSlots + 0) * lynx::ProcessTimes::meterOutputs;
- if (auto* times = offline.getProcessTimes())
- for (int k = 0; k < lynx::ProcessTimes::meterOutputs; ++k)
- times->effectMeters[key + (std::size_t) k].store (run->controlOutput (k), std::memory_order_relaxed);
- else
- line ("no process times: the editor shows nothing live");
- offline.getTransport().playing.store (playing);
- juce::String values;
- for (int k = 0; k < 7; ++k)
- values << " " << juce::String (run->controlOutput (k), 3);
- line ("gross beat outputs:" + values);
- };
- while ((double) done * tps / lynx::ppq < 2.9)
- block (gb.params);
- auto editor = lynx::makeNativeEffectEditor (offline, 1, 0, 1.0f);
- editor->setSize (editor->getWidth(), editor->getHeight());
- for (const int view : { 1, 0 })
- {
- lynx::showGrossBeatEnvelopeForSnapshot (*editor, view);
- publish (true);
- lynx::tickNativeEffectEditor (*editor);
- savePng (lynx::shot::snapshot (*editor), prefix + "-r2-grossbeat-playing-" + (view == 1 ? "volume" : "time") + ".png");
- }
- lynx::ui::motion::enabled() = false;
- lynx::tickNativeEffectEditor (*editor);
- editor->repaint();
- savePng (lynx::shot::snapshot (*editor), prefix + "-r2-grossbeat-playing-noanim.png");
- lynx::ui::motion::enabled() = true;
- // a click on another time slot: queued until the next 4 beats
- auto queued = gb.params;
- queued[0] = lynx::grossbeat::paramFromRaw (0, 5);
- block (queued);
- publish (true);
- lynx::tickNativeEffectEditor (*editor);
- savePng (lynx::shot::snapshot (*editor), prefix + "-r2-grossbeat-queued.png");
- publish (false); // stopped: no locator, no fill
- lynx::tickNativeEffectEditor (*editor);
- savePng (lynx::shot::snapshot (*editor), prefix + "-r2-grossbeat-stopped.png");
- // round 190jd (live check 190iw Q7): the locator in FL's colours (the editor's Options menu) on the beat (cream,
- // 3 px trail), a third into it (orange) and near its end (dusty red); LYNX's playhead colour stays the default
- lynx::gblocator::setFlStyle (true);
- lynx::showGrossBeatEnvelopeForSnapshot (*editor, 1);
- for (const auto at : { 4.02, 4.35, 4.9 })
- {
- while ((double) done * tps / lynx::ppq < at)
- block (queued);
- publish (true);
- juce::Thread::sleep (60); // (the editor's frame budget: ~21 frames a second in this style)
- lynx::tickNativeEffectEditor (*editor);
- savePng (lynx::shot::snapshot (*editor), prefix + "-r2-grossbeat-fl-colours-" + juce::String (at - 4.0, 2) + ".png");
- }
- lynx::gblocator::setFlStyle (false);
- offline.getTransport().playing.store (false);
- }
- {
- // R7: the Envelope Controller's Keyboard / Velocity mapping pages after a note (key 64, velocity 0.8)
- lynx::AudioEngine offline (false);
- lynx::Song song;
- lynx::ChannelDef env;
- env.name = "Envelope Controller";
- env.instrument = lynx::InstrumentKind::controller;
- auto ec = lynx::defaultEnvelopeController();
- ec[0].maps[lynx::mapKeyboard].count = 2;
- ec[0].maps[lynx::mapKeyboard].time = { 0.2f, 0.8f };
- ec[0].maps[lynx::mapKeyboard].level = { 0.0f, 1.0f };
- ec[0].maps[lynx::mapVelocity] = ec[0].maps[lynx::mapKeyboard];
- env.controllerState = lynx::writeEnvelopeController (ec);
- song.channels.push_back (env);
- song.patterns.emplace_back();
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- auto editor = lynx::makeEnvelopeControllerEditor (
- offline, [] (lynx::Song& s) -> lynx::ChannelDef* { return s.channels.empty() ? nullptr : &s.channels[0]; }, 0,
- [] (int k) { return k == 8 ? 64.0f : k == 9 ? 0.8f : 0.5f; });
- for (const int part : { 2, 3 })
- {
- for (auto* child : editor->getChildren())
- if (auto* box = dynamic_cast<juce::ComboBox*> (child))
- box->setSelectedItemIndex (part, juce::sendNotificationSync);
- savePng (lynx::shot::snapshot (*editor), prefix + "-r7-ec-" + (part == 2 ? "keyboard" : "velocity") + "-line.png");
- }
- }
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false);
- ui.setSize (1920, 1080);
- lynx::Song song;
- song.mixer = lynx::Song::defaultMixer (4);
- for (const auto* name : { "Grv Kick 27", "Snare", "Hat", "Bass (locked)" })
- {
- lynx::ChannelDef c;
- c.name = name;
- c.instrument = lynx::InstrumentKind::sampler;
- song.channels.push_back (c);
- }
- song.channels[3].receiveFrom = "MIDI keyboard";
- song.patterns.emplace_back();
- offline.setSong (std::move (song));
- offline.dispatchPendingMessages();
- ui.showDesktopForSnapshot (false);
- offline.dispatchPendingMessages();
- // R4: the rack's activity light — before, at note-on, held, after the release; a locked channel lit (orange)
- auto& rack = ui.getRackForSnapshot();
- const std::pair<const char*, float> states[] { { "before", 0.0f }, { "noteon", 1.0f }, { "held", lynx::activity::held }, { "after", 0.0f } };
- for (const auto& [name, level] : states)
- {
- rack.setActivityForSnapshot (0, level);
- rack.setActivityForSnapshot (3, level);
- savePng (lynx::shot::snapshot (rack), prefix + "-r4-rack-" + name + ".png");
- }
- rack.setActivityForSnapshot (0, 0.0f);
- rack.setActivityForSnapshot (3, 0.0f);
- // R3: the transport stopped, playing, recording (both blink phases), armed and stopped; the hint bar
- const auto toolbar = ui.getToolbarBoundsForSnapshot();
- auto& transport = offline.getTransport();
- ui.transportForSnapshot (false, true);
- saveArea (ui, toolbar, prefix + "-r3-toolbar-stopped.png");
- transport.playing.store (true);
- ui.transportForSnapshot (true, true);
- saveArea (ui, toolbar, prefix + "-r3-toolbar-playing.png");
- transport.recording.store (true);
- ui.transportForSnapshot (true, true);
- saveArea (ui, toolbar, prefix + "-r3-toolbar-recording-lit.png");
- ui.transportForSnapshot (true, false);
- saveArea (ui, toolbar, prefix + "-r3-toolbar-recording-dark.png");
- lynx::ui::motion::enabled() = false;
- ui.transportForSnapshot (true, false);
- saveArea (ui, toolbar, prefix + "-r3-toolbar-recording-noanim.png");
- lynx::ui::motion::enabled() = true;
- transport.playing.store (false);
- ui.transportForSnapshot (false, false);
- saveArea (ui, toolbar, prefix + "-r3-toolbar-armed-stopped.png");
- transport.recording.store (false);
- ui.transportForSnapshot (false, true);
- for (const bool on : { true, false })
- {
- offline.markLiveNote (60, 100, on);
- const auto hint = ui.liveNoteHintForSnapshot();
- line ("hint: " + hint);
- ui.setHintForSnapshot ({ hint, {}, false, false });
- saveArea (ui, toolbar, prefix + "-r3-hint-note" + (on ? "on" : "off") + ".png");
- }
- offline.editSong ([] (lynx::Song& s) { s.bpm = 128.0; }); // (a change: the project is modified)
- offline.dispatchPendingMessages();
- const auto reminder = ui.saveReminderForSnapshot();
- line ("reminder: " + reminder);
- ui.setHintForSnapshot ({ reminder, {}, false, false });
- saveArea (ui, toolbar, prefix + "-r3-save-reminder.png");
- // R14: the Simple dock's input level
- ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
- offline.dispatchPendingMessages();
- if (auto* simple = ui.getSimpleWorkflowForSnapshot())
- if (auto* dock = simple->dockForSnapshot())
- {
- dock->inputLevelForSnapshot (0.72f);
- offline.dispatchPendingMessages();
- savePng (lynx::shot::snapshot (*dock), prefix + "-r14-dock-input-level.png");
- line ("dock: " + juce::String (dock->getWidth()) + "x" + juce::String (dock->getHeight()));
- }
- ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
- offline.dispatchPendingMessages();
- }
- juce::File (prefix + "-report.txt").replaceWithText (report);
- }
- void runJsfxShots (const juce::String& folderPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- const juce::File folder (folderPath);
- folder.createDirectory();
- lynx::jsfx::installPack();
- juce::StringArray made;
- {
- lynx::AudioEngine offline (false);
- lynx::JsfxPluginFormat format;
- auto& known = offline.getPluginHost().getKnownPlugins();
- for (const auto& f : format.searchPathsForPlugins (juce::FileSearchPath (lynx::jsfx::packFolder().getFullPathName()), true, false))
- {
- juce::OwnedArray<juce::PluginDescription> found;
- format.findAllTypesForFile (found, f);
- for (auto* d : found)
- known.addType (*d);
- }
- // the slider panels (the plugin window's editor) of four bundled scripts
- for (const auto* rel : { "chokehold/Clipper/soft_clipper.jsfx", "chokehold/Generator/test_signals.jsfx",
- "chokehold/Instrument FX/mic_combiner.jsfx", "chokehold/MIDI/midi_chord_trigger.jsfx" })
- {
- const auto file = lynx::jsfx::packFolder().getChildFile (rel);
- juce::OwnedArray<juce::PluginDescription> found;
- format.findAllTypesForFile (found, file.getFullPathName());
- if (found.isEmpty())
- continue;
- juce::String error;
- auto instance = format.createInstanceFromDescription (*found[0], 48000.0, 512, error);
- if (instance == nullptr)
- {
- made.add (juce::String (rel) + ": " + error);
- continue;
- }
- lynx::preparePlugin (*instance, 48000.0, 512);
- juce::AudioBuffer<float> buffer (2, 512);
- juce::MidiBuffer midi;
- for (int b = 0; b < 8; ++b)
- {
- buffer.clear();
- instance->processBlock (buffer, midi);
- }
- offline.dispatchPendingMessages(); // (the latency it reported)
- std::unique_ptr<juce::AudioProcessorEditor> editor (instance->createEditor());
- const auto name = "jsfx-panel-" + file.getFileNameWithoutExtension() + ".png";
- saveSnapshot (*editor, folder.getChildFile (name).getFullPathName());
- made.add (name);
- editor = nullptr;
- }
- // the Browser's Plugin database with its JSFX categories open, in the default desktop
- lynx::MainComponent ui (offline, false);
- ui.setSize (1280, 720);
- offline.dispatchPendingMessages();
- ui.waitForBrowserForSnapshot();
- ui.getBrowserForSnapshot().showJsfxForSnapshot();
- offline.dispatchPendingMessages();
- saveSnapshot (ui, folder.getChildFile ("jsfx-browser.png").getFullPathName());
- saveArea (ui, ui.getBrowserForSnapshot().getBoundsInParent(), folder.getChildFile ("jsfx-browser-panel.png").getFullPathName());
- made.add ("jsfx-browser.png");
- // Settings › File with the JSFX folders list
- auto settings = lynx::makeSettingsPanel (offline, lynx::SettingsPage::files);
- if (settings->getWidth() < 200 || settings->getHeight() < 200)
- settings->setSize (720, 640);
- offline.dispatchPendingMessages();
- saveSnapshot (*settings, folder.getChildFile ("jsfx-settings-files.png").getFullPathName());
- made.add ("jsfx-settings-files.png");
- }
- folder.getChildFile ("jsfxshots.txt").replaceWithText (made.joinIntoString ("\n") + "\n");
- setApplicationReturnValue (0);
- quit();
- }
- void runSnapshot (const juce::String& prefix, const juce::String& projectPath)
- {
- juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
- // LYNX_SNAPSHOT_THEME=file.lynxtheme: the pictures in that theme (round 162d)
- if (const auto themeFile = juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_THEME", {}); themeFile.isNotEmpty())
- if (const auto spec = lynx::themeui::loadFile (juce::File (themeFile)))
- lynx::themeui::apply (*spec, false);
- {
- lynx::AudioEngine offline (false);
- lynx::MainComponent ui (offline, false); // default layout and keys, nothing saved
- // LYNX_SNAPSHOT_SIZE=WxH (default 1280x720)
- const auto size = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIZE", "1280x720"), "x", "");
- ui.setSize (juce::jlimit (800, 3840, size[0].getIntValue()), juce::jlimit (450, 2160, size[1].getIntValue()));
- if (projectPath.isNotEmpty())
- ui.openFile (juce::File (projectPath));
- offline.dispatchPendingMessages(); // change notifications are asynchronous
- ui.waitForBrowserForSnapshot();
- // the workspace desktop: the default layout, then with the Piano Roll and Mixer floating too
- // (and a sample hint in the status strip, as when hovering a knob)
- ui.showDesktopForSnapshot (false);
- ui.setMetersForSnapshot (0.23, (std::int64_t) 412 << 20, 6);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-desktop.png");
- // the first start: the setup wizard over the main window (round 140), also on a small screen (it scrolls)
- {
- const auto size = ui.getBounds();
- ui.showSetupWizard();
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-desktop-setup.png");
- ui.setSize (1024, 600);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-desktop-setup-small.png");
- ui.closeSetupWizardForSnapshot();
- ui.setBounds (size);
- offline.dispatchPendingMessages();
- }
- // the start-up desktop and the toolbar at the usual window sizes: the untouched default layout
- // follows the window (default rects, not scaled ones); panels drop from the toolbar by priority
- {
- const auto size = ui.getBounds();
- for (const auto& [w, h] : std::vector<std::pair<int, int>> { { 1280, 720 }, { 1366, 768 }, { 1600, 900 }, { 1920, 1080 }, { 2560, 1440 }, { 3840, 2160 } })
- {
- ui.setSize (w, h);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-desktop-" + juce::String (w) + ".png");
- saveArea (ui, ui.getToolbarBoundsForSnapshot(), prefix + "-toolbar-" + juce::String (w) + ".png");
- if (w == 1920) // the rack scrolled to its last steps: the controls column stays in view (round 90)
- {
- ui.scrollRackForSnapshot (100000);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-desktop-rack-scrolled.png");
- ui.scrollRackForSnapshot (0);
- }
- }
- // the toolbar with small and large icons, and a customized one (groups hidden and reordered)
- ui.setSize (1600, 900);
- for (auto [iconSize, name] : { std::pair { lynx::toolbarlayout::IconSize::small, "small" }, { lynx::toolbarlayout::IconSize::large, "large" } })
- {
- auto layout = lynx::toolbarlayout::Layout::makeDefault();
- layout.iconSize = iconSize;
- ui.setToolbarLayoutForSnapshot (layout);
- saveArea (ui, ui.getToolbarBoundsForSnapshot(), prefix + "-toolbar-" + name + "-1600.png");
- }
- {
- auto layout = lynx::toolbarlayout::Layout::makeDefault();
- layout.move (lynx::toolbarlayout::Group::windows, -3);
- layout.setShown (lynx::toolbarlayout::Group::record, false);
- layout.setShown (lynx::toolbarlayout::Group::meters, false);
- ui.setToolbarLayoutForSnapshot (layout);
- saveArea (ui, ui.getToolbarBoundsForSnapshot(), prefix + "-toolbar-custom-1600.png");
- }
- {
- // round 170e: the toolbar after a knob was moved: the last tweaked read-out (its caption) and the snap magnet
- ui.setSize (1920, 1080); // the read-out needs room beside the hint bar
- ui.setToolbarLayoutForSnapshot (lynx::toolbarlayout::Layout::makeDefault());
- lynx::AutomationTarget t;
- t.kind = lynx::AutomationTargetKind::mixerVolume;
- t.index = 0;
- offline.noteTweaked (t);
- ui.refreshTweakReadoutForSnapshot();
- offline.dispatchPendingMessages();
- saveArea (ui, ui.getToolbarBoundsForSnapshot(), prefix + "-toolbar-tweak-1920.png");
- ui.setSize (1600, 900);
- }
- {
- // the toolbar's edit mode (round 115): outlined panels and the tray of panels under it
- ui.setToolbarLayoutForSnapshot (lynx::toolbarlayout::Layout::makeDefault());
- auto layout = lynx::toolbarlayout::Layout::makeDefault();
- layout.setShown (lynx::toolbarlayout::Group::meters, false);
- ui.setToolbarLayoutForSnapshot (layout);
- ui.setToolbarEditingForSnapshot (true);
- offline.dispatchPendingMessages();
- saveArea (ui, ui.getToolbarBoundsForSnapshot().withHeight (ui.getToolbarAndTrayHeightForSnapshot()), prefix + "-toolbar-edit-1600.png");
- ui.setToolbarEditingForSnapshot (false);
- // Ctrl+F11: only the menu and the hint bar
- layout = lynx::toolbarlayout::Layout::makeDefault();
- layout.visible = false;
- ui.setToolbarLayoutForSnapshot (layout);
- saveArea (ui, ui.getLocalBounds().withHeight (120), prefix + "-toolbar-hidden-1600.png");
- }
- ui.setToolbarLayoutForSnapshot (lynx::toolbarlayout::Layout::makeDefault());
- // quick tips: the toolbar and title bars with a few name bubbles, and every tip on one sheet
- offline.dispatchPendingMessages();
- saveQuickTips (ui, prefix);
- ui.setBounds (size);
- offline.dispatchPendingMessages();
- }
- // the hint bar: a value control while it is dragged (live value), a gesture line with mouse and key
- // glyphs, and a text too long for one line (two lines)
- {
- const auto toolbar = ui.getToolbarBoundsForSnapshot().withWidth (juce::jmin (ui.getWidth(), 900));
- const lynx::ui::Hint hints[] = {
- { lynx::tr ("Volume") + " - " + lynx::tr ("drag (Ctrl: fine), wheel, Alt+click resets"), "-3.2 dB", true, true },
- { lynx::tr ("Piano Roll: [LMB] add a note, drag to move [RMB] delete [Ctrl][LMB] drag to select [Ctrl][Wheel] zoom"), {}, false, false },
- { lynx::tr ("Global snap: the grid of the Piano Roll and Playlist (when they follow it) and the quantise of recorded notes "
- "[LMB] choose [Wheel] step [RMB] length of new notes [Backspace] snap on/off [Alt] while dragging: no snap"), {}, false, true },
- };
- for (int i = 0; i < 3; ++i)
- {
- ui.setHintForSnapshot (hints[i], i == 0);
- saveArea (ui, toolbar, prefix + "-hint-" + juce::String (i + 1) + ".png");
- }
- }
- ui.showDesktopForSnapshot (true);
- ui.setHintForSnapshot ({ lynx::tr ("Volume") + " - " + lynx::tr ("drag (Ctrl: fine), wheel, Alt+click resets"), "78%", true, true });
- saveSnapshot (ui, prefix + "-desktop-all.png");
- ui.selectTabForSnapshot (0);
- saveSnapshot (ui, prefix + "-rack.png");
- // round 190io (design190ia FM-10…14): steps on the first channels, audio clip channels included (they show
- // their steps as in FL), a few selected rows, a muted channel; then the project as it was
- {
- const auto& kept = offline.getSong();
- const auto keptSelection = offline.getSelectedChannels();
- const auto keptPrimary = offline.getSelectedChannel();
- const auto channels = (int) kept.channels.size();
- offline.editSong ([channels] (lynx::Song& s) {
- auto& p = s.activePattern();
- for (int c = 0; c < juce::jmin (12, channels); ++c)
- for (const auto step : { 0, 4 + (c % 3) * 2, 8, 12 + (c % 2) * 2 })
- if (! p.hasStep (c, step))
- p.toggleStep (c, step);
- if (channels > 5)
- s.channels[5].muted = true;
- });
- if (channels > 3)
- offline.setChannelSelection ({ 1, 2, 3 }, 2);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-rack190io-steps.png");
- offline.undo(); // (one undo step: the project and its history as they were)
- offline.setChannelSelection (keptSelection, keptPrimary);
- offline.dispatchPendingMessages();
- }
- {
- // a pattern with piano-roll notes: those rows show a miniature instead of steps (round 90)
- int found = -1;
- const auto before = offline.getSong().currentPattern;
- {
- const auto& song = offline.getSong();
- for (int p = 0; p < (int) song.patterns.size() && found < 0; ++p)
- for (int c = 0; c < (int) song.channels.size() && found < 0; ++c)
- if (lynx::showsNotePreview (song.patterns[(std::size_t) p], c))
- found = p;
- }
- if (found >= 0)
- {
- offline.editSong ([found] (lynx::Song& s) { s.currentPattern = found; }, false);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-rack-preview.png");
- offline.editSong ([before] (lynx::Song& s) { s.currentPattern = before; }, false);
- offline.dispatchPendingMessages();
- }
- }
- ui.selectTabForSnapshot (1);
- saveSnapshot (ui, prefix + "-pianoroll.png");
- {
- // View › Keyboard style › Piano keys (round 190j, discussion #136), also with tall keys
- auto& roll = ui.getPianoRollForSnapshot();
- const auto keysBefore = lynx::PianoRollComponent::keyStyle; // (round 190oo: FL's keys are the default)
- lynx::PianoRollComponent::keyStyle = lynx::pianokeys::Style::piano;
- roll.repaint();
- saveSnapshot (ui, prefix + "-pianoroll-pianokeys.png");
- lynx::PianoRollComponent::keyStyle = lynx::pianokeys::Style::flat;
- roll.repaint();
- saveSnapshot (ui, prefix + "-pianoroll-flatkeys.png");
- lynx::PianoRollComponent::keyStyle = keysBefore;
- roll.repaint();
- // round 190j (discussion #10): the toolbar in a narrow window: the chord stamp as an icon button, and
- // the menu button still there
- for (int narrower : { 150, 270, 330 })
- {
- roll.squeezeToolbarForSnapshot (narrower);
- saveSnapshot (ui, prefix + "-pianoroll-narrow" + juce::String (narrower) + ".png");
- roll.squeezeToolbarForSnapshot (-narrower);
- }
- }
- if (const auto strip = ui.getToolStripAreaForSnapshot (false); ! strip.isEmpty())
- saveArea (ui, strip, prefix + "-pianoroll-tools.png");
- // the editors' mouse feel: the hovered note / clip edge (grip, outline) and its hint in the hint bar
- ui.setHintForSnapshot (ui.getPianoRollForSnapshot().hoverForSnapshot());
- saveSnapshot (ui, prefix + "-pianoroll-hover.png");
- {
- // a pattern with note Chance or a Velocity Range (round 187c): the Piano roll with those lanes
- const auto& song = offline.getSong();
- const auto& notes = song.patterns[(std::size_t) std::clamp (song.currentPattern, 0, (int) song.patterns.size() - 1)].notes;
- if (std::any_of (notes.begin(), notes.end(), [] (const lynx::Note& n) { return n.hasChance(); }))
- {
- auto& roll = ui.getPianoRollForSnapshot();
- ui.setHintForSnapshot ({});
- for (const auto& [lane, name] : { std::pair { lynx::PianoRollComponent::laneChance, "chance" },
- { lynx::PianoRollComponent::laneVelocityRange, "velrange" },
- { lynx::PianoRollComponent::laneVelocity, "velocity" } })
- {
- roll.setLaneForSnapshot (lane);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-pianoroll-" + name + ".png");
- }
- }
- }
- ui.selectTabForSnapshot (2);
- saveSnapshot (ui, prefix + "-playlist.png");
- {
- // round 190nr: the same with the song zoomed to fit (the site's and the Store's Playlist picture: at FL's
- // open zoom the demo song fills only the first fifth)
- auto& pl = ui.getPlaylistForSnapshot();
- const auto view = pl.viewForSnapshot();
- pl.zoomAllForSnapshot();
- saveSnapshot (ui, prefix + "-playlist-fit.png");
- pl.restoreViewForSnapshot (view);
- }
- if (const auto strip = ui.getToolStripAreaForSnapshot (true); ! strip.isEmpty())
- saveArea (ui, strip, prefix + "-playlist-tools.png");
- ui.setHintForSnapshot (ui.getPlaylistForSnapshot().hoverForSnapshot());
- saveSnapshot (ui, prefix + "-playlist-hover.png");
- ui.setHintForSnapshot ({ lynx::tr ("Volume") + " - " + lynx::tr ("drag (Ctrl: fine), wheel, Alt+click resets"), "78%", true, true });
- // the Playlist with a time selection over bars 2-3 (it selects the clips it touches) and the Knife tool
- ui.getPlaylistForSnapshot().setTimeSelectionForSnapshot (1, 3);
- ui.getPlaylistForSnapshot().setToolForSnapshot (lynx::EditTool::knife);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-timesel.png");
- ui.getPlaylistForSnapshot().setToolForSnapshot (lynx::EditTool::pencil);
- // round 177b: automation lanes on (two lanes under track 2: a volume ramp and a pan wobble)
- {
- const auto before = offline.getSong();
- offline.editSong ([] (lynx::Song& s) {
- s.loopStart = s.loopEnd = 0; // (no time selection in this one)
- const auto bar = s.barTicks();
- const auto vol = lynx::autolanes::addLane (s, 1, { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 }, "Insert 1 - Volume", 0.3f);
- s.automations[(std::size_t) vol].points = { { 0, 0.3f, 0.0f }, { bar * 2, 0.8f, 0.4f }, { bar * 4, 0.6f, 0.0f } };
- const auto pan = lynx::autolanes::addLane (s, 1, { lynx::AutomationTargetKind::mixerPan, 1, 0, 0 }, "Insert 1 - Pan", 0.5f);
- s.automations[(std::size_t) pan].points = { { 0, 0.5f, 0.0f }, { bar, 0.2f, 0.0f }, { bar * 2, 0.8f, 0.0f }, { bar * 3, 0.5f, 0.0f } };
- }, false);
- lynx::autolanes::setShown (true);
- ui.getPlaylistForSnapshot().resized();
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-lanes.png");
- lynx::autolanes::setShown (false);
- offline.editSong ([before] (lynx::Song& s) { s = before; }, false);
- offline.dispatchPendingMessages();
- }
- // round 104: a folded track group (FL's thin member rows) and the Picker's audio tab
- {
- int header = -1;
- for (int t = 0; t < (int) offline.getSong().playlistTracks.size() && header < 0; ++t)
- if (lynx::noteedit::isGroupHeader (offline.getSong(), t))
- header = t;
- if (header >= 0)
- {
- offline.editSong ([header] (lynx::Song& s) { lynx::noteedit::setGroupCollapsed (s, header, true); }, false);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-group-folded.png");
- offline.editSong ([header] (lynx::Song& s) { lynx::noteedit::setGroupCollapsed (s, header, false); }, false);
- }
- ui.getPickerForSnapshot().setView (1);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-picker-audio.png");
- ui.getPickerForSnapshot().setView (0);
- }
- // round 104: the Channel Rack filtered to its first filter group
- if (! offline.getSong().channelGroups.empty())
- {
- ui.selectTabForSnapshot (0);
- ui.getRackForSnapshot().setFilterGroup (0);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-rack-filter.png");
- ui.getRackForSnapshot().setFilterGroup (-1);
- }
- ui.selectTabForSnapshot (3);
- // LYNX_SNAPSHOT_ARRANGE=1 (round 186c): Mixer menu › "Arrange inserts like the Playlist" first
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_ARRANGE", {}) == "1")
- {
- offline.editSong ([] (lynx::Song& s) { lynx::mixerops::arrangeLikePlaylist (s); });
- offline.dispatchPendingMessages();
- }
- // LYNX_SNAPSHOT_TRACK=n: shows the effects of that mixer track
- if (const auto track = juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_TRACK", {}); track.isNotEmpty())
- {
- ui.selectMixerTrackForSnapshot (track.getIntValue(),
- juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SLOT", "-1").getIntValue());
- offline.dispatchPendingMessages();
- }
- saveSnapshot (ui, prefix + "-mixer.png");
- // round 190ir (Discord report, "it isnt picking up my audio input"): an armed insert without an input says so
- // in its input box (record colour)
- // (the first insert no channel plays into: armed without an input, it records silence)
- {
- const auto& song = offline.getSong();
- auto target = -1;
- for (int t = 1; t < (int) song.mixer.size() && target < 0; ++t)
- if (song.mixer[(std::size_t) t].inputChannel < 0
- && std::none_of (song.channels.begin(), song.channels.end(), [t] (const lynx::ChannelDef& c) { return c.mixerTrack == t; }))
- target = t;
- if (target > 0)
- {
- offline.setInsertArmed (target, true);
- ui.selectMixerTrackForSnapshot (target, -1);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer190ir-armed-noinput.png");
- offline.setInsertArmed (target, false);
- offline.dispatchPendingMessages();
- }
- }
- // round 190am: LYNX's two mixer extras, before and after (the demo project leaves most inserts unused). The
- // loudness panel shows a real measurement of 12 s of a test tone (a 1 kHz sine at -14 dBFS after a quieter
- // stretch, pushed through the Master's tap as the audio thread does)
- {
- auto& strips = ui.getMixerForSnapshot().getStripsForSnapshot();
- saveSnapshot (ui, prefix + "-mixer190am-before.png");
- strips.setShowUsedOnly (true);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer190am-usedonly.png");
- strips.setShowUsedOnly (false);
- strips.setShowLoudness (true);
- {
- const double sr = 48000.0;
- std::vector<float> tone (480);
- auto& tap = offline.getMeters().loudness;
- for (int block = 0; block < 1200; ++block)
- {
- const auto gain = std::pow (10.0, (block < 400 ? -20.0 : -14.0) / 20.0);
- for (int i = 0; i < 480; ++i)
- tone[(std::size_t) i] = (float) (gain * std::sin (2.0 * juce::MathConstants<double>::pi * 1000.0 * (block * 480 + i) / sr));
- tap.push (tone.data(), tone.data(), 480, sr);
- }
- }
- strips.refreshLoudnessForSnapshot();
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer190am-loudness.png");
- for (const auto l : { lynx::mixerlayout::Layout::compact, lynx::mixerlayout::Layout::extraLarge })
- {
- const auto was = lynx::MixerStrips::layout;
- strips.setLayout (l);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer190am-loudness-" + juce::String ((int) l) + ".png");
- strips.setLayout (was);
- }
- strips.setShowUsedOnly (true);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer190am-both.png");
- strips.setShowUsedOnly (false);
- strips.setShowLoudness (false);
- offline.dispatchPendingMessages();
- }
- // round 168h (issue #52): FL's 8 Mixer layouts
- {
- const auto before = lynx::MixerStrips::layout;
- for (int l = 0; l < lynx::mixerlayout::layoutCount; ++l)
- {
- ui.getMixerForSnapshot().getStripsForSnapshot().setLayout ((lynx::mixerlayout::Layout) l);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer168h-" + juce::String (l) + ".png");
- }
- ui.getMixerForSnapshot().getStripsForSnapshot().setLayout (before);
- offline.dispatchPendingMessages();
- }
- // round 163: the Mixer at short heights (UI zoom 150%+): the EQ folds, then the effects panel scrolls
- {
- const auto size = ui.getBounds();
- for (auto h : { 450, 560, 680, 820 })
- {
- ui.setSize (size.getWidth(), h);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer163-" + juce::String (h) + ".png");
- }
- ui.setBounds (size);
- offline.dispatchPendingMessages();
- }
- // round 170b (Busy Works Beats' review): inserts 1-3 selected and routed together to insert 4, a single effect
- // moved down into slot 2 (FL's slot places), and the plugin menus grouped by category, LYNX SHARE first
- {
- const auto before = offline.getSong();
- offline.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() < 5)
- return;
- s.mixer[1].effects.clear();
- lynx::EffectSlot fx;
- fx.kind = lynx::EffectKind::compressor;
- s.mixer[1].effects.push_back (fx);
- lynx::mixerops::moveEffectBy (s, 1, 0, 1);
- lynx::mixerops::switchSelectedRoute (s, { 1, 2, 3 }, 4, true);
- });
- ui.selectMixerTrackForSnapshot (1);
- ui.getMixerForSnapshot().getStripsForSnapshot().setSelection ({ 1, 2, 3 }, 1);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer170b.png");
- juce::PopupMenu effects, generators;
- lynx::quickpick::addFolderGroups (effects, offline, std::function<void (lynx::EffectSlot)> ([] (lynx::EffectSlot) {}));
- lynx::quickpick::addFolderViewItems (effects, offline);
- lynx::quickpick::addGeneratorMenu (generators, offline, [] (lynx::ChannelDef) {}, {}, nullptr, nullptr);
- lynx::quickpick::addFolderViewItems (generators, offline);
- saveMenus (juce::StringArray { "Mixer slot: add an effect", "Channel Rack: add" }, { effects, generators }, prefix + "-menus170b.png");
- // round 190bf (fl190be Q3): the Channel Rack's "+" menu in FL's three views, with two root entries (plugins
- // at the top of the database, in no folder) and the Categories / Simple / Tree switch at the end
- {
- auto& host = offline.getPluginHost();
- const auto keep = host.databaseFolders();
- auto folders = keep;
- int added = 0;
- for (const auto& e : lynx::quickpick::generatorEntries (offline))
- if (e.folder == 3 && e.available && added < 2) // (installed plugins: FL's root entries are such)
- {
- folders.top.insert (e.key);
- ++added;
- }
- for (const auto& e : lynx::quickpick::generatorEntries (offline))
- if (e.folder != 3 && added < 2)
- {
- folders.top.insert (e.key);
- ++added;
- }
- static const char* const views[] { "categories", "simple", "tree" };
- for (int v = 0; v < 3; ++v)
- {
- folders.view = v;
- host.setDatabaseFolders (folders);
- juce::PopupMenu plus;
- lynx::quickpick::addGeneratorMenu (plus, offline, [] (lynx::ChannelDef) {}, {}, nullptr, nullptr);
- lynx::quickpick::addFolderViewItems (plus, offline);
- saveMenus (juce::StringArray { juce::String ("Channel Rack +: ") + views[v] }, { plus }, prefix + "-menus190bf-" + views[v] + ".png");
- }
- host.setDatabaseFolders (keep);
- }
- offline.setSong (before);
- offline.dispatchPendingMessages();
- }
- // standalone windows, with the theme background
- auto saveWindow = [&prefix] (std::unique_ptr<juce::Component> c, const juce::String& name) {
- juce::Component frame;
- frame.setSize (c->getWidth(), c->getHeight());
- frame.setOpaque (true);
- // an AlertWindow is built on the desktop: shown there first, it would take the foreground from whoever has it
- // (TopLevelWindow::visibilityChanged calls toFront (true)). Off the desktop, its control that showing it would
- // have focused (what grabKeyboardFocus picks) is marked, so the picture keeps that control's focus ring
- if (c->isOnDesktop())
- {
- c->removeFromDesktop();
- auto* focus = c.get();
- for (int depth = 0; focus != nullptr && depth < 32; ++depth)
- {
- if (focus->getWantsKeyboardFocus() && (focus->isEnabled() || focus == c.get()))
- {
- focus->getProperties().set ("lynxSnapshotFocus", true);
- break;
- }
- auto traverser = focus->createKeyboardFocusTraverser();
- focus = traverser != nullptr ? traverser->getDefaultComponent (focus) : nullptr;
- }
- }
- frame.addAndMakeVisible (*c);
- c->setTopLeftPosition (0, 0);
- checkTextFit (*c, name.fromFirstOccurrenceOf ("-", false, false).upToLastOccurrenceOf (".", false, false));
- auto image = lynx::shot::paint (frame, lynx::theme::panel);
- const auto file = lynx::shot::file (juce::File (prefix + name));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (image, *out);
- };
- saveWindow (lynx::makeExportPanel (offline), "-export.png");
- saveWindow (lynx::makeExportPanel (offline, 1), "-export-mp3.png");
- saveWindow (lynx::makeExportPanel (offline, 3), "-export-flac-stems.png");
- saveWindow (lynx::makeExportPanel (offline, 4), "-export-aiff.png"); // owner decision D5
- if (lynx::aac::available())
- saveWindow (lynx::makeExportPanel (offline, 5), "-export-m4a.png");
- {
- // REA round 165f-mixer: the mixer track's Track latency / routing submenus, Disk recording, PDC, and the
- // Export window for "Render selected tracks to wave file(s)"
- const auto before = offline.getSong();
- offline.editSong ([] (lynx::Song& s) {
- if (s.mixer.size() > 3)
- {
- s.mixer[1].latencyMs = 5.0f;
- s.mixer[1].latencyBypass = lynx::LatencyBypass::whenRecordingOrStopped;
- s.mixer[2].latencyMs = -1.5f;
- }
- });
- offline.dispatchPendingMessages();
- auto& strips = ui.getMixerForSnapshot().getStripsForSnapshot();
- strips.setSelection ({ 1, 2, 3 }, 1);
- const auto menu = strips.buildMenu (1);
- juce::StringArray names { "Mixer track" };
- std::vector<juce::PopupMenu> menus { menu };
- const auto latencyPrefix = lynx::tr ("Track latency: {0}", { juce::String() });
- const juce::String wanted[] = { lynx::tr ("Selected tracks ⇄ this track"), lynx::tr ("Disk recording"),
- lynx::tr ("Plugin delay compensation") };
- for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
- {
- const auto& item = it.getItem();
- if (item.subMenu != nullptr && (item.text.startsWith (latencyPrefix) || std::find (std::begin (wanted), std::end (wanted), item.text) != std::end (wanted)))
- {
- names.add (item.text.upToFirstOccurrenceOf (":", false, false));
- menus.push_back (*item.subMenu);
- }
- }
- saveMenus (names, menus, prefix + "-menus165-mixer.png");
- saveWindow (lynx::makeExportPanelForTracks (offline, { 1, 2, 3 }), "-export165-tracks.png");
- offline.setSong (before);
- offline.dispatchPendingMessages();
- }
- saveSplashFrames (prefix);
- saveIconSheet (prefix + "-icons.png", 1.0f);
- saveIconSheet (prefix + "-icons-150.png", 1.5f);
- saveStateSheet (prefix + "-states190je.png", 1.0f); // round 190je: the one state rule, per button kind
- saveStateSheet (prefix + "-states190je-z3.png", 3.0f);
- saveWindow (lynx::MainComponent::makeHelpContent (nullptr, [] {}), "-help.png"); // (round 190ns: with its Manage shortcuts link)
- saveWindow (lynx::ui::makeTrackIconGrid (5, {}), "-trackicons168h.png"); // round 168h: the icon picker
- saveWindow (std::make_unique<lynx::toolbar::CustomizePanel> (lynx::toolbarlayout::Layout::makeDefault()), "-customize-toolbar.png");
- // two moved controls: Tools › Last tweaked and Add › Automation for last tweaked parameter show them (REA round 143)
- offline.noteTweaked ({ lynx::AutomationTargetKind::channelVolume, 0 });
- offline.noteTweaked ({ lynx::AutomationTargetKind::mixerVolume, 0 });
- saveMenus (ui, prefix + "-menus.png");
- {
- // the windows' own menus (title bars) and the toolbar's recording menu
- juce::StringArray names;
- std::vector<juce::PopupMenu> menus;
- for (auto [panel, name] : { std::pair { lynx::workspace::Panel::playlist, "Playlist" }, { lynx::workspace::Panel::channelRack, "Channel Rack" },
- { lynx::workspace::Panel::pianoRoll, "Piano Roll" }, { lynx::workspace::Panel::mixer, "Mixer" },
- { lynx::workspace::Panel::browser, "Browser" } })
- {
- names.add (name);
- menus.push_back (ui.getPanelMenuForSnapshot (panel));
- }
- names.add ("Recording");
- menus.push_back (ui.getRecordMenuForSnapshot());
- names.add ("Toolbar");
- menus.push_back (ui.getToolbarMenuForSnapshot());
- saveMenus (names, menus, prefix + "-panel-menus.png");
- }
- // round 189e: the Playlist menu's Edit and Select submenus (FL's items and order) and the header drop question
- saveMenus (juce::StringArray { "Playlist: Edit", "Playlist: Select" },
- std::vector<juce::PopupMenu> { ui.getPlaylistForSnapshot().editMenu(), ui.getPlaylistForSnapshot().selectMenu() },
- prefix + "-playlist-edit189e.png");
- saveWindow (lynx::PlaylistComponent::makeHeaderDropDialog(), "-header-drop189e.png");
- {
- // round 189i: FL's fade handle menu (right-click on an audio clip's fade handle), on the song's first audio
- // clip, or on one added for the shot
- const auto before = offline.getSong();
- auto clipIndex = -1;
- for (std::size_t i = 0; i < before.playlist.size() && clipIndex < 0; ++i)
- if (before.playlist[i].kind == lynx::ClipKind::audio)
- clipIndex = (int) i;
- if (clipIndex < 0)
- {
- auto song = before;
- lynx::ChannelDef channel;
- channel.instrument = lynx::InstrumentKind::audioClip;
- channel.name = "Audio clip";
- song.channels.push_back (channel);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = (int) song.channels.size() - 1;
- clip.length = lynx::ppq * 4;
- song.playlist.push_back (clip);
- clipIndex = (int) song.playlist.size() - 1;
- offline.setSong (song);
- offline.dispatchPendingMessages();
- }
- saveMenus (juce::StringArray { "Fade handle" },
- std::vector<juce::PopupMenu> { ui.getPlaylistForSnapshot().fadeHandleMenu (clipIndex, 1) },
- prefix + "-fade-handle189i.png");
- if (offline.getSong().playlist.size() != before.playlist.size())
- {
- offline.setSong (before);
- offline.dispatchPendingMessages();
- }
- }
- {
- // round 189n: FL's gain handle menu with two overlapping clips selected (Normalize selection individually / as a
- // group) and the later clip's fade in menu (Create crossfade enabled); FL shots in /mnt/e/lynx-work/flgap189n
- const auto before = offline.getSong();
- auto song = before;
- lynx::ChannelDef channel;
- channel.instrument = lynx::InstrumentKind::audioClip;
- channel.name = "Audio clip";
- song.channels.push_back (channel);
- int lane = 0;
- for (const auto& c : song.playlist)
- lane = std::max (lane, c.track + 1);
- for (int k = 0; k < 2; ++k)
- {
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = (int) song.channels.size() - 1;
- clip.track = lane;
- clip.start = k * lynx::ppq * 3;
- clip.length = lynx::ppq * 4;
- song.playlist.push_back (clip);
- }
- const auto second = (int) song.playlist.size() - 1;
- song.autoCrossfades = true; // FL's capture: Thief has Automatic crossfades on
- offline.setSong (song);
- offline.dispatchPendingMessages();
- auto& playlist = ui.getPlaylistForSnapshot();
- playlist.selectForSnapshot ({ second - 1, second });
- auto gain = playlist.gainMenu (second);
- auto fadeIn = playlist.fadeHandleMenu (second, 0); // (both selected, as in FL's capture)
- playlist.selectForSnapshot ({});
- saveMenus (juce::StringArray { "Gain handle, 2 selected", "Fade in, overlapping" },
- std::vector<juce::PopupMenu> { gain, fadeIn }, prefix + "-fade-gain189n.png");
- // round 189o: the audio clip menu with both overlapping clips selected (FL's Fades › Crossfade selected
- // shown) and with none selected (hidden)
- playlist.selectForSnapshot ({ second - 1, second });
- auto clipSelected = playlist.getClipMenuForSnapshot (second);
- playlist.selectForSnapshot ({});
- auto clipAlone = playlist.getClipMenuForSnapshot (second);
- saveMenus (juce::StringArray { "Audio clip, 2 selected", "Audio clip, none selected" },
- std::vector<juce::PopupMenu> { clipSelected, clipAlone }, prefix + "-xfadesel189o.png");
- offline.setSong (before);
- offline.dispatchPendingMessages();
- }
- {
- // REA round 143: the piano roll Tools menu, a Playlist track menu and a mixer insert menu (FL's layouts)
- std::vector<juce::PopupMenu> menus { ui.getPianoRollForSnapshot().getToolsMenuForSnapshot(),
- ui.getPlaylistForSnapshot().getTrackMenuForSnapshot (0),
- ui.getMixerForSnapshot().getStripsForSnapshot().buildMenu (1) };
- saveMenus (juce::StringArray { "Piano roll tools", "Playlist track", "Mixer track" }, menus, prefix + "-menus143.png");
- // round 190as: the Piano roll's scripts (FL's Tools › Scripts column) and a script's form
- saveMenus (juce::StringArray { "Piano roll scripts" }, std::vector<juce::PopupMenu> { ui.getPianoRollForSnapshot().getScriptsMenuForSnapshot() },
- prefix + "-prscripts-menu.png");
- {
- lynx::prscript::Score score;
- const auto out = lynx::prscript::run (lynx::prscript::builtins().front().source, score, {});
- if (out.status == lynx::prscript::Outcome::Status::needsForm)
- {
- lynx::ScriptPanel::Options options;
- options.acceptText = lynx::tr ("Accept");
- saveWindow (std::make_unique<lynx::ScriptPanel> (out.form, [] (const lynx::scriptform::Form&) {}, [] (const lynx::scriptform::Form&) {},
- nullptr, options),
- "-prscript-form.png");
- }
- }
- // round 190j (discussion #10): the Piano roll menu's Chord stamp list
- saveMenus (juce::StringArray { "Chord stamp" }, std::vector<juce::PopupMenu> { ui.getPianoRollForSnapshot().getStampMenuForSnapshot() },
- prefix + "-stamp-menu.png");
- // round 167l: the channel menu ("Lock active/mute state")
- if (! offline.getSong().channels.empty())
- saveMenus (juce::StringArray { "Channel" }, std::vector<juce::PopupMenu> { ui.getRackForSnapshot().getChannelMenuForSnapshot (0) }, prefix + "-channel-menu.png");
- // round 163: menu density, compact (default) and comfortable, on a Browser folder menu
- {
- juce::PopupMenu folder;
- folder.addSectionHeader ("Documents");
- folder.addItem (1, "Expand all");
- folder.addItem (2, "Collapse all");
- folder.addSeparator();
- folder.addItem (3, "Refresh");
- folder.addSectionHeader ("System");
- folder.addItem (4, "Open");
- folder.addItem (5, "Copy the file path");
- folder.addSectionHeader ("Tags");
- folder.addItem (6, "Starred", true, true);
- folder.addSeparator();
- folder.addItem (7, "Add folder...");
- const auto wasCompact = lynx::theme::menus::compact();
- lynx::theme::menus::setCompact (true);
- saveMenus (juce::StringArray { "Compact" }, { folder }, prefix + "-menu163-compact.png");
- lynx::theme::menus::setCompact (false);
- saveMenus (juce::StringArray { "Comfortable" }, { folder }, prefix + "-menu163-comfortable.png");
- lynx::theme::menus::setCompact (wasCompact);
- }
- // and the clip menus of the first pattern, audio and automation clips of the project
- juce::StringArray clipNames;
- std::vector<juce::PopupMenu> clipMenus;
- for (auto [kind, name] : { std::pair { lynx::ClipKind::pattern, "Pattern clip" }, { lynx::ClipKind::audio, "Audio clip" },
- { lynx::ClipKind::automation, "Automation clip" } })
- for (int c = 0; c < (int) offline.getSong().playlist.size(); ++c)
- if (offline.getSong().playlist[(std::size_t) c].kind == kind)
- {
- clipNames.add (name);
- clipMenus.push_back (ui.getPlaylistForSnapshot().getClipMenuForSnapshot (c));
- break;
- }
- if (! clipMenus.empty())
- saveMenus (clipNames, clipMenus, prefix + "-menus143-clips.png");
- }
- auto saveAlert = [&] (std::unique_ptr<juce::AlertWindow> alert, const juce::String& name) {
- alert->setOpaque (true);
- saveWindow (std::move (alert), name);
- };
- saveAlert (ui.makeConfirmDiscardWindow(), "-confirm.png");
- saveAlert (lynx::MainComponent::makeAboutWindow(), "-about.png");
- saveAlert (lynx::support::makeSupportWindow(), "-support.png"); // round 190fq: Help › Support LYNX SHARE...
- saveAlert (lynx::makeNameAndColourDialog (lynx::tr ("Rename pattern"), "Pattern 2", lynx::lynxPalette()[6]), "-rename.png");
- saveAlert (lynx::makeRecordChoiceDialog(), "-record-dialog.png");
- // round 190ah: Online Sessions — a guest's "go back in?" at start-up, the host's question at a guest's file limit
- saveAlert (lynx::liveui::makeRejoinDialog ("Ana", juce::Time (2026, 10, 10, 21, 40).toString (true, true, false, true)), "-live-rejoin.png");
- saveAlert (lynx::liveui::makeMediaLimitDialog ("Pedro", (juce::int64) 1010 << 20, (juce::int64) 1 << 30), "-live-media-limit.png");
- saveAlert (lynx::makeSamplePitchDialog (7.25f, true, true), "-sample-pitch.png"); // round 163c
- saveAlert (lynx::makeGradientColourDialog (juce::Colour (0xffe5383b), juce::Colour (0xff3a7bd5), 8), "-gradient.png"); // round 177a
- saveAlert (lynx::makeMidiImportDialog(), "-midi-import-dialog.png"); // File › Import › MIDI file (REA round 143)
- // round 186c: FL's mixer "Delete" questions and its Settings › General › Manage messages menu
- saveAlert (lynx::makeFlMessageDialog ({ lynx::tr ("Delete tracks"), lynx::tr ("This will |delete| {0} selected mixer track(s). Are you sure?", { "1" }),
- { lynx::tr ("Yes"), lynx::tr ("No") }, true }),
- "-delete-tracks.png");
- saveAlert (lynx::makeFlMessageDialog ({ lynx::tr ("Playlist tracks"),
- lynx::tr ("One or more mixer tracks that will be deleted are connected to instrument/audio tracks.") + "\n"
- + lynx::tr ("Do you want to unlink the tracks and channels or delete them?"),
- { lynx::tr ("Delete tracks and channels"), lynx::tr ("Unlink tracks and channels"), lynx::tr ("Cancel") }, false }),
- "-delete-tracks-linked.png");
- saveMenus (juce::StringArray { "Manage messages" }, std::vector<juce::PopupMenu> { lynx::messages::manageMenu() }, prefix + "-manage-messages.png");
- saveWindow (lynx::makeSetupWizardContent (offline, {}, {}), "-setup.png");
- saveWindow (lynx::crashreporter::makeDialogForSnapshot (false), "-crash-report.png"); // round 159
- saveWindow (lynx::crashreporter::makeDialogForSnapshot (true), "-report-problem.png");
- // round 166b: the update bar in its states (available, downloading, failed, ready) and the release notes window
- {
- struct Bars final : juce::Component
- {
- Bars()
- {
- constexpr int h = lynx::updater::UpdateBar::height;
- setSize (1100, 6 * (h + 6));
- for (int state = 0; state < 6; ++state) // (round 190gh: 4 going back, 5 went back)
- {
- bars[state].setBounds (0, state * (h + 6), getWidth(), h);
- bars[state].showForSnapshot (state);
- addAndMakeVisible (bars[state]);
- }
- }
- lynx::updater::UpdateBar bars[6];
- };
- saveWindow (std::make_unique<Bars>(), "-update-bar.png");
- saveWindow (lynx::updater::makeReleaseNotesForSnapshot(), "-update-notes.png");
- // round 190gh (B23): Help › Test audio output... in its states
- for (int state = 0; state < 5; ++state)
- saveWindow (lynx::makeAudioCheckForSnapshot (offline, state), "-audio-check-" + juce::String (state) + ".png");
- }
- saveWindow (lynx::makeMissingFilesPanel (lynx::missingFilesSnapshotInfo(), 0, 1), "-missing-files.png");
- saveWindow (lynx::makeMissingFilesPanel (lynx::missingFilesSnapshotInfo(), 1), "-missing-plugins.png");
- saveWindow (lynx::makeMissingFilesPanel (lynx::missingFilesSnapshotInfo(), 2), "-missing-found.png");
- {
- // the Settings pages, with credits like a project imported from FL would carry
- offline.editSong ([] (lynx::Song& s) {
- s.info = { "Night Drive", "LYNX SHARE demo", "Synthwave", "https://lynx-share.com",
- "Made with LYNX SHARE.\nDrums and bass from the Channel Rack, pads from the Browser.", false };
- }, false);
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::project), "-settings-project.png");
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::info), "-settings-info.png");
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::files), "-settings-files.png");
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::general), "-settings-general.png");
- {
- // round 189o: the whole General page (the Editing and Plugins sections hold FL's "Monophonic painting in
- // piano roll" and "Limit the number of open plugin editors")
- auto tall = lynx::makeSettingsPanel (offline, lynx::SettingsPage::general);
- tall->setSize (tall->getWidth(), 3200);
- saveWindow (std::move (tall), "-settings-general-tall189o.png");
- }
- {
- // the whole General page (round 186a: the Startup section is below the first screen)
- auto tall = lynx::makeSettingsPanel (offline, lynx::SettingsPage::general);
- tall->setSize (tall->getWidth(), 1500);
- saveWindow (std::move (tall), "-settings-general-tall.png");
- }
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::theme), "-settings-theme.png");
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::extras), "-settings-extras.png"); // round 190am
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::audio), "-settings-audio.png");
- saveWindow (lynx::makeSettingsPanel (offline, lynx::SettingsPage::midi), "-settings-midi.png");
- {
- // round 190bj (QA): the MIDI page in a small window keeps each row's switch and device name
- auto small = lynx::makeSettingsPanel (offline, lynx::SettingsPage::midi);
- small->setSize (390, 390);
- saveWindow (std::move (small), "-settings-midi-small.png");
- }
- {
- // round 190bj (QA): the Apex Limiter's window content at its default size, as sized before (JUCE's ratio
- // on the whole window: the status row cut off) and now
- lynx::AudioEngine apexEngine (false);
- lynx::Song song;
- song.mixer.resize (2);
- song.mixer[0].name = "Master";
- song.mixer[1].name = "Insert 1";
- song.mixer[1].effects.push_back (lynx::makeEffectSlot (lynx::EffectKind::apexLimiter));
- apexEngine.setSong (std::move (song));
- apexEngine.dispatchPendingMessages();
- savePng (lynx::ProEditorWindows::windowContentForSnapshot (apexEngine, 1, 0, true), prefix + "-apex-window-before190bj.png");
- savePng (lynx::ProEditorWindows::windowContentForSnapshot (apexEngine, 1, 0, false), prefix + "-apex-window.png");
- }
- saveWindow (lynx::makePluginManagerPanel (offline, false), "-plugin-manager.png");
- // round 190gg: the crash prompt and a plugin window's crash notice, with "Always run ... in a separate process"
- saveWindow (lynx::PluginWindows::makeCrashPromptPanel ("Serum", false), "-plugin-crash-prompt.png");
- saveWindow (lynx::PluginWindows::makeCrashNoticePanel ("Serum", true), "-plugin-crash-notice.png");
- saveWindow (lynx::makeShortcutManagerPanel (false), "-shortcuts.png");
- }
- {
- // round 84: New project, Clip properties, Arrangements, Plugin performance monitor, Touch keyboard
- saveWindow (lynx::makeNewProjectPanel(), "-new-project.png");
- const auto& clips = offline.getSong().playlist;
- for (int i = 0; i < (int) clips.size(); ++i)
- if (clips[(std::size_t) i].kind == lynx::ClipKind::pattern)
- {
- saveWindow (lynx::makeClipPropertiesPanel (offline, i, { i, (i + 1) % (int) clips.size() }), "-clip-properties.png");
- break;
- }
- for (int i = 0; i < (int) clips.size(); ++i)
- if (clips[(std::size_t) i].kind == lynx::ClipKind::audio)
- {
- saveWindow (lynx::makeClipPropertiesPanel (offline, i, { i }), "-clip-properties-audio.png");
- break;
- }
- if (offline.getSong().arrangements.size() < 2)
- offline.editSong ([] (lynx::Song& s) {
- const auto current = s.currentArrangement;
- s.addArrangement ("Radio edit", true);
- s.addArrangement ("Intro loop");
- s.selectArrangement (current);
- }, false);
- saveWindow (lynx::makeArrangementsPanel (offline), "-arrangements.png");
- saveWindow (lynx::makePluginMonitorPanel (offline), "-plugin-monitor.png");
- saveWindow (lynx::makeTouchKeyboardPanel (offline), "-touch-keyboard.png");
- }
- {
- // round 142: the Newtone / Newtime editors on a synthetic sung line (A3 B3 C4 · E4), one note moved
- const auto wav = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-snapshot-newtone.wav");
- {
- juce::AudioBuffer<float> line (1, 44100 * 2);
- const double hz[] = { 220.0, 246.94, 261.63, 0.0, 329.63 };
- double ph = 0.0;
- for (int i = 0; i < line.getNumSamples(); ++i)
- {
- const auto f0 = hz[std::min (4, i / 17640)];
- ph += 2.0 * juce::MathConstants<double>::pi * f0 * (1.0 + 0.004 * std::sin (2.0 * juce::MathConstants<double>::pi * 5.5 * i / 44100.0)) / 44100.0;
- float v = 0.0f;
- for (int h = 1; f0 > 0.0 && h < 8; ++h)
- v += (float) (0.3 / h * std::sin (h * ph));
- line.setSample (0, i, v);
- }
- wav.deleteFile();
- juce::WavAudioFormat format;
- std::unique_ptr<juce::OutputStream> out (wav.createOutputStream().release());
- if (auto* w = out != nullptr ? format.createWriterFor (out.get(), 44100.0, 1, 16, {}, 0) : nullptr)
- {
- out.release();
- std::unique_ptr<juce::AudioFormatWriter> writer (w);
- writer->writeFromAudioSampleBuffer (line, 0, line.getNumSamples());
- }
- }
- if (const auto sample = offline.getSampleLibrary().load (wav.getFullPathName()))
- {
- auto notes = lynx::newtonefx::analyseNotes (*sample);
- if (notes.pitches.size() > 1)
- notes.pitches[1].shift = 2.0;
- lynx::newtonefx::WarpMap warp;
- warp.frames = (std::int64_t) sample->frames();
- warp.markers = { { 22050, 33075 } };
- int at = 0;
- offline.editSong ([&] (lynx::Song& song) {
- if (song.mixer.size() < 2)
- song.mixer.resize (2);
- auto& fx = song.mixer[1].effects;
- auto tone = lynx::makeEffectSlot (lynx::EffectKind::newtone);
- tone.samplePath = wav.getFullPathName().toStdString();
- tone.state = lynx::newtonefx::writeNative (notes);
- auto time = lynx::makeEffectSlot (lynx::EffectKind::newtime);
- time.samplePath = tone.samplePath;
- time.state = lynx::newtonefx::writeWarp (warp);
- at = (int) fx.size();
- fx.push_back (tone);
- fx.push_back (time);
- }, false);
- saveWindow (lynx::makeNewtoneEditor (offline, 1, at), "-newtone.png");
- saveWindow (lynx::makeNewtoneEditor (offline, 1, at + 1), "-newtime.png");
- offline.editSong ([at] (lynx::Song& song) {
- auto& fx = song.mixer[1].effects;
- fx.erase (fx.begin() + at, fx.begin() + at + 2);
- }, false);
- }
- }
- if (! offline.getSong().automations.empty())
- {
- auto editor = lynx::makeAutomationEditor (offline, 0);
- editor->setSize (760, 300);
- saveWindow (std::move (editor), "-automation.png");
- // round 177b: the same clip in FL's LFO mode: FL's defaults, then one shaped state (the UI gate pairs)
- const auto before = offline.getSong().automations[0].lfo;
- const auto lfoShot = [&offline, &saveWindow] (std::function<void (lynx::AutomationLfo&)> set, const char* suffix) {
- offline.editSong ([&set] (lynx::Song& song) {
- auto& lfo = song.automations[0].lfo;
- lfo = lynx::AutomationLfo {};
- lfo.on = true;
- set (lfo);
- }, false);
- auto lfoEditor = lynx::makeAutomationEditor (offline, 0);
- lfoEditor->setSize (760, 346);
- saveWindow (std::move (lfoEditor), suffix);
- };
- lfoShot ([] (lynx::AutomationLfo&) {}, "-automation-lfo.png");
- lfoShot ([] (lynx::AutomationLfo& lfo) {
- // the state set through FL's own UI for the UI gate (TNS 50 %, SKEW 25 %, PW 25 %, two points), as FL saved it
- lfo.tension = 64;
- lfo.skew = 32;
- lfo.pulseWidth = 28;
- lfo.amp = { { 0, 0.6716f, 0.0f }, { (std::int64_t) (lynx::ppq * 1.4128), 0.9204f, 0.0f } };
- }, "-automation-lfo-shape.png");
- offline.editSong ([before] (lynx::Song& song) { song.automations[0].lfo = before; }, false);
- }
- // round 177b: LYNX's modulators window, with one routed modulator
- {
- offline.editSong ([] (lynx::Song& song) {
- lynx::Modulator m;
- m.name = "LFO 1";
- m.shape = lynx::ModShape::triangle;
- m.routes = { { { lynx::AutomationTargetKind::mixerVolume, 1, 0, 0 }, 0.25f }, { { lynx::AutomationTargetKind::mixerPan, 1, 0, 0 }, -0.5f } };
- song.modulators.push_back (m);
- lynx::Modulator r;
- r.name = "LFO 2";
- r.shape = lynx::ModShape::smoothRandom;
- r.sync = false;
- r.hz = 0.5;
- song.modulators.push_back (r);
- }, false);
- auto mods = lynx::makeModulatorsPanel (offline);
- mods->setSize (900, 420); // (round 190ox: the stage 2 rows are wider)
- saveWindow (std::move (mods), "-modulators.png");
- offline.editSong ([] (lynx::Song& song) { song.modulators.clear(); }, false);
- }
- saveWindow (lynx::makeChannelSettingsPanel (offline, 0), "-sampler.png");
- // the channel window frame (REA round 143b): header strip + tabs; the Misc tab of the first channel and of a synth
- saveWindow (lynx::makeChannelFrame (offline, 0), "-channel-frame.png");
- saveWindow (lynx::makeChannelFrame (offline, 0, -1), "-channel-misc.png");
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::synth)
- {
- saveWindow (lynx::makeChannelSettingsPanel (offline, c), "-synth.png");
- saveWindow (lynx::makeChannelModulationPanel (offline, c), "-modulation.png");
- break;
- }
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::controller)
- {
- saveWindow (lynx::makeChannelSettingsPanel (offline, c), "-controller.png");
- break;
- }
- for (const auto kind : { lynx::InstrumentKind::sakura, lynx::InstrumentKind::drumpad })
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == kind)
- {
- saveWindow (lynx::makeChannelSettingsPanel (offline, c), kind == lynx::InstrumentKind::sakura ? "-sakura.png" : "-drumpad.png");
- break;
- }
- // round 180c: Fruity Slicer's editor
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::fruityslicer)
- {
- saveWindow (lynx::makeChannelSettingsPanel (offline, c), "-fruityslicer.png");
- // rounds 190f / 190m: its Envelope / instrument page, one picture per target
- saveWindow (lynx::makeChannelFrame (offline, c, 1), "-fruityslicer-envelope.png");
- for (const auto& [target, name] : std::vector<std::pair<int, const char*>> { { 0, "panning" }, { 2, "modx" }, { 3, "mody" }, { 4, "pitch" } })
- {
- auto frame = lynx::makeChannelFrame (offline, c, 1);
- lynx::showFlVoiceTarget (*frame, target);
- saveWindow (std::move (frame), juce::String ("-fruityslicer-envelope-") + name + ".png");
- }
- break;
- }
- // round 190r: Slicex's editor
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::slicex)
- {
- saveWindow (lynx::makeChannelSettingsPanel (offline, c), "-slicex.png");
- break;
- }
- // round 190q: FPC's editor
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::fpc)
- {
- saveWindow (lynx::makeChannelSettingsPanel (offline, c), "-fpc.png");
- break;
- }
- // round 190hz: DirectWave's editor
- for (int c = 0; c < (int) offline.getSong().channels.size(); ++c)
- if (offline.getSong().channels[(std::size_t) c].instrument == lynx::InstrumentKind::directwave)
- {
- saveWindow (lynx::makeChannelSettingsPanel (offline, c), "-directwave.png");
- break;
- }
- // parametric EQ: the one with the most pronounced curve (in an imported .flp, with FL's settings)
- {
- int bestTrack = -1, bestSlot = -1;
- double bestShape = -1.0;
- const auto& mixer = offline.getSong().mixer;
- for (int t = 0; t < (int) mixer.size(); ++t)
- for (int s = 0; s < (int) mixer[(std::size_t) t].effects.size(); ++s)
- if (const auto& fx = mixer[(std::size_t) t].effects[(std::size_t) s]; fx.kind == lynx::EffectKind::parametricEq)
- {
- double shape = 0.0;
- for (double hz = 30.0; hz < 18000.0; hz *= 1.5)
- shape += std::abs (lynx::peq::responseDb (fx.params, 48000.0, hz));
- if (shape > bestShape)
- {
- bestShape = shape;
- bestTrack = t;
- bestSlot = s;
- }
- }
- if (bestTrack >= 0)
- saveWindow (lynx::makeParametricEqEditor (offline, bestTrack, bestSlot), "-peq.png");
- }
- // Note inspector for the Piano Roll's notes (its selection, or all of the channel's notes)
- if (auto inspector = ui.getPianoRollForSnapshot().makeNoteInspectorForSnapshot())
- saveWindow (std::move (inspector), "-noteinspector.png");
- if (auto inspector = ui.getPianoRollForSnapshot().makeNoteInspectorForSnapshot (true))
- saveWindow (std::move (inspector), "-noteinspector-one.png");
- // workflow P2: note tool dialogs (they preview on the pattern; each one puts the notes back when destroyed)
- {
- auto& roll = ui.getPianoRollForSnapshot();
- const std::pair<lynx::NoteTool, const char*> tools[] = { { lynx::NoteTool::strum, "-tool-strum.png" },
- { lynx::NoteTool::arpeggiate, "-tool-arpeggiate.png" },
- { lynx::NoteTool::flip, "-tool-flip.png" },
- { lynx::NoteTool::randomise, "-tool-randomise.png" },
- { lynx::NoteTool::scaleLevels, "-tool-scalelevels.png" },
- { lynx::NoteTool::limit, "-tool-limit.png" },
- { lynx::NoteTool::quantize, "-tool-quantize.png" },
- { lynx::NoteTool::chop, "-tool-chop.png" },
- { lynx::NoteTool::flam, "-tool-flam.png" },
- { lynx::NoteTool::lfo, "-tool-lfo.png" },
- { lynx::NoteTool::claw, "-tool-claw.png" },
- { lynx::NoteTool::articulate, "-tool-articulate.png" },
- { lynx::NoteTool::riffMachine, "-tool-riff.png" },
- { lynx::NoteTool::chordProgression, "-tool-chords.png" } };
- for (const auto& [tool, name] : tools)
- saveWindow (lynx::makeNoteToolPanel (offline, tool, roll.noteIndicesForSnapshot(), roll.gridForSnapshot()), name);
- }
- // round 83: the event editor, with sample events on the selected channel's volume (removed afterwards)
- {
- const lynx::AutomationTarget volume { lynx::AutomationTargetKind::channelVolume, offline.getSelectedChannel() };
- const auto before = offline.getSong().patterns[(std::size_t) offline.getSong().currentPattern].events;
- offline.editSong ([&] (lynx::Song& s) {
- auto& lane = lynx::eventedit::laneFor (s.patterns[(std::size_t) s.currentPattern], volume);
- lynx::eventedit::line (lane, 0, lynx::ppq * 2, 0.2f, 0.9f, lynx::ticksPerStep);
- lynx::prtools::LfoOptions lfo;
- lfo.startSpeed = 7 * 4096; // one beat
- lynx::eventedit::applyLfo (lane, lynx::ppq * 2, lynx::ppq * 4, lfo, lynx::ticksPerStep);
- }, false);
- saveWindow (lynx::makeEventEditor (offline, volume), "-eventeditor.png");
- offline.editSong ([&] (lynx::Song& s) { s.patterns[(std::size_t) s.currentPattern].events = before; }, false);
- // issue #86: the same editor on the Tempo target, with the project's own Tempo events (a sample ramp if none)
- const lynx::AutomationTarget tempo { lynx::AutomationTargetKind::tempo, 0 };
- offline.editSong ([&] (lynx::Song& s) {
- auto& lane = lynx::eventedit::laneFor (s.patterns[(std::size_t) s.currentPattern], tempo);
- if (lane.events.empty())
- lynx::eventedit::line (lane, 0, lynx::ppq * 2, 0.05f, 0.11f, lynx::ticksPerStep);
- }, false);
- saveWindow (lynx::makeEventEditor (offline, tempo), "-eventeditor-tempo.png");
- {
- auto compact = lynx::makeEventEditor (offline, tempo); // the toolbar in a small window
- compact->setSize (640, 300);
- saveWindow (std::move (compact), "-eventeditor-tempo-small.png");
- auto narrowest = lynx::makeEventEditor (offline, tempo); // the tool window's lower limit
- narrowest->setSize (400, 300);
- saveWindow (std::move (narrowest), "-eventeditor-tempo-narrowest.png");
- }
- offline.editSong ([&] (lynx::Song& s) { s.patterns[(std::size_t) s.currentPattern].events = before; }, false);
- }
- // round 86: the audio editor with a synthetic drum loop (markers, a region, a loop), waveform and spectrogram,
- // and its menu items (-audioeditor-menu.txt)
- {
- namespace ae = lynx::audioedit;
- ae::Document d;
- d.title = "Drum loop";
- d.audio.sampleRate = 44100.0;
- const auto frames = (std::size_t) (44100 * 2);
- d.audio.channels.assign (2, std::vector<float> (frames, 0.0f));
- std::uint32_t seed = 7;
- for (int hit = 0; hit < 8; ++hit)
- {
- const auto at = (std::size_t) hit * frames / 8;
- const auto kick = hit % 2 == 0;
- double phase = 0.0;
- for (std::size_t i = 0; i < 12000 && at + i < frames; ++i)
- {
- seed = seed * 1664525u + 1013904223u;
- const auto noise = (float) (seed >> 8) / 16777216.0f - 0.5f;
- const auto t = (double) i / 44100.0;
- phase += 2.0 * 3.141592653589793 * (kick ? 45.0 + 160.0 * std::exp (-t * 30.0) : 190.0) / 44100.0;
- const auto body = (float) std::sin (phase) * (float) std::exp (-t * (kick ? 9.0 : 22.0));
- const auto v = kick ? 0.85f * body : 0.35f * body + 0.6f * noise * (float) std::exp (-t * 18.0);
- d.audio.channels[0][at + i] += v;
- d.audio.channels[1][at + i] += kick ? v : v * 0.8f + 0.1f * noise * (float) std::exp (-t * 30.0);
- }
- }
- ae::addMarker (d, (std::int64_t) frames / 8, "Snare");
- ae::addRegion (d, { (std::int64_t) frames / 2, (std::int64_t) frames * 3 / 4 }, "Fill");
- ae::setLoop (d, { 0, (std::int64_t) frames });
- auto wave = lynx::makeAudioEditorForSnapshot (offline, d, false);
- juce::File (prefix + "-audioeditor-menu.txt").replaceWithText (lynx::audioEditorMenuForSnapshot (*wave).joinIntoString ("\n") + "\n");
- saveWindow (std::move (wave), "-audioeditor.png");
- saveWindow (lynx::makeAudioEditorForSnapshot (offline, d, true), "-audioeditor-spectrum.png");
- }
- // warp markers (round 175a, M3): the audio editor of the first audio clip whose channel has warp markers,
- // opened as the Playlist opens it, with its warp lane
- {
- const auto& song = offline.getSong();
- for (int i = 0; i < (int) song.playlist.size(); ++i)
- {
- const auto& c = song.playlist[(std::size_t) i];
- if (c.kind == lynx::ClipKind::audio && juce::isPositiveAndBelow (c.channel, (int) song.channels.size())
- && song.channels[(std::size_t) c.channel].sampler.warp.size() >= 3)
- {
- if (auto panel = lynx::makeAudioEditorPanel (offline, c.channel, i, true))
- saveWindow (std::move (panel), "-audioeditor-warp.png");
- break;
- }
- }
- }
- // the tempo tapper after five steady taps (round 132)
- saveWindow (lynx::makeTempoTapperForSnapshot (offline, 5, 128.0), "-tempotapper.png");
- // the Channel Rack's piano-roll view (round 132)
- ui.selectTabForSnapshot (0);
- ui.getRackForSnapshot().setPianoRollView (true);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-rack-pianoroll-view.png");
- ui.getRackForSnapshot().setPianoRollView (false);
- // the Channel Rack with the step graph lane (velocity), and the Euclidean fill window
- ui.selectTabForSnapshot (0);
- ui.getRackForSnapshot().setGraphLevelForSnapshot (0);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-rack-graph.png");
- ui.getRackForSnapshot().setGraphLevelForSnapshot (1);
- saveSnapshot (ui, prefix + "-rack-graph-pan.png");
- // FL's Note pitch, Shift and Repeat lanes (issue #208)
- ui.getRackForSnapshot().setGraphLevelForSnapshot ((int) lynx::notetools::Level::notePitch);
- saveSnapshot (ui, prefix + "-rack-graph-pitch.png");
- ui.getRackForSnapshot().setGraphLevelForSnapshot ((int) lynx::notetools::Level::shift);
- saveSnapshot (ui, prefix + "-rack-graph-shift.png");
- ui.getRackForSnapshot().setGraphLevelForSnapshot ((int) lynx::notetools::Level::repeat);
- saveSnapshot (ui, prefix + "-rack-graph-repeat.png");
- ui.getRackForSnapshot().toggleGraphLanes();
- saveWindow (ui.getRackForSnapshot().makeEuclideanPanel (0), "-euclidean.png");
- // the Mixer with three inserts selected and one armed for recording
- ui.selectTabForSnapshot (3);
- if (offline.getSong().mixer.size() > 4)
- {
- ui.getMixerForSnapshot().getStripsForSnapshot().setSelection ({ 1, 2, 3 }, 2);
- offline.setInsertArmed (3, true);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer-multi.png");
- // the armed insert with an audio input (its input row in the side panel, the level bar on the strip)
- offline.editSong ([] (lynx::Song& s) { s.mixer[3].inputChannel = 0; });
- ui.getMixerForSnapshot().selectTrack (3);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer-input.png");
- offline.undo();
- offline.setInsertArmed (3, false);
- ui.getMixerForSnapshot().getStripsForSnapshot().setSelection ({}, 0);
- }
- // the Mixer's routing lane: an insert with sends selected (send knobs and wires)
- if (offline.getSong().mixer.size() > 6)
- {
- int source = -1;
- for (int t = 1; t < (int) offline.getSong().mixer.size() && source < 0; ++t)
- if (! offline.getSong().mixer[(std::size_t) t].sends.empty())
- source = t;
- const auto temporary = source < 0;
- if (temporary) // the demo has no sends: add two for the picture
- {
- source = 1;
- offline.editSong ([] (lynx::Song& s) { s.setRoute (1, 5, true, 0.6f); s.setRoute (1, 6, true, 0.3f); s.setRoute (4, 1, true, 0.8f); });
- }
- ui.getMixerForSnapshot().selectTrack (source);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer-sends.png");
- if (temporary)
- offline.editSong ([] (lynx::Song& s) { s.setRoute (1, 5, false); s.setRoute (1, 6, false); s.setRoute (4, 1, false); });
- ui.getMixerForSnapshot().selectTrack (0);
- }
- // round 190io (issue #154 part 2): the Mixer view that lists each strip's insert effects (a LYNX view, off by
- // default), with an insert selected whose sends light the route arrows
- {
- auto& strips = ui.getMixerForSnapshot().getStripsForSnapshot();
- strips.setShowStripInserts (true);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-mixer190io-inserts.png");
- strips.setShowStripInserts (false);
- offline.dispatchPendingMessages();
- }
- // the Playlist with ripple editing on
- ui.selectTabForSnapshot (2);
- ui.getPlaylistForSnapshot().setRipple (true);
- saveSnapshot (ui, prefix + "-playlist-ripple.png");
- ui.getPlaylistForSnapshot().setRipple (false);
- // FL's legacy Pattern Blocks (round 170f, issue #60): the section under the clip tracks, a row per pattern
- {
- const auto saved = offline.getSong();
- offline.editSong ([] (lynx::Song& s) {
- s.patternBlocksOn = true;
- while (s.patterns.size() < 5) // a few rows to show (Drums, Bass...: copies of the demo's pattern)
- lynx::clonePattern (s, (int) s.patterns.size() - 1);
- const auto rows = juce::jmin (6, (int) s.patterns.size());
- for (int r = 0; r < rows; ++r)
- lynx::patternblocks::paintRange (s, r, (std::int64_t) (r % 3) * 4 * lynx::ppq * 2,
- (std::int64_t) (8 + r * 2) * 4 * lynx::ppq);
- }, false);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-blocks.png");
- // issue #127 (PR #132 and our follow-up): the Playlist's pencil, brush and eraser on the blocks, driven
- // with real mouse events on the view. One picture per tool, and the gestures' results in
- // <prefix>-playlist-blocks-tools.txt ("OK", or the checks that failed).
- if (auto* blocks = ui.getPlaylistForSnapshot().getBlocksViewForSnapshot())
- {
- juce::StringArray failed;
- const auto expect = [&failed] (bool ok, const char* what) { if (! ok) failed.add (what); };
- const auto bar = offline.getSong().barTicks();
- offline.editSong ([bar] (lynx::Song& s) {
- s.blocks.clear();
- for (std::size_t r = 0; r < 4 && r < s.patterns.size(); ++r)
- s.patterns[r].lengthTicks = r == 1 ? 2 * bar : bar; // row 2 holds a 2-bar pattern
- }, false);
- offline.dispatchPendingMessages();
- const auto source = juce::Desktop::getInstance().getMainMouseSource();
- const juce::ModifierKeys left (juce::ModifierKeys::leftButtonModifier), right (juce::ModifierKeys::rightButtonModifier);
- juce::Point<float> pressedAt;
- const auto event = [&] (int row, std::int64_t tick, juce::ModifierKeys mods) {
- const auto at = blocks->pointForSnapshot (row, tick).toFloat();
- const auto now = juce::Time::getCurrentTime();
- return juce::MouseEvent (source, at, mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, blocks, blocks, now, pressedAt, now, 1, false);
- };
- const auto press = [&] (int row, std::int64_t tick, juce::ModifierKeys mods) {
- pressedAt = blocks->pointForSnapshot (row, tick).toFloat();
- blocks->mouseDown (event (row, tick, mods));
- };
- const auto dragTo = [&] (int row, std::int64_t tick, juce::ModifierKeys mods) { blocks->mouseDrag (event (row, tick, mods)); };
- const auto release = [&] (int row, std::int64_t tick) { blocks->mouseUp (event (row, tick, {})); };
- // the starts of row `row`'s blocks, as "0,2,5" (bars from 0)
- const auto rowBars = [&] (int row) {
- juce::StringArray bars;
- for (const auto& b : offline.getSong().blocks)
- if (b.pattern == row)
- bars.add (juce::String (b.start / bar) + (b.start % bar != 0 ? "+" : ""));
- return bars.joinIntoString (",");
- };
- auto& tools = ui.getPlaylistForSnapshot();
- // Pencil: a press on empty space places one block that follows the mouse along its row
- tools.setToolForSnapshot (lynx::EditTool::pencil);
- press (0, 2 * bar + 40, left);
- expect (rowBars (0) == "2", "pencil: a press places one block");
- dragTo (2, 5 * bar + 40, left); // (over another row: the block stays in its own)
- release (2, 5 * bar + 40);
- expect (rowBars (0) == "5" && rowBars (2).isEmpty(), "pencil: the placed block follows the drag in its row");
- // a 2-bar block grabbed by its second bar keeps that bar under the mouse (it used to jump a bar)
- press (1, 1 * bar + 40, left);
- release (1, 1 * bar + 40);
- expect (rowBars (1) == "1", "pencil: a click places the 2-bar block");
- press (1, 2 * bar + 40, left);
- dragTo (1, 2 * bar + bar / 2, left);
- expect (rowBars (1) == "1", "move: a small move on the grabbed bar leaves the block in place");
- dragTo (1, 4 * bar + 40, left);
- release (1, 4 * bar + 40);
- expect (rowBars (1) == "3", "move: the grabbed bar stays under the mouse");
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-blocks-pencil.png");
- // Brush: a drag over empty space paints a run; a press on a block moves it
- tools.setToolForSnapshot (lynx::EditTool::brush);
- press (2, 0, left);
- dragTo (2, 3 * bar + 40, left);
- release (2, 3 * bar + 40);
- expect (rowBars (2) == "0,1,2,3", "brush: a drag paints a run");
- press (2, 3 * bar + 40, left);
- dragTo (2, 6 * bar + 40, left);
- release (2, 6 * bar + 40);
- expect (rowBars (2) == "0,1,2,6", "brush: a press on a block moves it");
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-blocks-brush.png");
- // Eraser, and the right button with any tool: only the blocks under the mouse, row by row
- offline.editSong ([bar] (lynx::Song& s) {
- for (int r = 0; r < 4 && r < (int) s.patterns.size(); ++r)
- lynx::patternblocks::place (s, r, 8 * bar);
- }, false);
- offline.dispatchPendingMessages();
- expect (rowBars (0) == "5,8" && rowBars (3) == "8", "eraser: the column is set up");
- saveSnapshot (ui, prefix + "-playlist-blocks-eraser-before.png");
- tools.setToolForSnapshot (lynx::EditTool::eraser);
- press (0, 8 * bar + 40, left);
- expect (rowBars (0) == "5" && rowBars (1) == "3,8" && rowBars (2) == "0,1,2,6,8" && rowBars (3) == "8",
- "eraser: a click takes only the block under the mouse");
- dragTo (1, 8 * bar + 60, left); // down one row: that row's block goes too, the rows below stay
- release (1, 8 * bar + 60);
- expect (rowBars (1) == "3" && rowBars (2) == "0,1,2,6,8" && rowBars (3) == "8", "eraser: the drag erases the rows it crosses, no others");
- tools.setToolForSnapshot (lynx::EditTool::pencil);
- press (3, 8 * bar + 40, right);
- release (3, 8 * bar + 40);
- expect (rowBars (3).isEmpty() && rowBars (2) == "0,1,2,6,8", "right click: erases only the block under the mouse");
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-playlist-blocks-eraser.png");
- juce::File (prefix + "-playlist-blocks-tools.txt").replaceWithText (failed.isEmpty() ? juce::String ("OK\n") : "ERROR\n" + failed.joinIntoString ("\n") + "\n");
- }
- offline.editSong ([saved] (lynx::Song& s) { s = saved; }, false);
- offline.dispatchPendingMessages();
- }
- // quick-add palette, and the Browser searching
- saveWindow (ui.makeQuickAddForSnapshot(), "-quickadd.png");
- ui.showDesktopForSnapshot (false);
- ui.getBrowserForSnapshot().setSearchForSnapshot ("kick");
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser-search.png");
- ui.getBrowserForSnapshot().setSearchForSnapshot ({});
- ui.getBrowserForSnapshot().selectFirstSampleForSnapshot(); // the tree with a sample selected and its waveform
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser-tree.png");
- // the Browser's PROJECT tab: the patterns, generators and audio files of the project in their colours
- ui.getBrowserForSnapshot().showProjectForSnapshot();
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser-project.png");
- ui.getBrowserForSnapshot().showPluginDatabaseForSnapshot(); // round 142: the Plugin database's FL engines
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser-plugins.png");
- // round 190bf (fl190be Q1): the Plugin database's right-click menus, a folder's and an entry's (FL's System group)
- saveMenus (juce::StringArray { "Plugin database: folder", "Plugin database: entry" }, ui.getBrowserForSnapshot().pluginDatabaseMenusForSnapshot(),
- prefix + "-browser190bf-menus.png");
- ui.getBrowserForSnapshot().setTab (lynx::BrowserComponent::allTab);
- saveWindow (ui.getBrowserForSnapshot().makeFoldersPanelForSnapshot(), "-browser-folders.png"); // round 164
- {
- // round 164: the content filter leaves out the folders with nothing to list (a small library)
- const auto lib = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-snapshot-library");
- lib.deleteRecursively();
- for (const auto* path : { "Drums/Kicks/kick 1.wav", "Drums/Kicks/kick 2.wav", "Drums/snare.wav", "Keys/pad.sf2", "Presets/Synth/lead.fst",
- "Projects/beat.flp", "Projects/MIDI/chords.mid", "Notes/readme.txt", "Empty/Nothing/.keep" })
- lib.getChildFile (path).create();
- ui.showDesktopForSnapshot (false);
- ui.getBrowserForSnapshot().showFilterForSnapshot (lib, lynx::browserview::ContentFilter::all);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser164-all.png");
- ui.getBrowserForSnapshot().showFilterForSnapshot (lib, lynx::browserview::ContentFilter::samples);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser164-samples.png");
- ui.getBrowserForSnapshot().showFilterForSnapshot (lib, lynx::browserview::ContentFilter::projects);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser164-projects.png");
- lib.deleteRecursively();
- ui.getBrowserForSnapshot().resetViewForSnapshot();
- }
- {
- // round 190as: "Find similar samples" on a small library of kicks, hats and pads (LYNX_SNAPSHOT_SIMILAR =
- // "<folder>|<file>" lists a real folder instead)
- auto lib = juce::File::getSpecialLocation (juce::File::tempDirectory).getChildFile ("lynx-snapshot-similar");
- auto query = lib.getChildFile ("Drums/Kicks/Kick 2.wav");
- const auto real = juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_SIMILAR", {});
- const auto made = real.isEmpty();
- if (made)
- {
- lib.deleteRecursively();
- juce::Random random (190);
- const auto write = [&] (const juce::String& path, char kind, int v) {
- const auto rate = 44100.0;
- const auto frames = (int) (rate * (kind == 'k' ? 0.35 : kind == 'h' ? 0.09 : 2.5));
- juce::AudioBuffer<float> audio (1, frames);
- double phase = 0.0;
- float last = 0.0f;
- for (int i = 0; i < frames; ++i)
- {
- const auto t = i / rate;
- float x = 0.0f;
- if (kind == 'k')
- {
- phase += juce::MathConstants<double>::twoPi * ((46.0 + 3.0 * v) + 150.0 * std::exp (-t * 35.0)) / rate;
- x = (float) (std::sin (phase) * std::exp (-t * (8.0 + v)));
- }
- else if (kind == 'h')
- {
- const auto n = random.nextFloat() * 2.0f - 1.0f;
- x = (n - last) * 0.5f * (float) std::exp (-t * (50.0 + 12.0 * v));
- last = n;
- }
- else
- {
- const auto base = 220.0 * std::pow (2.0, v / 12.0);
- x = (float) (0.25 * std::min (1.0, t / 0.4) * std::min (1.0, (2.5 - t) / 0.5)
- * (std::sin (juce::MathConstants<double>::twoPi * base * t) + std::sin (juce::MathConstants<double>::twoPi * base * 1.5 * t)));
- }
- audio.setSample (0, i, 0.8f * x);
- }
- const auto file = lib.getChildFile (path);
- file.getParentDirectory().createDirectory();
- juce::WavAudioFormat wav;
- if (auto out = file.createOutputStream())
- if (auto writer = std::unique_ptr<juce::AudioFormatWriter> (wav.createWriterFor (out.release(), rate, 1, 16, {}, 0)))
- writer->writeFromAudioSampleBuffer (audio, 0, frames);
- };
- for (int v = 1; v <= 5; ++v)
- {
- write ("Drums/Kicks/Kick " + juce::String (v) + ".wav", 'k', v);
- write ("Drums/Hats/Hat " + juce::String (v) + ".wav", 'h', v);
- write ("Keys/Pad " + juce::String (v) + ".wav", 'p', v);
- }
- }
- else
- {
- lib = juce::File (real.upToFirstOccurrenceOf ("|", false, false));
- query = juce::File (real.fromFirstOccurrenceOf ("|", false, false));
- }
- ui.showDesktopForSnapshot (false);
- ui.getBrowserForSnapshot().showFilterForSnapshot (lib, lynx::browserview::ContentFilter::all);
- ui.getBrowserForSnapshot().findSimilarForSnapshot (query, lib);
- offline.dispatchPendingMessages();
- saveSnapshot (ui, prefix + "-browser-similar.png");
- ui.getBrowserForSnapshot().setSearchForSnapshot ({});
- if (made)
- lib.deleteRecursively();
- ui.getBrowserForSnapshot().resetViewForSnapshot();
- }
- // the undo history after a few edits
- offline.editSong ([] (lynx::Song& s) { s.bpm += 1.0; });
- offline.editSong ([] (lynx::Song& s) { if (! s.channels.empty()) s.channels[0].muted = ! s.channels[0].muted; });
- offline.editSong ([] (lynx::Song& s) { if (! s.patterns.empty()) s.patterns[(std::size_t) s.currentPattern].notes.push_back ({}); });
- offline.undo();
- saveWindow (lynx::makeHistoryPanel (offline), "-history.png");
- // spectral waveforms: a synthetic beat (kick, hats, a chord, a noise riser) as audio clips in spectral
- // colours, zoomed in, classic and stereo; the same file in the Sampler editor and the Browser preview
- {
- const juce::File wav (prefix + "-wavedemo.wav");
- writeWaveDemo (wav, offline.getSong().bpm);
- const auto path = wav.getFullPathName();
- const auto pathUtf8 = path.toStdString();
- int samplerChannel = -1, firstTrack = 0;
- offline.editSong ([&] (lynx::Song& s) {
- for (const auto& clip : s.playlist)
- firstTrack = std::max (firstTrack, clip.track + 1);
- lynx::ChannelDef audio;
- audio.name = "Beat (audio)";
- audio.instrument = lynx::InstrumentKind::audioClip;
- audio.samplePath = pathUtf8;
- s.channels.push_back (audio);
- const auto audioChannel = (int) s.channels.size() - 1;
- lynx::ChannelDef sampler = audio;
- sampler.name = "Beat (sampler)";
- sampler.instrument = lynx::InstrumentKind::sampler;
- sampler.sampler.regionStart = 0.06f;
- sampler.sampler.regionEnd = 0.94f;
- s.channels.push_back (sampler);
- samplerChannel = (int) s.channels.size() - 1;
- const auto bar = s.barTicks();
- const auto whole = (std::int64_t) std::llround (8.0 * s.bpm / 60.0 * lynx::ppq);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = audioChannel;
- clip.track = firstTrack;
- clip.length = whole;
- s.playlist.push_back (clip);
- clip.track = firstTrack + 1; // a slice of it, later in the song
- clip.start = bar;
- clip.offset = bar;
- clip.length = 2 * bar;
- s.playlist.push_back (clip);
- // taller rows for the audio (tracks can be resized: P18)
- if ((int) s.playlistTracks.size() < firstTrack + 2)
- s.playlistTracks.resize ((std::size_t) firstTrack + 2);
- s.playlistTracks[(std::size_t) firstTrack].height = 80;
- s.playlistTracks[(std::size_t) firstTrack + 1].height = 60;
- });
- offline.dispatchPendingMessages();
- auto& cache = *lynx::ui::WaveformCache::getInstance();
- cache.find (path, [&offline, path] { return offline.getSampleLibrary().load (path); });
- cache.waitUntilIdle (30000);
- ui.selectTabForSnapshot (2);
- auto& playlist = ui.getPlaylistForSnapshot();
- playlist.setTimeSelectionForSnapshot (0, 0);
- {
- // the Playlist alone (the floating Channel Rack would cover the clips)
- auto saveSnapshot = [&playlist] (juce::Component&, const juce::String& file) { saveArea (playlist, playlist.getLocalBounds(), file); };
- playlist.setViewForSnapshot (180.0, 0, std::max (0, firstTrack - 3));
- saveSnapshot (ui, prefix + "-playlist-audio.png");
- playlist.setViewForSnapshot (1400.0, 0, std::max (0, firstTrack - 3));
- saveSnapshot (ui, prefix + "-playlist-audio-zoom.png");
- lynx::ui::WaveformCache::stereo = true;
- saveSnapshot (ui, prefix + "-playlist-audio-stereo.png");
- lynx::ui::WaveformCache::stereo = false;
- lynx::ui::WaveformCache::spectral = true;
- playlist.setViewForSnapshot (180.0, 0, std::max (0, firstTrack - 3));
- saveSnapshot (ui, prefix + "-playlist-audio-spectral.png");
- lynx::ui::WaveformCache::spectral = false;
- playlist.setViewForSnapshot (40.0, 0, 0);
- saveSnapshot (ui, prefix + "-playlist-audio-far.png");
- // LYNX_SNAPSHOT_AUDIO=a.wav;b.wav...: real audio as clips (default-height tracks, one tall,
- // a fade, a reversed copy), at three zoom levels
- if (const auto files = juce::StringArray::fromTokens (juce::SystemStats::getEnvironmentVariable ("LYNX_SNAPSHOT_AUDIO", {}), ";", "");
- ! files.isEmpty())
- {
- const auto realTrack = firstTrack + 2;
- std::vector<juce::String> paths;
- for (const auto& f : files)
- if (juce::File (f.trim()).existsAsFile())
- paths.push_back (f.trim());
- offline.editSong ([&] (lynx::Song& s) {
- const auto bar = s.barTicks();
- const std::uint32_t colours[] = { 0, 0xffd9a441, 0xff6fb36a, 0xffb06fd0, 0xff5fb7c9, 0xffd06f6f };
- for (std::size_t i = 0; i < paths.size(); ++i)
- {
- lynx::ChannelDef audio;
- audio.name = juce::File (paths[i]).getFileNameWithoutExtension().toStdString();
- audio.instrument = lynx::InstrumentKind::audioClip;
- audio.samplePath = paths[i].toStdString();
- audio.colour = colours[i % 6];
- audio.sampler.stretchBeats = i % 2 == 0 ? 16.0f : 0.0f; // fitted to 4 bars, or as recorded
- audio.sampler.keepPitch = true;
- s.channels.push_back (audio);
- lynx::Clip clip;
- clip.kind = lynx::ClipKind::audio;
- clip.channel = (int) s.channels.size() - 1;
- clip.track = realTrack + (int) i;
- clip.length = 4 * bar;
- clip.fadeIn = i == 1 ? bar / 2 : 0;
- s.playlist.push_back (clip);
- clip.start = 4 * bar;
- clip.fadeIn = 0;
- clip.fadeOut = i == 0 ? bar : 0;
- s.playlist.push_back (clip);
- }
- if ((int) s.playlistTracks.size() < realTrack + (int) paths.size())
- s.playlistTracks.resize ((std::size_t) realTrack + paths.size());
- if (! paths.empty())
- s.playlistTracks[(std::size_t) realTrack].height = 90;
- });
- offline.dispatchPendingMessages();
- for (const auto& path2 : paths)
- cache.find (path2, [&offline, path2] { return offline.getSampleLibrary().load (path2); });
- cache.waitUntilIdle (60000);
- playlist.setViewForSnapshot (160.0, 0, std::max (0, realTrack - 4));
- saveSnapshot (ui, prefix + "-playlist-real.png");
- playlist.setViewForSnapshot (700.0, 0, std::max (0, realTrack - 1));
- saveSnapshot (ui, prefix + "-playlist-real-zoom.png");
- playlist.setViewForSnapshot (2400.0, 0, std::max (0, realTrack - 1));
- saveSnapshot (ui, prefix + "-playlist-real-close.png");
- playlist.setViewForSnapshot (50.0, 0, std::max (0, realTrack - 4));
- saveSnapshot (ui, prefix + "-playlist-real-far.png");
- // the clip menu of the first real clip
- if (const auto menu = playlist.getClipMenuForSnapshot ((int) offline.getSong().playlist.size() - (int) paths.size() * 2); menu.getNumItems() > 0)
- saveMenus (juce::StringArray { "Audio clip" }, std::vector<juce::PopupMenu> { menu }, prefix + "-clip-menu-audio.png");
- if (const auto menu = playlist.getClipMenuForSnapshot (0); menu.getNumItems() > 0)
- saveMenus (juce::StringArray { "Pattern clip" }, std::vector<juce::PopupMenu> { menu }, prefix + "-clip-menu-pattern.png");
- // the clip menu's actions, run through the menu itself; results in -clip-actions.txt
- {
- juce::StringArray log;
- auto clipOf = [&offline] (const std::string& channelName, int nth) {
- const auto& sg = offline.getSong();
- for (int i = 0; i < (int) sg.playlist.size(); ++i)
- {
- const auto& c = sg.playlist[(std::size_t) i];
- if (c.kind == lynx::ClipKind::audio && c.channel >= 0 && sg.channels[(std::size_t) c.channel].name == channelName && nth-- == 0)
- return i;
- }
- return -1;
- };
- std::function<bool (const juce::PopupMenu&, const juce::String&)> run = [&run] (const juce::PopupMenu& m, const juce::String& text) {
- for (juce::PopupMenu::MenuItemIterator it (m); it.next();)
- {
- auto& item = it.getItem();
- if (item.subMenu != nullptr && run (*item.subMenu, text))
- return true;
- // (without the menu mnemonic's mark: FL's underlined letters, round 190dz)
- if (item.text.removeCharacters (juce::String::charToString (1)).startsWith (text) && item.isEnabled && item.action)
- {
- item.action();
- return true;
- }
- }
- return false;
- };
- auto act = [&] (const std::string& name, int nth, const juce::String& text) {
- const auto clip = clipOf (name, nth);
- const auto ok = clip >= 0 && run (playlist.getClipMenuForSnapshot (clip), text);
- offline.dispatchPendingMessages();
- return ok;
- };
- auto channelOf = [&] (const std::string& name) -> const lynx::ChannelDef* {
- for (const auto& c : offline.getSong().channels)
- if (c.name == name)
- return &c;
- return nullptr;
- };
- auto check = [&log] (const juce::String& what, bool ok) { log.add ((ok ? "OK " : "FAIL ") + what); };
- const auto names = [&] { std::vector<std::string> n; for (auto& p2 : paths) n.push_back (juce::File (p2).getFileNameWithoutExtension().toStdString()); return n; }();
- if (names.size() >= 4)
- {
- const auto channelsBefore = offline.getSong().channels.size();
- check ("Reverse", act (names[2], 0, lynx::tr ("Reverse")) && channelOf (names[2])->sampler.reverse);
- offline.undo();
- offline.dispatchPendingMessages();
- check ("Reverse undone", ! channelOf (names[2])->sampler.reverse);
- act (names[2], 0, lynx::tr ("Reverse"));
- check ("Make unique", act (names[3], 1, lynx::tr ("Make unique")) && offline.getSong().channels.size() == channelsBefore + 1
- && channelOf (names[3] + " #2") != nullptr);
- check ("Fit to tempo, resample", act (names[1], 0, lynx::tr ("Fit to tempo, resample ({0})", { juce::String() }).upToFirstOccurrenceOf ("(", false, false))
- && channelOf (names[1])->sampler.stretchBeats > 0.0f && ! channelOf (names[1])->sampler.keepPitch);
- const auto gainBefore = offline.getSong().playlist[(std::size_t) clipOf (names[0], 1)].gain;
- check ("Normalize", act (names[0], 1, lynx::tr ("Normalize"))
- && offline.getSong().playlist[(std::size_t) clipOf (names[0], 1)].gain != gainBefore);
- const auto clipsBefore = offline.getSong().playlist.size();
- check ("Split here", act (names[3], 0, lynx::tr ("Split here")) && offline.getSong().playlist.size() == clipsBefore + 1);
- check ("Mute", act (names[0], 0, lynx::tr ("Mute")) && offline.getSong().playlist[(std::size_t) clipOf (names[0], 0)].muted);
- check ("Copy + Paste here", act (names[0], 0, lynx::tr ("Copy")) && act (names[0], 1, lynx::tr ("Paste here"))
- && offline.getSong().playlist.size() == clipsBefore + 2);
- check ("Delete", act (names[0], 2, lynx::tr ("Delete")) && offline.getSong().playlist.size() == clipsBefore + 1);
- check ("Chop to grid", act (names[3], 0, lynx::tr ("Chop to grid")) && offline.getSong().playlist.size() > clipsBefore + 1);
- }
- playlist.setViewForSnapshot (160.0, 0, std::max (0, realTrack - 4));
- saveSnapshot (ui, prefix + "-playlist-real-actions.png");
- juce::File (prefix + "-clip-actions.txt").replaceWithText (log.joinIntoString ("\n") + "\n");
- }
- }
- }
- saveWindow (lynx::makeChannelSettingsPanel (offline, samplerChannel), "-sampler-wave.png");
- ui.showDesktopForSnapshot (false);
- ui.getBrowserForSnapshot().showPreviewForSnapshot (wav);
- saveSnapshot (ui, prefix + "-browser-preview.png");
- }
- }
- // round 165o: every Label / button / tick box whose text the drawing squeezes below its minimum scale or cuts
- // (an ellipsis), per language: `LYNX --lang de --snapshot shots/de` -> shots/de-textfit.txt
- juce::File (prefix + "-textfit.txt").replaceWithText (textFitLog().joinIntoString ("\n") + "\n");
- juce::LookAndFeel::setDefaultLookAndFeel (nullptr);
- quit();
- }
- // --snapshot: 8 s of a synthetic stereo beat whose parts sit in different bands (kick = low, chord = mid,
- // hats and the noise riser = high), to show the spectral waveform colours
- #include "BrowserShot190iz.inc" // round 190iz
- #include "LynxModelShot190ni.inc" // round 190ni
- #include "UndoGesture190jv.inc" // round 190jv
- #include "TrimShot190jv.inc" // round 190jv
- #include "PrChordShot190kd.inc" // round 190kd
- #include "ModalShot190mc.inc" // round 190mc
- #include "KeysShot190nu.inc" // round chord2_190nu
- #include "SectionsShot190ol.inc" // round 190ol (research190oe P1 / P6)
- #include "ChordLaneShot190pf.inc" // round 190pf (research190oe P13 / P12)
- #include "PrShot190jv.inc" // round 190jv
- #include "HostPlay190ll.inc" // round 190ll (issue #199)
- #include "IssuesShot190ll.inc" // round 190ll (issues #200, #201, #203)
- #include "IssuesShot190qr.inc" // round 190qr (issues #274-#281: the FL | LYNX pictures)
- #include "SimpleGbShot190ke.inc" // round 190ke
- #include "LoopShot190kf.inc" // round gaps190kf
- #include "QaRest190lcShot.inc" // rollup 0.1.30 step 7 (round 190lc)
- #include "LoopInfoShot190kx.inc" // round 190kx
- static void writeWaveDemo (const juce::File& file, double bpm)
- {
- constexpr double rate = 44100.0;
- const auto frames = (int) (8.0 * rate);
- juce::AudioBuffer<float> buffer (2, frames);
- buffer.clear();
- auto* l = buffer.getWritePointer (0);
- auto* r = buffer.getWritePointer (1);
- const auto beat = 60.0 / juce::jlimit (40.0, 300.0, bpm);
- std::uint32_t noise = 0x9e3779b9u;
- auto white = [&noise] {
- noise ^= noise << 13;
- noise ^= noise >> 17;
- noise ^= noise << 5;
- return (float) (noise & 0xffffff) / (float) 0x800000 - 1.0f;
- };
- float previous = 0.0f;
- for (int i = 0; i < frames; ++i)
- {
- const auto t = i / rate;
- const auto inBeat = std::fmod (t, beat);
- const auto bar = (int) (t / (beat * 4.0));
- float left = 0.0f, right = 0.0f;
- // kick on every beat: a falling sine
- {
- const auto phase = 2.0 * juce::MathConstants<double>::pi * (48.0 * inBeat + 4.0 * (1.0 - std::exp (-inBeat * 30.0)));
- const auto k = (float) (std::sin (phase) * std::exp (-inBeat * 7.0)) * 0.85f;
- left += k;
- right += k;
- }
- // hats on the off-beats: high-passed noise bursts, a little to the right
- {
- const auto h = std::fmod (t + beat * 0.5, beat);
- const auto n = white();
- const auto hp = (n - previous) * 0.5f;
- previous = n;
- const auto hat = hp * (float) std::exp (-h * 45.0) * 0.55f;
- left += hat * 0.6f;
- right += hat;
- }
- // a chord in the second and third bars (mid band)
- if (bar == 1 || bar == 2)
- {
- const auto env = (float) std::min (1.0, std::min (t - beat * 4.0, beat * 12.0 - t) * 8.0);
- float chord = 0.0f;
- for (const auto hz : { 523.25, 659.25, 783.99 })
- chord += (float) (std::sin (2.0 * juce::MathConstants<double>::pi * hz * t) + 0.3 * std::sin (4.0 * juce::MathConstants<double>::pi * hz * t));
- left += chord * 0.09f * std::max (0.0f, env);
- right += chord * 0.09f * std::max (0.0f, env);
- }
- // a white-noise riser over the last two seconds (high band)
- if (t > 6.0)
- {
- const auto rise = (float) ((t - 6.0) / 2.0);
- left += white() * 0.4f * rise * rise;
- right += white() * 0.4f * rise * rise;
- }
- l[i] = left;
- r[i] = right;
- }
- buffer.applyGain (0.9f / juce::jmax (1.0e-6f, buffer.getMagnitude (0, frames)));
- file.deleteFile();
- juce::WavAudioFormat wav;
- if (std::unique_ptr<juce::AudioFormatWriter> writer { wav.createWriterFor (file.createOutputStream().release(), rate, 2, 24, {}, 0) })
- writer->writeFromAudioSampleBuffer (buffer, 0, frames);
- }
- // the menu bar's menus side by side, drawn with the LookAndFeel as they appear when opened
- static void saveMenus (lynx::MainComponent& ui, const juce::String& path)
- {
- const auto names = ui.getMenuNamesForSnapshot();
- std::vector<juce::PopupMenu> source;
- for (int m = 0; m < names.size(); ++m)
- source.push_back (ui.getMenuForSnapshot (m));
- saveMenus (names, source, path);
- }
- // menus side by side, each under its name, in the columns JUCE shows them in: its own column breaks, or (round 190je,
- // cmake/LynxPatchJuce.cmake fix 40) the split of a menu taller than 70 % of a 1080 px screen
- static void saveMenus (const juce::StringArray& names, const std::vector<juce::PopupMenu>& source, const juce::String& path)
- {
- auto& lf = juce::LookAndFeel::getDefaultLookAndFeel();
- struct Row
- {
- const juce::PopupMenu::Item* item;
- int height;
- };
- struct Laid
- {
- juce::PopupMenu menu;
- std::vector<std::vector<Row>> columns;
- std::vector<int> widths;
- int width = 0, height = 0;
- };
- std::vector<Laid> menus;
- menus.reserve ((std::size_t) names.size());
- const auto border = lf.getPopupMenuBorderSize();
- const auto separatorWidth = lf.getPopupMenuColumnSeparatorWidthWithOptions (juce::PopupMenu::Options());
- for (int m = 0; m < names.size(); ++m)
- {
- menus.push_back (Laid { source[(std::size_t) m] });
- auto& laid = menus.back();
- std::vector<Row> rows;
- std::vector<lynx::themes::MenuRow> shape;
- std::vector<int> breaks;
- for (juce::PopupMenu::MenuItemIterator it (laid.menu); it.next();)
- {
- const auto& item = it.getItem();
- int w = 0, h = 0;
- if (item.customComponent != nullptr)
- item.customComponent->getIdealSize (w, h); // (a title band: its own height, as JUCE asks it)
- else
- lf.getIdealPopupMenuItemSize (item.text, item.isSeparator, item.isSectionHeader ? -1 : 0, w, h);
- if (item.isSectionHeader) h += h / 2; // as JUCE does
- rows.push_back ({ &item, h });
- shape.push_back ({ h, item.isSeparator, item.isSectionHeader });
- if (item.shouldBreakAfter)
- breaks.push_back ((int) rows.size() - 1);
- }
- if (breaks.empty())
- if (const auto at = lynx::themes::tallMenuBreak (shape, 1080 * 7 / 10); at >= 0)
- breaks.push_back (at);
- laid.columns.emplace_back();
- laid.widths.push_back (160);
- for (int i = 0; i < (int) rows.size(); ++i)
- {
- const auto& item = *rows[(std::size_t) i].item;
- int w = 0, h = 0;
- if (item.customComponent != nullptr)
- item.customComponent->getIdealSize (w, h);
- else
- lf.getIdealPopupMenuItemSize (item.text, item.isSeparator, item.isSectionHeader ? -1 : 0, w, h);
- if (item.shortcutKeyDescription.isNotEmpty() || item.text.containsChar ('\t'))
- w += 90;
- laid.columns.back().push_back (rows[(std::size_t) i]);
- laid.widths.back() = juce::jmax (laid.widths.back(), w + 10);
- if (std::find (breaks.begin(), breaks.end(), i) != breaks.end() && i + 1 < (int) rows.size())
- {
- laid.columns.emplace_back();
- laid.widths.push_back (160);
- }
- }
- laid.width = (int) (laid.columns.size() - 1) * separatorWidth;
- for (std::size_t c = 0; c < laid.columns.size(); ++c)
- {
- laid.width += laid.widths[c];
- int h = 2 * border;
- for (const auto& row : laid.columns[c])
- h += row.height;
- laid.height = juce::jmax (laid.height, h);
- }
- }
- int totalWidth = 16, totalHeight = 0;
- for (const auto& l : menus)
- {
- totalWidth += l.width + 16;
- totalHeight = juce::jmax (totalHeight, l.height + 32);
- }
- auto image = lynx::shot::canvas (totalWidth, totalHeight);
- {
- juce::Graphics g (image);
- lynx::shot::logical (g);
- g.fillAll (lynx::theme::colour::bg1);
- int x = 16;
- bool first = true;
- for (int m = 0; m < (int) menus.size(); ++m)
- {
- const auto& l = menus[(std::size_t) m];
- g.setColour (lynx::theme::colour::textSecondary);
- g.setFont (lynx::theme::font (lynx::theme::type::small, true));
- g.drawText (names[m], x, 0, l.width, 24, juce::Justification::centredLeft);
- {
- juce::Graphics::ScopedSaveState state (g);
- g.reduceClipRegion (x, 24, l.width, l.height);
- g.setOrigin (x, 24);
- lf.drawPopupMenuBackground (g, l.width, l.height);
- int columnX = 0;
- for (std::size_t c = 0; c < l.columns.size(); ++c)
- {
- int y = border;
- for (const auto& row : l.columns[c])
- {
- const auto& item = *row.item;
- const juce::Rectangle<int> r (columnX + (c == 0 ? border : 0), y, l.widths[c] - (c == 0 ? border : 0) - (c + 1 == l.columns.size() ? border : 0),
- row.height);
- auto text = item.text, shortcut = item.shortcutKeyDescription;
- if (text.containsChar ('\t'))
- {
- shortcut = text.fromFirstOccurrenceOf ("\t", false, false);
- text = text.upToFirstOccurrenceOf ("\t", false, false);
- }
- if (item.isSectionHeader)
- lf.drawPopupMenuSectionHeader (g, r, text);
- else if (item.customComponent != nullptr)
- {
- juce::Graphics::ScopedSaveState itemState (g);
- g.setOrigin (r.getPosition());
- item.customComponent->setSize (r.getWidth(), r.getHeight());
- item.customComponent->paintEntireComponent (g, false);
- }
- else
- lf.drawPopupMenuItem (g, r, item.isSeparator, item.isEnabled, first && ! item.isSeparator && m == 0, item.isTicked,
- item.subMenu != nullptr, text, shortcut, item.image.get(), nullptr);
- first = false;
- y += row.height;
- }
- columnX += l.widths[c];
- if (c + 1 < l.columns.size())
- {
- lf.drawPopupMenuColumnSeparatorWithOptions (g, juce::Rectangle<int> (columnX, border, separatorWidth, l.height - 2 * border),
- juce::PopupMenu::Options());
- columnX += separatorWidth;
- }
- }
- }
- x += l.width + 16;
- }
- }
- const auto file = lynx::shot::file (juce::File (path));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (image, *out);
- }
- static void writePng (const juce::Image& image, const juce::String& path)
- {
- const auto file = lynx::shot::file (juce::File (path));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (image, *out);
- }
- // the splash screen: one settled frame, and a strip of frames through its animation
- static void saveSplashFrames (const juce::String& prefix)
- {
- lynx::SplashScreen splash;
- splash.setStatus (lynx::tr ("Loading the workspace..."));
- splash.setTimeForSnapshot (1.6);
- writePng (lynx::shot::snapshot (splash), prefix + "-splash.png");
- const double times[] = { 0.10, 0.22, 0.29, 0.40, 0.58, 0.75, 1.00, 1.30 };
- const auto w = lynx::SplashScreen::width / 2, h = lynx::SplashScreen::height / 2;
- auto strip = lynx::shot::canvas (4 * (w + 8) + 8, 2 * (h + 8) + 8);
- {
- juce::Graphics g (strip);
- lynx::shot::logical (g);
- g.fillAll (lynx::theme::colour::bg1);
- for (int i = 0; i < 8; ++i)
- {
- splash.setTimeForSnapshot (times[i]);
- const auto frame = lynx::shot::snapshot (splash);
- g.drawImage (frame, 8 + (i % 4) * (w + 8), 8 + (i / 4) * (h + 8), w, h, 0, 0, frame.getWidth(), frame.getHeight());
- }
- }
- writePng (strip, prefix + "-splash-frames.png");
- }
- // every icon at 16, 20 and 24 px (at `scale`, e.g. 1.5 for a 150% display), in the toolbar's
- // colours: at rest, hovered and switched on
- // round 190je (design190ia G1): one state sheet per button kind: idle, hover, pressed, on, disabled, as the one state rule
- // draws them (core/ThemePalette.h buttonLook); the menu rows in both menu styles
- static void saveStateSheet (const juce::String& path, float scale)
- {
- using namespace lynx;
- scale *= shot::scale();
- auto& lf = juce::LookAndFeel::getDefaultLookAndFeel();
- const int labelWidth = 220, cellW = 120, cellH = 40, columns = 5;
- const juce::String heads[] = { "idle", "hover", "pressed", "on", "disabled" };
- enum Kind { text, iconFilled, iconOnce, iconSwitch, iconSwitchOwn, tick, radio, combo, tab, menuDark, menuFl, kinds };
- const char* names[] = { "Text button", "Icon button (filled)", "Toolbar icon (acts once)", "Toolbar switch", "Toolbar switch (own colours)",
- "Tick box", "Radio choice", "Combo box", "Tab", "Menu item (LYNX dark)", "Menu item (FL classic)" };
- const auto w = labelWidth + columns * cellW + 16, h = 30 + kinds * cellH + 16;
- juce::Image image (juce::Image::ARGB, juce::roundToInt ((float) w * scale), juce::roundToInt ((float) h * scale), true);
- {
- juce::Graphics g (image);
- g.addTransform (juce::AffineTransform::scale (scale));
- g.fillAll (theme::colour::bg3);
- g.setFont (theme::font (theme::type::small, true));
- g.setColour (theme::colour::textSecondary);
- for (int c = 0; c < columns; ++c)
- g.drawText (heads[c], labelWidth + c * cellW, 6, cellW, 20, juce::Justification::centred);
- const auto styleBefore = theme::menus::style();
- for (int k = 0; k < kinds; ++k)
- {
- const auto y = 30 + k * cellH;
- g.setFont (theme::font (theme::type::small));
- g.setColour (theme::colour::textPrimary);
- g.drawText (names[k], 8, y, labelWidth - 12, cellH, juce::Justification::centredLeft);
- for (int c = 0; c < columns; ++c)
- {
- const auto hover = c == 1, down = c == 2, on = c == 3, disabled = c == 4;
- const juce::Rectangle<int> cell (labelWidth + c * cellW, y, cellW, cellH);
- juce::Graphics::ScopedSaveState state (g);
- g.reduceClipRegion (cell);
- switch (k)
- {
- case text:
- {
- juce::TextButton b ("Export");
- b.setSize (96, 26);
- b.setToggleState (on, juce::dontSendNotification);
- b.setEnabled (! disabled);
- g.setOrigin (cell.getX() + 12, cell.getY() + 7);
- lf.drawButtonBackground (g, b, b.findColour (on ? juce::TextButton::buttonOnColourId : juce::TextButton::buttonColourId), hover, down);
- lf.drawButtonText (g, b, hover, down);
- break;
- }
- case iconFilled:
- case iconOnce:
- case iconSwitch:
- case iconSwitchOwn:
- {
- IconButton b ("state", k == iconFilled ? Icon::plus : k == iconOnce ? Icon::save : Icon::metronome);
- b.setFlat (k != iconFilled);
- if (k == iconSwitch)
- b.setToggleLook (true);
- if (k == iconSwitchOwn)
- {
- b.setOnColour (theme::colour::bg6);
- b.setIconColourWhenOn (theme::colour::accent);
- }
- b.setSize (k == iconFilled ? 34 : 30, 30);
- b.setToggleState (on, juce::dontSendNotification);
- b.setEnabled (! disabled);
- g.setOrigin (cell.getX() + 12, cell.getY() + 5);
- b.paintButton (g, hover, down);
- break;
- }
- case tick:
- case radio:
- {
- juce::ToggleButton b (k == tick ? "Snap to grid" : "Pattern");
- if (k == radio)
- b.getProperties().set ("lynxRadio", true);
- b.setSize (110, 24);
- b.setToggleState (on, juce::dontSendNotification);
- b.setEnabled (! disabled);
- g.setOrigin (cell.getX() + 6, cell.getY() + 8);
- lf.drawToggleButton (g, b, hover, down);
- break;
- }
- case combo:
- {
- if (hover || down || on) // (a combo box's hover comes from the mouse itself: --uitest covers it)
- break;
- juce::ComboBox b;
- b.setSize (100, 24);
- b.setEnabled (! disabled);
- g.setOrigin (cell.getX() + 10, cell.getY() + 8);
- lf.drawComboBox (g, 100, 24, false, 0, 0, 0, 0, b);
- g.setColour (disabled ? theme::colour::textDisabled : theme::colour::textPrimary);
- g.setFont (lf.getComboBoxFont (b));
- g.drawText ("1/16 step", 6, 0, 70, 24, juce::Justification::centredLeft);
- break;
- }
- case tab:
- {
- if (disabled)
- break;
- juce::TabbedButtonBar bar (juce::TabbedButtonBar::TabsAtTop);
- bar.setSize (220, 32);
- bar.addTab ("Audio", theme::colour::bg2, -1);
- bar.addTab ("MIDI", theme::colour::bg2, -1);
- bar.setCurrentTabIndex (on ? 1 : 0, false);
- auto* tabButton = bar.getTabButton (1);
- tabButton->setBounds (0, 0, 100, 32);
- g.setOrigin (cell.getX() + 10, cell.getY() + 4);
- g.setColour (theme::colour::bg1);
- g.fillRect (0, 0, 100, 32);
- lf.drawTabButton (*tabButton, g, hover, down);
- break;
- }
- case menuDark:
- case menuFl:
- {
- if (down)
- break;
- theme::menus::setStyle (k == menuFl ? themes::MenuStyle::flClassic : themes::MenuStyle::lynxDark);
- g.setOrigin (cell.getX() + 4, cell.getY() + 8);
- lf.drawPopupMenuBackground (g, 112, 25);
- lf.drawPopupMenuItem (g, { 2, 2, 108, 21 }, false, ! disabled, hover, on, false, theme::mnemonic ("Open", 'O'), "Ctrl+O", nullptr, nullptr);
- theme::menus::setStyle (styleBefore);
- break;
- }
- default:
- break;
- }
- }
- }
- }
- writePng (image, path);
- }
- static void saveIconSheet (const juce::String& path, float scale)
- {
- scale *= lynx::shot::scale();
- const int sizes[] = { 16, 20, 24 };
- const int cell = 34, columns = 3 * 3, labelWidth = 110;
- const auto w = labelWidth + columns * cell + 16, h = lynx::iconCount * cell + 16;
- juce::Image image (juce::Image::ARGB, juce::roundToInt ((float) w * scale), juce::roundToInt ((float) h * scale), true);
- {
- juce::Graphics g (image); // (drawing is flushed when it goes out of scope)
- g.addTransform (juce::AffineTransform::scale (scale));
- g.fillAll (lynx::theme::colour::bg3);
- g.setFont (lynx::theme::font (lynx::theme::type::small));
- for (int i = 1; i < lynx::iconCount; ++i)
- {
- const auto y = 8 + (i - 1) * cell;
- g.setColour (lynx::theme::colour::textDisabled);
- g.drawText (juce::String (i), 8, y, labelWidth - 8, cell, juce::Justification::centredLeft);
- for (int v = 0; v < 3; ++v)
- for (int s = 0; s < 3; ++s)
- {
- const juce::Rectangle<float> box ((float) (labelWidth + (v * 3 + s) * cell), (float) y, (float) cell, (float) cell);
- const auto bg = v == 2 ? lynx::theme::colour::accent : v == 1 ? lynx::theme::colour::bg5 : lynx::theme::colour::bg3;
- g.setColour (bg);
- g.fillRoundedRectangle (box.reduced (2.0f), 4.0f);
- const auto fg = v == 2 ? lynx::theme::colour::onAccent : v == 1 ? lynx::theme::colour::textPrimary
- : lynx::theme::colour::textSecondary.brighter (0.25f);
- lynx::icons::draw (g, (lynx::Icon) i, box.withSizeKeepingCentre ((float) sizes[s], (float) sizes[s]), fg);
- }
- }
- }
- writePng (image, path);
- }
- // a part of a component (e.g. the main toolbar)
- static void saveArea (juce::Component& c, juce::Rectangle<int> area, const juce::String& path)
- {
- const auto file = lynx::shot::file (juce::File (path));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (lynx::shot::snapshot (c, area), *out);
- }
- static void savePng (const juce::Image& image, const juce::String& path)
- {
- const auto file = lynx::shot::file (juce::File (path));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (image, *out);
- }
- // -toolbar-tips.png: the top of the window with the bubbles of a few controls as they appear under the
- // mouse; -tips-sheet.png: every quick tip of the window, to check names, shortcuts and translations
- static void saveQuickTips (lynx::MainComponent& ui, const juce::String& prefix)
- {
- const auto tips = ui.getQuickTipsForSnapshot();
- const auto top = juce::Rectangle<int> (0, 0, ui.getWidth(), juce::jmin (ui.getHeight(), ui.getToolbarBoundsForSnapshot().getHeight() + 72));
- auto image = lynx::shot::snapshot (ui, top);
- {
- juce::Graphics g (image);
- lynx::shot::logical (g);
- const juce::String shown[] = { lynx::tr ("Pattern mode"), lynx::tr ("Play"), lynx::tr ("Metronome"), lynx::tr ("Mixer"), lynx::tr ("Save project"),
- lynx::tr ("Window options"), lynx::tr ("Close") };
- std::vector<juce::Rectangle<int>> used;
- for (const auto& [area, tip] : tips)
- {
- const auto name = tip.upToFirstOccurrenceOf ("\t", false, false);
- if (std::find (std::begin (shown), std::end (shown), name) == std::end (shown))
- continue;
- const auto bubble = lynx::ui::quickTipBounds (tip, area, top);
- if (std::any_of (used.begin(), used.end(), [&] (const auto& r) { return r.intersects (bubble); }))
- continue;
- used.push_back (bubble);
- g.setColour (juce::Colours::white.withAlpha (0.075f)); // the hovered control
- g.fillRoundedRectangle (area.toFloat().reduced (0.5f), lynx::theme::radius::md);
- lynx::ui::paintQuickTip (g, bubble.toFloat(), tip);
- }
- }
- savePng (image, prefix + "-toolbar-tips.png");
- // the sheet: bubbles in rows
- const int width = 900;
- int x = 12, y = 12;
- std::vector<std::pair<juce::Rectangle<int>, juce::String>> placed;
- for (const auto& [area, tip] : tips)
- {
- auto r = lynx::ui::quickTipSize (tip);
- if (x + r.getWidth() > width - 12)
- {
- x = 12;
- y += r.getHeight() + 10;
- }
- placed.emplace_back (r.withPosition (x, y), tip);
- x += r.getWidth() + 10;
- }
- auto sheet = lynx::shot::canvas (width, y + 20 + 12);
- {
- juce::Graphics g (sheet);
- lynx::shot::logical (g);
- g.fillAll (lynx::theme::colour::bg3);
- for (const auto& [r, tip] : placed)
- lynx::ui::paintQuickTip (g, r.toFloat(), tip);
- }
- savePng (sheet, prefix + "-tips-sheet.png");
- }
- static juce::StringArray& textFitLog()
- {
- static juce::StringArray log;
- return log;
- }
- // drawFittedText would shrink `text` below `minScale` or cut it: fewer visible glyphs than the text has
- static bool textIsCut (const juce::Font& font, const juce::String& text, juce::Rectangle<int> area, int maxLines, float minScale)
- {
- if (text.trim().isEmpty() || area.getWidth() <= 4 || area.getHeight() <= 4)
- return false;
- auto visible = [] (juce::GlyphArrangement& ga) {
- int n = 0;
- for (int i = 0; i < ga.getNumGlyphs(); ++i)
- n += ga.getGlyph (i).isWhitespace() ? 0 : 1;
- return n;
- };
- juce::GlyphArrangement fitted, full;
- fitted.addFittedText (font, text, 0.0f, 0.0f, (float) area.getWidth(), (float) area.getHeight(), juce::Justification::centredLeft,
- juce::jmax (1, maxLines), minScale);
- full.addLineOfText (font, text, 0.0f, 0.0f);
- return visible (fitted) < visible (full);
- }
- // walks the visible components under `root` and logs the texts that don't fit (labels, text buttons, tick boxes)
- static void checkTextFit (juce::Component& root, const juce::String& where)
- {
- std::function<void (juce::Component&)> visit = [&] (juce::Component& c) {
- if (! c.isVisible() || c.getWidth() <= 0 || c.getHeight() <= 0)
- return;
- juce::String text;
- bool cut = false;
- if (auto* label = dynamic_cast<juce::Label*> (&c); label != nullptr && ! label->isBeingEdited())
- {
- const auto font = label->getLookAndFeel().getLabelFont (*label);
- const auto area = label->getBorderSize().subtractedFrom (label->getLocalBounds());
- text = label->getText();
- cut = textIsCut (font, text, area, juce::jmax (1, (int) ((float) area.getHeight() / font.getHeight())),
- label->getMinimumHorizontalScale());
- }
- else if (auto* toggle = dynamic_cast<juce::ToggleButton*> (&c))
- {
- const auto tick = juce::jmin (16.0f, (float) c.getHeight() - 4.0f);
- text = toggle->getButtonText();
- cut = textIsCut (juce::Font (lynx::theme::font (juce::jmin ((float) lynx::theme::type::body, (float) c.getHeight() * 0.75f))), text,
- c.getLocalBounds().withTrimmedLeft (juce::roundToInt (tick) + 8).withTrimmedRight (2), 2, 0.85f);
- }
- else if (auto* button = dynamic_cast<juce::TextButton*> (&c);
- button != nullptr && (int) button->getProperties().getWithDefault (lynx::theme::LookAndFeel::iconProperty, 0) == 0)
- {
- text = button->getButtonText();
- cut = textIsCut (button->getLookAndFeel().getTextButtonFont (*button, button->getHeight()), text,
- button->getLocalBounds().reduced (juce::jmin (8, button->getWidth() / 6), 0), 2, 0.85f);
- }
- if (cut)
- {
- juce::String path;
- for (auto* p = &c; p != nullptr && p != &root; p = p->getParentComponent())
- if (p->getName().isNotEmpty())
- path = p->getName() + (path.isEmpty() ? "" : "/") + path;
- const auto line = where + " | " + juce::String (c.getWidth()) + "x" + juce::String (c.getHeight()) + " | " + text.replace ("\n", "\\n")
- + (path.isEmpty() ? juce::String() : " | " + path);
- textFitLog().addIfNotAlreadyThere (line);
- }
- for (auto* child : c.getChildren())
- visit (*child);
- };
- visit (root);
- }
- static void saveSnapshot (juce::Component& c, const juce::String& path)
- {
- checkTextFit (c, juce::File (path).getFileNameWithoutExtension());
- const auto file = lynx::shot::file (juce::File (path));
- file.deleteFile();
- juce::PNGImageFormat png;
- if (auto out = file.createOutputStream())
- png.writeImageToStream (lynx::shot::snapshot (c), *out);
- }
- class MainWindow final : public juce::DocumentWindow
- {
- public:
- MainWindow (const juce::String& name, lynx::AudioEngine& engine)
- : DocumentWindow (name, lynx::theme::window, DocumentWindow::allButtons, false)
- {
- probeEngine = &engine;
- // (round 190hd) one desktop window, made with the native title bar: before, JUCE made one with its own title
- // bar and setUsingNativeTitleBar made it again (~20-35 ms each, the Direct2D context included)
- setUsingNativeTitleBar (true);
- addToDesktop();
- setIcon (lynx::logoImage());
- startupTrace.mark (" window: its desktop window (native title bar), icon");
- content = new lynx::MainComponent (engine);
- setContentOwned (content, true);
- startupTrace.mark (" window: content set");
- setResizable (true, true);
- setResizeLimits (800, 400, 10000, 10000);
- // ~88% of the main display's usable area (at least the UI's design size, but never larger than the
- // display: the AppImage catalog test runs on an 800x600 screen)
- if (const auto* display = juce::Desktop::getInstance().getDisplays().getPrimaryDisplay())
- {
- const auto area = display->userArea;
- const auto fit = [] (int design, int available) {
- return juce::jmin (available, juce::jmax (design, (int) (available * 0.88)));
- };
- setSize (fit (getWidth(), area.getWidth()), fit (getHeight(), area.getHeight()));
- }
- centreWithSize (getWidth(), getHeight());
- // where it was last time (round 167v); the first start opens maximized, the Playlist filling the screen
- // with the Browser at the left and the Channel Rack above it, like FL Studio's first start
- const auto saved = stateFile().loadFileAsString().trim();
- // (LYNX_TEST_MODE keeps the fixed-size window scripted checks expect, unless LYNX_TEST_MAXIMIZE=1)
- const auto firstStart = saved.isEmpty()
- && (! lynx::platform::testMode() || juce::SystemStats::getEnvironmentVariable ("LYNX_TEST_MAXIMIZE", {}) == "1");
- maximiseOnReveal = firstStart || saved.startsWithIgnoreCase ("fs");
- if (saved.isNotEmpty())
- restoreWindowStateFromString (saved.startsWithIgnoreCase ("fs") ? saved.substring (2).trim() : saved);
- }
- // Shows the window (built hidden while the splash screen is up).
- void reveal()
- {
- if (lynx::uitrace::enabled()) // LYNX_TRACE_UI: the frames per second and the longest gap in ui.log (round 173f)
- watchFrames ({});
- setVisible (true);
- // LYNX_LOCATOR_PROBE=1 (round 190ip, measurements): a floating window with a locator moving 30 times a second
- if (juce::SystemStats::getEnvironmentVariable ("LYNX_LOCATOR_PROBE", {}) == "1")
- juce::Timer::callAfterDelay (1500, [e = probeEngine] {
- lynx::ui::openLocatorProbe ([e] {
- const auto& transport = e->getTransport();
- const auto bar = (double) juce::jmax<std::int64_t> (1, e->getSong().barTicks());
- return transport.playing.load() ? std::fmod (transport.positionTicks.load(), bar) / bar : -1.0;
- });
- });
- lynx::applyWindowChrome (*this);
- lynx::fitWindowOnScreen (*this); // a size saved at another UI zoom still fits (round 163)
- if (maximiseOnReveal)
- setFullScreen (true); // (a title-bar window: maximized, the taskbar stays)
- toFront (true);
- content->grabKeyboardFocus();
- // issue #62: the detached panels restored with the layout (built before this window was shown): their saved
- // place and above it, once the window manager has placed this one
- juce::Timer::callAfterDelay (250, [safe = juce::Component::SafePointer<MainWindow> (this)] {
- if (safe != nullptr)
- safe->content->restoreDetachedWindows();
- });
- }
- // Runs `then` once, right after the window's next frame (round 190go: the audio device opens behind the
- // window's first frame, not before it); at the latest after 300 ms (a window that paints nothing: minimised).
- void whenPainted (std::function<void()> then)
- {
- afterPaint = std::move (then);
- afterPaintPosted = false;
- repaint();
- juce::Timer::callAfterDelay (300, [safe = juce::Component::SafePointer<MainWindow> (this)] {
- if (safe != nullptr)
- safe->runAfterPaint();
- });
- }
- void runAfterPaint()
- {
- if (auto then = std::exchange (afterPaint, nullptr))
- then();
- }
- // The window's place and maximized state for the next start (main-window.txt in the settings folder).
- void saveState() { stateFile().replaceWithText (getWindowStateAsString()); }
- static juce::File stateFile() { return lynx::PluginHost::settingsFolder().getChildFile ("main-window.txt"); }
- void openFile (const juce::File& file) { content->openFile (file); }
- lynx::MainComponent& getContent() { return *content; }
- void showSetupWizard() { content->showSetupWizard(); }
- void confirmDiscard (std::function<void()> then) { content->confirmDiscard (std::move (then)); }
- void closeButtonPressed() override { JUCEApplication::getInstance()->systemRequestedQuit(); }
- // Every frame the window paints, with its dirty area (ui/FrameProbe.h; --uiperf, LYNX_TRACE_UI). The trace keeps
- // counting when --uiperf watches too.
- void watchFrames (std::function<void (double, juce::Rectangle<int>)> callback)
- {
- if (probe == nullptr)
- {
- probe = std::make_unique<lynx::ui::FrameProbe>();
- Component::addAndMakeVisible (*probe); // (ResizableWindow hides the plain overload)
- probe->setBounds (getLocalBounds());
- }
- probe->onFrame = [callback = std::move (callback)] (double now, juce::Rectangle<int> area) {
- if (lynx::uitrace::enabled())
- lynx::uitrace::frame (now);
- if (callback)
- callback (now, area);
- };
- }
- void resized() override
- {
- DocumentWindow::resized();
- if (probe != nullptr)
- probe->setBounds (getLocalBounds());
- }
- // --uiperf: the time of each frame the window paints (its own paint, then every child's, up to the last)
- std::function<void (double)> onFrame;
- void paint (juce::Graphics& g) override
- {
- if (onFrame)
- frameStart = juce::Time::getMillisecondCounterHiRes();
- DocumentWindow::paint (g);
- }
- void paintOverChildren (juce::Graphics& g) override
- {
- DocumentWindow::paintOverChildren (g);
- if (afterPaint != nullptr && ! std::exchange (afterPaintPosted, true)) // (the frame is presented first)
- juce::MessageManager::callAsync ([safe = juce::Component::SafePointer<MainWindow> (this)] {
- if (safe != nullptr)
- safe->runAfterPaint();
- });
- if (onFrame && frameStart > 0.0)
- onFrame (juce::Time::getMillisecondCounterHiRes() - frameStart);
- frameStart = 0.0;
- }
- private:
- lynx::MainComponent* content = nullptr; // owned by the window
- std::unique_ptr<lynx::ui::FrameProbe> probe; // (on top of the content; see watchFrames)
- double frameStart = 0.0;
- bool maximiseOnReveal = false;
- std::function<void()> afterPaint; // (whenPainted)
- lynx::AudioEngine* probeEngine = nullptr; // (LYNX_LOCATOR_PROBE)
- bool afterPaintPosted = false;
- JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
- };
- lynx::theme::LookAndFeel lookAndFeel;
- std::unique_ptr<lynx::AudioEngine> engine;
- std::unique_ptr<lynx::RemoteControl> remoteControl;
- std::unique_ptr<juce::XmlElement> savedDeviceState; // --rtstress: the user's device before this run's --type/--buffer
- // Hidden test mode --asiodll "<driver.dll>[|{CLSID}]" (REA round 97): an ASIO driver loaded straight from its file,
- // without registering it, listed as the driver type "ASIO driver file". True when one was added.
- bool addDriverFileDeviceType()
- {
- const auto args = juce::JUCEApplication::getCommandLineParameterArray();
- const auto i = args.indexOf ("--asiodll");
- if (i < 0 || i + 1 >= args.size() || engine == nullptr)
- return false;
- auto& devices = engine->getDeviceManager();
- devices.getAvailableDeviceTypes(); // creates the standard types first
- for (auto* t : devices.getAvailableDeviceTypes())
- if (t->getTypeName() == lynx::dllAsioTypeName)
- return true;
- auto type = lynx::makeDllAsioDeviceType (args[i + 1].unquoted());
- if (type == nullptr)
- return false;
- devices.addAudioDeviceType (std::move (type));
- return true;
- }
- void restoreSavedDeviceState()
- {
- if (engine != nullptr)
- engine->restoreAudioDeviceState (savedDeviceState.get());
- }
- std::unique_ptr<MainWindow> mainWindow;
- std::unique_ptr<juce::Timer> perf; // --uiperf
- std::unique_ptr<lynx::StartupSplash> splash;
- static constexpr double landingSeconds = 1.05; // the logo's drop (SplashScreen::remainingDuration's `landing`)
- std::shared_future<std::pair<juce::Image, double>> graphicsDeviceJob; // (round 190hd) holds the graphics device
- bool graphicsDeviceMarked = false, windowRevealed = false;
- std::future<std::shared_ptr<const lynx::SampleData>> startupSampleJob; // (round 190go: the built-in start-up sound)
- bool startedAfterWindow = false, startupSoundPlayed = false;
- double splashDuration = lynx::SplashScreen::minimumDuration; // seconds of its clock (round 121: from the process start)
- lynx::StartupOptions startupOptions;
- juce::File fileToOpen;
- bool startupFileHandled = false;
- bool startWithoutPlugins = false; // --no-plugins project.lynx (round 190ap)
- juce::File openTimeReport; // --opentime
- int openTimeIdleSeconds = 10;
- };
- START_JUCE_APPLICATION (LynxApplication)
|