Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not know how to proportionally reduce the central BPF frequencies of the filter bank used in Rockpool AFE #24

Open
xafarranxera opened this issue Dec 18, 2024 · 0 comments

Comments

@xafarranxera
Copy link

xafarranxera commented Dec 18, 2024

Good morning, @ssinhaleite,

Here's Vicent again from ITI. We are trying to process a bunch of wav files from ESC-50 dataset (fs=44,1 kHz) with AFE to work with them on the XYLOv2 module. The Python list called wavs contains several instances of wav_class that have been filled with data from ESC-50 via wave library (j.filename contains the name of each wav file) like this:

import wave

class wav_class:
    def __init__(self, metadata, frames, normamps):
        self.metadata = metadata
        self.frames = frames
        self.normamps = normamps

with wave.open(os.path.join(audio_path,j.filename)) as wav_file:
    metadata = wav_file.getparams()
    frames = wav_file.readframes(metadata.nframes)
    normamps = np.frombuffer(frames, dtype="<h") / (2 ** 15)
    wav = wav_class(metadata,frames,normamps)
    wavs.append(wav)

However, when we try to work with AFE modifying this example code from tutorials:

# - import AFE
from rockpool.devices.xylo.syns61201 import AFESim

# - AFE parameters
fs = 44100                          # The sampling frequency of the input, in Hz
raster_period = 10e-3               # The output rasterisation time-step in seconds
max_spike_per_raster_period = 15    # Maximum number of events per output time-step
add_noise = False                   # Enables / disables simulated noise generated by the AFE
add_offset = True                   # Add mismatch offset to each filter
add_mismatch = True                 # Add simualted mismatch to filter parameters
seed = None                         # Seed for mistmatch generation

# - Initialize the AFE simulation, and convert it to a high-level `TimedModule`
afe = AFESim(
        fs = fs,
        raster_period = raster_period,
        max_spike_per_raster_period = max_spike_per_raster_period,
        add_noise = add_noise,
        add_offset = add_offset,
        add_mismatch = add_mismatch,
        seed = seed,
).timed()

We get the following error:

ValueError: Sampling frequency (44100) must be at least 6 times the highest BPF centre freq. (i.e. >101640 Hz)
                The main reason is that the microphone produces THD (third-order distortion) which may fallback into the wrong frequency
                if the sampling frequency is not large enough.

Therefore, we would like to proportionally reduce all the central frequencies of the BFP bank to be able to process these wav 44,1 kHz files properly.

Could you give us a hand on this?

Thank yo so much in advance,
Vicent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant