No BSD License  

Highlights from
LFO - Maker

from LFO - Maker by Cristian Zambelli
A system for build different LFO Type

fcnLFO(action)
%Function File esterno per i callback
%
%written by Zambelli Cristian
function fcnLFO(action)
global popup rsstep wallsupply rate amp phase dcoffset rectif damping;
switch(action)
case 'plot'
   popuphandle=findobj(gcbf,'Tag','PopupMenu1');
   popup=get(popuphandle,'Value');
   popuphandle2=findobj(gcbf,'Tag','PopupMenu2');
   popup2=get(popuphandle2,'Value');
   %LFW sinusoidale
   if popup==1
   rsstephandle=findobj(gcbf,'Tag','Checkbox1');
   rsstep=get(rsstephandle,'Value');
   if rsstep==0
      samplerate=11025;
   elseif rsstep==1
      samplerate=50;
   end
   wallsupplyhandle=findobj(gcbf,'Tag','Checkbox2');
   wallsupply=get(wallsupplyhandle,'Value');
   ratehandle=findobj(gcbf,'Tag','EditText1');
   rate=str2num(get(ratehandle,'String'));
   if (rate<0.3)|(rate>16)
      h=warndlg('This is not a right rate value for an LFO please type a value from 0.3 to 16 Hz','Warning!!');
   end
   amphandle=findobj(gcbf,'Tag','EditText2');
   amp=str2num(get(amphandle,'String'));
   if (amp<0)|(amp>18)
      h=warndlg('This is not a right amplitude value for an LFO please type a value from 0 to 18 V','Warning!!');
   end
   phasehandle=findobj(gcbf,'Tag','EditText3');
   phase=str2num(get(phasehandle,'String'));
   if (phase<0)|(phase>359)
      h=warndlg('This is not a right phase value for an LFO please type a value from 0 to 359 degrees','Warning!!');
   end
   dchandle=findobj(gcbf,'Tag','EditText4');
   dcoffset=str2num(get(dchandle,'String'));
   if (dcoffset<-18)|(dcoffset>18)
      h=warndlg('This is not a right dcoffset value for an LFO please type a value from -18 to 18 V','Warning!!');
   end
   dampinghandle=findobj(gcbf,'Tag','EditText5');
   damping=str2num(get(dampinghandle,'String'));
   rectifhandle=findobj(gcbf,'Tag','Checkbox3');
   rectif=get(rectifhandle,'Value');
   h=waitbar(0,'Performing Calculus on LFO... Please Wait');
   for i=1:100,t=0:1/samplerate:5;
      waitbar(i/100);
   end
   close(h);
   if wallsupply==0
      x=dcoffset+amp*exp(-(t*damping)).*sin(2*pi*rate*t+phase);
   elseif wallsupply==1
      x=dcoffset+amp*exp(-(t*damping)).*sin(2*pi*rate*t+phase)+0.1*sin(2*pi*50*t);
   end
   if rectif==1
      y=abs(x);
   elseif rectif==0
      y=x;
   end
   switch(popup2)
   case 1
      i=int8(y);
   case 2
      i=int16(y);
   case 3
      i=int32(y);
   case 4
      i=single(y);
   case 5
      i=double(y);
   end
   plot(t,i,'EraseMode','xor');
	end
   %%LFW cosinusoidale
   if popup==2
   rsstephandle=findobj(gcbf,'Tag','Checkbox1');
   rsstep=get(rsstephandle,'Value');
   if rsstep==0
      samplerate=11025;
   elseif rsstep==1
      samplerate=50;
   end
   wallsupplyhandle=findobj(gcbf,'Tag','Checkbox2');
   wallsupply=get(wallsupplyhandle,'Value');
   ratehandle=findobj(gcbf,'Tag','EditText1');
   rate=str2num(get(ratehandle,'String'));
   if (rate<0.3)|(rate>16)
      h=warndlg('This is not a right rate value for an LFO please type a value from 0.3 to 16 Hz','Warning!!');
   end
   amphandle=findobj(gcbf,'Tag','EditText2');
   amp=str2num(get(amphandle,'String'));
   if (amp<0)|(amp>18)
      h=warndlg('This is not a right amplitude value for an LFO please type a value from 0 to 18 V','Warning!!');
   end
   phasehandle=findobj(gcbf,'Tag','EditText3');
   phase=str2num(get(phasehandle,'String'));
   if (phase<0)|(phase>359)
      h=warndlg('This is not a right phase value for an LFO please type a value from 0 to 359 degrees','Warning!!');
   end
   dchandle=findobj(gcbf,'Tag','EditText4');
   dcoffset=str2num(get(dchandle,'String'));
   if (dcoffset<-18)|(dcoffset>18)
      h=warndlg('This is not a right dcoffset value for an LFO please type a value from -18 to 18 V','Warning!!');
   end
   dampinghandle=findobj(gcbf,'Tag','EditText5');
   damping=str2num(get(dampinghandle,'String'));
   rectifhandle=findobj(gcbf,'Tag','Checkbox3');
   rectif=get(rectifhandle,'Value');
   h=waitbar(0,'Performing Calculus on LFO... Please Wait');
   for i=1:100,t=0:1/samplerate:5;
      waitbar(i/100);
   end
   close(h);
   if wallsupply==0
      x=dcoffset+amp*exp(-(t*damping)).*cos(2*pi*rate*t+phase);
   elseif wallsupply==1
      x=dcoffset+amp*exp(-(t*damping)).*cos(2*pi*rate*t+phase)+0.1*sin(2*pi*50*t);
   end
   if rectif==1
      y=abs(x);
   elseif rectif==0
      y=x;
   end
   switch(popup2)
   case 1
      i=int8(y);
   case 2
      i=int16(y);
   case 3
      i=int32(y);
   case 4
      i=single(y);
   case 5
      i=double(y);
   end
   plot(t,i,'EraseMode','xor');
	end
   %%LFW triangolare
   if popup==3
   rsstephandle=findobj(gcbf,'Tag','Checkbox1');
   rsstep=get(rsstephandle,'Value');
   if rsstep==0
      samplerate=11025;
   elseif rsstep==1
      samplerate=50;
   end
   wallsupplyhandle=findobj(gcbf,'Tag','Checkbox2');
   wallsupply=get(wallsupplyhandle,'Value');
   ratehandle=findobj(gcbf,'Tag','EditText1');
   rate=str2num(get(ratehandle,'String'));
   if (rate<0.3)|(rate>16)
      h=warndlg('This is not a right rate value for an LFO please type a value from 0.3 to 16 Hz','Warning!!');
   end
   amphandle=findobj(gcbf,'Tag','EditText2');
   amp=str2num(get(amphandle,'String'));
   if (amp<0)|(amp>18)
      h=warndlg('This is not a right amplitude value for an LFO please type a value from 0 to 18 V','Warning!!');
   end
   phasehandle=findobj(gcbf,'Tag','EditText3');
   phase=str2num(get(phasehandle,'String'));
   if (phase<-0.5)|(phase>0.5)
      h=warndlg('This is not a right width value for an LFO please type a value from -0.5 to 0.5','Warning!!');
   end
   dchandle=findobj(gcbf,'Tag','EditText4');
   dcoffset=str2num(get(dchandle,'String'));
   if (dcoffset<-18)|(dcoffset>18)
      h=warndlg('This is not a right dcoffset value for an LFO please type a value from -18 to 18 V','Warning!!');
   end
   dampinghandle=findobj(gcbf,'Tag','EditText5');
   damping=str2num(get(dampinghandle,'String'));
   rectifhandle=findobj(gcbf,'Tag','Checkbox3');
   rectif=get(rectifhandle,'Value');
   h=waitbar(0,'Performing Calculus on LFO... Please Wait');
   for i=1:100,t=0:1/samplerate:5;
      waitbar(i/100);
 	end
   close(h);
   if wallsupply==0
      x=dcoffset+amp*exp(-t*damping).*sawtooth(2*pi*rate*t,phase+0.5);
   elseif wallsupply==1
      x=dcoffset+amp*exp(-t*damping).*sawtooth(2*pi*rate*t,phase+0.5)+0.1*sin(2*pi*50*t);
   end
   if rectif==1
      y=abs(x);
   elseif rectif==0
      y=x;
   end 
   switch(popup2)
   case 1
      i=int8(y);
   case 2
      i=int16(y);
   case 3
      i=int32(y);
   case 4
      i=single(y);
   case 5
      i=double(y);
   end
   plot(t,i,'EraseMode','xor');
	end
	%%LFW Square
	if popup==4
   rsstephandle=findobj(gcbf,'Tag','Checkbox1');
   rsstep=get(rsstephandle,'Value');
   if rsstep==0
      samplerate=11025;
   elseif rsstep==1
      samplerate=50;
   end
   wallsupplyhandle=findobj(gcbf,'Tag','Checkbox2');
   wallsupply=get(wallsupplyhandle,'Value');
   ratehandle=findobj(gcbf,'Tag','EditText1');
   rate=str2num(get(ratehandle,'String'));
   if (rate<0.3)|(rate>16)
      h=warndlg('This is not a right rate value for an LFO please type a value from 0.3 to 16 Hz','Warning!!');
   end
   amphandle=findobj(gcbf,'Tag','EditText2');
   amp=str2num(get(amphandle,'String'));
   if (amp<0)|(amp>18)
      h=warndlg('This is not a right amplitude value for an LFO please type a value from 0 to 18 V','Warning!!');
   end
   phasehandle=findobj(gcbf,'Tag','EditText3');
   phase=str2num(get(phasehandle,'String'));
   if (phase<0)|(phase>100)
      h=warndlg('This is not a right phase value for an LFO please type a value from 0 to 100 %','Warning!!');
   end
   dchandle=findobj(gcbf,'Tag','EditText4');
   dcoffset=str2num(get(dchandle,'String'));
   if (dcoffset<-18)|(dcoffset>18)
      h=warndlg('This is not a right dcoffset value for an LFO please type a value from -18 to 18 V','Warning!!');
   end
   dampinghandle=findobj(gcbf,'Tag','EditText5');
   damping=str2num(get(dampinghandle,'String'));
   rectifhandle=findobj(gcbf,'Tag','Checkbox3');
   rectif=get(rectifhandle,'Value');
   h=waitbar(0,'Performing Calculus on LFO... Please Wait');
   for i=1:100,t=0:1/samplerate:5;
      waitbar(i/100);
 	end
   close(h);
   if wallsupply==0
      x=dcoffset+amp*exp(-t*damping).*square(2*pi*rate*t,phase);
   elseif wallsupply==1
      x=dcoffset+amp*exp(-t*damping).*square(2*pi*rate*t,phase)+0.1*sin(2*pi*50*t);
   end
   if rectif==1
      y=abs(x);
   elseif rectif==0
      y=x;
   end
   switch(popup2)
   case 1
      i=int8(y);
   case 2
      i=int16(y);
   case 3
      i=int32(y);
   case 4
      i=single(y);
   case 5
      i=double(y);
   end
   plot(t,i,'EraseMode','xor');
	end
   %%LFW esponenziale - sinusoidale
   if popup==5
   rsstephandle=findobj(gcbf,'Tag','Checkbox1');
   rsstep=get(rsstephandle,'Value');
   if rsstep==0
      samplerate=11025;
   elseif rsstep==1
      samplerate=50;
   end
   wallsupplyhandle=findobj(gcbf,'Tag','Checkbox2');
   wallsupply=get(wallsupplyhandle,'Value');
   ratehandle=findobj(gcbf,'Tag','EditText1');
   rate=str2num(get(ratehandle,'String'));
   if (rate<0.3)|(rate>16)
      h=warndlg('This is not a right rate value for an LFO please type a value from 0.3 to 16 Hz','Warning!!');
   end
   amphandle=findobj(gcbf,'Tag','EditText2');
   amp=str2num(get(amphandle,'String'));
   if (amp<0)|(amp>18)
      h=warndlg('This is not a right amplitude value for an LFO please type a value from 0 to 18 V','Warning!!');
   end
   phasehandle=findobj(gcbf,'Tag','EditText3');
   phase=str2num(get(phasehandle,'String'));
   if (phase<0)|(phase>359)

      h=warndlg('This is not a right phase value for an LFO please type a value from 0 to 359 degrees','Warning!!');
   end
   dchandle=findobj(gcbf,'Tag','EditText4');
   dcoffset=str2num(get(dchandle,'String'));
   if (dcoffset<-18)|(dcoffset>18)
      h=warndlg('This is not a right dcoffset value for an LFO please type a value from -18 to 18 V','Warning!!');
   end
   dampinghandle=findobj(gcbf,'Tag','EditText5');
   damping=str2num(get(dampinghandle,'String'));
   rectifhandle=findobj(gcbf,'Tag','Checkbox3');
   rectif=get(rectifhandle,'Value');
   h=waitbar(0,'Performing Calculus on LFO... Please Wait');
   for i=1:100,t=0:1/samplerate:5;
      waitbar(i/100);
  	end
   close(h);
   if wallsupply==0
      x=dcoffset+amp*exp(-(t*damping)).*exp(-sin(2*pi*rate*t+phase));
   elseif wallsupply==1
      x=dcoffset+amp*exp(-(t*damping)).*exp(-sin(2*pi*rate*t+phase))+0.1*sin(2*pi*50*t);
   end
   if rectif==1
      y=abs(x);
   elseif rectif==0
      y=x;
   end
   switch(popup2)
   case 1
      i=int8(y);
   case 2
      i=int16(y);
   case 3
      i=int32(y);
   case 4
      i=single(y);
   case 5
      i=double(y);
   end
   plot(t,i,'EraseMode','xor');
	end
   %%LFW Sawtooth
   if popup==6
   rsstephandle=findobj(gcbf,'Tag','Checkbox1');
   rsstep=get(rsstephandle,'Value');
   if rsstep==0
      samplerate=11025;
   elseif rsstep==1
      samplerate=50;
   end
   wallsupplyhandle=findobj(gcbf,'Tag','Checkbox2');
   wallsupply=get(wallsupplyhandle,'Value');
   ratehandle=findobj(gcbf,'Tag','EditText1');
   rate=str2num(get(ratehandle,'String'));
   if (rate<0.3)|(rate>16)
      h=warndlg('This is not a right rate value for an LFO please type a value from 0.3 to 16 Hz','Warning!!');
   end
   amphandle=findobj(gcbf,'Tag','EditText2');
   amp=str2num(get(amphandle,'String'));
   if (amp<0)|(amp>18)
      h=warndlg('This is not a right amplitude value for an LFO please type a value from 0 to 18 V','Warning!!');
   end
   phasehandle=findobj(gcbf,'Tag','EditText3');
   phase=str2num(get(phasehandle,'String'));
   if (phase<0)|(phase>1)
      h=warndlg('This is not a right width value for an LFO please type a value from 0 to 1','Warning!!');
   end
   dchandle=findobj(gcbf,'Tag','EditText4');
   dcoffset=str2num(get(dchandle,'String'));
   if (dcoffset<-18)|(dcoffset>18)
      h=warndlg('This is not a right dcoffset value for an LFO please type a value from -18 to 18 V','Warning!!');
   end
   dampinghandle=findobj(gcbf,'Tag','EditText5');
   damping=str2num(get(dampinghandle,'String'));
   rectifhandle=findobj(gcbf,'Tag','Checkbox3');
   rectif=get(rectifhandle,'Value');
   h=waitbar(0,'Performing Calculus on LFO... Please Wait');
   for i=1:100,t=0:1/samplerate:5;
      waitbar(i/100);
  	end
   close(h);
   if wallsupply==0
      x=dcoffset+amp*exp(-(t*damping)).*sawtooth(2*pi*rate*t,phase);
   elseif wallsupply==1
      x=dcoffset+amp*exp(-(t*damping)).*sawtooth(2*pi*rate*t,phase)+0.1*sin(2*pi*50*t);
   end
   if rectif==1
      y=abs(x);
   elseif rectif==0
      y=x;
   end
   switch(popup2)
   case 1
      i=int8(y);
   case 2
      i=int16(y);
   case 3
      i=int32(y);
   case 4
      i=single(y);
   case 5
      i=double(y);
   end
   plot(t,i,'EraseMode','xor');
	end
   %%LFW Pseudo-Randomica
   if popup==7
   rsstephandle=findobj(gcbf,'Tag','Checkbox1');
   rsstep=get(rsstephandle,'Value');
   if rsstep==0
      samplerate=100;
   elseif rsstep==1
      samplerate=50;
   end
   wallsupplyhandle=findobj(gcbf,'Tag','Checkbox2');
   wallsupply=get(wallsupplyhandle,'Value');
   ratehandle=findobj(gcbf,'Tag','EditText1');
   rate=str2num(get(ratehandle,'String'));
   if (rate<0.3)|(rate>16)
      h=warndlg('This is not a right rate value for an LFO please type a value from 0.3 to 16 Hz','Warning!!');
   end
   amphandle=findobj(gcbf,'Tag','EditText2');
   amp=str2num(get(amphandle,'String'));
   if (amp<0)|(amp>18)
      h=warndlg('This is not a right amplitude value for an LFO please type a value from 0 to 18 V','Warning!!');
   end
   phasehandle=findobj(gcbf,'Tag','EditText3');
   phase=str2num(get(phasehandle,'String'));
   if (phase<0)|(phase>359)
      h=warndlg('This is not a right phase value for an LFO please type a value from 0 to 359 degrees','Warning!!');
   end
   dchandle=findobj(gcbf,'Tag','EditText4');
   dcoffset=str2num(get(dchandle,'String'));
   if (dcoffset<-18)|(dcoffset>18)
      h=warndlg('This is not a right dcoffset value for an LFO please type a value from -18 to 18 V','Warning!!');
   end
   dampinghandle=findobj(gcbf,'Tag','EditText5');
   damping=str2num(get(dampinghandle,'String'));
   rectifhandle=findobj(gcbf,'Tag','Checkbox3');
   rectif=get(rectifhandle,'Value');
   h=waitbar(0,'Performing Calculus on LFO... Please Wait');
   for i=1:100,t=0:1/samplerate:5;
      waitbar(i/100);
  	end
   close(h);
   if wallsupply==0
      x=dcoffset+amp*exp(-(t*damping)).*sin(2*pi*rand(1)*10*rate*t+phase)+sin(4*pi*rand(1)*10*rate*t+phase)+sin(8*pi*rand(1)*10*rate*t+phase)+sin(16*pi*rand(1)*10*rate*t+phase)+sin(32*pi*rand(1)*10*rate*t+phase)+sin(64*pi*rand(1)*10*rate*t+phase);
   elseif wallsupply==1
      x=dcoffset+amp*exp(-(t*damping)).*sin(2*pi*rand(1)*10*rate*t+phase)+sin(4*pi*rand(1)*10*rate*t+phase)+sin(8*pi*rand(1)*10*rate*t+phase)+sin(16*pi*rand(1)*10*rate*t+phase)+sin(32*pi*rand(1)*10*rate*t+phase)+sin(64*pi*rand(1)*10*rate*t+phase)+0.1*sin(2*pi*50*t+phase);
   end
   if rectif==1
      y=abs(x);
   elseif rectif==0
      y=x;
   end
   switch(popup2)
   case 1
      i=int8(y);
   case 2
      i=int16(y);
   case 3
      i=int32(y);
   case 4
      i=single(y);
   case 5
      i=double(y);
   end
   plot(t,i,'EraseMode','xor');
	end
case 'save'
   [newfile,newpath]=uiputfile('*.lfo','Save LFO type');
   newfile1=[newfile];
   newpath1=[newpath];
   fid=fopen(strcat(newpath1,newfile1,'.lfo'),'wb');
   switch(popup)
   case 1
      ty='sin';
   case 2
      ty='cos';
   case 3
      ty='tri';
   case 4
      ty='squ';
   case 5
      ty='exp';
   case 6
      ty='saw';
   case 7
      ty='ran';
   end
   rsst=num2str(rsstep);
   wall=num2str(wallsupply);
   ra=num2str(rate);
   am=num2str(amp);
   ph=num2str(phase);
   dc=num2str(dcoffset);
   damp=num2str(damping);
   rec=num2str(rectif);
   h=waitbar(0,'Saving LFW Data on a file... Please Wait');
   for i=1:100,
      waitbar(i/100);
   end
   close(h);
   fprintf(fid,'%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n',ty,rsst,wall,ra,am,ph,dc,damp,rec);
   status=fclose(fid);
   if status==-1
      errordlg('An error has occured during the file writing -> Operation Aborted','Error');
   end
case 'credits'
   h=helpdlg('This is the LFO - Maker inside of Nova - Mod Tools enviroment built by Zambelli Cristian','Information');
case 'close'
   close(gcbf);
end

Contact us at files@mathworks.com