static void add_scaled_fxnodeline( struct FXNodeLines **tofxnodeline, struct FXNodeLines *nodeline1, struct FXNodeLines *nodeline2, Place p, Place subtract ){ struct FXNodeLines fxnodeline = *nodeline1; fxnodeline.l.p = p; R_ASSERT(p_Greater_Or_Equal(p, nodeline1->l.p)); R_ASSERT(p_Greater_Or_Equal(nodeline2->l.p, p)); if (nodeline1->logtype != LOGTYPE_HOLD) fxnodeline.val = scale(p_float(p), p_float(nodeline1->l.p), p_float(nodeline2->l.p), nodeline1->val, nodeline2->val); add_fxnodeline(tofxnodeline, &fxnodeline, subtract); }
struct WSignatures *WSignatures_get( const struct Tracker_Windows *window, const struct WBlocks *wblock ) { struct WSignatures *wsignatures = (struct WSignatures *)talloc_atomic_clean(sizeof(struct WSignatures)*wblock->num_reallines); int realline=0; int last_written_realline = -1; int last_written_new_bar_realline = -1; struct Beats *beat = wblock->block->beats; while(beat!=NULL){ realline=FindRealLineFor(wblock,realline,&beat->l.p); bool is_new_bar = beat->beat_num==1; if(PlaceNotEqual(&wblock->reallines[realline]->l.p,&beat->l.p)) { wsignatures[realline].type=SIGNATURE_BELOW; float *f = (float*)talloc_atomic(sizeof(float)); float y1 = p_float(wblock->reallines[realline]->l.p); float y2 = realline==wblock->num_reallines-1 ? wblock->num_reallines : p_float(wblock->reallines[realline+1]->l.p); *f = scale( p_float(beat->l.p), y1, y2, 0,1); VECTOR_push_back(&wsignatures[realline].how_much_below, f); } /* if (realline==1) { printf("1: %s %d %d %s\n", ratio_to_string(beat->signature), beat->bar_num, beat->beat_num, wsignatures[realline].type != SIGNATURE_MUL ? "true" : "false" ); } */ if (is_new_bar && realline != last_written_new_bar_realline) { // Unlike the multi-behavior for other wxxx-types, we show the first element, and not the last. wsignatures[realline].signature = beat->signature; wsignatures[realline].bar_num = beat->bar_num; wsignatures[realline].beat_num = beat->beat_num; } else if (realline != last_written_realline) { wsignatures[realline].signature = beat->signature; wsignatures[realline].bar_num = beat->bar_num; wsignatures[realline].beat_num = beat->beat_num; } else { wsignatures[realline].type=SIGNATURE_MUL; } last_written_realline = realline; if (is_new_bar) last_written_new_bar_realline = realline; beat = NextBeat(beat); } return wsignatures; }
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); } }