1/2 division, , array[PS]=2; array[PS+1]=5; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=3; array[PS+9]=5; PS+=10;//part2 /// 1 measure array[PS]=1; array[PS+1]=3; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=3; array[PS+9]=5; PS+=10;//part3 /// 1 bar array[PS]=2; array[PS+1]=2; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=3; array[PS+9]=5; PS+=10;//part4 /// no looping for first 4 parts array[PS]=3; array[PS+1]=3; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=1; array[PS+6]=1; array[PS+7]=4; array[PS+8]=3; array[PS+9]=5; PS+=10;//part5 /// loop back to part1 four times after fifth part //intermezzo1 array[PS]=4; array[PS+1]=6; array[PS+2]=3; array[PS+3]=4; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=4; array[PS+9]=4; PS+=10;//part6 /// start intermezzo1 after loop is finished //couplet2 array[PS]=5; array[PS+1]=5; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=5; array[PS+9]=5; PS+=10;//part7 /// start another couplet with mostly same settings as first couplet array[PS]=1; array[PS+1]=3; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=6; array[PS+9]=5; PS+=10;//part8 /// some variations in preset selection and nominators (swapped) array[PS]=5; array[PS+1]=3; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=5; array[PS+9]=5; PS+=10;//part9 array[PS]=1; array[PS+1]=2; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=6; array[PS+9]=5; PS+=10;//part10 array[PS]=6; array[PS+1]=6; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=1; array[PS+6]=7; array[PS+7]=2; array[PS+8]=7; array[PS+9]=5; PS+=10;//part11 ///loop back to part7 two times, last part is twice as fast and length is doubled to remain "on the beat" //intermezzo2 array[PS]=4; array[PS+1]=3; array[PS+2]=3; array[PS+3]=4; array[PS+4]=2; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=7; array[PS+9]=4; PS+=10;//part12 /// start intermezzo2 after loop is finished with an intermediate faster timing //chorus array[PS]=7; array[PS+1]=3; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=8; array[PS+9]=6; PS+=10;//part13 ///start chorus with some new presets and faster timing array[PS]=7; array[PS+1]=3; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=9; array[PS+9]=6; PS+=10;//part14 array[PS]=7; array[PS+1]=2; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=1; array[PS+6]=13; array[PS+7]=2; array[PS+8]=10; array[PS+9]=6; PS+=10;//part15 loop back to part13 two times //intermezzo3 array[PS]=6; array[PS+1]=8; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=8; array[PS+9]=4; PS+=10;//part16 array[PS]=5; array[PS+1]=7; array[PS+2]=5; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=6; array[PS+9]=4; PS+=10;//part17 array[PS]=4; array[PS+1]=6; array[PS+2]=4; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=4; array[PS+9]=4; PS+=10;//part18 array[PS]=3; array[PS+1]=5; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=3; array[PS+9]=4; PS+=10;//part19 array[PS]=2; array[PS+1]=4; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=2; array[PS+9]=4; PS+=10;//part20 //couplet3 array[PS]=9; array[PS+1]=3; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=4; array[PS+9]=5; PS+=10;//part21 array[PS]=10; array[PS+1]=5; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=5; array[PS+9]=5; PS+=10;//part22 array[PS]=9; array[PS+1]=3; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=4; array[PS+9]=5; PS+=10;//part23 array[PS]=10; array[PS+1]=2; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=6; array[PS+9]=5; PS+=10;//part24 array[PS]=11; array[PS+1]=4; array[PS+2]=4; array[PS+3]=1; array[PS+4]=1; array[PS+5]=1; array[PS+6]=21; array[PS+7]=4; array[PS+8]=8; array[PS+9]=5; PS+=10;//part25 loop back to part 21 4 times //chorus array[PS]=12; array[PS+1]=3; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=11; array[PS+9]=6; PS+=10;//part26 ///start chorus with some new presets and faster timing array[PS]=13; array[PS+1]=2; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=11; array[PS+9]=6; PS+=10;//part27 array[PS]=14; array[PS+1]=3; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=12; array[PS+9]=6; PS+=10; //part28 array[PS]=15; array[PS+1]=3; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=15; array[PS+9]=7; PS+=10;//part29 array[PS]=16; array[PS+1]=2; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=16; array[PS+9]=7; PS+=10;//part30 array[PS]=17; array[PS+1]=2; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=1; array[PS+8]=16; array[PS+9]=7; PS+=10; //part31 array[PS]=18; array[PS+1]=2; array[PS+2]=6; array[PS+3]=1; array[PS+4]=1; array[PS+5]=1; array[PS+6]=26; array[PS+7]=2; array[PS+8]=16; array[PS+9]=7; PS+=10; //part32 /* preset(0-127) nominator(1-127) denominator(1-127) measures(1-128) bars(1-128) loop (0/1) loop2part(0-127) loops(1-127) character(1-16) (songpart(1-16) part# (important to keep track of loop points) */ //outro array[PS]=19; array[PS+1]=2; array[PS+2]=4; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=13; array[PS+9]=3; PS+=10;//part33 ///decending denominator to reduce tempo array[PS]=20; array[PS+1]=2; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=10; array[PS+9]=3; PS+=10;//part34 ///all 1 measure and 1 bar, but different presets array[PS]=21; array[PS+1]=2; array[PS+2]=3; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=7; array[PS+9]=3; PS+=10;//part35 array[PS]=22; array[PS+1]=2; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=4; array[PS+9]=2; PS+=10;//part36 array[PS]=23; array[PS+1]=2; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=2; array[PS+9]=2; PS+=10;//part37 array[PS]=24; array[PS+1]=2; array[PS+2]=2; array[PS+3]=1; array[PS+4]=1; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=1; array[PS+9]=1; PS+=10;//part38 array[PS]=25; array[PS+1]=4; array[PS+2]=1; array[PS+3]=4; array[PS+4]=4; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=1; array[PS+9]=1; PS+=10;//part39 ///last fade out array[PS]=26; array[PS+1]=8; array[PS+2]=1; array[PS+3]=4; array[PS+4]=4; array[PS+5]=0; array[PS+6]=0; array[PS+7]=2; array[PS+8]=1; array[PS+9]=1; PS+=10;//part40 ///last fade out //a bit of post editing to adjust the array values to the right set for(int i=0;i<(PS/10);i++){ int k=i*10; array[k+1]-=1; array[k+2]-=1; array[k+3]-=1; array[k+4]-=1; array[k+7]-=1; array[k+8]-=1; array[k+9]-=1;} ]]> (USE WITH THE MODULE: patt/songtracker) a songtracker to create songs a song is divided into parts where each part is divided in bars, bars in measures and measures in steps. Each part has it's own settings for: -nominator (steps in measure) -denominator (rate within the measure based on main tempo) -amount of measures within a bar -amount of bars within the part -whether the part loops back to another part (repeating several parts as a whole) -which part to loop back to -how many times this loop has to be performed before going further to the next part after the loop. (don't loop back within another loop, otherwise it will loop endlessly) the remaining controls set the last part of the song and whether the song will repeat after the last part has been played These two modules should be able to setup whole songs (hopefully) Remco van der Most BSD table.axh 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 PExch[PARAM_INDEX_attr_legal_name_preset+i],array[part+i]+(!(i==5)?1:0),0xFFFD); } if(DO){DO=0;} } if(inlet_copy2next&&!copy){ copy=1; for(i=0;i<10;i++){ array[part+i+10]=array[part+i]; } } else if(copy&&!inlet_copy2next){copy=0;} loop=param_loopparts; max=param_lastpart-1; array[part]=param_preset-1; array[part+1]=param_nominator-1; array[part+2]=param_denominator-1; array[part+3]=param_measures-1; array[part+4]=param_bars-1; array[part+5]=param_loopback; array[part+6]=param_loop2part-1; array[part+7]=param_loops-1; array[part+8]=param_character-1; array[part+9]=param_songpart-1; total=0; for(i=0;i<10;i++){ total+=array[part+i]; } if((!(ptotal==total))&&(param_part>param_lastpart)){ PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_lastpart],param_part,0xFFFD); } ptotal=total;]]> (USE WITH MODULE: patt/songsetup) A tracker consisting of several counters that uses the stored table of the "songsetup" module to play a song. The integer outputs give the "counter position" or "counter maximum" of the respective counters. These are seperated into: -independent outputs for the different counters (steps/measure, measures/bar,bars/part,parts/song) and their own maximum steplength. -combinations of 2,3 or 4 counters and their combined maximum steplength. By controlling pattern and preset generators/controllers with these outputs, these two modules should be able to setup whole songs (hopefully) Johannes Taelman BSD counter.axh 0) && !rtrig) { for(i=0;i<5;i++){ cnt[i]=0; } cnt[3]=inlet_reset2part>0?inlet_reset2part-1:0; rtrig = 1; start=1;} else if (!(rst>0)){ rtrig=0; } int part=cnt[3]*10; outlet_clock=0; if(run>0){ int32_t frq; MTOF(inlet_tempo,frq) frq=frq>>2; phs+=frq*(attr_memory.array[2+part]+1); if(phs>0){ outlet_clock=1;} if ((phs>0) && !ntrig) { cnt[0] += 1;//steps cnt[0] if(start==1){ cnt[0]=0; start=0; } if (cnt[0]>=(attr_memory.array[part+1]+1)) {//measure cnt[1] cnt[0] = 0; cnt[1]+=1; if (cnt[1]>=(attr_memory.array[part+3]+1)) {//bars cnt[3] cnt[1]=0; cnt[2]+=1; if(cnt[2]>=(attr_memory.array[part+4]+1)) { if(attr_memory.array[part+5]==0) {//loopback off cnt[3]+=1; } else {//loopback on if(cnt[4]<(attr_memory.array[7]+1)) { cnt[3]=attr_memory.array[part+6]; cnt[4]+=1; } else { cnt[3]+=1;cnt[4]=0; } } cnt[2]=0; } } } ntrig=1; } else if (!(phs>0)) {ntrig=0; } } if(cnt[3]>attr_memory.max){ if(attr_memory.loop>0){ for(i=0;i<5;i++){ cnt[i]=0; } start=1; replay=1; } else{run=0; for(i=0;i<5;i++) { cnt[i]=0; } start=1;} } outlet_run=run; if(run>0){ Sc=cnt[0]; Sm=attr_memory.array[part+1]+1; Mc=cnt[1]; Mm=attr_memory.array[part+3]+1; Bc=cnt[2]; Bm=attr_memory.array[part+4]+1; Pc=cnt[3]; Pm=attr_memory.max; lc=cnt[4]; lm=attr_memory.array[part+7]+1; character=attr_memory.array[part+8]; songpart=attr_memory.array[part+9]; pst=attr_memory.array[part]; } int add=(param_addLoop>>27-attr_memory.LENGTHPOW)*lc; outlet_step=Sc; outlet_maxstep=Sm; outlet_measure=Mc; outlet_maxmeasure=Mm; outlet_bar=Bc; outlet_maxbar=Bm; outlet_part=Pc; outlet_maxparts=Pm; outlet_loop=lc; outlet_loopmax=lm; outlet_character=character; outlet_songpart=songpart; outlet_preset=pst; outlet_sm=Sc+Mc*Sm+add; outlet_smmax=Sm*Mm; outlet_smb=outlet_sm+Bc*Mm*Sm+add; outlet_smbmax=outlet_smmax*Bm; outlet_smbp=outlet_smb+Pc*Bm*Mm*Sm+add; outlet_smbpmax=outlet_smbmax*Pm; outlet_mb=Mc+Bc*Mm+add; outlet_mbmax=Mm*Bm; outlet_mbp=outlet_mb+Pc*Mm*Bm+add; outlet_mbpmax=outlet_mbmax*Pm; outlet_bp=Bc+Pc*Bm+add; outlet_bpmax=Bm*Pm; outlet_replay=replay;]]> allocate table in SDRAM memory, -128..127 Johannes Taelman BSD table.axh 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 multiply Johannes Taelman BSD math.axh >27-attr_table.LENGTHPOW;]]> multiply Johannes Taelman BSD math.axh >27-attr_table.LENGTHPOW;]]> uniform distributed (white) noise, k-rate generation. Range 0..(n-1) Johannes Taelman BSD 0) && !ntrig) { val += (int32_t)(GenerateRandomNumber()&1)>0?7:-7; val+=val>11?-12:0; val+=val<0?12:0; ntrig=1; } else if (!(inlet_trig>0)) ntrig=0; outlet_v = val;]]> (param_treshold>>19)?(!(inlet_count==count)):0; count=inlet_count;]]> add Johannes Taelman BSD math.axh 0?S:-S; S=S-S/6*6; for(int i=0;i<6;i++){ int sel=(chord[in][i]); if(i==S){ sel=inlet_note&7; } sel+=inlet_shift-inlet_key; note[i]=NT[i][sel&7]+inlet_key+((sel>>3)&1)*12; } note[1]+=5; note[2]+=10; note[3]+=15; note[4]+=19; note[5]+=24; for(int i=0;i<6;i++){ int Oct; int Semi; Oct=note[i]/12; Semi=note[i]-Oct*12; if(semi<0){ Semi+=12; Oct-=1; } if(inlet_negativeHrm){ Semi=11-Semi+param_offset; } int out=Semi+Oct*12; int diff=note[i]-out; int rect=diff>0?diff:-diff; if(rect>6){ out+=diff>0?-12:12; } note[i]=out; } outlet_o1=note[0]; outlet_o2=note[1]; outlet_o3=note[2]; outlet_o4=note[3]; outlet_o5=note[4]; outlet_o6=note[5]; outlet_sel=B[in]; //outlet_bass=NT[(B[in])][(chord[in][(B[in])])]-24; for(int i=0;i<6;i++){ note[i]=note[i]-note[i]/12*12; note[i]+=note[i]<0?12:0; } outlet_bass=note[(B[in])];]]> input multiplexer. Output is i1 when s < 1, i[i] when.... Johannes Taelman BSD mux.axh (param_treshold>>19)?(param_gated>0?1:(!(inlet_count==count))):0; count=inlet_count;]]> (param_treshold>>19)?(!(inlet_count==count)):0; count=inlet_count;]]> (param_treshold>>19)?(!(inlet_count==count)):0; count=inlet_count;]]> (param_treshold>>19)?(!(inlet_count==count)):0; count=inlet_count;]]> (param_treshold>>19)?(!(inlet_count==count)):0; count=inlet_count;]]> (param_treshold>>19)?(param_gated>0?1:(!(inlet_count==count))):0; count=inlet_count;]]> exponential smooth with enable Johannes Taelman BSD math.axh >9; int dir=inlet_in>val?1:0; val +=inlet_in>val?glide:-glide; if(dir){ val=val>inlet_in?inlet_in:val; } else{val=val divide integer with constant, also outputs remainder (modulo) Johannes Taelman BSD math.axh =0) r = ((unsigned int)in)/12; else r = -(((unsigned int)(12-in))/12); int tmp=r; tmp=tmp-tmp/param_range*param_range; tmp+=tmp<0?param_range:0; tmp*=12; outlet_rem = inlet_a-(r*12)+param_oct*12+tmp;]]> divide integer with constant, also outputs remainder (modulo) Johannes Taelman BSD math.axh =0) r = ((unsigned int)in)/12; else r = -(((unsigned int)(12-in))/12); int tmp=r; tmp=tmp-tmp/param_range*param_range; tmp+=tmp<0?param_range:0; tmp*=12; outlet_rem = inlet_a-(r*12)+param_oct*12+tmp;]]> divide integer with constant, also outputs remainder (modulo) Johannes Taelman BSD math.axh =0) r = ((unsigned int)in)/12; else r = -(((unsigned int)(12-in))/12); int tmp=r; tmp=tmp-tmp/param_range*param_range; tmp+=tmp<0?param_range:0; tmp*=12; outlet_rem = inlet_a-(r*12)+param_oct*12+tmp;]]> divide integer with constant, also outputs remainder (modulo) Johannes Taelman BSD math.axh =0) r = ((unsigned int)in)/12; else r = -(((unsigned int)(12-in))/12); int tmp=r; tmp=tmp-tmp/param_range*param_range; tmp+=tmp<0?param_range:0; tmp*=12; outlet_rem = inlet_a-(r*12)+param_oct*12+tmp;]]> divide integer with constant, also outputs remainder (modulo) Johannes Taelman BSD math.axh =0) r = ((unsigned int)in)/12; else r = -(((unsigned int)(12-in))/12); int tmp=r; tmp=tmp-tmp/param_range*param_range; tmp+=tmp<0?param_range:0; tmp*=12; outlet_rem = inlet_a-(r*12)+param_oct*12+tmp;]]> divide integer with constant, also outputs remainder (modulo) Johannes Taelman BSD math.axh =0) r = ((unsigned int)in)/12; else r = -(((unsigned int)(12-in))/12); int tmp=r; tmp=tmp-tmp/param_range*param_range; tmp+=tmp<0?param_range:0; tmp*=12; outlet_rem = inlet_a-(r*12)+param_oct*12+tmp;]]> Midi note output. Sends to midi/in/* objects only. Johannes Taelman BSD 0) && !ntrig) { lastnote = (64+(inlet_note>>21))&0x7F; lastchannel=attr_channel-1; PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_NOTE_ON + lastchannel,lastnote,inlet_velo>>20); ntrig=1; } if (!(inlet_trig>0) && ntrig) {PatchMidiInHandler((midi_device_t) 0,0,MIDI_NOTE_OFF + lastchannel,lastnote,__USAT(inlet_velo>>20,7)); ntrig=0;}]]> Midi note output. Sends to midi/in/* objects only. Johannes Taelman BSD 0) && !ntrig) { lastnote = (64+(inlet_note>>21))&0x7F; lastchannel=inlet_channel&15; PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_NOTE_ON + lastchannel,lastnote,inlet_velo>>20); ntrig=1; } if (!(inlet_trig>0) && ntrig) {PatchMidiInHandler((midi_device_t) 0,0,MIDI_NOTE_OFF + lastchannel,lastnote,__USAT(inlet_velo>>20,7)); ntrig=0;}]]> Midi note output. Sends to midi/in/* objects only. Johannes Taelman BSD 0) && !ntrig) { lastnote = (64+(inlet_note>>21))&0x7F; lastchannel=attr_channel-1; PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_NOTE_ON + lastchannel,lastnote,inlet_velo>>20); ntrig=1; } if (!(inlet_trig>0) && ntrig) {PatchMidiInHandler((midi_device_t) 0,0,MIDI_NOTE_OFF + lastchannel,lastnote,__USAT(inlet_velo>>20,7)); ntrig=0;}]]> Midi note output. Sends to midi/in/* objects only. Johannes Taelman BSD 0) && !ntrig) { lastnote = (64+(inlet_note>>21))&0x7F; lastchannel=attr_channel-1; PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_NOTE_ON + lastchannel,lastnote,inlet_velo>>20); ntrig=1; } if (!(inlet_trig>0) && ntrig) {PatchMidiInHandler((midi_device_t) 0,0,MIDI_NOTE_OFF + lastchannel,lastnote,__USAT(inlet_velo>>20,7)); ntrig=0;}]]> Midi note output. Sends to midi/in/* objects only. Johannes Taelman BSD 0) && !ntrig) { lastnote = (64+(inlet_note>>21))&0x7F; lastchannel=attr_channel-1; PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_NOTE_ON + lastchannel,lastnote,inlet_velo>>20); ntrig=1; } if (!(inlet_trig>0) && ntrig) {PatchMidiInHandler((midi_device_t) 0,0,MIDI_NOTE_OFF + lastchannel,lastnote,__USAT(inlet_velo>>20,7)); ntrig=0;}]]> Midi note output. Sends to midi/in/* objects only. Johannes Taelman BSD 0) && !ntrig) { lastnote = (64+(inlet_note>>21))&0x7F; lastchannel=attr_channel-1+cnt; PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_NOTE_ON + lastchannel,lastnote,inlet_velo>>20); ntrig=1; cnt=(cnt+1)&1; } if (!(inlet_trig>0) && ntrig) {PatchMidiInHandler((midi_device_t) 0,0,MIDI_NOTE_OFF + lastchannel,lastnote,__USAT(inlet_velo>>20,7)); ntrig=0;}]]> exponential smooth with enable Johannes Taelman BSD math.axh >9; int dir=inlet_in>val?1:0; val +=inlet_in>val?glide:-glide; if(dir){ val=val>inlet_in?inlet_in:val; } else{val=val allocate 16bit table in SDRAM memory, -128.00 .. 127.99 Johannes Taelman BSD table.axh 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 >1))<<5); for(i=0;i>15; } } int32_t lvl=0; for(i=0;i0?tmp:-tmp; lvl=tmp>lvl?tmp:lvl; } float32_t ratio=(float32_t)(1<<12)/lvl; for(i=0;i 0)&&!rnd){ rnd=1; DO=0; int range=param_range>>20; range=range>0?range:1; for(i=0;i<(LENGTH*8);i++){ array[i]=0; } int32_t tmp; for(int l=0;l<8;l++){ uint32_t pl=l*LENGTH; int hrms=param_hrms>>21; hrms=(int32_t)(GenerateRandomNumber()%(hrms))+1; hrms=hrms>0?hrms:1; for(j=0;j>1))<<5); if((j<1)&&((param_root<<(l&1))>((int32_t)(GenerateRandomNumber()>>5)))){k=1;PHS=0;mod=(1<<29);} for(i=0;i>17),16);///hrms>>18),16); } } int32_t lvl=0; for(i=0;i0?tmp:-tmp; lvl=tmp>lvl?tmp:lvl; } float32_t ratio=(float32_t)(1<<12)/lvl; for(i=0;i linear interpolation from k- to s-rate Johannes Taelman BSD >4; int32_t _i = _prev; _prev = inlet_i; ]]> delay read, linear interpolated Johannes Taelman BSD delay.axh >5; uint32_t tmp_di = (tmp_d>>(27-attr_table.LENGTHPOW)); uint32_t tmp_w1 = (tmp_d<<(attr_table.LENGTHPOW+3)) & 0x3FFFFFFF; uint32_t tmp_w2 = (1<<30) - tmp_w1; int32_t tmp_a1 = attr_table.array[(tmp_di&attr_table.LENGTHMASK)+SEL]<<14; int32_t tmp_a2 = attr_table.array[((tmp_di+1)&attr_table.LENGTHMASK)+SEL]<<14; int32_t tmp_r = tmp_a1+(___SMMUL(tmp_a2-tmp_a1,tmp_w1)<<2); wave=tmp_r; }]]> >24; mix-=sel1<<24; mix=mix<<7; sel1=(param_wave+sel1)&7; sel2=(sel1+1)&7; sel1=sel1<0?diff:-diff; if(diff>v5){ dcl+=tp-tmp; } tp=tmp; tmp+=dcl; dcl-=dcl>>9; hp+=tmp-hp>>8; outlet_out=tmp-hp;]]> Attack/decay envelope, linear attack, exponential decay Johannes Taelman BSD env.axh 0) && !ntrig) { ntrig = 1; stage = 1; } else if (!(inlet_trig>0)) { ntrig = 0; } if (stage == 0){ val -= ___SMMUL(val,d)>>1; } else { int32_t t; MTOF(-param_a-inlet_a,t); val = val + (t>>3); if (val<0) { val =0x7FFFFFFF; stage = 0; } } outlet_env = val>>4;]]> polyphonic 1 true 0 0 0 0 0 0 1361 774 Monophonic MIDI keyboard note input, gate, velocity and release velocity Johannes Taelman BSD midi_in.axh >14; } ofs=(int32_t)GenerateRandomNumber();]]> >3; d[i]=d[i]>>7; }]]> >10; absS[i]+=__USAT(param_absS+(attr_table.array[(ofs+inlet_preset+i+(attr_voices))&attr_table.LENGTHMASK]<<20),27)-absS[i]>>14; all[i]+=__SSAT(param_all+((int8_t)attr_table.array[(ofs+inlet_preset+i+(attr_voices<<1))&attr_table.LENGTHMASK]<<19),28)-all[i]>>14; self[i]+=__SSAT(param_self+((int8_t)attr_table.array[(ofs+inlet_preset+i+(attr_voices<<2))&attr_table.LENGTHMASK]<<19),28)-self[i]>>14; if ((gate[i]>0) && !ntrig[i]) { ntrig[i] = 1; stage[i] = 1; pgate=1; } else if (!(gate[i]>0)) { ntrig[i] = 0; } if (stage[i] == 0){ val[i] -= ___SMMUL(val[i],d[i]); } else { val[i] = val[i] + (a[i]>>3); if (val[i]<0) { val[i] =0x7FFFFFFF; stage[i] = 0; } } phs[i]+=frq[i]+(___SMMUL(frq[i],___SMMUL(out,all[i])+___SMMUL(ind[i],self[i])<<3)<<6); int32_t r; SINE2TINTERP(phs[i],r) vl[i]+=(velo[i]<<18)-vl[i]>>4; r=___SMMUL(r,vl[i]); hp2[i]+=r-hp2[i]>>9; r-=hp2[i]; ind[i]=___SMMUL(r,val[i])<<1; sum+=___SMMUL(r,val[i])<<1; ind[i]=ind[i]+(___SMMUL((___SMMUL(ind[i],ind[i])<<5)-ind[i],absS[i])<<5); hp1[i]+=ind[i]-hp1[i]>>8; ind[i]-=hp1[i]; } out=sum; out=out+(___SMMUL((___SMMUL(sum,sum)<<5)-sum,absA[i])<<5); HP+=out-HP>>8; out-=HP; //snc-=snc>>3; //if(pgate>0){ // int32_t tp=sum-prv; //snc-=tp-(tp>>5); // pgate=0; //} int32_t tmp=sum;//+snc<<1; Hp+=tmp-Hp>>8; tmp-=Hp; outlet_out=tmp; prv=sum;]]> Monophonic MIDI keyboard note input, gate, velocity and release velocity Johannes Taelman BSD midi_in.axh >24; int32_t mx=STR-(str<<24)<<7; int32_t mix=phase+(1<<31); mix=mix>0?mix:-mix; for(int i=0;i>1))<<2; phase=___SMMUL(mix,___SMMUL(phase,V)<<5)<<1; return phase; } int32_t vector,strength,p1,vc,sh,pp;]]> >14; } ofs=(int32_t)GenerateRandomNumber();]]> 0?hrm:-hrm; int32_t stp=hrm>>23; int32_t MX=hrm-(stp<<23)<<7; hrm=stp+1; for(i=0;i0) && !ntrig[i]) { pgate=1; ntrig[i] = 1; stage[i] = 1; } else if (!(gate[i]>0)) { ntrig[i] = 0; } if (stage[i] == 0){ val[i] -= ___SMMUL(val[i],d[i])>>6; } else { int32_t t; val[i] = val[i] + (a[i]>>6); if (val[i]<0) { val[i] =0x7FFFFFFF; stage[i] = 0; } } phs[i]+=frq[i]; int32_t r; vc+=(((int8_t)attr_table.array[(i+(attr_voices<<1)+inlet_preset+ofs)&attr_table.LENGTHMASK])<<20)-vc>>14; sh+=(((int8_t)attr_table.array[(i+(attr_voices<<2)+inlet_preset+ofs)&attr_table.LENGTHMASK])<<20)-sh>>14; pp+=(((int8_t)attr_table.array[(i+(attr_voices<<3)+inlet_preset+ofs)&attr_table.LENGTHMASK])<<20)-pp>>14; vector=__SSAT((___SMMUL((val[i]>>4)+vc,param_modv)<<5)+param_vector,28); strength=__SSAT((___SMMUL((val[i]>>4)+sh,param_mods)<<5)+param_strength,28); p1=(___SMMUL((val[i]>>4)+pp,param_modp)<<1)+param_position; r=VCT(phs[i],vector,strength); int32_t q1,q2; SINE2TINTERP((r<<5)+phs[i]*HRM+(p1<<4),q1) SINE2TINTERP((r<<5)+phs[i]*Hrm+(p1<<4),q2) q1=q1>>2; q2=q2>>2; r=q1+(___SMMUL(q2-q1,MX)<<2); vl[i]+=(velo[i]<<19)-vl[i]>>4; r=___SMMUL(r,vl[i]); sum+=___SMMUL(r,val[i])<<2; } snc-=snc>>4; if(pgate>0){ pgate=0; int32_t tp=sum-prv; snc-=tp-(tp>>5); } int32_t tmp=sum+snc; Hp+=tmp-Hp>>9; tmp-=Hp; outlet_out=tmp; prv=sum;]]> Monophonic MIDI keyboard note input, gate, velocity and release velocity Johannes Taelman BSD midi_in.axh >24; int32_t mx=STR-(str<<24)<<7; int32_t mix=phase+(1<<31); mix=mix>0?mix:-mix; for(int i=0;i>1))<<2; phase=___SMMUL(mix,___SMMUL(phase,V)<<5)<<1; return phase; } int32_t vector,strength,p1,vc,sh,pp;]]> >14; } ofs=(int32_t)GenerateRandomNumber();]]> 0) && !ntrig[i]) { pgate=1; stage[i] = 1; ntrig[i] = 1; } if (!(gate[i]>0) && ntrig[i]) { stage[i] = 0; ntrig[i]=0; } if (stage[i] == 0){ val[i] -= ___SMMUL(val[i],r)>>4; } else if (stage[i] == 1){ val[i] = val[i] + (a>>7); if (val[i]<0) { val[i] =0x7FFFFFFF; stage[i] = 2; } } else if (stage[i] == 2) { val[i] += ___SMMUL((s<<4) - val[i],d)>>4; } phs[i]+=frq[i]; int32_t r; vc+=(((int8_t)attr_table.array[(i+(attr_voices<<1)+inlet_preset+ofs)&attr_table.LENGTHMASK])<<18)-vc>>13; sh+=(((int8_t)attr_table.array[(i+(attr_voices<<2)+inlet_preset+ofs)&attr_table.LENGTHMASK])<<18)-sh>>13; pp+=(((int8_t)attr_table.array[(i+(attr_voices<<3)+inlet_preset+ofs)&attr_table.LENGTHMASK])<<18)-pp>>13; vector=__SSAT((___SMMUL((val[i]>>4)+vc,param_modv)<<5)+param_vector,28); strength=__SSAT((___SMMUL((val[i]>>4)+sh,param_mods)<<5)+param_strength,28); p1=(___SMMUL((val[i]>>4)+pp,param_modp)<<1)+param_position; r=VCT(phs[i],vector,strength); SINE2TINTERP((r<<5)+phs[i]*param_hrm+(p1<<5),r) vl[i]+=(velo[i]<<19)-vl[i]>>4; r=___SMMUL(r,vl[i]); sum+=___SMMUL(r,val[i])<<1; } snc-=snc>>3; if(pgate>0){ int32_t tp=sum-prv; snc-=tp-(tp>>5); pgate=0; } int32_t tmp=sum+snc; Hp+=tmp-Hp>>9; tmp-=Hp; outlet_out=tmp; prv=sum;]]> 5 input s-rate mixer, square gain scale Johannes Taelman BSD "voltage controlled amplifier", multiplies v and a inputs, with linear interpolation from k- to s-rate Johannes Taelman BSD >4; int32_t i = prev; prev = inlet_v; ]]> no -11 -2 1818 1096