Exemple #1
0
static struct Notes *sort_notes_by_pitch_a_little_bit(struct Notes *notes){
  struct Notes *ret = notes;
  struct Notes *note_to_place_after = NULL;
  
  while(notes != NULL){
    struct Notes *next = NextNote(notes);

    R_ASSERT_RETURN_IF_FALSE2(next!=NULL, NULL);
    
    if (PlaceEqual(&notes->l.p, &next->l.p))
      if (notes->note > next->note) {
        note_to_place_after = notes;
        break;
      }
    
    notes = next;
  }

  ListRemoveElement3(&ret, &note_to_place_after->l);
  ListAddElement3_a(&ret, &note_to_place_after->l);
  
  return ret;
}
Exemple #2
0
static void SetNum_Vel_rec(
	struct WTracks *wtrack,
	struct FindNum_Velstruct **velroot,
	struct Notes *note
){
	struct FindNum_Velstruct temp_start;
	struct FindNum_Velstruct temp_end;

	if(note==NULL){
		SetNum_Vel_set(wtrack,velroot);
		return;
	}

	PlaceCopy(&temp_start.l.p,&note->l.p);
	temp_start.startstop=1;
	ListAddElement3_a(velroot,&temp_start.l);

	PlaceCopy(&temp_end.l.p,&note->end);
	temp_end.startstop= -1;
	ListAddElement3(velroot,&temp_end.l);

	SetNum_Vel_rec(wtrack,velroot,NextNote(note));
}
Exemple #3
0
void TRACK_split_into_monophonic_tracks(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack){
  
  PlayStop(); // This function is too chaotic. Don't bother pausing player.

  vector_t notesvector = {0};
  
  struct Tracks *track = wtrack->track;

  struct Notes *notes = track->notes;
  struct Notes *notes_nexttrack = NULL;

  bool have_made_undo = false;

  if (NOTES_sorted_by_pitch_questionmark(track->notes)==false) {
    ADD_UNDO(Block_CurrPos(window));    
    have_made_undo = true;
    notes = NOTES_sort_by_pitch(notes);
  }
  
  while(notes != NULL){

    struct Notes *notes_root = notes;
    
    while(notes != NULL) {

      struct Notes *next = NextNote(notes);
      if (next==NULL)
        break;

      if (PlaceGreaterThan(&notes->end, &next->l.p)){

        if (have_made_undo==false) {
            have_made_undo=true;
        }
        
        ListRemoveElement3(&notes, &next->l);                           
        ListAddElement3_a(&notes_nexttrack, &next->l);

      } else
        notes = next;
    }

    VECTOR_push_back(&notesvector, notes_root);

    notes = notes_nexttrack;
    notes_nexttrack = NULL;
  }

  if (have_made_undo==false){
    GFX_Message(NULL, "Track is already monophonic");
    return;
  }

  int num_tracks = notesvector.num_elements;

  track->notes = NULL;

  struct WTracks *wtrack_copy = CB_CopyTrack(wblock,wtrack);
  VECTOR_clean(&wtrack_copy->track->fxs);

  InsertTracks(window, wblock, wtrack->l.num+1, num_tracks-1);

  printf("Vector length: %d\n",num_tracks);
  int i;
  for(i=0;i<num_tracks;i++){
    struct Notes *notes = notesvector.elements[i];
    printf("  %d: %d\n", i, ListFindNumElements3(&notes->l));
    while(notes != NULL){
      printf("    %s\n",NotesTexts3[(int)notes->note]);
      notes = NextNote(notes);
    }
    
    struct WTracks *towtrack = ListFindElement1(&wblock->wtracks->l, wtrack->l.num+i);
    
    if (i>0)
      co_CB_PasteTrack(wblock, wtrack_copy, towtrack);

    towtrack->track->notes = notesvector.elements[i];
  }

  window->must_redraw = true;
}