@@ -1869,6 +1869,119 @@ void fdmdv_16_to_8_short(short out8k[], short in16k[], int n)
18691869}
18701870
18711871
1872+ /*---------------------------------------------------------------------------*\
1873+
1874+ FUNCTION....: fdmdv_8_to_48()
1875+ AUTHOR......: David Rowe
1876+ DATE CREATED: 9 May 2012
1877+
1878+ Changes the sample rate of a signal from 8 to 48 kHz.
1879+
1880+ n is the number of samples at the 8 kHz rate, there are FDMDV_OS*n samples
1881+ at the 48 kHz rate. A memory of FDMDV_OS_TAPS_48/FDMDV_OS samples is reqd for
1882+ in8k[] (see t48_8.c unit test as example).
1883+
1884+ \*---------------------------------------------------------------------------*/
1885+
1886+ void fdmdv_8_to_48 (float out48k [], float in8k [], int n )
1887+ {
1888+ int i ,j ,k ,l ;
1889+
1890+ /* make sure n is an integer multiple of the oversampling rate, ow
1891+ this function breaks */
1892+
1893+ assert ((n % FDMDV_OS_48 ) == 0 );
1894+
1895+ for (i = 0 ; i < n ; i ++ ) {
1896+ for (j = 0 ; j < FDMDV_OS_48 ; j ++ ) {
1897+ out48k [i * FDMDV_OS_48 + j ] = 0.0 ;
1898+ for (k = 0 ,l = 0 ; k < FDMDV_OS_TAPS_48K ; k += FDMDV_OS_48 ,l ++ )
1899+ out48k [i * FDMDV_OS_48 + j ] += fdmdv_os_filter48 [k + j ]* in8k [i - l ];
1900+ out48k [i * FDMDV_OS_48 + j ] *= FDMDV_OS_48 ;
1901+
1902+ }
1903+ }
1904+
1905+ /* update filter memory */
1906+
1907+ for (i = - FDMDV_OS_TAPS_48_8K ; i < 0 ; i ++ )
1908+ in8k [i ] = in8k [i + n ];
1909+ }
1910+
1911+ void fdmdv_8_to_48_short (short out48k [], short in8k [], int n )
1912+ {
1913+ int i ,j ,k ,l ;
1914+ float acc ;
1915+
1916+ /* make sure n is an integer multiple of the oversampling rate, ow
1917+ this function breaks */
1918+
1919+ assert ((n % FDMDV_OS_48 ) == 0 );
1920+
1921+ for (i = 0 ; i < n ; i ++ ) {
1922+ for (j = 0 ; j < FDMDV_OS_48 ; j ++ ) {
1923+ acc = 0.0 ;
1924+ for (k = 0 ,l = 0 ; k < FDMDV_OS_TAPS_48K ; k += FDMDV_OS_48 ,l ++ )
1925+ out48k [i * FDMDV_OS_48 + j ] += fdmdv_os_filter48 [k + j ]* in8k [i - l ];
1926+ out48k [i * FDMDV_OS_48 + j ] = acc * FDMDV_OS_48 ;
1927+
1928+ }
1929+ }
1930+
1931+ /* update filter memory */
1932+
1933+ for (i = - FDMDV_OS_TAPS_48_8K ; i < 0 ; i ++ )
1934+ in8k [i ] = in8k [i + n ];
1935+ }
1936+
1937+ /*---------------------------------------------------------------------------*\
1938+
1939+ FUNCTION....: fdmdv_48_to_8()
1940+ AUTHOR......: David Rowe
1941+ DATE CREATED: 9 May 2012
1942+
1943+ Changes the sample rate of a signal from 48 to 8 kHz.
1944+
1945+ n is the number of samples at the 8 kHz rate, there are FDMDV_OS_48*n
1946+ samples at the 48 kHz rate. As above however a memory of
1947+ FDMDV_OS_TAPS_48 samples is reqd for in48k[] (see t48_8.c unit test as example).
1948+
1949+ \*---------------------------------------------------------------------------*/
1950+
1951+ void fdmdv_48_to_8 (float out8k [], float in48k [], int n )
1952+ {
1953+ int i ,j ;
1954+
1955+ for (i = 0 ; i < n ; i ++ ) {
1956+ out8k [i ] = 0.0 ;
1957+ for (j = 0 ; j < FDMDV_OS_TAPS_48K ; j ++ )
1958+ out8k [i ] += fdmdv_os_filter48 [j ]* in48k [i * FDMDV_OS_48 - j ];
1959+ }
1960+
1961+ /* update filter memory */
1962+
1963+ for (i = - FDMDV_OS_TAPS_48K ; i < 0 ; i ++ )
1964+ in48k [i ] = in48k [i + n * FDMDV_OS_48 ];
1965+ }
1966+
1967+ void fdmdv_48_to_8_short (short out8k [], short in48k [], int n )
1968+ {
1969+ int i ,j ;
1970+ float acc ;
1971+
1972+ for (i = 0 ; i < n ; i ++ ) {
1973+ acc = 0.0 ;
1974+ for (j = 0 ; j < FDMDV_OS_TAPS_48K ; j ++ )
1975+ acc += fdmdv_os_filter48 [j ]* in48k [i * FDMDV_OS_48 - j ];
1976+ out8k [i ] = acc ;
1977+ }
1978+
1979+ /* update filter memory */
1980+
1981+ for (i = - FDMDV_OS_TAPS_48K ; i < 0 ; i ++ )
1982+ in48k [i ] = in48k [i + n * FDMDV_OS_48 ];
1983+ }
1984+
18721985/*---------------------------------------------------------------------------*\
18731986
18741987 Function used during development to test if magnitude of digital
0 commit comments