Example #1
0
char *GFX_ReadStringFromPythonCommand(char *pythoncommand){
  FILE *file;
  char filename[50];
  char temp[strlen(pythoncommand)+500];
  char *ret=talloc_atomic(strlen(pythoncommand)+500);
  ret[0] = '\0';

  sprintf(filename,"/tmp/radiumipctempfileXXXXXX");
  int x1 = mkstemp(filename);
  (void)x1;

  sprintf(temp,pythoncommand,filename);


  PyRun_SimpleString(temp);


  file=fopen(filename,"r");
  if(file==NULL) {
    RError("GFX_ReadStringFromPythonCommand: File is null -%s-.\n",filename);
    return ret;
  }

  void* x2 = fgets(ret,strlen(pythoncommand)+499,file);
  fclose(file);
  (void)x2;

  printf("Tried to read -%s-\n",ret);
  sprintf(temp,"rm %s",filename);
  if(system(temp)==-1)
    RWarning("Unable to delete \"%s\"",filename);
  
  return ret;
}
Example #2
0
int GFX_Menu(
	struct Tracker_Windows *tvisual,
	ReqType reqtype,
	char *seltext,
	int num_sel,
	char **menutext
){
  char *temp=talloc_atomic(num_sel*500);
  char *selectedtext;
  int lokke;

  if(reqtype==NULL || num_sel>20){

    sprintf(temp,"X11_Qtstuff.GFX_MenuDialog(\"%%s\",\"%s\"",seltext);
    
    for(lokke=0;lokke<num_sel;lokke++){
      sprintf(temp,"%s,\"%s\"",temp,menutext[lokke]);
    }
    sprintf(temp,"%s,\"cancel\")",temp);
    
    selectedtext=GFX_ReadStringFromPythonCommand(temp);
    
    for(lokke=0;;){
      if(!strcmp(selectedtext,menutext[lokke])) break;
      lokke++;
      if(lokke==num_sel){
	return -1;
      }
    }

    return lokke;
  }else{
    return GFX_ReqTypeMenu(tvisual,reqtype,seltext,num_sel,menutext);
  }
}
Example #3
0
static float *load_interleaved_samples(const wchar_t *filename, SF_INFO *sf_info){
  SNDFILE *sndfile          = sf_open(STRING_get_chars(filename),SFM_READ,sf_info);
  if(sndfile==NULL)
    return NULL;

  float   *ret              = talloc_atomic(sizeof(float) * sf_info->channels * sf_info->frames);
  int      allocated_frames = sf_info->frames;

  int total_read_frames     = sf_readf_float(sndfile, ret, sf_info->frames);

  if(total_read_frames==0)
    return NULL;

  while(true){
    float samples[1024*sf_info->channels];
    int read_now = sf_readf_float(sndfile, samples, 1024);
    if(read_now==0)
      break;

    if(total_read_frames + read_now > allocated_frames){
      allocated_frames = (total_read_frames+read_now) * 2;
      ret = talloc_realloc(ret, allocated_frames * sizeof(float) * sf_info->channels);
    }

    memcpy(ret + (total_read_frames*sf_info->channels), samples, sizeof(float)*1024*sf_info->channels);

    total_read_frames += read_now;
  }

  sf_close(sndfile);

  sf_info->frames = total_read_frames;
  return ret;
}
Example #4
0
Blt *Blt_getBlt(){
  Blt *ret;
  if(bltsroot==NULL){
    return talloc_atomic(sizeof(struct Blts));
  }

  ret=bltsroot;
  bltsroot=ret->next;

  return ret;
}
Example #5
0
void Amiga_ConfigColors(void){
	FILE *file;
	UWORD depth;
	long num_colors=1;
	long lokke;
	int lokke2;
	ULONG *table;

	rtPaletteRequest(
		"Color Config. Saved as radium:radiumcolors.conf",NULL,
		RT_Screen,mainscreen,
		TAG_END
	);

	file=fopen("radium:radiumcolors.conf","w");
	if(file==NULL){
		RError("Could not save radium:radiumcolors.conf\n");
		return;
	}
	depth=GetBitMapAttr(mainscreen->RastPort.BitMap,BMA_DEPTH);
	for(lokke=0;lokke<depth;lokke++){
		num_colors*=2;
	}

	fprintf(file,"%d\n",num_colors);

	table=talloc_atomic((size_t)(sizeof(ULONG)*num_colors*3));

	GetRGB32(mainscreen->ViewPort.ColorMap,0,num_colors,table);

	for(lokke=0;lokke<num_colors;lokke++){
		if(lokke==256) break;
		for(lokke2=0;lokke2<3;lokke2++){
			fprintf(file,"%lu\n",table[lokke*3+lokke2]);
		}
	}

	fclose(file);
	
}
Example #6
0
void Undo_TrackHeader(
	struct Tracker_Windows *window,
	struct Blocks *block,
	struct Tracks *track,
	int realline
){
	struct Undo_TrackHeader *u_th=talloc_atomic(sizeof(struct Undo_TrackHeader));
	u_th->volume=track->volume;
	u_th->pan=track->pan;
	u_th->volumeonoff=track->volumeonoff;
	u_th->panonoff=track->panonoff;

        Undo_Add_dont_stop_playing(
                                   window->l.num,
                                   block->l.num,
                                   track->l.num,
                                   realline,
                                   u_th,
                                   Undo_Do_TrackHeader
                                   );

}
Example #7
0
void ADD_UNDO_FUNC(
                   MainTempo(
                             struct Tracker_Windows *window,
                             struct WBlocks *wblock
                             )
                   )
{
	struct Undo_MainTempo *u_rt=talloc_atomic(sizeof(struct Undo_MainTempo));
	u_rt->tempo=root->tempo;
	u_rt->lpb=root->lpb;
        u_rt->signature=root->signature;
        u_rt->quantitize_options = root->quantitize_options;

	Undo_Add(
                 window->l.num,
                 wblock->l.num,
                 wblock->wtrack->l.num,
                 wblock->curr_realline,
                 u_rt,
                 Undo_Do_MainTempo,
                 "Block tempo/lpb/signature/quantiatize settings"
	);

}
Example #8
0
struct WSignatures *WSignatures_get(
                                    const struct Tracker_Windows *window,
                                    const struct WBlocks *wblock
                                    )
{
        struct WSignatures *wsignatures = (struct WSignatures *)talloc_atomic_clean(sizeof(struct WSignatures)*wblock->num_reallines);

	int realline=0;
        int last_written_realline = -1;
        int last_written_new_bar_realline = -1;
        
        struct Beats *beat = wblock->block->beats;

	while(beat!=NULL){

		realline=FindRealLineFor(wblock,realline,&beat->l.p);
                bool is_new_bar = beat->beat_num==1;
                
                if(PlaceNotEqual(&wblock->reallines[realline]->l.p,&beat->l.p)) {
                  wsignatures[realline].type=SIGNATURE_BELOW;
                  float *f = (float*)talloc_atomic(sizeof(float));
                  float y1 = p_float(wblock->reallines[realline]->l.p);
                  float y2 = realline==wblock->num_reallines-1 ? wblock->num_reallines : p_float(wblock->reallines[realline+1]->l.p);
                  *f = scale( p_float(beat->l.p),
                              y1, y2,
                              0,1);
                  VECTOR_push_back(&wsignatures[realline].how_much_below, f);
                }

                /*
                if (realline==1) {
                  printf("1: %s %d %d %s\n",
                         ratio_to_string(beat->signature),
                         beat->bar_num,
                         beat->beat_num,
                         wsignatures[realline].type != SIGNATURE_MUL ? "true" : "false"
                         );
                }
                */
                
                if (is_new_bar && realline != last_written_new_bar_realline) {  // Unlike the multi-behavior for other wxxx-types, we show the first element, and not the last.
                  
                  wsignatures[realline].signature = beat->signature;
                  wsignatures[realline].bar_num  = beat->bar_num;
                  wsignatures[realline].beat_num  = beat->beat_num;
                  
                } else if (realline != last_written_realline) {
                  
                  wsignatures[realline].signature = beat->signature;
                  wsignatures[realline].bar_num  = beat->bar_num;
                  wsignatures[realline].beat_num  = beat->beat_num;
                  
                } else {
                  
                  wsignatures[realline].type=SIGNATURE_MUL;
                  
		}
        
        
                last_written_realline = realline;
                if (is_new_bar)
                  last_written_new_bar_realline = realline;
		beat = NextBeat(beat);
	}

        return wsignatures;
}
Example #9
0
static void create_peaks(
                         struct Tracker_Windows *window,
                         struct WBlocks *wblock,
                         struct WTracks *wtrack)
{
  struct Blocks *block = wblock->block;

  int realline;
  for(realline=0;realline<wblock->num_reallines;realline++){
    struct TrackRealline *trackrealline= &wtrack->trackreallines[realline];
    struct TrackReallineElements *element;
    for(element=trackrealline->trackreallineelements;element!=NULL;element=element->next){
      if(element->type==TRE_VELLINE){
        
        if(TRACK_has_peaks(wtrack->track)==true && (element->y2-element->y1)>0.001){

          struct Patch *patch = wtrack->track->patch;

          struct Notes *note=element->pointer;
          float note_time = Place2STime(block, &note->l.p);

          element->num_peaks = ((element->y2-element->y1)*NUM_PEAKS_PER_LINE)+1;
          if(element->num_peaks<0){
            RError("element->num_peaks<0: %d",element->num_peaks);
            element->num_peaks=0;
          }

          if(element->num_peaks>0){

            element->num_peaks++; // We're generating coordinates for a polygon, and it needs to stretch to the start of the next node.

            float time1 = Place2STime(block, &wblock->reallines[realline]->l.p) - note_time;
            float time2;

            if(realline<wblock->num_reallines-1){
              time2 = Place2STime(block, &wblock->reallines[realline+1]->l.p);
            }else{
              time2 = block->times[block->num_lines].time;
            }
            time2 = time2 - note_time;

            const int num_channels=PATCH_get_peaks(patch, 0,
                                                   -1,
                                                   wtrack->track,
                                                   0,0,
                                                   NULL,NULL);
            int ch;

            for(ch=0;ch<num_channels;ch++){
              APoint *peaks=talloc_atomic(element->num_peaks*2*sizeof(APoint));
              
              element->peaks[ch] = peaks;

              int i;
              for(i=0;i<element->num_peaks;i++){
                float y1 = scale(i,0,element->num_peaks-1,element->y1,element->y2); // -1 is here since we generate 2 points for each node.
                float y2 = scale(i+1,0,element->num_peaks-1,element->y1,element->y2);

                float track_volume =  wtrack->track->volumeonoff ? (float)wtrack->track->volume / MAXTRACKVOL : 1.0f;
                float velocity = scale(y2,element->y1,element->y2,element->x1,element->x2);

                float min,max;
                PATCH_get_peaks(patch, 
                                note->note,
                                ch,
                                wtrack->track,
                                scale(y1,0,1,time1,time2) / block->reltempo,
                                scale(y2,0,1,time1,time2) / block->reltempo,
                                &min,
                                &max);
                
                float bound_x1 = scale(ch,0,num_channels,0.0f,velocity);
                float bound_x2 = scale(ch+1,0,num_channels,0.0f,velocity);

                peaks[i].x = R_MAX(bound_x1, scale(min*track_volume,-1,1, bound_x1, bound_x2));
                peaks[i].y = y1;
                peaks[element->num_peaks*2 - 1 - i].x = R_MIN(bound_x2, scale(max*track_volume,-1,1, bound_x1, bound_x2));
                peaks[element->num_peaks*2 - 1 - i].y = y1; //max
              }
            }
          }
        }

        element->velocity_polygon=talloc_atomic(2*2*sizeof(APoint));
          
        element->velocity_polygon[0].x = 0.0f;
        element->velocity_polygon[0].y = element->y1;
          
        element->velocity_polygon[1].x = 0.0f;
        element->velocity_polygon[1].y = element->y2;
        
        element->velocity_polygon[2].x = element->x2;
        element->velocity_polygon[2].y = element->y2;
        
        element->velocity_polygon[3].x = element->x1;
        element->velocity_polygon[3].y = element->y1;
      }
    }
  }
}