Beispiel #1
0
static bool co_CB_PasteTrackFX(
	struct WBlocks *wblock,
	struct WTracks *wtrack,
	struct WTracks *towtrack
){
	struct Tracks *totrack;
	struct Tracks *track;
	Place *p1,p2;

        R_ASSERT_RETURN_IF_FALSE2(towtrack!=NULL, false);

	totrack=towtrack->track;
	track=wtrack->track;

        make_patches_usable(track);

        if (totrack->patch == NULL)
          totrack->patch = track->patch;
                      
	if(track->midi_instrumentdata!=NULL){
          totrack->midi_instrumentdata=MIDI_CopyInstrumentData(track);
	}

	VECTOR_clean(&totrack->fxs);

	p1=PlaceGetFirstPos();
	PlaceSetLastPos(wblock->block,&p2);

	CopyRange_fxs(&totrack->fxs,&track->fxs,p1,&p2);

	LegalizeFXlines(wblock->block,totrack);

	return true;
}
Beispiel #2
0
void InsertTracks(
                  struct Tracker_Windows *window,
                  struct WBlocks *wblock,
                  NInt tracknum,
                  NInt toinsert
){
	NInt lokke;
	NInt num_tracks;
	struct Blocks *block=wblock->block;
	struct WTracks *wtrack;
	struct Tracks *track;

	if(tracknum>=block->num_tracks+1 || tracknum<0) return;

	if(toinsert<=0){
          if(toinsert<0) DeleteTracks(window,wblock,tracknum,-toinsert);
          return;
	}

	num_tracks=block->num_tracks+toinsert;

        PC_Pause();{
          Block_Set_num_tracks(block,num_tracks);

          for(lokke=num_tracks-1;lokke>=tracknum+toinsert;lokke--){
            wtrack=CB_CopyTrack(
                                wblock,
                                ListFindElement1(&wblock->wtracks->l,lokke-toinsert)
                                );
            co_CB_PasteTrack(
                             wblock,
                             wtrack,
                             ListFindElement1(&wblock->wtracks->l,lokke)
                             );
          }
          
          for(lokke=tracknum;lokke<tracknum+toinsert;lokke++){
            wtrack=ListFindElement1(&wblock->wtracks->l,lokke);
            track=wtrack->track;
            
            track->notes=NULL;
            track->stops=NULL;
            VECTOR_clean(&track->fxs);
            track->patch=NULL;
          }
        }PC_StopPause(NULL);
}
Beispiel #3
0
static void stop_all_notes_in_track(struct Tracks *track){
  int tracknum = track->l.num;

  if (tracknum < MAX_SCROLLPLAYTRACKS) {

    struct Patch *patch=track->patch;

    if (patch!=NULL) {
            
      VECTOR_FOR_EACH(struct Notes *note, &scrollplaying_notes[tracknum]){
        PATCH_stop_note(patch,note->note,note->id);
      }END_VECTOR_FOR_EACH;
      
    }

    VECTOR_clean(&scrollplaying_notes[tracknum]);
  }
Beispiel #4
0
static bool paste_track(
                        struct WBlocks *wblock,
                        struct WTracks *wtrack,
                        struct WTracks *towtrack
                        )
{
        struct Tracks *totrack = towtrack->track;
        struct Tracks *track = wtrack->track;
        Place *p1,p2;

	towtrack->notelength=wtrack->notelength;
	towtrack->fxwidth=wtrack->fxwidth;

	totrack->onoff=track->onoff;
	totrack->pan=track->pan;
	totrack->volume=track->volume;
	totrack->panonoff=track->panonoff;
	totrack->volumeonoff=track->volumeonoff;
        ATOMIC_SET(totrack->midi_channel, ATOMIC_GET(track->midi_channel));
        
	if(track->midi_instrumentdata!=NULL){
          totrack->midi_instrumentdata=MIDI_CopyInstrumentData(track);
	}

	totrack->trackname=talloc_strdup(track->trackname);

	totrack->notes=NULL;
	totrack->stops=NULL;
	VECTOR_clean(&totrack->fxs);

	p1=PlaceGetFirstPos();
	PlaceSetLastPos(wblock->block,&p2);

	CopyRange_notes(&totrack->notes,track->notes,p1,&p2);
	CopyRange_stops(&totrack->stops,track->stops,p1,&p2);

        if (totrack->patch != NULL)
          CopyRange_fxs(&totrack->fxs,&track->fxs,p1,&p2);

	LegalizeFXlines(wblock->block,totrack);
	LegalizeNotes(wblock->block,totrack);

	return true;

}
Beispiel #5
0
static void stop_all_notes_in_track(struct Tracks *track){
  int tracknum = track->l.num;

  if (tracknum < MAX_SCROLLPLAYTRACKS) {

    struct Patch *patch=track->patch;

    if (patch!=NULL) {
            
      VECTOR_FOR_EACH(struct Notes *note, &scrollplaying_notes[tracknum]){
        PATCH_stop_note(patch,create_note_t(NULL,
                                            note->id,
                                            note->note,
                                            0,
                                            0,
                                            ATOMIC_GET(track->midi_channel),
                                            0
                                            ));
      }END_VECTOR_FOR_EACH;
      
    }

    VECTOR_clean(&scrollplaying_notes[tracknum]);
  }
Beispiel #6
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;
}