Пример #1
0
void FAUST_change_qtguistyle(const char *style_name){

  QString filename = OS_get_full_program_file_path("packages/faust2/architecture/faust/gui/Styles/" + QString(getFaustGuiStyle()) + ".qss");
  disk_t *disk = DISK_open_for_reading(filename);
  if (disk==NULL){
      
    GFX_Message(NULL, "File not found (%s)", filename.toUtf8().constData());
    
  } else {
    
    QString stylesheet = DISK_read_qstring_file(disk);
    if (DISK_close_and_delete(disk)==false) {
      GFX_Message(NULL, "Unable to read from %s", filename.toUtf8().constData());
      stylesheet = "";
    }

    if (stylesheet!="")
      g_qtgui_stylesheet = stylesheet;
  }

  if (g_qtgui_stylesheet != "")
    for(auto faustqdialog : g_faustqdialogs)
      faustqdialog->setStyleSheet(g_qtgui_stylesheet);
  
}
Пример #2
0
void saveBlock(const char *filename, int blocknum, int windownum){
  struct Tracker_Windows *window;
  struct WBlocks *wblock;

  wblock=getWBlockFromNumA(
                           windownum,
                           &window,
                           blocknum
                           );

  if(wblock==NULL)
    return;

  if (filename==NULL || !strcmp(filename, ""))
    filename = "/tmp/block.block";

  if (Save_Initialize(STRING_create(filename), "RADIUM BLOCK")==false)
    return;

  SaveWBlock(wblock);
  SaveBlock(wblock->block);

  if( ! dc.success){
    handleError("Problems writing to file.\n");
  }
  
  DISK_close_and_delete(dc.file);
}
Пример #3
0
// Only used for audio files, so we don't bother with compression.
const char *DISK_file_to_base64(const wchar_t *wfilename){
  disk_t *disk = DISK_open_binary_for_reading(wfilename);

  if (disk==NULL)
    return NULL;

  QByteArray data = disk->file()->readAll();

  DISK_close_and_delete(disk);

  return talloc_strdup(data.toBase64().constData());
}
Пример #4
0
static void set_wav_loop_points(Sample *sample, const wchar_t *filename, bool set_loop_on_off){
  
  disk_t *file = DISK_open_binary_for_reading(filename);
  
  if(file==NULL){
    GFX_Message(NULL, "Could not open file \"%s\". libsndfile could open the file though. Something might be wrong with your disk.",filename);
    return;
  }

  if(set_wav_loop_points_using_smpl_chunk(sample,file, set_loop_on_off)==false)
    set_wav_loop_points_using_cues(sample,file, set_loop_on_off);

  DISK_close_and_delete(file);
}
Пример #5
0
QString FAUST_get_cpp_code(const struct SoundPlugin *plugin){
  Devdata *devdata = (Devdata*)plugin->data;
  if (devdata->reply.svg_dir==NULL || devdata->reply.svg_dir->isValid()==false)
    return "";

  QString filename = devdata->reply.svg_dir->path() + QDir::separator() + "cppsource.cpp";
  disk_t *disk = DISK_open_for_reading(filename);

  if (disk==NULL){
    GFX_Message(NULL, "File not found (%s)", filename.toUtf8().constData());
    return "";
  }

  QString cpp_code = DISK_read_qstring_file(disk);
      
  if (DISK_close_and_delete(disk)==false) {
    GFX_Message(NULL, "Unable to read from %s", filename.toUtf8().constData());
    return "";
  }

  return cpp_code;
}
Пример #6
0
static bool Load(const wchar_t *filename){
	struct Root *newroot;

        dc.success=true;

        curr_disk_line = 0;

	dc.file=DISK_open_for_reading(filename);
	if(dc.file==NULL){
          GFX_Message(NULL,"Could not open \"%s\" for loading\n",STRING_get_chars(filename));
          return false;
	}

	DC_fgets();
        if (dc.success==false)
          return false;
        
	if(strcmp("RADIUM SONG",dc.ls)){
          GFX_Message(NULL,"First line in song was not 'RADIUM SONG', but '%s'. Last: %d\n",dc.ls,dc.ls[strlen(dc.ls)-1]);
          DISK_close_and_delete(dc.file);
          return false;
	}

	disk_load_version=DC_LoadF();
        if (dc.success==false)
          return false;

	if(disk_load_version>0.4201 && disk_load_version<0.50){
		disk_load_version=0.51;
		dc.colorize=true;
		dc.startcolor=5;
	}else{
		dc.colorize=false;
	}

#if 0
        if (disk_load_version < 0.75){
          GFX_Message(NULL,
                      "<p>Note! The portamento behavior for polyphonic tracks changed in Radium V3.4.9"
                      "</p>"
                      "<p>"
                      "Before Radium V3.4.9, the default final portamento value was the pitch value of the next note after the <i>start</i> of the note. "
                      "Now, the default final portamento value is the pitch value of the next note after the <i>end</i> of the note."
                      "</p>"
                      "<p>"
                      "Old songs with portamento in polyphonic tracks might not sound the same."
                      "</p>"
                      );
        }
#endif

        if(disk_load_version>DISKVERSION+0.0001){
          GFX_Message(NULL,"Need a newer version of Radium to load this song. The song version is %f, while this program only supports %f.\n",disk_load_version,DISKVERSION);
          return false;
        }else{
          printf("Song diskVersion: %f\n",disk_load_version);
        }

	dc.filename=filename;

	dc.playlist=NULL;

	DC_Next();
        if (dc.success==false)
          return false;
        
	if(strcmp(dc.ls,"OSSTUFF")){
          GFX_Message(NULL, "OSSTUFF not found, but: '%s'. File: '%s'\n",dc.ls,STRING_get_chars(filename));
          DISK_close_and_delete(dc.file);
          EndProgram();
          exit(4);
	}

	LoadOsStuff();
        
	printf("dc.ls: -%s-\n",dc.ls);
	if(strcmp(dc.ls,"ROOT")){
          GFX_Message(NULL, "ROOT not found. Found '%s' instead.\n", dc.ls);
          DISK_close_and_delete(dc.file);
          EndProgram();
          exit(5);
	}

	newroot=LoadRoot();
        
        DISK_close_and_delete(dc.file);

	if(!dc.success){
          GFX_Message(NULL, "Loading failed.\n");
          EndProgram();
          exit(6);
	}
        
	ResetUndo();

        
#ifdef _AMIGA
	CloseHelpWindow();
	CloseCPPWindowWindow();
	CloseBlockSelectWindow();
#endif
	CloseAllTrackerWindows();

        GL_lock();{
          GL_pause_gl_thread_a_short_while();
        }GL_unlock();

        //GL_draw_lock();{
        PLAYER_lock();{ //<-- Locks within locks are dangerous. But it doesn't matter since the player isn't playing now anyway.
          root=newroot;		//BANG!
        }PLAYER_unlock();
        //}GL_draw_unlock();

        Undo_start_ignoring_undo_operations();{
          DLoadRoot(newroot);
        }Undo_stop_ignoring_undo_operations();

        GL_create_all(root->song->tracker_windows);
        

        if(COMMENT_show_after_loading())
          COMMENTDIALOG_open();

#ifdef _AMIGA
	currpatch=-1;
#endif

        ResetUndo();
                
	return true;

}
Пример #7
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();
}