** Oscillator Separation test 1: Empirical mode decomposition **

Trying out various methods of identifying individual oscillators in a multi-oscillator wave file.

This first test attempts to decompose the signal into the constituent oscillators using empirical mode decomposition.

It's not really meant for audio, but I was hoping this might do a better job of preserving the individual wave shapes than using FFT, which I understand only generates sin waves. Since oscillators can produce much more than just sines, that's not particularly useful here.

Script is below, along with graphics and audio. Unfortunately, this doesn't seem to generate anything useful.

In [11]:

```
from PyEMD import EMD
import numpy as np
import pylab as plt
import librosa
import librosa.display
from pathlib import Path
import matplotlib.pyplot as plt
# load & show signal
download_path = Path.cwd()/'Documents/M220c/3 Oscillators'
audio_file = download_path/'1,1,100,67,99,69,34,101,66,53,66.wav'
aud, sr = librosa.load(audio_file)
# Trim signal to exclude silence
trim_aud, yt = librosa.effects.trim(aud, top_db = 10)
librosa.display.waveshow(trim_aud, sr = sr)
```

Out[11]:

<librosa.display.AdaptiveWaveplot at 0x7fc2c0f9cdf0>

In [6]:

```
# Execute EMD on signal
IMF = EMD().emd(trim_aud, max_imf = 5)
N = IMF.shape[0]+1
t = np.linspace(0, 1, trim_aud.size)
# Plot results
plt.subplot(N,1,1)
plt.plot(t, trim_aud, 'r')
plt.title("Input signal: $S(t)=cos(22\pi t^2) + 6t^2$")
plt.xlabel("Time [s]")
for n, imf in enumerate(IMF):
plt.subplot(N,1,n+2)
plt.plot(t, imf, 'g')
plt.title("IMF "+str(n+1))
plt.xlabel("Time [s]")
plt.savefig('simple_example')
plt.show()
```

In [7]:

```
# Export IMFs to audio to see how they sound
from scipy.io.wavfile import write
for n, imf in enumerate(IMF):
write('Trim_IMF' + str(n) + '.wav', sr, imf)
```

Unfortunately this doesn't seem to generate any useful waveforms. You can listen to the resulting files here:

IMF 0

IMF 1

IMF 2

IMF 3

IMF 4

IMF 5

On the off chance it was the length of the file causing the issues (since analysis took quite a while to compile) I tried reducing the length of the audio file down to the shortest possible length to capture the frequency.

Unfortunately this didn't really make any difference.

In [8]:

```
# Trim audio to a single cycle
SAMPLE_RATE = 44100
MIN_HZ = 20
MIN_SIZE = int((1/MIN_HZ)*SAMPLE_RATE)
cut_aud = np.resize(trim_aud,(MIN_SIZE,))
np.trim_zeros(cut_aud)
librosa.display.waveshow(cut_aud, sr = sr)
print(cut_aud.size)
```

2205

In [9]:

```
IMF = EMD().emd(cut_aud, max_imf = 5)
N = IMF.shape[0]+1
t = np.linspace(0, 1, cut_aud.size)
# Plot results
plt.subplot(N,1,1)
plt.plot(t, cut_aud, 'r')
plt.title("Input signal: $S(t)=cos(22\pi t^2) + 6t^2$")
plt.xlabel("Time [s]")
for n, imf in enumerate(IMF):
plt.subplot(N,1,n+2)
plt.plot(t, imf, 'g')
plt.title("IMF "+str(n+1))
plt.xlabel("Time [s]")
plt.savefig('simple_example')
plt.show()
```

In [10]:

```
# Save IMFs as wav files to see how they sound
from scipy.io.wavfile import write
for n, imf in enumerate(IMF):
write('cut_IMF' + str(n) + '.wav', sr, imf)
```

Unfortunately, even trimming this down to try and simplify the waveform doesn't do much. So I'm concluding this isn't a musically useful method.

IMF 0

IMF 1

IMF 2

IMF 3

IMF 4

IMF 5

In [ ]:

```
```