zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit a734ee27ea7b1236cfabbf9e112fee784fce8365
parent 057c16d4aba0d8c07499cc82ed61e3557f008db5
Author: Harald Hvaal <harald.hvaal@gmail.com>
Date:   Sat,  8 May 2010 15:58:15 +0200

Revert "Reducing lock time for instrument load"

This reverts commit cac44090604c8582f8484ab999c7a8f70cc45c31.

Diffstat:
Msrc/Misc/Bank.cpp | 19+++++--------------
Msrc/Misc/Bank.h | 2+-
Msrc/Misc/Part.cpp | 6+-----
Msrc/Misc/Part.h | 3---
Msrc/Params/LFOParams.cpp | 3++-
Msrc/UI/BankUI.fl | 17++++++++++-------
6 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/src/Misc/Bank.cpp b/src/Misc/Bank.cpp @@ -26,9 +26,7 @@ #include <stdlib.h> #include <dirent.h> #include <sys/stat.h> -#include <algorithm> -#include <pthread.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> @@ -36,8 +34,6 @@ #include "Config.h" -using namespace std; - #define INSTRUMENT_EXTENSION ".xiz" //if this file exists into a directory, this make the directory to be considered as a bank, even if it not contains a instrument file @@ -241,21 +237,16 @@ void Bank::savetoslot(unsigned int ninstrument, Part *part) /* * Loads the instrument from the bank */ -void Bank::loadfromslot(unsigned int ninstrument, Part *&part) +void Bank::loadfromslot(unsigned int ninstrument, Part *part) { if(emptyslot(ninstrument)) return; - Part *p = new Part(part->getMicrotonal(), part->getFFT(), part->mutex); - p->loadXMLinstrument(ins[ninstrument].filename); - p->Penabled = true; - p->applyparameters(); + part->defaultsinstrument(); + +// printf("load: %s\n",ins[ninstrument].filename); - //swap pointers to greatly reduce locked time - pthread_mutex_lock(part->mutex); - swap(part,p); - delete p; - pthread_mutex_unlock(part->mutex); + part->loadXMLinstrument(ins[ninstrument].filename); } diff --git a/src/Misc/Bank.h b/src/Misc/Bank.h @@ -57,7 +57,7 @@ class Bank /**Saves the given Part to slot*/ void savetoslot(unsigned int ninstrument, Part *part); /**Loads the given slot into a Part*/ - void loadfromslot(unsigned int ninstrument, Part *&part); + void loadfromslot(unsigned int ninstrument, Part *part); /**Swaps Slots*/ void swapslot(unsigned int n1, unsigned int n2); diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp @@ -178,11 +178,7 @@ void Part::cleanup() Part::~Part() { - for(int k = 0; k < POLIPHONY; k++) - KillNotePos(k); - for(int nefx = 0; nefx < NUM_PART_EFX; nefx++) - partefx[nefx]->cleanup(); - + cleanup(); for(int n = 0; n < NUM_KIT_ITEMS; n++) { if(kit[n].adpars != NULL) delete (kit[n].adpars); diff --git a/src/Misc/Part.h b/src/Misc/Part.h @@ -106,9 +106,6 @@ class Part void setkeylimit(unsigned char Pkeylimit); void setkititemstatus(int kititem, int Penabled_); - Microtonal *getMicrotonal(){return microtonal;}; - FFTwrapper *getFFT(){return fft;}; - unsigned char Penabled; /**<if the part is enabled*/ unsigned char Pvolume; /**<part volume*/ unsigned char Pminkey; /**<the minimum key that the part receives noteon messages*/ diff --git a/src/Params/LFOParams.cpp b/src/Params/LFOParams.cpp @@ -25,7 +25,7 @@ #include "../globals.h" #include "LFOParams.h" -int LFOParams::time=0; +int LFOParams::time; LFOParams::LFOParams(char Pfreq_, char Pintensity_, @@ -55,6 +55,7 @@ LFOParams::LFOParams(char Pfreq_, Ddelay = Pdelay_; Dcontinous = Pcontinous_; fel = fel_; + time = 0; defaults(); } diff --git a/src/UI/BankUI.fl b/src/UI/BankUI.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0300 +version 1.0107 header_name {.h} code_name {.cc} decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {} @@ -31,13 +31,13 @@ decl {\#include "../Misc/Config.h"} {public } class BankProcess_ {} { - Function {process()} {return_type {virtual void} + Function {process()} {open return_type {virtual void} } {} decl {Bank *bank;} {public } } -class BankSlot {: {public Fl_Button,BankProcess_} +class BankSlot {open : {public Fl_Button,BankProcess_} } { Function {BankSlot(int x,int y, int w, int h, const char *label=0):Fl_Button(x,y,w,h,label)} {} { code {what=NULL; @@ -59,7 +59,8 @@ int tmp=Fl_Button::handle(event); if ((*what!=0) && Fl::event_inside(this)) (bp->*fnc)(); return(tmp);} {} } - Function {init(int nslot_, int *what_, int *whatslot_,void (BankProcess_:: *fnc_)(void),BankProcess_ *bp_,Bank *bank_,int *nselected_)} {} { + Function {init(int nslot_, int *what_, int *whatslot_,void (BankProcess_:: *fnc_)(void),BankProcess_ *bp_,Bank *bank_,int *nselected_)} {open + } { code {nslot=nslot_; what=what_; whatslot=whatslot_; @@ -73,7 +74,8 @@ labelsize(13); align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP); highlight=0; -refresh();} {} +refresh();} {selected + } } Function {refresh()} {} { code {if (bank->emptyslot(nslot)) { @@ -252,7 +254,9 @@ if ((what==2)&&(bank->emptyslot(slot)==0)&&(mode!=4)) {//Rename slot }; if ((what==1)&&(mode==1)&&(!bank->emptyslot(slot))){//Reads from slot + pthread_mutex_lock(&master->mutex); bank->loadfromslot(slot,master->part[*npart]); + pthread_mutex_unlock(&master->mutex); master->part[*npart]->applyparameters(); snprintf((char *)master->part[*npart]->Pname,PART_MAX_NAME_LEN,"%s",bank->getname(slot)); cbwig->do_callback(); @@ -301,8 +305,7 @@ if (mode==4){//swap bs[slot]->refresh(); }; }; -if (mode!=4) refreshmainwindow();} {selected - } +if (mode!=4) refreshmainwindow();} {} } Function {refreshmainwindow()} {} { code {bankuiwindow->label(bank->bankfiletitle);