NMFFilter
Decomposes and resynthesises a signal against a set of spectral templates
NMFFilter splits an incoming audio signal into different audio streams based on a set of spectral templates provided by the user (such as bases from a BufNMF analysis). It does this by performing non-negative matrix factorisation on a single spectral frame using the provided bases as seeds. Learn more about the seeding process in the Seeding NMF Overview.
Example Code
In this example, we’ll use the bases from the analysis on the BufNMF page. These bases contain spectral templates for the (1) kick drum, (2) snare drum, and (3) hi-hat components of the original drum loop.
First, let’s send the original drum loop through NMFFilter in real-time using the bases derived from the drum loop analysis.
Audio stream output based on basis 1:
Audio stream output based on basis 2:
Audio stream output based on basis 3:
This will give us very similar sounding results as BufNMF’s resynthesized buffer–the difference here is that results are produced in real-time. This means that one could send a live input of this drummer and (hopefully) get similarly successful results decomposing the drum loop into the individual drum instruments in real-time.
Audio Input From a Different Source
One could also send a different audio signal through these bases using NMFFilter. Here we’ll use an excerpt from an ensemble recording that also has kick drum, snare drum, and hi-hat.
Original ensemble recording:
Audio stream output based on basis 1:
Audio stream output based on basis 2:
Audio stream output based on basis 3:
NMFFilter has relatively well separated the hi hat, kick drum, and snare drum sounds in this song, because those are the bases from the drum loop. One can hear other sounds from the song mixed into these streams as well, as all of the sound from the original will be represented somewhere in these output streams.
Filtering Noise
Sending some pink noise through NMFFilter can provide another way of hearing and thinking about what it offers. Below are short clips of steady volume pink noise going through the three bases used above.
One can hear that the noise is filtered by the spectral templates of the bases (seen below as spectra).