| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288 |
- #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 "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 <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 "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 "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); }
- 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);
- }
- }
- 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
- 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");
- }
- 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 ("--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 ("--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;
- }
- // --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;
- }
- // --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 ("--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();
- }
- 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()
- {
- 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::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();
- 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;
- // 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 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
- || 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 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);
- 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);
- 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",
- "Effector's Kilohearts Flanger and Dual Delay laws" };
- 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 != 4)
- rollup032Result = "ERROR set-up: a new channel is not at revision 4";
- 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);
- 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";
- }
- 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 < 200 && str == juce::File() && stretched != nullptr; ++tries)
- {
- 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 = "ERROR stretch cache: nothing written";
- 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 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 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" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "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"
- && 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");
- 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"
- << "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"
- << "repeats190pm=" << repeats190pmResult << "\n"
- << "mixerqol190qh=" << mixerqol190qhResult << "\n"
- << "hotfixplaces190qp=" << hotfixPlacesResult << "\n"
- << "toolbar_overflow_190qg=" << toolbar190qgResult << "\n"
- << "autolinks190ov=" << autolinks190ovResult << "\n"
- << "sections190ol=" << sections190olResult << "\n"
- << "heldsteps190oz=" << heldSteps190ozResult << "\n"
- << "slides190pi=" << slides190piResult << "\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)
- {
- 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)
- {
- 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)
- && (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>)>>();
- *drive = [this, runPass, 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)
- {
- juce::Timer::callAfterDelay (40, [pass, drive] { (*drive) (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, first, step, finish, drive, onsets] {
- 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)>>();
- *run = [this, scenarios, step, outputs, ok, run, block, seconds, report] (std::size_t index, int pass) {
- 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; };
- 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_by_default", ! 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);
- 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 "IssuesShot190oq.inc" // round 190oq (issues #243-#252)
- #include "IssuesShot190qb.inc" // round 190qb (follow-ups of issues #206, #215)
- #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 "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 "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;
- if (s.videoTracks.size() < 2)
- 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 };
- 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";
- 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)); };
- 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() = false;
- 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* ticked = find (list->rowMenu (2), 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 "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)
|