Skip to content

Support for dtypes uint32 and int32 #341

@pumelo

Description

@pumelo

Describe the solution you'd like
Support dtypes int32 and uint32.

Additional context
I do get an array of int32 from other hardware (i2s microphone). I did currently not find an efficient way to use this data with ulab than iterating over the array and converting it to an array of floats. This seems cumbersome and slow. So it would be nice to have int32 directly supported.

This is what I am doing right now:

samples = bytearray(2048)  # bytearray to receive audio samples
data = uctypes.struct(uctypes.addressof(samples), {'arr': (0 | uctypes.ARRAY, 512 | uctypes.INT32)})

np_a = np.zeros(512, dtype=np.float)

# <--  here, get data from hardware into samples buffer

for i in range(512):
    np_a[i] = data.arr[i]

This loop above loop takes about 90ms on a esp32s2 @ 240MHz which is insanely slow. While the fft on the same data thereafter takes about 10ms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions