예제 #1
0
파일: py_wrap.c 프로젝트: dieface/radium-1
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,&note->l.p);
  Float2Placement(end,&note->end);
  PlaceSetLastPos(block,&p2);

  if(PlaceGreaterOrEqual(&note->l.p,&p2)) return;
  if(PlaceGreaterOrEqual(&note->end,&p2)){
    PlaceCopy(&note->end,&p2);
  }

  note->note=notenum;
  note->velocity=boundaries(
			    volume*(*track->instrument->getMaxVelocity)(track),
			    0,
			    (*track->instrument->getMaxVelocity)(track)
			    );

  ListAddElement3(&track->notes,&note->l);
}
예제 #2
0
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, &note->end))
    return;
  
  if (PlaceLessOrEqual(&place, &note->l.p))
    return;

  CutNoteAt(wblock->block, wtrack->track, note, &place);
}
예제 #3
0
static void set_legal_start_and_end_pos(const struct Blocks *block, struct Tracks *track, struct Notes *note){
  Place *start = &note->l.p;
  Place *end = &note->end;
  Place endplace;

  PlaceSetLastPos(block,&endplace);
  
  if(PlaceGreaterOrEqual(start,&endplace)) {
    RError("note is placed after block end. start: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end));
    set_new_position(track, note, PlaceCreate(block->num_lines - 2, 0, 1), NULL);
    start = &note->l.p;
  }
  
  if (start->line < 0) {
    RError("note is placed before block start. start: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end));
    set_new_position(track, note, PlaceCreate(0,1,1), NULL);
    start = &note->l.p;
  }
  
  if(PlaceGreaterThan(end,&endplace)) {
    RError("note end is placed after block end. start: %f, end: %f. block end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end), GetfloatFromPlace(&endplace));
    set_new_position(track, note, NULL, &endplace);
    end = &note->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(&note->l.p), GetfloatFromPlace(&first_velocity->l.p), GetfloatFromPlace(&note->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 = &note->l.p;
      }
    }

    struct Velocities *last_velocity = (struct Velocities*)ListLast3(&note->velocities->l);
    if(PlaceLessThan(end, &last_velocity->l.p)){
      RError("note end is placed before last velocity. start: %f, last: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&last_velocity->l.p), GetfloatFromPlace(&note->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 = &note->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(&note->l.p), GetfloatFromPlace(&first_pitch->l.p), GetfloatFromPlace(&note->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 = &note->l.p;
      }
    }
    
    struct Pitches *last_pitch = (struct Pitches*)ListLast3(&note->pitches->l);
    if(PlaceLessThan(end, &last_pitch->l.p)){
      RError("note end is placed before last pitch. start: %f, last: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&last_pitch->l.p), GetfloatFromPlace(&note->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 = &note->end;
    }
  }
  
  if(PlaceLessOrEqual(end,start)) {
    RError("note end is placed before (or on) note start. start: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end));
    float e = p_float(*start);
    e += 0.01;
    Place new_end;
    Float2Placement(e, &new_end);
    set_new_position(track, note, NULL, &new_end);
  }

}
예제 #4
0
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(&note1->l.p);
	f2=GetfloatFromPlacement(&note2->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
                           );

	}

}