void RemoveNoteCurrPos(struct Tracker_Windows *window){ struct WBlocks *wblock = window->wblock; struct WTracks *wtrack = wblock->wtrack; struct Tracks *track = wtrack->track; struct LocalZooms *realline = wblock->reallines[wblock->curr_realline]; int curr_realline = wblock->curr_realline; const Trs &trs = TRS_get(wblock, wtrack, curr_realline); ADD_UNDO(Notes_CurrPos(window)); if (trs.size()==0) { InsertStop(window,wblock,wtrack,&realline->l.p); maybe_scroll_down(window); return; } const TrackRealline2 &tr2 = trs[0]; if (tr2.pitch != NULL) { DeletePitch(track, tr2.note, tr2.pitch); if (trs.size()==1) maybe_scroll_down(window); return; } if (tr2.is_end_pitch) { struct Pitches *pitch = (struct Pitches*)ListLast3(&tr2.note->pitches->l); if (pitch!=NULL) tr2.note->pitch_end = pitch->note; else tr2.note->pitch_end = 0; return; } if (tr2.note != NULL) { PLAYER_lock();{ ListRemoveElement3(&track->notes,&tr2.note->l); LengthenNotesTo(wblock->block,track,&realline->l.p); }PLAYER_unlock(); SetNotePolyphonyAttributes(wtrack->track); ValidateCursorPos(window); if (trs.size()==1) maybe_scroll_down(window); return; } const struct Stops *stop = tr2.stop; PLAYER_lock();{ ListRemoveElement3(&track->stops, &stop->l); LengthenNotesTo(wblock->block,track,&realline->l.p); }PLAYER_unlock(); if (trs.size()==1) maybe_scroll_down(window); }
static void set_legal_start_and_end_pos(const struct Blocks *block, struct Tracks *track, struct Notes *note){ Place *start = ¬e->l.p; Place *end = ¬e->end; Place endplace; PlaceSetLastPos(block,&endplace); if(PlaceGreaterOrEqual(start,&endplace)) { RError("note is placed after block end. start: %f, end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(¬e->end)); set_new_position(track, note, PlaceCreate(block->num_lines - 2, 0, 1), NULL); start = ¬e->l.p; } if (start->line < 0) { RError("note is placed before block start. start: %f, end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(¬e->end)); set_new_position(track, note, PlaceCreate(0,1,1), NULL); start = ¬e->l.p; } if(PlaceGreaterThan(end,&endplace)) { RError("note end is placed after block end. start: %f, end: %f. block end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(¬e->end), GetfloatFromPlace(&endplace)); set_new_position(track, note, NULL, &endplace); end = ¬e->end; } if (note->velocities != NULL) { { struct Velocities *first_velocity = note->velocities; if(PlaceGreaterThan(start, &first_velocity->l.p)){ RError("note start is placed after first velocity. start: %f, first: %f, end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(&first_velocity->l.p), GetfloatFromPlace(¬e->end)); float e = p_float(first_velocity->l.p); e -= 0.01; e = R_MAX(0.0, e); Place new_start; Float2Placement(e, &new_start); set_new_position(track, note, &new_start, NULL); start = ¬e->l.p; } } struct Velocities *last_velocity = (struct Velocities*)ListLast3(¬e->velocities->l); if(PlaceLessThan(end, &last_velocity->l.p)){ RError("note end is placed before last velocity. start: %f, last: %f, end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(&last_velocity->l.p), GetfloatFromPlace(¬e->end)); float e = p_float(last_velocity->l.p); e += 0.01; Place new_end; Float2Placement(e, &new_end); set_new_position(track, note, NULL, &new_end); end = ¬e->end; } } if (note->pitches != NULL) { { struct Pitches *first_pitch = note->pitches; if(PlaceGreaterThan(start, &first_pitch->l.p)){ RError("note start is placed after first pitch. start: %f, first: %f, end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(&first_pitch->l.p), GetfloatFromPlace(¬e->end)); float e = p_float(first_pitch->l.p); e -= 0.01; e = R_MAX(0.0, e); Place new_start; Float2Placement(e, &new_start); set_new_position(track, note, &new_start, NULL); start = ¬e->l.p; } } struct Pitches *last_pitch = (struct Pitches*)ListLast3(¬e->pitches->l); if(PlaceLessThan(end, &last_pitch->l.p)){ RError("note end is placed before last pitch. start: %f, last: %f, end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(&last_pitch->l.p), GetfloatFromPlace(¬e->end)); float e = p_float(last_pitch->l.p); e += 0.01; Place new_end; Float2Placement(e, &new_end); set_new_position(track, note, NULL, &new_end); end = ¬e->end; } } if(PlaceLessOrEqual(end,start)) { RError("note end is placed before (or on) note start. start: %f, end: %f", GetfloatFromPlace(¬e->l.p), GetfloatFromPlace(¬e->end)); float e = p_float(*start); e += 0.01; Place new_end; Float2Placement(e, &new_end); set_new_position(track, note, NULL, &new_end); } }
void CB_PasteBlock( struct Tracker_Windows *window, struct WBlocks *wblock, struct WBlocks *towblock ){ R_ASSERT(is_playing()==false); struct Blocks *block=wblock->block; struct Blocks *toblock=towblock->block; struct WTracks *towtrack=towblock->wtracks; struct WTracks *towtrack_wtrack=towblock->wtrack; struct Tracks *totrack=toblock->tracks; struct WTracks *wtrack; NInt wblocknum=towblock->l.num; struct ListHeader1 *nextwblock=towblock->l.next; NInt blocknum=toblock->l.num; struct ListHeader1 *nextblock=toblock->l.next; unsigned int org_color = toblock->color; NInt org_num_tracks=toblock->num_tracks; memcpy(towblock,wblock,sizeof(struct WBlocks)); memcpy(toblock,block,sizeof(struct Blocks)); toblock->color = org_color; // Don't want to paste color. towblock->l.next=nextwblock; towblock->l.num=wblocknum; towblock->block=toblock; towblock->wtracks=towtrack; towblock->wtrack=towtrack_wtrack; toblock->tracks=totrack; toblock->l.next=nextblock; toblock->l.num=blocknum; //printf("org num_tracks: %d, before: %d\n",org_num_tracks,toblock->num_tracks); toblock->num_tracks=org_num_tracks; Block_Set_num_tracks(toblock,block->num_tracks); TIME_everything_in_block_has_changed(towblock->block); // UpdateReallines requires updated time values (for whether to show swing type track or not). toblock->name=block->name; towblock->localzooms=NULL; CB_UnpackLocalZooms(&towblock->localzooms,wblock->localzooms,block->num_lines); //towblock->reallines=NULL; UpdateRealLines_dont_change_curr_realline(window, towblock); //towblock->wtempos=NULL; //towblock->wlpbs=NULL; toblock->swings=CB_CopySwings(block->swings, NULL); toblock->signatures=CB_CopySignatures(block->signatures); toblock->lpbs=CB_CopyLPBs(block->lpbs); toblock->tempos=CB_CopyTempos(block->tempos); toblock->temponodes=CB_CopyTempoNodes(block->temponodes); toblock->lasttemponode=(struct TempoNodes *)ListLast3(&toblock->temponodes->l); UpdateReallinesDependens(window,towblock); wtrack=wblock->wtracks; towtrack=towblock->wtracks; while(wtrack!=NULL){ if(towtrack==NULL){ RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack=NULL\n"); break; } if(towtrack->l.num!=wtrack->l.num){ RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack->l.num!=wtrack->l.num\n"); break; } co_CB_PasteTrack(towblock,wtrack,towtrack); towtrack=NextWTrack(towtrack); wtrack=NextWTrack(wtrack); } if(towtrack!=NULL){ RError("Error in funtion CB_PasteBlock in file clipboard_block_paste.c; towtrack!=NULL when wtrack==NULL\n"); } g_editor_blocks_generation++; BS_UpdateBlockList(); BS_UpdatePlayList(); }