Untitled

 avatar
user_2969974
plain_text
a year ago
12 kB
1
Indexable
Never
;Content.makeFrontInterface(750, 582);

Engine.loadFontAs("{PROJECT_FOLDER}Rounded_Elegance.ttf", "Rounded_Elegance");
Engine.setGlobalFont("Rounded_Elegance");


// CONSTANTS
const var HAS_HIDDEN_VOICE = false;
const var HIDDEN_VOICE_PARTNER = -1;
const var NUM_VOICES = 12;
const var NUM_HIDDEN_VOICES = 0;


//

const var PresetButtonTest = Content.getComponent("PresetButtonTest");






const var VinylSampleButton = [];
const var CasetteSample = [];
const var RtoRSampleButton = [];
const FirstSamplerNotes = [66, 59, 57, 55];
const FirstSamplerVel = [77, 76, 76, 76];
reg index = 0;

reg eventId;

//const var btnTrigger = [];
const intensity;
const var notes = [60 , 64, 68 , 70, 72 , 75];
reg value = 0;

const MasterMacroPitch1 = Synth.getModulator("MacroPitch1");
const var Drive_val = Content.getComponent("Drive");

const var MasterPitch1 = Synth.getModulator("MasterPitch1");


// array holders
var TheSamplers = [];
for (i=0;i<NUM_VOICES; i++)
{
    TheSamplers[i] = Synth.getChildSynth("Sampler" + (i+1));
 //   TheSamplers[i].setBypassed(true);

};

var VinylSamplers = [];
var CasetteSamplers = [];
var RToRSamplers = [];
for(i = 0; i < 4; i++){
	VinylSamplers[i+1] = Synth.getChildSynth("Sampler" + (i+1));
	VinylSamplers[i+1].setBypassed(true);
	
	CasetteSamplers[i] = Synth.getChildSynth("Sampler" + (i+5));
//	CasetteSamplers[i].setBypassed(true);
	
	RToRSamplers[i] = Synth.getChildSynth("Sampler" + (i+9));
//	RToRSamplers[i].setBypassed(true);
};

//Sampler2.setBypassed(true);
//VinylSamplers[1].setBypassed(true);

// distorion , EQ (10 band EQ - 30 knobs total), LFO, compression


//	VinylVolume - Add the vol for the panel inc all the samplers



var max_value = 12;
var min_value = -12;


for(i = 1;  i< 5; i++){
	VinylSampleButton[i] = Content.getComponent("VinylSampleButton" + i);
    VinylSampleButton[i].setControlCallback(onVinylSampleButtonControl);
    
    CasetteSample[i] = Content.getComponent("CasetteSample" + i);
   // CasetteSample[i].setControlCallback(onCasetteSampleControl);
    
    RtoRSampleButton[i] = Content.getComponent("RtoRSampleButton" + i);
    RtoRSampleButton[i].setControlCallback(onRtoRSampleButtonControl);
	}


inline function onVinylSampleButton1Control(component, value)
{
	
		// will need the sample notes to play for 3 or more than 3 sec
		if(value){
		VinylSamplers[1].setBypassed(false);
				local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 100);
				
				    Synth.startTimer(delay / 1000);
			
		//		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
		//		Synth.playNote(66 , 77);
			}else{
		//	Synth.noteOffByEventId(eventId);
					Synth.stopTimer();	
					VinylSamplers[1].setBypassed(true);
			}	
};

Content.getComponent("VinylSampleButton1").setControlCallback(onVinylSampleButton1Control);



inline function onVinylSampleButton2Control(component, value)
{
	
	if(value){
	VinylSamplers[2].setBypassed(false);
			local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 100);
			
			    Synth.startTimer(delay / 1000);
		
	//		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
	//		Synth.playNote(66 , 77);
		}else{
	//	Synth.noteOffByEventId(eventId);
				Synth.stopTimer();	
				VinylSamplers[2].setBypassed(true);
		}	
};

Content.getComponent("VinylSampleButton2").setControlCallback(onVinylSampleButton2Control);



inline function onVinylSampleButton3Control(component, value)
{
	
	if(value){
	VinylSamplers[3].setBypassed(false);
			local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 100);
			
			    Synth.startTimer(delay / 1000);
		
	//		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
	//		Synth.playNote(66 , 77);
		}else{
	//	Synth.noteOffByEventId(eventId);
				Synth.stopTimer();	
				VinylSamplers[3].setBypassed(true);
		}	
};

Content.getComponent("VinylSampleButton3").setControlCallback(onVinylSampleButton3Control);



inline function onVinylSampleButton4Control(component, value)
{
   
   if(value){
   VinylSamplers[4].setBypassed(false);
   		local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 100);
   		
   		    Synth.startTimer(delay / 1000);
   	
   //		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
   //		Synth.playNote(66 , 77);
   	}else{
   //	Synth.noteOffByEventId(eventId);
   			Synth.stopTimer();	
   			VinylSamplers[4].setBypassed(true);
   	}	
};

Content.getComponent("VinylSampleButton4").setControlCallback(onVinylSampleButton4Control);



/*
inline function onVinylSampleButtonControl(component, value)
{
	if(value){

		local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 150);
		
		    Synth.startTimer(delay / 1000);
	
//		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
//		Synth.playNote(66 , 77);
	}else{
//	Synth.noteOffByEventId(eventId);
			Synth.stopTimer();	
	}	
};

*/


/*
inline function onCasetteSampleControl(component, value)
{
	if(value){
		local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 150);
		
		    Synth.startTimer(delay / 1000);
	
//		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
//		Synth.playNote(66 , 77);
	}else{
//	Synth.noteOffByEventId(eventId);
			Synth.stopTimer();	
	}	
};

*/


inline function onRtoRSampleButtonControl(component, value)
{
	if(value){
		local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 150);
		
		    Synth.startTimer(delay / 1000);
	
//		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
//		Synth.playNote(66 , 77);
	}else{
//	Synth.noteOffByEventId(eventId);
			Synth.stopTimer();	
	}	
};




inline function onVinylSampleButton1Control(component, value)
{
if(value){
		local delay = Engine.getMilliSecondsForQuarterBeatsWithTempo(1, 150);
		
		    Synth.startTimer(delay / 1000);
	
//		Synth.playNote(55, 76);   // (66 , 77)  (59, 76) (57, 76) (55, 76)
//		Synth.playNote(66 , 77);
	}else{
//	Synth.noteOffByEventId(eventId);
			Synth.stopTimer();	
	}	
};

Content.getComponent("VinylSampleButton1").setControlCallback(onVinylSampleButton1Control);

/*
for(i = 1; i <4; i++ ){
		MasterController[i] = Content.getComponent("MasterController" + i);
		    MasterController[i].setControlCallback(onMasterControllerControl);
	}
*/

inline function onMasterControllerControl(component, value)
{

// Gain LFO Depth
	
	MasterPitch1.setIntensity((value*(max_value - min_value))+min_value);
	GlobalGainLFO.setIntensity(value);
	GlobalPitchLFO.setIntensity(value);
	processModWheelValue(value * 127);
	processPitchWheelValue(value*16383);
	//FaustCompressor.setAttribute(FaustCompressor.Attack, value/100);
	for (i = 0; i < NUM_VOICES; i++)
		{
		    ThePitchMods[i].setIntensity(value);
	    };
	    
	   	//macro work
	   	HiddenPitchLFODepth.setValue(component.getValueNormalized());
	   	HiddenPitchLFODepth.changed(); // sets percentages only
	   	//GlobalPitchLFO.setAttribute(GlobalPitchLFO.Frequency, value);
	   	
	   	FreqModulator1.setIntensity(value);
	   	
	   	   	//macro work
	   	   	HiddenFilterLFODepth.setValue(component.getValueNormalized());
	   	   	HiddenFilterLFODepth.changed(); // sets percentages only
	   	
	if (value == 0)
	    {
	        ShapeFX1.setBypassed(true);
	    }else{
	        ShapeFX1.setBypassed(false);
	    }
		ShapeFX1.setAttribute(ShapeFX1.Gain,value * 60);
		ShapePanelDrive.setValue(value);
		HiddenDriveMix.setValue(component.getValueNormalized());
		HiddenDriveMix.changed(); //calc the precentages only
	
};

Content.getComponent("MasterController").setControlCallback(onMasterControllerControl);


//

function clearArpArray()
{
    /*for(n=0;n<arpInboundIDs.length;n++)
    {
        // clear each note ID
        Synth.noteOffByEventId(arpInboundIDs[n]);
        arpInboundIDs.remove(n);
    }
    */
}

function closeAllPanels()
{
    reg fdx;
    for (fdx = 0;fdx<NUM_VOICES;fdx++)
    {
        theFXPanels[fdx].showControl(false);
    };
    EnvelopePanel.showControl(false);
    FilterPanel.showControl(false);
    ShapePanel.showControl(false);
    ReverbPanel.showControl(false);
    MasterCompressorPanel.showControl(false);
    
    MasterFXPanelCollection.showControl(false);
}

// array holders
var TheSamplers = [];
for (i=0;i<NUM_VOICES; i++)
{
    TheSamplers[i] = Synth.getChildSynth("Sampler" + (i+1));

};
// we treat the rr sampler as a seperate thing to load...

var expansions = Engine.getExpansionList();
//Console.print(trace(expansions));


///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

include("AuthorisationHQ.js");

include("NF_Header.js");

include("NF_Mixer.js");

include("VoiceExpansions.js");

include("NF_MasterFX.js");

//include for now..
//include("MasterFX2_1.js");

include("NF_Modulators.js");

include("NF_arpeggiator.js");

include("NF_PatternBuilder.js");

include("NF_Settings.js");

include("NF_Presets.js");

include("NF_VoiceEffects.js");

include("VoiceTaggingSelector.js");

include("NF_envelopes.js");

include("NF_Filter.js");

include("NF_Shaper.js");

include("NF_Reverb.js");

include("NF_MasterComp.js");

include("NF_MacroManagement.js");

include("NF_AboutBox.js");


const var th = Engine.createTransportHandler();

inline function onStop(isPlaying)
{
    if(!isPlaying)
    {
        Engine.allNotesOff();
    }
};

th.setOnTransportChange(true, onStop);

/*
Console.print("we want to load the init......");
//OK let go find the INIT preset wherever Philip has put it...
allPresets = Engine.getUserPresetList();
for(n in allPresets)
{
	if(n.indexOf("INIT") != -1)
	{
		Console.print(n + ".preset");
		Engine.loadUserPreset(n + ".preset");
	}
}

*/
/* 
So all of this is so the end-customer can set up a preset called INIT anywhere in the preset system - and it will
automatically be the loaded preset the first time the plugin ever starts...

We need to load the correct preset (INIT) if we have just loaded ourselves and our Preset Name = PRESETS
   so use the setLoad callback - which will wait for any other start-up preset loading to finish 
   then this finishing event we will trigger a reload but this time using the INIT values, then we set the flag (initLoad) to "Done"
   
   So onInit:
      - wait for any sampler loading to finish... 
      - when it has it may have loaded any old sample set so... 
      - check to see if we have done this processing (initLoad)
      - if not we need to do it *IF* the preset name = PRESETS 
      - if it does set the flag(initLoad) to say we have done this processing...
      - find and load a preset called INIT
   So worst case we laod the correct INIT preset, wait for it to finish, and then do it all again... 
   as the samples are already loaded these not much overhead ion this... 
   
   Note: when the INIT preset loads - there's some processing that changes its displayed name to "PRESETS"
      
*/

const var PostSampleLoadPanel = Content.getComponent("PostSampleLoadPanel");
var initLoad = false;
var allPresets = Engine.getUserPresetList();
PostSampleLoadPanel.setLoadingCallback(function(isPreloading)
{
	if(!isPreloading)
	{	
		//Console.print("done.......");
		if(initLoad == false && myPresetName.get("text") == "PRESETS")
		{
			//Console.print("reload the presets");
			for(n in allPresets)
			{
				if(n.indexOf("INIT") != -1)
				{
					//Console.print(n + ".preset");
					initLoad = true;
					Engine.loadUserPreset(n + ".preset");
				}
			}
		}
	}
});