11import { Properties } from './Properties' ;
22import { AbletonLive } from '.' ;
33import { Note , SerializedNote } from './Note' ;
4-
4+ import { ClipView } from './ClipView' ;
55
66// TODO Missing properties
77// > groove
@@ -11,7 +11,6 @@ import { Note, SerializedNote } from './Note';
1111// > warp_markers (bang)
1212// > playing_status (bang)
1313
14-
1514export const enum WarpMode {
1615 Beats = 0 ,
1716 Tones = 1 ,
@@ -216,6 +215,26 @@ export interface ClipGetProperties {
216215 warping : boolean ;
217216}
218217
218+ /**
219+ * @interface ClipChildrenProperties
220+ */
221+ export interface ClipChildrenProperties {
222+ /**
223+ * Includes mixer device.
224+ */
225+ clipView : null ;
226+ }
227+
228+ /**
229+ * @interface ClipTransformedProperties
230+ */
231+ export interface ClipTransformedProperties {
232+ /**
233+ * Includes mixer device.
234+ */
235+ clipView : ClipView ;
236+ }
237+
219238/**
220239 * @interface ClipSetProperties
221240 */
@@ -454,7 +473,7 @@ export interface RawClip {
454473/**
455474 * @private
456475 */
457- export const RawClipKeys = [ 'name' , 'is_audio_clip' , 'length' ] ;
476+ export const RawClipKeys = [ 'name' , 'is_audio_clip' , 'length' ] ;
458477
459478type NotesResponse = {
460479 notes : SerializedNote [ ] ;
@@ -464,17 +483,23 @@ type NotesResponse = {
464483 * This class represents a clip in Live. It can be either an audio clip or a MIDI clip in the Arrangement or Session View, depending on the track / slot it lives in.
465484 *
466485 * @class Clip
467- * @extends {Properties<ClipGetProperties, unknown, unknown , ClipSetProperties, ClipObservableProperties> }
486+ * @extends {Properties<ClipGetProperties, ClipChildrenProperties, ClipTransformedProperties , ClipSetProperties, ClipObservableProperties> }
468487 */
469- export class Clip extends Properties < ClipGetProperties , unknown , unknown , ClipSetProperties , ClipObservableProperties > {
488+ export class Clip extends Properties <
489+ ClipGetProperties ,
490+ ClipChildrenProperties ,
491+ ClipTransformedProperties ,
492+ ClipSetProperties ,
493+ ClipObservableProperties
494+ > {
470495 static sessionPath = 'live_set tracks $1 clip_slots $2 clip' ;
471496 static arrangementPath = 'live_set tracks $1 arrangement_clips $2 clip' ;
472497
473498 static getSessionPath ( trackNumber : number , clipSlotNumber : number ) : string {
474499 return Clip . sessionPath . replace ( '$1' , `${ trackNumber } ` ) . replace ( '$2' , `${ clipSlotNumber } ` ) ;
475500 }
476501
477- static getArrangementPath ( trackNumber : number , clipSlotNumber : number , ) : string {
502+ static getArrangementPath ( trackNumber : number , clipSlotNumber : number ) : string {
478503 return Clip . arrangementPath . replace ( '$1' , `${ trackNumber } ` ) . replace ( '$2' , `${ clipSlotNumber } ` ) ;
479504 }
480505
@@ -498,7 +523,9 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
498523 this . _type = raw . is_audio_clip ? ClipType . Midi : ClipType . Audio ;
499524 this . _length = raw . length ;
500525
501- this . childrenTransformers = { } ;
526+ this . childrenTransformers = {
527+ clipView : ( ) => new ClipView ( this . ableton ) ,
528+ } ;
502529 }
503530
504531 // =========================================================================
@@ -566,7 +593,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
566593 * @return {void }
567594 */
568595 public async addNewNotes ( notes : Note [ ] ) : Promise < void > {
569- return this . call ( 'add_new_notes' , [ this . prepareNotes ( notes ) ] ) ;
596+ return this . call ( 'add_new_notes' , [ this . prepareNotes ( notes ) ] ) ;
570597 }
571598
572599 /**
@@ -578,7 +605,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
578605 * @return {void }
579606 */
580607 public async applyNoteModifications ( notes : Note [ ] ) : Promise < void > {
581- return this . call ( 'apply_note_modifications' , [ this . prepareNotes ( notes ) ] ) ;
608+ return this . call ( 'apply_note_modifications' , [ this . prepareNotes ( notes ) ] ) ;
582609 }
583610
584611 /**
@@ -599,7 +626,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
599626 * @return {void }
600627 */
601628 public async clearEnvelope ( deviceParameterId : number ) : Promise < void > {
602- return this . call ( 'clear_envelope' , [ deviceParameterId ] ) ;
629+ return this . call ( 'clear_envelope' , [ deviceParameterId ] ) ;
603630 }
604631
605632 /**
@@ -660,7 +687,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
660687 pitch = - 1 ,
661688 transpositionAmount = 0
662689 ) : Promise < void > {
663- return this . call ( 'duplicate_region' , [ regionStart , regionLength , destinationTime , pitch , transpositionAmount ] ) ;
690+ return this . call ( 'duplicate_region' , [ regionStart , regionLength , destinationTime , pitch , transpositionAmount ] ) ;
664691 }
665692
666693 /**
@@ -685,7 +712,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
685712 * @return {void }
686713 */
687714 public async getNotes ( startTime = 0 , timeRange = 256 , startPitch = 0 , pitchRange = 127 ) : Promise < Note [ ] > {
688- return this . call ( 'get_notes_extended' , [ startPitch , pitchRange , startTime . toFixed ( 3 ) , timeRange . toFixed ( 3 ) ] ) . then (
715+ return this . call ( 'get_notes_extended' , [ startPitch , pitchRange , startTime . toFixed ( 3 ) , timeRange . toFixed ( 3 ) ] ) . then (
689716 this . parseNotes . bind ( this )
690717 ) ;
691718 }
@@ -699,7 +726,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
699726 * @return {void }
700727 */
701728 public async getNotesById ( ids : number [ ] ) : Promise < Note [ ] > {
702- return this . call ( 'get_notes_by_id' , [ ...ids ] ) . then ( this . parseNotes . bind ( this ) ) ;
729+ return this . call ( 'get_notes_by_id' , [ ...ids ] ) . then ( this . parseNotes . bind ( this ) ) ;
703730 }
704731
705732 /**
@@ -723,7 +750,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
723750 * @return {void }
724751 */
725752 public async movePlayingPos ( beats : number ) : Promise < void > {
726- return this . call ( 'move_playing_pos' , [ beats ] ) ;
753+ return this . call ( 'move_playing_pos' , [ beats ] ) ;
727754 }
728755
729756 /**
@@ -736,7 +763,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
736763 * @return {void }
737764 */
738765 public async quantize ( quantizationGrid : number , amount : number ) : Promise < void > {
739- return this . call ( 'quantize' , [ quantizationGrid , amount ] ) ;
766+ return this . call ( 'quantize' , [ quantizationGrid , amount ] ) ;
740767 }
741768
742769 /**
@@ -750,7 +777,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
750777 * @return {void }
751778 */
752779 public async quantizePitch ( pitch : number , quantizationGrid : number , amount : number ) : Promise < void > {
753- return this . call ( 'quantize_pitch' , [ pitch , quantizationGrid , amount ] ) ;
780+ return this . call ( 'quantize_pitch' , [ pitch , quantizationGrid , amount ] ) ;
754781 }
755782
756783 /**
@@ -765,7 +792,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
765792 * @return {void }
766793 */
767794 public async removeNotes ( startTime = 0 , timeRange = 256 , startPitch = 0 , pitchRange = 127 ) : Promise < void > {
768- return this . call ( 'remove_notes_extended' , [ startPitch , pitchRange , startTime . toFixed ( 4 ) , timeRange . toFixed ( 4 ) ] ) ;
795+ return this . call ( 'remove_notes_extended' , [ startPitch , pitchRange , startTime . toFixed ( 4 ) , timeRange . toFixed ( 4 ) ] ) ;
769796 }
770797
771798 /**
@@ -777,7 +804,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
777804 * @return {void }
778805 */
779806 public async removeNotesById ( ids : number [ ] ) : Promise < void > {
780- return this . call ( 'remove_notes_by_id' , [ ...ids ] ) ;
807+ return this . call ( 'remove_notes_by_id' , [ ...ids ] ) ;
781808 }
782809
783810 /**
@@ -791,7 +818,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
791818 * @return {void }
792819 */
793820 public async scrub ( beatTime : number ) : Promise < void > {
794- return this . call ( 'scrub' , [ beatTime ] ) ;
821+ return this . call ( 'scrub' , [ beatTime ] ) ;
795822 }
796823
797824 /**
@@ -814,7 +841,7 @@ export class Clip extends Properties<ClipGetProperties, unknown, unknown, ClipSe
814841 * @return {void }
815842 */
816843 public async setFireButtonState ( state : boolean ) : Promise < void > {
817- return this . call ( 'set_fire_button_state' , [ state ] ) ;
844+ return this . call ( 'set_fire_button_state' , [ state ] ) ;
818845 }
819846
820847 /**
0 commit comments