readFilter -- delay-line access routine (band splitting) * * Reads sample x[n-i] from a previously established delay line. * With this syntax i is +ve for a time delay and -ve for a time advance. * * The use of explicit indexing rather than implicit index incrementing * allows multiple lattice structures to access the same delay line. * (adapted from csound/Opcodes/hrtfopcodes.c) * */
| 1884 | * |
| 1885 | */ |
| 1886 | static double readFilter(HOAMBDEC* p, int32_t i, int j) |
| 1887 | { |
| 1888 | |
| 1889 | double* readPoint; /* Generic pointer address */ |
| 1890 | int32_t delay; |
| 1891 | /* Calculate the address of the index for this read */ |
| 1892 | readPoint = p->currPos[j] - i; |
| 1893 | delay = p->ndelay; |
| 1894 | |
| 1895 | /* Wrap around for time-delay if necessary */ |
| 1896 | if (readPoint < ((double*)p->delay[j].auxp) ) |
| 1897 | readPoint += delay; |
| 1898 | else |
| 1899 | /* Wrap for time-advance if necessary */ |
| 1900 | if (readPoint > ((double*)p->delay[j].auxp + (delay-1)) ) |
| 1901 | readPoint -= delay; |
| 1902 | |
| 1903 | return *readPoint; /* Dereference read address for delayed value */ |
| 1904 | } |
| 1905 | |
| 1906 | |
| 1907 | /* insertFilter -- delay-line update routine (band splitting) |