1+ # EARLYREFLECTIONS
2+ # This function creates a tapped delay line to be used for the early
3+ # reflections of a reverb algorithm. THe delays and gains of the taps
4+ # are included in this function and were based on an IR measurement from a
5+ # recording studio in Nashville, TN.
6+ #
7+ # Also see MOORERREVERB
8+
9+ import numpy as np
10+
11+ def earlyReflections (x , buffer , Fs , n ):
12+
13+ # Delay times converted from milliseconds
14+ delayTimes = [np .fix (0 * Fs ), np .fix (0.01277 * Fs ), np .fix (0.01283 * Fs ), np .fix (0.01293 * Fs ), np .fix (0.01333 * Fs ),
15+ np .fix (0.01566 * Fs ), np .fix (0.02404 * Fs ), np .fix (0.02679 * Fs ), np .fix (0.02731 * Fs ), np .fix (0.02737 * Fs ), np .fix (0.02914 * Fs ),
16+ np .fix (0.02920 * Fs ), np .fix (0.02981 * Fs ), np .fix (0.03389 * Fs ), np .fix (0.04518 * Fs ), np .fix (0.04522 * Fs ), np .fix (0.04527 * Fs ),
17+ np .fix (0.05452 * Fs ), np .fix (0.06958 * Fs )]
18+
19+ numDelays = len (delayTimes )
20+ for delay in range (numDelays ):
21+ delayTimes [delay ] = int (delayTimes [delay ])
22+
23+ # There must be a 'gain' for each of the 'delayTimes'
24+ gains = [1 , 0.1526 , - 0.4097 , 0.2984 , 0.1553 , 0.1442 ,
25+ - 0.3124 , - 0.4176 , - 0.9391 , 0.6926 , - 0.5787 , 0.5782 ,
26+ 0.4206 , 0.3958 , 0.3450 , - 0.5361 , 0.417 , 0.1948 , 0.1548 ]
27+
28+ # Determine indexes for circular buffer
29+ M = len (buffer )
30+ indexC = np .mod (n , M ) # current index
31+ buffer [indexC ] = x
32+
33+ out = 0 # initialize the output to be used in loop
34+
35+ # Loop through all the taps
36+ for tap in range (len (delayTimes )):
37+ # Find the circular buffer index for the current tap
38+ indexTDL = np .mod (n - delayTimes [tap ], M )
39+
40+ # 'Tap' the delay line and add current tap with output
41+ out = out + gains [tap ] * buffer [indexTDL ]
42+
43+ return out , buffer
0 commit comments