void RA_addNote_FloatPlace( int blocknum, int tracknum, float start, int notenum, float volume, float end) { struct Blocks *block=SWIG_getBlock(blocknum); struct Tracks *track=SWIG_getTrack(blocknum,tracknum); struct Notes *note; Place p2; if(track==NULL) return; note=NewNote(); Float2Placement(start,¬e->l.p); Float2Placement(end,¬e->end); PlaceSetLastPos(block,&p2); if(PlaceGreaterOrEqual(¬e->l.p,&p2)) return; if(PlaceGreaterOrEqual(¬e->end,&p2)){ PlaceCopy(¬e->end,&p2); } note->note=notenum; note->velocity=boundaries( volume*(*track->instrument->getMaxVelocity)(track), 0, (*track->instrument->getMaxVelocity)(track) ); ListAddElement3(&track->notes,¬e->l); }
void cutNote(float floatplace, int notenum, int tracknum, int blocknum, int windownum){ 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; Float2Placement(floatplace, &place); if (PlaceGreaterOrEqual(&place, ¬e->end)) return; if (PlaceLessOrEqual(&place, ¬e->l.p)) return; CutNoteAt(wblock->block, wtrack->track, note, &place); }
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); } }
static void Glissando( struct WBlocks *wblock, struct WTracks *wtrack, struct Notes *note1 ){ // struct Notes *note; struct Notes *note2=NextNote(note1); float f1,f,f2; Place p; int notenote; int notediff; if(note2==NULL) return; notediff=R_ABS(note2->note-note1->note); if(notediff==0 || notediff==1) return; f1=GetfloatFromPlacement(¬e1->l.p); f2=GetfloatFromPlacement(¬e2->l.p); bool up = note2->note > note1->note; for(notenote=note1->note;;){ if (up) notenote++; else notenote--; if (up){ if (notenote>=note2->note) break; } else { if (notenote<=note2->note) break; } f=f1+( R_ABS(note1->note-notenote)*(f2-f1) / notediff ); if (f<0) f=0; if (f>=wblock->block->num_lines) break; Float2Placement(f,&p); InsertNote( wblock, wtrack, &p,NULL, notenote, (int)(note1->velocity+( ((f-f1)*(note2->velocity-note1->velocity))/(f2-f1) )), false ); } }