/* circumspect - redistribute the spectral content of a monaural signal between 6 loudspeakers DESCRIPTION redistribute the spectral content of a monaural signal between 6 loudspeakers SYNTAX circumspect iNumBins, iampin, iampoutlist, ipantab INITIALIZATION iNumBins - the number of indices in each table, which should match the number of bins in each analysis frame. This is calculated from the FFT size: FFT size/2+1. iampin - the name of the table holding the amplitude values from the current frame. iampoutlist - a table containing a list of 6 table ID numbers to which the calculated amplitude values are written. ipantab - the ID number of the table that holds the user-defined amplitude panning values for each bin. There should be one 'panning' value for each FFT bin. The size of the table is defined by the FFT size (FFT_size/2+1). Integer values correspond with single channels (loudspeakers) while fractional values mix the bin between adjacent channels using square amplitude panning. The mapping is as follows: The value 0 will mix the bin amplitude into iampout1. The value 1 will mix the bin amplitude into iampout2. The value 2 will mix the bin amplitude into iampout3. The value 3 will mix the bin amplitude into iampout4. The value 4 will mix the bin amplitude into iampout5. The value 5 will mix the bin amplitude into iampout6. The value 6 will mix the bin amplitude into iampout1. (This allows the bin to be mixed between iampout6 and iampout1.) Note that inputing values by hand is unlikely to be of practical use. A higher-level table-filling instrument is needed for generating and scaling weighted random distributions. CREDITS Peiman Khosravi */ opcode circumspect,0,iiii iNumBins, iampin, iampoutlist, ipantab xin ;iNumBins: the number of indices in each table, which should match the number of bins ;iampin: the name of the table holding the amplitude values from the current fsig frame ;iampoutlist: a table containing a list of 6 table numbers to which the calculated amplitude values are written ;ipantab: the name of the table that holds the user-defined amplitude-panning values for each bin iampout1 tab_i 0, iampoutlist ;unpack list of ampout tables iampout2 tab_i 1, iampoutlist iampout3 tab_i 2, iampoutlist iampout4 tab_i 3, iampoutlist iampout5 tab_i 4, iampoutlist iampout6 tab_i 5, iampoutlist iclear ftgen 0, 0, iNumBins, -2, 0 ;make an empty table tablecopy iampout1, iclear ;copy the content of the above empty table into tablecopy iampout2, iclear ;the iampout tables to zero them out before each frame is processed tablecopy iampout3, iclear tablecopy iampout4, iclear tablecopy iampout5, iclear tablecopy iampout6, iclear kcount = 0 ;set the initial pointer value for counting through the bins (table indices) ;start the loop block loop: kamp tab kcount, iampin ;use kcount as read pointer into the table of input amplitude values kpan tab kcount, ipantab ;use kcount as read pointer into the table of panning values ;do the magic per-bin panning if (kpan<=1) then kpan1 = sqrt(1-kpan) kpan2 = sqrt(kpan) tabw kamp*kpan1 , kcount, iampout1 tabw kamp*kpan2 , kcount, iampout2 elseif (kpan<=2) then kpan = kpan - 1 kpan1 = sqrt(1-kpan) kpan2 = sqrt(kpan) tabw kamp*kpan1 , kcount, iampout2 tabw kamp*kpan2 , kcount, iampout4 elseif (kpan<=3) then kpan = kpan - 2 kpan1 = sqrt(1-kpan) kpan2 = sqrt(kpan) tabw kamp*kpan1 , kcount, iampout4 tabw kamp*kpan2 , kcount, iampout6 elseif (kpan<=4) then kpan = kpan - 3 kpan1 = sqrt(1-kpan) kpan2 = sqrt(kpan) tabw kamp*kpan1 , kcount, iampout6 tabw kamp*kpan2 , kcount, iampout5 elseif (kpan<=5) then kpan = kpan - 4 kpan1 = sqrt(1-kpan) kpan2 = sqrt(kpan) tabw kamp*kpan1 , kcount, iampout5 tabw kamp*kpan2 , kcount, iampout3 elseif (kpan<=6) then kpan = kpan - 5 kpan1 = sqrt(1-kpan) kpan2 = sqrt(kpan) tabw kamp*kpan1 , kcount, iampout3 tabw kamp*kpan2 , kcount, iampout1 elseif (kpan > 6) then tabw kamp, kcount, iampout1 endif ;increment kcount by one value and go back to the top of the loop section, unless kcount has reached the final bin kcount = kcount + 1 if (kcount < (iNumBins-1)) kgoto loop endop