void setNoteEndPlace(int line,int counter,int dividor,int windownum,int blocknum,int tracknum,int notenum){ struct Tracker_Windows *window=getWindowFromNum(windownum); struct Notes *note=getNoteFromNum(windownum,blocknum,tracknum,notenum); if(window==NULL) return; if(note==NULL) return; PlaceCopy(¬e->end, PlaceCreate(line,counter,dividor)); }
int addNote2(float notenum,int velocity, int line,int counter,int dividor, int end_line,int end_counter,int end_dividor, int windownum, int blocknum, int tracknum) { struct Tracker_Windows *window; struct WBlocks *wblock=getWBlockFromNumA(-1,&window,blocknum); struct WTracks *wtrack=getWTrackFromNum(windownum,blocknum,tracknum); if(wblock==NULL || wtrack==NULL) { GFX_Message(NULL, "unknown wblock(%p) or wtrack(%p) %d/%d/%d\n",wblock,wtrack,windownum,blocknum,tracknum); return -1; } Place *place = PlaceCreate(line,counter,dividor); ValidatePlace(place); if (!PlaceLegal(wblock->block, place)) { GFX_Message(NULL, "Place %d + %d/%d is not legal", line, counter, dividor); return -1; } Place *end_place = end_line==-1 ? NULL : PlaceCreate(end_line,end_counter,end_dividor); ValidatePlace(end_place); if (end_place != NULL && !PlaceLegal(wblock->block, end_place)) { GFX_Message(NULL, "Place %d + %d/%d is not legal", end_line, end_counter, end_dividor); return -1; } struct Notes *note = InsertNote(wblock, wtrack, place, end_place, notenum, velocity, true); window->must_redraw=true; return ListFindElementPos3(&wtrack->track->notes->l,¬e->l); }
int addNote(int notenum,int velocity, int line,int counter,int dividor, int end_line,int end_counter,int end_dividor, int windownum, int blocknum, int tracknum) { struct WBlocks *wblock=getWBlockFromNum(windownum,blocknum); struct WTracks *wtrack=getWTrackFromNum(windownum,blocknum,tracknum); if(wblock==NULL || wtrack==NULL) { RError("unknown wblock(%p) or wtrack(%p) %d/%d/%d\n",wblock,wtrack,windownum,blocknum,tracknum); return -1; } struct Notes *note = InsertNote(wblock, wtrack, PlaceCreate(line,counter,dividor), end_line==-1 ? NULL : PlaceCreate(end_line,end_counter,end_dividor), notenum, velocity, true); wblock->block->is_dirty = true; return ListFindElementPos3(&wtrack->track->notes->l,¬e->l); }
void setNoteEndPlace(int line,int counter,int dividor,int windownum,int blocknum,int tracknum,int notenum){ struct Tracker_Windows *window; struct WBlocks *wblock; struct WTracks *wtrack; struct Notes *note = getNoteFromNumA(windownum, &window, blocknum, &wblock, tracknum, &wtrack, notenum); if (note==NULL) return; Place *place = PlaceCreate(line,counter,dividor); if (!PlaceLegal(wblock->block, place)) { GFX_Message(NULL, "Place %d + %d/%d is not legal", line, counter, dividor); return; } PlaceCopy(¬e->end, place); }
int addBPM(int bpm, int line,int counter,int dividor, int blocknum) { struct WBlocks *wblock=getWBlockFromNum(-1,blocknum); if(wblock==NULL) { RError("unknown block(%p)",blocknum); return -1; } Place *place = PlaceCreate(line,counter,dividor); struct Tempos *tempo = SetTempo(wblock->block,place,bpm); wblock->block->is_dirty = true; return ListFindElementPos3(&wblock->block->tempos->l,&tempo->l); }
int addLPB(int lpb_value, int line,int counter,int dividor, int blocknum) { struct WBlocks *wblock=getWBlockFromNum(-1,blocknum); if(wblock==NULL) { RError("unknown block(%p)",blocknum); return -1; } Place *place = PlaceCreate(line,counter,dividor); struct LPBs *lpb = SetLPB(wblock->block,place,lpb_value); wblock->block->is_dirty = true; return ListFindElementPos3(&wblock->block->lpbs->l,&lpb->l); }
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); } }