@@ -397,73 +397,6 @@ export function seqEdits(t: Timeline, op: Op): SeqEdit[] | { why: string } {
397397 }
398398}
399399
400- // ---------------------------------------------------------------- a sound's own tracks (TL14b)
401-
402- /** A track of a sound in the feed as its host lists it (raea-feed host/sounds.ts), in seconds of the render. */
403- export interface SoundTrack {
404- /** its id in the sound's file */
405- id : string
406- /** what its head says */
407- name : string
408- /** what it holds: notes (a part played from notes), clips (files placed in time) or lines (words sung or said) */
409- kind : "notes" | "clips" | "lines"
410- /** the bus it plays through */
411- bus : string
412- /** its clips, each with its span in seconds, what it is, its file, where in the file it starts and its level in dB */
413- clips : { id : string ; from : number ; to : number ; label : string ; src ?: string ; offset ?: number ; gainDb ?: number } [ ]
414- }
415- /** A clip's span and level, in seconds and dB: what the host writes back for a clip that was moved, trimmed or
416- * turned up or down (raea-feed host/clips.ts). */
417- export interface ClipSpan {
418- /** where it starts, in seconds of the render */
419- start : number
420- /** where it ends, in seconds of the render */
421- end : number
422- /** where in its file it starts playing, in seconds */
423- offset : number
424- /** its level change, in dB (0 as recorded) */
425- gainDb : number
426- }
427-
428- const level = ( db : number ) => Math . round ( 10 ** ( db / 20 ) * 1000 ) / 1000
429- const dB = ( v : number ) => Math . round ( 20 * Math . log10 ( Math . max ( v , 0.001 ) ) * 10 ) / 10
430-
431- /** A sound's tracks as a timeline: a sound track each, by its bus; a clip of a file keeps its place in the file
432- * (its offset) and its level. Notes and lines are clips too, locked here: they are edited where they are written
433- * (the roll, the words). No magnet: a mix's clips are where they were put. */
434- export function fromTracks ( tracks : SoundTrack [ ] , fps : number ) : Timeline {
435- const f = ( s : number ) => Math . round ( s * fps )
436- return {
437- ...empty ( fps ) ,
438- magnet : false ,
439- tracks : tracks . map ( ( k ) => ( {
440- id : k . id ,
441- kind : "sound" as const ,
442- name : k . name ,
443- clips : k . clips
444- . map ( ( c ) : Clip => ( { id : c . id , kind : k . kind === "clips" ? "audio" : k . kind , name : c . label , start : f ( c . from ) , length : Math . max ( 1 , f ( c . to ) - f ( c . from ) ) , ...( c . src ? { in : f ( c . offset ?? 0 ) , at : c . src , volume : level ( c . gainDb ?? 0 ) } : { locked : k . kind === "notes" ? "edited on its roll" : "edited in its words" } ) } ) )
445- . sort ( ( a , b ) => a . start - b . start ) ,
446- } ) ) ,
447- }
448- }
449-
450- /** A clip of a file as the host is told it: where it plays, how far into its file, how loud. */
451- const spanOf = ( c : Clip , fps : number ) : ClipSpan => ( { start : c . start / fps , end : end ( c ) / fps , offset : ( c . in ?? 0 ) / fps , gainDb : dB ( c . volume ?? 1 ) } )
452-
453- /** The file clips that differ between the timeline as it was read and as it stands, each with its span before and
454- * after: what a sound's hand edit carries (its `clips`). A clip that was removed or made here isn't one of these. */
455- export function clipEdits ( read : Timeline , now : Timeline ) : { id : string ; src : string ; from : ClipSpan ; to : ClipSpan } [ ] {
456- const out : { id : string ; src : string ; from : ClipSpan ; to : ClipSpan } [ ] = [ ]
457- for ( const k of read . tracks )
458- for ( const was of k . clips ) {
459- const is = find ( now , was . id ) ?. clip
460- if ( ! was . at || ! is ) continue
461- const a = spanOf ( was , read . fps ) , b = spanOf ( is , now . fps )
462- if ( a . start !== b . start || a . end !== b . end || a . offset !== b . offset || a . gainDb !== b . gainDb ) out . push ( { id : was . id , src : was . at , from : a , to : b } )
463- }
464- return out
465- }
466-
467400// ---------------------------------------------------------------- a timeline an item declares (TL0d)
468401
469402/** A timeline as an agent wrote it on a feed item or a controller's field (its own data: a schedule, a set list, a
0 commit comments