bool CB_PasteTrack( struct WBlocks *wblock, struct WTracks *wtrack, struct WTracks *towtrack ){ struct Tracks *totrack; struct Tracks *track; Place *p1,p2; if(towtrack==NULL){ RError("Error in function CB_PasteTrack in file clipboard_track_paste.c; towtrack=NULL\n"); return false; } totrack=towtrack->track; track=wtrack->track; towtrack->notelength=wtrack->notelength; towtrack->fxwidth=wtrack->fxwidth; totrack->patch=track->patch; totrack->onoff=track->onoff; totrack->pan=track->pan; totrack->volume=track->volume; totrack->panonoff=track->panonoff; totrack->volumeonoff=track->volumeonoff; if(track->midi_instrumentdata!=NULL){ totrack->midi_instrumentdata=MIDI_CopyInstrumentData(track); } totrack->trackname=talloc_strdup(track->trackname); totrack->notes=NULL; totrack->stops=NULL; totrack->fxs=NULL; p1=PlaceGetFirstPos(); PlaceSetLastPos(wblock->block,&p2); CopyRange_notes(&totrack->notes,track->notes,p1,&p2); CopyRange_stops(&totrack->stops,track->stops,p1,&p2); CopyRange_fxs(&totrack->fxs,track->fxs,p1,&p2); LegalizeFXlines(wblock->block,totrack); LegalizeNotes(wblock->block,totrack); return true; }
void CopyRange_notes( struct Notes **tonote, struct Notes *fromnote, Place *p1, Place *p2 ){ struct Notes *note; if(fromnote==NULL){ return; } if(PlaceLessThan(&fromnote->l.p,p1)){ CopyRange_notes(tonote,NextNote(fromnote),p1,p2); return; } if(PlaceGreaterOrEqual(&fromnote->l.p,p2)){ return; } note=CopyNote(fromnote); note->pitches = NULL; note->velocities = NULL; NOTE_init(note); PlaceSub(¬e->l.p,p1); PlaceSub(¬e->end,p1); ListAddElement3(tonote,¬e->l); CopyRange_velocities(¬e->velocities,fromnote->velocities,p1,p2); CopyRange_pitches(¬e->pitches,fromnote->pitches,p1,p2); CopyRange_notes(tonote,NextNote(fromnote),p1,p2); }
static bool paste_track( struct WBlocks *wblock, struct WTracks *wtrack, struct WTracks *towtrack ) { struct Tracks *totrack = towtrack->track; struct Tracks *track = wtrack->track; Place *p1,p2; towtrack->notelength=wtrack->notelength; towtrack->fxwidth=wtrack->fxwidth; totrack->onoff=track->onoff; totrack->pan=track->pan; totrack->volume=track->volume; totrack->panonoff=track->panonoff; totrack->volumeonoff=track->volumeonoff; ATOMIC_SET(totrack->midi_channel, ATOMIC_GET(track->midi_channel)); if(track->midi_instrumentdata!=NULL){ totrack->midi_instrumentdata=MIDI_CopyInstrumentData(track); } totrack->trackname=talloc_strdup(track->trackname); totrack->notes=NULL; totrack->stops=NULL; VECTOR_clean(&totrack->fxs); p1=PlaceGetFirstPos(); PlaceSetLastPos(wblock->block,&p2); CopyRange_notes(&totrack->notes,track->notes,p1,&p2); CopyRange_stops(&totrack->stops,track->stops,p1,&p2); if (totrack->patch != NULL) CopyRange_fxs(&totrack->fxs,&track->fxs,p1,&p2); LegalizeFXlines(wblock->block,totrack); LegalizeNotes(wblock->block,totrack); return true; }
void Undo_Range( struct Tracker_Windows *window, struct Blocks *block, NInt starttrack, NInt endtrack, int realline ){ Place *p1=PlaceGetFirstPos(); Place p2; struct Range *undo_range; NInt num_tracks; NInt lokke; struct Tracks *track; NInt num_tracks_in_block=block->num_tracks; if(endtrack>=num_tracks_in_block){ num_tracks=num_tracks_in_block-1; }else{ num_tracks=endtrack-starttrack+1; } undo_range=talloc(sizeof(struct Range)); undo_range->notes=talloc((size_t)(sizeof(struct Notes *)*num_tracks)); undo_range->stops=talloc((size_t)(sizeof(struct Stops *)*num_tracks)); undo_range->num_tracks=num_tracks; PlaceSetLastPos(block,&p2); for(lokke=0;lokke<num_tracks;lokke++){ track=ListFindElement1(&block->tracks->l,lokke+starttrack); CopyRange_stops(&undo_range->stops[lokke],track->stops,p1,&p2); CopyRange_notes(&undo_range->notes[lokke],track->notes,p1,&p2); } Undo_Add(window->l.num,block->l.num,starttrack,realline, undo_range,Undo_Do_Range, "Range", LOC() ); }
void Undo_Notes( struct Tracker_Windows *window, struct Blocks *block, struct Tracks *track, int realline ){ Place *p1=PlaceGetFirstPos(); Place p2; struct Undo_Notes *undo_notes=talloc(sizeof(struct Undo_Notes)); PlaceSetLastPos(block,&p2); CopyRange_stops(&undo_notes->stops,track->stops,p1,&p2); CopyRange_notes(&undo_notes->notes,track->notes,p1,&p2); Undo_Add( window->l.num, block->l.num, track->l.num, realline, undo_notes, Undo_Do_Notes); }