feat: added pitch bend support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { KGRegion } from './KGRegion';
|
||||
import { KGMidiNote } from '../midi/KGMidiNote';
|
||||
import { KGMidiPitchBend } from '../midi/KGMidiPitchBend';
|
||||
|
||||
/**
|
||||
* KGMidiRegion - Class representing a MIDI region in the DAW
|
||||
@@ -14,6 +15,10 @@ export class KGMidiRegion extends KGRegion {
|
||||
@Type(() => KGMidiNote)
|
||||
protected notes: KGMidiNote[] = [];
|
||||
|
||||
@Expose()
|
||||
@Type(() => KGMidiPitchBend)
|
||||
protected pitchBends: KGMidiPitchBend[] = [];
|
||||
|
||||
constructor(id: string, trackId: string, trackIndex: number, name: string, startFromBeat: number = 0, length: number = 0) {
|
||||
super(id, trackId, trackIndex, name, startFromBeat, length);
|
||||
this.__type = 'KGMidiRegion';
|
||||
@@ -29,6 +34,14 @@ export class KGMidiRegion extends KGRegion {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public getPitchBends(): KGMidiPitchBend[] {
|
||||
return this.pitchBends;
|
||||
}
|
||||
|
||||
public setPitchBends(pitchBends: KGMidiPitchBend[]): void {
|
||||
this.pitchBends = pitchBends;
|
||||
}
|
||||
|
||||
// Add a single note
|
||||
public addNote(note: KGMidiNote): void {
|
||||
this.notes.push(note);
|
||||
@@ -39,6 +52,14 @@ export class KGMidiRegion extends KGRegion {
|
||||
this.notes = this.notes.filter(note => note.getId() !== noteId);
|
||||
}
|
||||
|
||||
public addPitchBend(pitchBend: KGMidiPitchBend): void {
|
||||
this.pitchBends.push(pitchBend);
|
||||
}
|
||||
|
||||
public removePitchBend(pitchBendId: string): void {
|
||||
this.pitchBends = this.pitchBends.filter(pitchBend => pitchBend.getId() !== pitchBendId);
|
||||
}
|
||||
|
||||
// Override getCurrentType to return specific subclass type
|
||||
public override getCurrentType(): string {
|
||||
return 'KGMidiRegion';
|
||||
|
||||
Reference in New Issue
Block a user