Ejemplo n.º 1
0
void ListAddElement3_a(
	void *voidlistroot,
	struct ListHeader3 *element
){
	struct ListHeaderPointer3 *listroot=voidlistroot;
	struct ListHeader3 *prev=NULL;
	struct ListHeader3 *temp=listroot->root;

	if(element==NULL) return;

	while(temp!=NULL){
		if(PlaceGreaterThan(&temp->p,&element->p)) break;
		prev=temp;
		temp=temp->next;
	}

	if(prev==NULL){
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		element->next=listroot->root;
		listroot->root=element;
	}else{
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		element->next=prev->next;
		prev->next=element;
	}
}
Ejemplo n.º 2
0
/******************************************************************************
    SHORT
        Add an Element to a list.

    NAME
      ListAddElement

    SYNOPSIS
        void ListAddElement(
          struct ListHeaderPointer *listroot,
          struct ListHeader *element
        )

    FUNCTION
		  Reads element->place, element->counter and element->dividor
        and puts the element before before that in the list.
******************************************************************************/
void ListAddElement3(
	void *voidlistroot,
	struct ListHeader3 *element
){
	struct ListHeaderPointer3 *listroot=voidlistroot;
	struct ListHeader3 *prev=NULL;
	struct ListHeader3 *temp=listroot->root;

	if(element==NULL) return;

	/* According to profiling, this function used quite a bit of time,
	   and by adding the next four lines, it seems to be a bit better. */
	while(temp!=NULL && temp->p.line < element->p.line){
		prev=temp;
		temp=temp->next;
	}

	while(temp!=NULL){
		if(PlaceGreaterOrEqual(&temp->p,&element->p)) break;
		prev=temp;
		temp=temp->next;
	}

	if(prev==NULL){
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		element->next=listroot->root;
		listroot->root=element;
	}else{
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		element->next=prev->next;
		prev->next=element;
	}
}
Ejemplo n.º 3
0
void CopyRange_fxs(
                   vector_t *tofxs,
                   vector_t *das_fromfxs,
                   Place *p1,
                   Place *p2
                   )
{
  VECTOR_FOR_EACH(struct FXs *fromfxs, das_fromfxs){

        R_ASSERT_RETURN_IF_FALSE(fromfxs->fx->patch->is_usable);
        
#if 0
        // This thing should perhaps be moved into co_CB_PasteTrack.
        if (!fromfxs->fx->patch->is_usable) {
          fromfxs->fx->patch = PATCH_create_audio(NULL, NULL, fromfxs->fx->patch->name, fromfxs->fx->patch->state);
          R_ASSERT_RETURN_IF_FALSE(fromfxs->fx->patch->patchdata != NULL);
        }
#endif
        
	struct FXs *fxs=talloc(sizeof(struct FXs));

	fxs->fx=tcopy(fromfxs->fx, sizeof(struct FX)); // Why not just reference the existing fx? (fx is modified)

	VECTOR_push_back(tofxs,fxs);

	CopyRange_fxnodelines(&fxs->fxnodelines,fromfxs->fxnodelines,NULL,*p1,*p2);

  }END_VECTOR_FOR_EACH;
Ejemplo n.º 4
0
/******************************************************************************
  FUNCTION
    Same as ListAddElement1, except that it puts the element after all
    elements that has equal l.num. ListAddElement1 puts it before.
    (this is important for the player-routine, to ensure that when
     a note is started at the same time as another one is ended, that it doesnt
     start the new note before the previous is ended.)
******************************************************************************/
void ListAddElement1_a(
	void *voidlistroot,
	struct ListHeader1 *element
){
	struct ListHeaderPointer1 *listroot=voidlistroot;
	struct ListHeader1 *temp=listroot->root;
	struct ListHeader1 *prev=NULL;

	if(element==NULL) return;

	while(temp!=NULL){
		if(temp->num > element->num) break;
		prev=temp;                
		temp=temp->next;
	}

	if(prev==NULL){
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		element->next=listroot->root;
		listroot->root=element;
	}else{
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		element->next=prev->next;
		prev->next=element;
	}
}
Ejemplo n.º 5
0
    virtual ~Gui(){
      R_ASSERT_RETURN_IF_FALSE(g_guis.contains(this));
      R_ASSERT_RETURN_IF_FALSE(g_guis[_gui_num] != NULL);
                               
      printf("Deleting Gui %p\n",this);

      for(Gui *child : children)
        delete child;

      for(Callback *callback : _callbacks)
        delete callback;
      
      g_guis[_gui_num] = NULL;
    }
Ejemplo n.º 6
0
static void RT_MIDI_send_msg_to_patch(struct Patch *patch, MidiMessage message, int64_t seq_time){       
  if (message.isNoteOn())
    RT_PATCH_play_note(patch, message.getNoteNumber(), -1, message.getVelocity() / 127.0f, 0.0f, seq_time);
  
  else if (message.isNoteOff())
    RT_PATCH_stop_note(patch, message.getNoteNumber(), -1, seq_time);
  
  else if (message.isAftertouch())
    RT_PATCH_change_velocity(patch, message.getNoteNumber(), -1, message.getChannelPressureValue() / 127.0f, seq_time);

  else {
    
    const uint8_t *raw_data = message.getRawData();
    int len = message.getRawDataSize();

    R_ASSERT_RETURN_IF_FALSE(len>=1 && len<=3);

    uint32_t msg;

    if (len==3)
      msg = MIDI_msg_pack3(raw_data[0],raw_data[1],raw_data[2]);
    else if (len==2)
      msg = MIDI_msg_pack2(raw_data[0],raw_data[1]);
    else if (len==1)
      msg = MIDI_msg_pack1(raw_data[0]);
    else
      return;
    
    RT_PATCH_send_raw_midi_message(patch, msg, seq_time);
  }
}
Ejemplo n.º 7
0
void List_InsertLines3(
	void *to,
	struct ListHeader3 *l,
	int line,
	int toinsert,
	void (*Insert_Lines_extra)(void *to,struct ListHeader3 *l,int line,int toinsert)
){
	struct ListHeader3 *temp;

	while(l!=NULL){
		if(Insert_Lines_extra!=NULL){
			(*Insert_Lines_extra)(to,l,line,toinsert);
		}
		if(l->p.line>=line){
			if(l->p.line<line-toinsert){
                                R_ASSERT_RETURN_IF_FALSE(l!=NULL);
				temp=l->next;
				ListRemoveElement3(to,l);
				l=temp;
				continue;
			}
			l->p.line+=toinsert;
		}

		l=l->next;
	}

}
Ejemplo n.º 8
0
/*****************************************************************************
  FUNCTION
    Moves the element to new place 'p', or closest legal position.
    A "legal position" means that it can not be positioned before the
    previous element, or after the next element. In addition, it can not be
    position at the same position as the previous element or next element
    ("ns" means "not same").

    The value for 'firstlegalpos' is only used if prev element is NULL.
    The value for 'lastlegalpos' is only used if next element is NULL.
******************************************************************************/
void ListMoveElement3_ns(
                         const void *voidlistroot,
                         struct ListHeader3 *element,
                         Place *newplace,
                         const Place *firstlegalpos,
                         const Place *lastlegalpos
){
  const struct ListHeaderPointer3 *listroot=voidlistroot;
  struct ListHeader3 *prev=NULL;
  struct ListHeader3 *next = element->next;
  struct ListHeader3 *l=listroot->root;

  while(l!=element){    
    prev = l;
    R_ASSERT_RETURN_IF_FALSE(l!=NULL);
    l=l->next;
  }

  Place firstlegalpos2;
  if (prev!=NULL)
    PlaceFromLimit(&firstlegalpos2, &prev->p);
  else
    PlaceCopy(&firstlegalpos2, firstlegalpos);

  Place lastlegalpos2;
  if (next!=NULL)
    PlaceTilLimit(&lastlegalpos2, &next->p);
  else
    PlaceCopy(&lastlegalpos2, lastlegalpos);

  element->p = *PlaceBetween(&firstlegalpos2, newplace, &lastlegalpos2);
}
Ejemplo n.º 9
0
static void schedule_next_LPB(struct SeqTrack *seqtrack, const struct SeqBlock *seqblock, const struct LPBs *next_lpb){
  R_ASSERT_RETURN_IF_FALSE(next_lpb != NULL);
  R_ASSERT_RETURN_IF_FALSE(seqblock!=NULL);
  
  const int num_args = 1;
        
  union SuperType args[num_args];
  args[0].const_pointer = seqblock;

  LPB_Iterator *iterator = &seqtrack->lpb_iterator;
    
  iterator->next_lpb = next_lpb;

  int64_t time = get_seqblock_place_time(seqblock, next_lpb->l.p);
  
  SCHEDULER_add_event(seqtrack, time, RT_scheduled_LPB, &args[0], num_args, SCHEDULER_LPB_PRIORITY);
}
Ejemplo n.º 10
0
 Gui(QWidget *widget)
   : _widget(widget)
 {
   R_ASSERT_RETURN_IF_FALSE(!g_guis.contains(this));
   
   _gui_num = g_guis.size();
   g_guis.push_back(this);
   _widget->setAttribute(Qt::WA_DeleteOnClose);
 }
Ejemplo n.º 11
0
void setNoteScrollLength(int l){
  R_ASSERT_RETURN_IF_FALSE(l>=0);

  if (l != g_downscroll){
  
    g_downscroll = l;

    GFX_OS_update_bottombar();
  }
}
Ejemplo n.º 12
0
void NOTE_validate(const struct Blocks *block, struct Tracks *track, struct Notes *note){
  R_ASSERT_RETURN_IF_FALSE(block!=NULL);
  R_ASSERT_RETURN_IF_FALSE(note!=NULL);

  R_ASSERT(track==NULL || PLAYER_current_thread_has_lock() || is_playing()==false);
  
  if (note->note<=0.0f){
    RError("notenum<=0.0f: %f. Setting to 0.01",note->note);
    note->note=0.01f;
  }
  if(note->note>=128.0f){
    RError("notenum>=128.0f: %f. Setting to 127.99",note->note);
    note->note=127.99;
  }

  set_legal_start_and_end_pos(block, track, note);

  ValidatePlace(&note->l.p);
  ValidatePlace(&note->end);
}
Ejemplo n.º 13
0
static void PlayerNextSignature(struct PEventQueue *peq,int doit){
  R_ASSERT_RETURN_IF_FALSE(g_signature != NULL);

  //printf("Player Next signature\n");
  
  g_signature_value = g_signature->signature;

  g_signature = NextSignature(g_signature);

  InsertNextSignature_PEQ(peq);
}
Ejemplo n.º 14
0
static void DrawAllWTrackNames(
                               struct Tracker_Windows *window,
                               const struct WBlocks *wblock
                               )
{  
  //int num_tracks = ListFindNumElements1(&wblock->wtracks->l);
  //bool *draw_border = alloca(sizeof(bool) * num_tracks);
  //memset(draw_border, 0, sizeof(bool) * num_tracks);

  {
    const struct WTracks *wtrack1 = get_leftmost_visible_wtrack(wblock);
    if (wtrack1==NULL)
      return;

    const struct WTracks *rightmost_wtrack = get_rightmost_visible_wtrack(wblock, wtrack1);
    R_ASSERT_RETURN_IF_FALSE(rightmost_wtrack!=NULL);
                      
    int tracknum1 = wtrack1->l.num;
    
    int channelnum1 = ATOMIC_GET(wtrack1->track->midi_channel);
    struct Patch   *patch1   = wtrack1->track->patch;
    struct WTracks *wtrack2  = NextWTrack(wtrack1);
    int tracknum2            = tracknum1;

    for(;;){
      int channelnum2 = wtrack2==NULL ? 0 : ATOMIC_GET(wtrack2->track->midi_channel);
    
      if (wtrack2==NULL || wtrack2->track->patch==NULL || patch1==NULL || wtrack2->track->patch != patch1 || channelnum2 != channelnum1){
      
        DrawWTrackNames(window, wblock, tracknum1, tracknum2);
        tracknum1 = tracknum2 = tracknum2+1;
        channelnum1 = channelnum2;
        patch1 = wtrack2==NULL ? NULL : wtrack2->track->patch;

        if (tracknum1 > rightmost_wtrack->l.num)
          break;
      
      } else {
        tracknum2++;
      }

      if (wtrack2==NULL)
        break;

      //if (tracknum2 - tracknum1 >= 1)
      //  draw_border[wtrack2->l.num] = true;
    
      wtrack2 = NextWTrack(wtrack2);
    }
  }
  

}
Ejemplo n.º 15
0
void DISK_delete_base64_file(const wchar_t *wfilename){
  radium::ScopedMutex lock(&g_mutex);
  
  QString key = STRING_get_qstring(wfilename);
  QTemporaryFile *file = g_temporary_files[key];

  R_ASSERT_RETURN_IF_FALSE(file!=NULL);

  g_temporary_files.remove(key);
  
  delete file;
}
Ejemplo n.º 16
0
void ListRemoveElement3(
	void *voidlistroot,
	const struct ListHeader3 *element
){
	struct ListHeaderPointer3 *listroot=voidlistroot;
	struct ListHeader3 *temp=listroot->root;
	struct ListHeader3 *prev=NULL;

	if(temp==element){
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		listroot->root=element->next;
	}else{
		while(temp!=element){
                        R_ASSERT_RETURN_IF_FALSE(temp!=NULL);
			prev=temp;
			temp=temp->next;

		}
                R_ASSERT_RETURN_IF_FALSE(prev!=NULL);
                R_ASSERT_RETURN_IF_FALSE(element!=NULL);
		prev->next=element->next;
	}
}
Ejemplo n.º 17
0
void ListRemoveElement3_fromNum(
                                void *voidlistroot,
                                int num
                                )
{
	struct ListHeaderPointer3 *listroot=voidlistroot;
	struct ListHeader3 *temp=listroot->root;
	struct ListHeader3 *prev=NULL;
        int n = 0;
        
	if(num==0){
          listroot->root=temp->next;
	}else{
          while(n!=num){
            prev=temp;
            R_ASSERT_RETURN_IF_FALSE(temp!=NULL);
            temp=temp->next;
            n++;
          }
          R_ASSERT_RETURN_IF_FALSE(prev!=NULL);
          R_ASSERT_RETURN_IF_FALSE(temp!=NULL);
          prev->next=temp->next;
	}
}
Ejemplo n.º 18
0
void GFX_update_instrument_patch_gui(struct Patch *patch){
  //printf("Called GFX_update_instrument_patch_gui for patch \"%s\"\n",patch==NULL?"<>":patch->name);
  if(patch!=NULL && patch->patchdata!=NULL){
    R_ASSERT_RETURN_IF_FALSE(patch->instrument != NULL);
    if (patch->instrument->PP_Update!=NULL)
      patch->instrument->PP_Update(patch->instrument,
                                   patch,
                                   false);
  }
#if 0
  if(wblock->wtrack->track->patch!=NULL && wblock->wtrack->track->patch->instrument->PP_Update!=NULL)
    wblock->wtrack->track->patch->instrument->PP_Update(wblock->wtrack->track->patch->instrument,
                                                        wblock->wtrack->track->patch);
#endif
}
Ejemplo n.º 19
0
void CHIP_kick_right(Chip *chip){
  std::set<Chip*> kicks;

  CHIP_kick_right_rec(chip, kicks);

  for(std::set<Chip*>::iterator chip = kicks.begin() ; chip!=kicks.end() ; chip++){
    QPointF pos=(*chip)->pos();

    SoundPlugin *plugin = SP_get_plugin((*chip)->_sound_producer);
    volatile struct Patch *patch = plugin->patch;
    R_ASSERT_RETURN_IF_FALSE(patch!=NULL);

    Undo_ChipPos_CurrPos((struct Patch*)patch);
    (*chip)->setPos(pos.x()+grid_width, pos.y());
  }
}
Ejemplo n.º 20
0
void testColorInRealtime(enum ColorNums num, QColor color){
  R_ASSERT_RETURN_IF_FALSE(num<END_CONFIG_COLOR_NUM);

  struct Tracker_Windows *window = root->song->tracker_windows;
  EditorWidget *my_widget=(EditorWidget *)window->os_visual.widget;
  setColor(num,color.rgb());
  updateAll(my_widget);

  if(false && num==0)
    my_widget->repaint(); // todo: fix flicker.
  else{
    // Doesn't draw everything.
    DO_GFX({
        DrawUpTrackerWindow(window);
      });
    //GL_create(window, window->wblock);
    my_widget->updateEditor();
  }
Ejemplo n.º 21
0
static void RT_schedule_reallines_in_block2(struct SeqTrack *seqtrack, struct SeqBlock *seqblock, struct WBlocks *wblock, int realline){
  R_ASSERT_RETURN_IF_FALSE(seqblock->block != NULL);

  if(realline>=wblock->num_reallines)
    return;

  const int num_args = 4;
    
  union SuperType args[num_args];

  args[0].const_pointer = seqblock;
  args[1].pointer = wblock;
  args[2].int32_num = realline;
  args[3].int_num = ++seqblock->curr_scheduled_realline_counter;

  Place realline_place = wblock->reallines[realline]->l.p;
  int64_t time = get_seqblock_place_time(seqblock, realline_place);

  SCHEDULER_add_event(seqtrack, time, RT_scheduled_realline, &args[0], num_args, SCHEDULER_INIT_PRIORITY);
}
Ejemplo n.º 22
0
static void setColor(enum ColorNums num, const QRgb &rgb){
  R_ASSERT_RETURN_IF_FALSE(num<END_CONFIG_COLOR_NUM);

  GL_lock();{

#if USE_GTK_VISUAL
    GTK_SetColor(num,qRed(rgb),qGreen(rgb),qBlue(rgb));
#endif

    if (g_config_colors[num]==NULL)
      get_config_qcolor(num);

    g_config_colors[num]->setRgb(rgb);
    
    if(num==LOW_BACKGROUND_COLOR_NUM)
      system_color->setRgb(rgb);
    else if(num==HIGH_BACKGROUND_COLOR_NUM)
      button_color->setRgb(rgb);
    
  }GL_unlock();
}
Ejemplo n.º 23
0
static void distribute_trackreallines(const struct WBlocks *wblock, vector_t *tr, vector_t *trs, int realline1, int realline2){  
  int num_elements      = tr->num_elements;
  int num_lines         = realline2 - realline1;
  //int elements_per_line = R_MAX(1, num_elements / num_lines);
  int elements_per_line = ceilf((float)num_elements / (float)num_lines);
  R_ASSERT_RETURN_IF_FALSE(elements_per_line>0);
  
  int element_pos = 0;
  int num_elements_left = num_elements;

  int realline;
  for(realline=realline1 ; realline < realline2 ; realline++){
    int num_elements_to_copy = R_MIN(num_elements_left, elements_per_line);
    //printf("copying from %d: %d -> %d, into %d\n", realline1, element_pos, element_pos+num_elements_to_copy, realline);
    VECTOR_copy_elements(tr, element_pos, num_elements_to_copy, &trs[realline]);

    element_pos += num_elements_to_copy;    
    num_elements_left -= num_elements_to_copy;

    if (num_elements_left==0)
      break;
  }
}
Ejemplo n.º 24
0
void setNoteScrollLength(int l){
  R_ASSERT_RETURN_IF_FALSE(l>=0);
  g_downscroll = l;
}
Ejemplo n.º 25
0
static void set_iterator_data(LPB_Iterator *iterator, const struct Blocks *block, const struct LPBs *lpb){  
  R_ASSERT_RETURN_IF_FALSE(lpb != NULL);

  set_iterator_data2(iterator, block, lpb->l.p, lpb->lpb, NextLPB(lpb));
}