POV-Ray : Newsgroups : povray.general : Collision chance : Collision chance Server Time
15 May 2021 19:57:10 EDT (-0400)
  Collision chance  
From: ingo
Date: 24 Apr 2021 13:44:32
Message: <XnsAD16C8D2DAFAAseed7@news.povray.org>
Currently I'm working on a sequencer and ADSR. They require a lot of 
array manipulation. The system I use, give everything a name, works quite 
well. The names get long and I'd like to shorten tem. Hence te question, 
what are the chance on collisions with names from other file for only 
#local names. I'd like to drop the _sq bit but then I'm left with rather 
general names like _out.


Code snippet:
---%<------%<------%<---

// Setting up the data structure for the sequencer
// Enum primary index
#declare _sq_ctrl = 0;
#declare _sq_out = 1;
#declare _sq_row = 2;
#declare _sq_primary_arr = array[3]{
  "_sq_ctrl",
  "_sq_out", 
  "_sq_row"
} 
// Enum secondary indices
// ctrl
#declare _sq_bpm = 0;
#declare _sq_steps = 1;
#declare _sq_srate = 2;
#declare _sq_beat_samples = 3;
#declare _sq_pattern_samples = 4;
#declare _sq_tick = 5;
#declare _sq_ctrl_arr = array[6]{
  "_sq_bpm",
  "_sq_steps",
  "_sq_srate",
  "_sq_beat_samples",
  "_sq_pattern_samles",
  "_sq_tick"
}
// output  
#declare _sq_clk_gate = 0;
#declare _sq_clk_pulse = 1;
#declare _sq_beat_prog = 2;
#declare _sq_pattern_prog = 3;
#declare _sq_col_curr = 4;
#declare _sq_col_gate = 5;
#declare _sq_row_output = 6;
#declare _sq_output_arr = array[7]{
  "_sq_clk_gate", 
  "_sq_clk_pulse",
  "_sq_beat_prog",
  "_sq_pattern_prog",
  "_sq_col_curr",
  "_sq_col_gate",   
  "_sq_row_output", 
}


#macro SEQinit(BPM, Rows, Steps, SampleRate)
  /*: Initialise a sequencer. Rows, steps are filled with zero's
  They have to be set later with SEQSetRow
  */
  #local SEQarr = array[3];
  
  #local SEQarr[_sq_ctrl] = array[6];
  #local SEQarr[_sq_ctrl][_sq_bpm] = BPM;
  #local SEQarr[_sq_ctrl][_sq_steps] = Steps;
  #local SEQarr[_sq_ctrl][_sq_srate] = SampleRate;
  #local SEQarr[_sq_ctrl][_sq_beat_samples] = BPM2Samples(
    SEQarr[_sq_ctrl][_sq_bpm], SEQarr[_sq_ctrl][_sq_srate]
  );
  #local SEQarr[_sq_ctrl][_sq_pattern_samples] = (
    SEQarr[_sq_ctrl][_sq_beat_samples] * SEQarr[_sq_ctrl][_sq_steps]
  );
  #local SEQarr[_sq_ctrl][_sq_tick] = 0;
  
  #local SEQarr[_sq_out] = array mixed[7];
  #local SEQarr[_sq_out][_sq_clk_gate] = 0;
  #local SEQarr[_sq_out][_sq_clk_pulse] = 0; 
  #local SEQarr[_sq_out][_sq_beat_prog] = 0;
  #local SEQarr[_sq_out][_sq_pattern_prog] =0;
  #local SEQarr[_sq_out][_sq_col_curr] = 0;
  #local SEQarr[_sq_out][_sq_col_gate] = arrFill(Steps, 0);
  #local SEQarr[_sq_out][_sq_row_output] = arrFill(Rows, 0);
  
  #local SEQarr[_sq_row] = array[Rows];
  #for(i, 0, Rows - 1)
    #local SEQarr[_sq_row][i] = arrFill(Steps,0);
  #end
  SEQarr
#end

#macro SEQsetBPM(SEQarr, BPM)
  /*The boom tschack speed*/
  #local SEQarr[_sq_ctrl][_sq_bpm] = BPM;
  #local SEQarr[_sq_ctrl][_sq_beat_samples] = BPM2Samples(SEQarr
[_sq_ctrl][_sq_bpm], SEQarr[_sq_ctrl][_sq_srate]);
  #local SEQarr[_sq_ctrl][_sq_pattern_samples] = SEQarr[_sq_ctrl]
[_sq_beat_samples] * SEQarr[_sq_ctrl][_sq_steps];
#end


#macro SEQsetRow(SEQarr, ValArr, Row)
  /*Set values for a whole row*/
  #local SEQarr[_sq_row][Row] = ValArr;
#end
---%<------%<------%<---


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.