Пример #1
0
struct TempoNodes *AddTempoNode(
	struct Tracker_Windows *window,
	struct WBlocks *wblock,
	Place *p,
	float reltempo
){
	struct Blocks *block=wblock->block;
	struct TempoNodes *temponode;

	temponode=talloc(sizeof(struct TempoNodes));
	temponode->reltempo=reltempo;

	PlaceCopy(&temponode->l.p,p);

        Undo_TempoNodes_CurrPos(window);

	if(ListAddElement3_ns(&block->temponodes,&temponode->l)==-1) {
          Undo_CancelLastUndo();
          return NULL;
        } else
          return temponode;
}
Пример #2
0
void loadBlock(const char *filename_c){
  struct Tracker_Windows *window=getWindowFromNum(-1);if(window==NULL) return;
    
  bool success = false;
  bool have_made_undo = false;
  
  if (filename_c==NULL || !strcmp(filename_c, ""))
    filename_c = "/tmp/block.block";

  const wchar_t *filename = STRING_create(filename_c);
  
  int num_blocks = root->song->num_blocks;
    
  if (Load_Initialize(filename, "RADIUM BLOCK")==false) {
    goto exit;
    return;
  }
        
  if(strcmp(dc.ls,"WBLOCK")){
    handleError("Loading failed.\nExpected \"WBLOCK\", but found instead: '%s'.\nFile: '%s'\n",dc.ls,STRING_get_chars(filename));
    DISK_close_and_delete(dc.file);
    goto exit;
    return;
  }

  struct WBlocks *wblock = LoadWBlock();
  wblock->l.num = num_blocks;

  DC_Next();
  if(strcmp(dc.ls,"BLOCK")){
    handleError("Loading failed.\nExpected \"BLOCK\", but found instead: '%s'.\nFile: '%s'\n",dc.ls,STRING_get_chars(filename));
    DISK_close_and_delete(dc.file);
    goto exit;
  }

  struct Blocks *block = LoadBlock();
  block->l.num = num_blocks;
  
  DISK_close_and_delete(dc.file);

  if(!dc.success){
    handleError("Loading failed.\n");
    goto exit;
  }
  
  printf("Got it: %p / %p\n",wblock,block);


  ADD_UNDO(Block_Insert(num_blocks));
  have_made_undo = true;

  /*
  DC_ListAdd1(&root->song->blocks,block);
  DC_ListAdd1(&root->song->tracker_windows->wblocks, wblock);
  */

  wblock->block = block;
  window->curr_track = 0;

  DLoadBlocks(root, block);
  DLoadWBlocks(window, window, wblock);  

  CB_PasteBlock(window, wblock, window->wblock);

  success = true;
  
 exit:
  if (success==false)
    if (have_made_undo)
      Undo_CancelLastUndo();
}
Пример #3
0
bool FXTEXT_keypress(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack, int realline, Place *place, int key){
  struct FXs *fxs;
  
  int subsubtrack = FXTEXT_subsubtrack(window, wtrack, &fxs);
  if (subsubtrack==-1)
    return false;

  struct FX *fx = fxs->fx;
  //printf("FXmin: %d, fxmax: %d\n",fx->min, fx->max);
  
  const FXText_trss &fxtexts = FXTEXTS_get(wblock, wtrack, fxs);

  const FXText_trs &fxtext = fxtexts[realline];

  //  if (fxtext->num_elements == 0 && val==0)
  //   return true;

  ADD_UNDO(FXs(window, wblock->block, wtrack->track, wblock->curr_realline));

  if (fxtext.size() > 1){

    // MORE THAN ONE ELEMENT
    
    if (key == EVENT_DEL){
      
      for (auto vt : fxtext) {
        if (VECTOR_is_in_vector(&wtrack->track->fxs, fxs) && isInList3(&fxs->fxnodelines->l, &vt.fxnodeline->l)) // We might have removed all nodes already (see line below)
          DeleteFxNodeLine(window, wtrack, fxs, vt.fxnodeline); // In this line, two nodes are removed if there's only two left.
      }
      
    } else {
      
      Undo_CancelLastUndo();
      
    }
    
  } else if (fxtext.size() == 0){

    // NO ELEMENTS

    if (fx == NULL){

      fprintf(stderr, "Can this happen?\n");
      Undo_CancelLastUndo();
      
    } else {

      data_as_text_t dat = DAT_get_newvalue(subsubtrack, key, round(scale_double(0x80, 0, 0x100, fx->min, fx->max)), fx->min, fx->max, true);
      if (dat.value > fx->max)
        dat.value = fx->max;
      
      if (dat.is_valid==false)
        return false;

      int pos = AddFXNodeLine(window, wblock, wtrack, fxs, dat.value, place);
            
      struct FXNodeLines *fxnodeline = (struct FXNodeLines*)ListFindElement1_num(&fxs->fxnodelines->l, pos);
      fxnodeline->logtype = dat.logtype;      
    }

  } else {

    // ONE ELEMENT
    
    const FXText &vt = fxtext.at(0);
    struct FXNodeLines *fxnodeline = vt.fxnodeline;
  
    if (key == EVENT_DEL) {

      if (subsubtrack == 2)
        fxnodeline->logtype = LOGTYPE_LINEAR;
      else
        DeleteFxNodeLine(window, wtrack, fxs, fxnodeline);
      
    } else {

      data_as_text_t dat = DAT_get_overwrite(vt.value, vt.logtype, subsubtrack, key, fx->min, fx->max, true, true);
      printf("fx->min: %x, fx->max: %x, vt.value: %x, dat.value: %x\n",fx->min,fx->max,vt.value,dat.value);

      if (dat.is_valid==false)
        return false;

      fxnodeline->val = dat.value;
      fxnodeline->logtype = dat.logtype;
      
    }    
  }

  return true;
}
Пример #4
0
bool CHANCETEXT_keypress(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack, int realline, Place *place, int key){
  int subsubtrack = CHANCETEXT_subsubtrack(window, wtrack);

  if (subsubtrack==-1)
    return false;
  
  const Trs &trs = TRS_get(wblock, wtrack, realline);

  ADD_UNDO(Notes_CurrPos(window));  

  if (trs.size() > 1) {

    // MORE THAN ONE ELEMENT
    
    if (key == EVENT_DEL){

      for (const TrackRealline2 &tr2 : trs){
        struct Notes *note = tr2.note;
        struct Pitches *pitch = tr2.pitch;
        if (pitch!=NULL)
          safe_int_write(&pitch->chance, 0x100);
        else if (note!=NULL)
          safe_int_write(&note->chance, 0x100);
      }
      
    } else {
      
      Undo_CancelLastUndo();
      
    }
    
  } else if (trs.size() == 0) {

    // NO ELEMENTS
    
    Undo_CancelLastUndo();

  } else {

    // ONE ELEMENT
    
    const TrackRealline2 &tr2 = trs[0];
    struct Notes *dasnote = tr2.note;
    struct Pitches *pitch = tr2.pitch;
  
    if (key == EVENT_DEL) {

      if (pitch!=NULL)
        safe_int_write(&pitch->chance, 0x100);
      else if (pitch!=NULL)
        safe_int_write(&dasnote->chance, 0x100);
      else
        return false;
      
    } else {

      int chance;
      
      if (pitch!=NULL)
        chance = pitch->chance;
      else if (dasnote!=NULL)
        chance = dasnote->chance;
      else
        return false;
      
      data_as_text_t dat = DAT_get_overwrite(chance, 0, subsubtrack, key, 0, 0xff, true, false);

      if (dat.is_valid==false)
        return false;

      //double new_note = floor(note) + ((double)dat.value / 100.0);
      printf("new_chance: %d\n",dat.value);
      
      if (pitch!=NULL)
        safe_int_write(&pitch->chance, dat.value);
      else
        safe_int_write(&dasnote->chance, dat.value);
      
    }    
  }

  return true;
}