chipaudette / openaudio_arduinolibrary Goto Github PK
View Code? Open in Web Editor NEWArduino Library for OpenAudio Hacking
Arduino Library for OpenAudio Hacking
When trying to compile the SineCosOut.ino example for Teensy 3.2, compilation failed with the following error:
_C:\Users\Paul\Documents\Arduino\libraries\OpenAudio_ArduinoLibrary/AudioFilterConvolution_F32.h:107:31: fatal error: arm_const_structs.h: No such file or directory
compilation terminated._
Found an instance of arm_const_structs.h in C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4.
But this file is not present in C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3, hence the compilation error.
Environment: Windows 10, Arduino 1.8.19, Teensyduino 1.57.
Regards,
Paul
While playing with the OpenAudio library on a Teensy 3.2 plus PCM5102A DAC to be used as a sine wave generator, I noticed that setting the sample_rate_Hz did not have an effect. I tried 48000 Hz and 96000 Hz.
Here is the code used:
#include "OpenAudio_ArduinoLibrary.h"
#include "AudioStream_F32.h"
#include <Audio.h>
// T3.x supported sample rates: 2000, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 44117, 48000,
// 88200, 88235 (44117*2), 95680, 96000, 176400, 176470, 192000
// T4.x supports any sample rate the codec will handle.
const float sample_rate_Hz = 96000.0f; // logic analyzer shows LRCK 44100 Hz, bit clock BCLK 2.82 MHz
const float freq = 1000.0f;
const int audio_block_samples = 128;
AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);
AudioSynthWaveformSine_F32 sine1;
AudioOutputI2S_F32 audioOutI2S1;
AudioConnection_F32 patchCord1(sine1, 0, audioOutI2S1, 0);
AudioConnection_F32 patchCord2(sine1, 0, audioOutI2S1, 1);
void setup() {
AudioMemory_F32(20);
sine1.amplitude(1.0);
sine1.frequency(freq * 44117.647f / sample_rate_Hz); // this shows ~460 Hz on oscilloscope, phase shifted
}
void loop() {
}
The logic analyzer shows this for the I2S signals:
As you can see the LRCK is ~44110 Hz.
From the logic analyzer data I observed that audio data is 16 bits. How do increase that to 20 or even 24 bits?
I also noticed the sine output is phase shifted, although the mono sine source AudioSynthWaveformSine_F32 is just splitted to the L & R signals:
On the logic analyzer image you can also see that the left & right datablock is different within each LRCK sample.
Environment: Windows 10, Arduino 1.8.19, Teensyduino 1.57, Teensy 3.2, OpenAudio library up to and including commit 88126e2.
Regards,
Paul
In lines 126, 128, and 132, please do not use N_2, but N_2 -1
Otherwise the audio will contain nasty artefacts.
N_2 is FFT_Size / 2 + 1, but the index should only have a max of FFT_Size / 2
@chipaudette @boblark Keep up the good work!
S/W: Windows 10, Arduino 1.8.19, Teensyduino 1.57, OpenAudio library up to and including commit 88126e2.
H/W: Teensy 3.2 plus PCM5102A DAC.
While playing with the OpenAudio library generating a sine wave, I noticed that for sample rates 44100 & 44117 Hz, the sine output is out-of-phase.
Here is the code used:
#include "OpenAudio_ArduinoLibrary.h"
#include "AudioStream_F32.h"
#include <Audio.h>
// T3.x supported sample rates: 2000, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 44117, 48000,
// 88200, 88235 (44117*2), 95680, 96000, 176400, 176470, 192000
// T4.x supports any sample rate the codec will handle.
const float sample_rate_Hz = 32000,0f;
const float freq = 1000.0f;
const int audio_block_samples = 128;
AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);
AudioSynthWaveformSine_F32 sine1(audio_settings);
AudioOutputI2S_F32 audioOutI2S1(audio_settings);
AudioConnection_F32 patchCord1(sine1, 0, audioOutI2S1, 0);
AudioConnection_F32 patchCord2(sine1, 0, audioOutI2S1, 1);
void setup() {
AudioMemory(20);
AudioMemory_F32(20);
sine1.amplitude(1.0);
sine1.frequency(freq);
sine1.begin();
}
void loop() {
}
Output on scope at SR = 32000 Hz:
Output on scope at SR = 44100 Hz:
Output on scope at SR = 44117 Hz:
Output on scope at SR = 48000 Hz:
The logic analyzer on the I2S signals also shows different L&R samples at 44100 & 44117 Hz.
Paul
I've been trying to get any of the examples to produce audio to no avail. That means "it's me" but I'm not sure what I'm doing wrong. I have a Teensy 4.0 with the Dev D audio board. The interface pins are different https://www.pjrc.com/store/teensy3_audio.html from the previous version, but I'm unsure if that's the issue. The examples compile without error but no audio paths appear to be working or at least I cannot get audio out the headphone jack. The stock PJRC audio library works so I know my card is functioning properly and the Arduino IDE is configured.
Thank you for the excellent library!
The AudioConnection class that comes as a part of the Teensy Audio Library has connect and disconnect methods allowing one to reroute AudioConnections (PatchCords) as seen here . These are missing in the AudioConnection_F32 class and I was wondering if they could be added…
Thank you!
This is not so much an Issue, as an RFC and note of intent.
I'm in the process of adding a Spectral noise reduction class to the OpenAudio library.
I've made a start, and have something working, but it needs refinement, some interface improvements, and documentation.
The work is based on the code you can find in the Convolution-SDR and UHSDR - see:
A partly 'sanitized' version of the code can be found in the DSPham code base: https://github.com/grahamwhaley/DSPham/blob/master/spectral.cpp , but even that has a bunch of code that needs cleaning, documenting or removing (there is some old code and data blobs that are legacy from other previous NR data schemes from long ago in the code history).
The best introduction to how the code works can be found in the UHSDR wiki: https://github.com/df8oe/UHSDR/wiki/Noise-reduction
I've got some other stuff to do, so it may be a few weeks yet before I polish it enough for an initial PR.
When using the formant shifter setting sample size greater than 128 (256) which equates to 512 in the FFT size the Teensy crashes when trying to create the FFT object?
This is on a teensy 4.0 oveclocked to 712mhz
Is 512 the max I can get?
I hope you don't mind me contacting you like this. I am not getting the OpenAudio examples to compile. They all fail with following error message. I have tested with an Teensy 3.6 with Audio Adapter and also with an Teensy 3.2 with Audio Adapter.
/Users/slexer/Documents/Arduino/libraries/OpenAudio_ArduinoLibrary/output_i2s_f32.cpp: In function 'float setI2SFreq(float)':
/Users/slexer/Documents/Arduino/libraries/OpenAudio_ArduinoLibrary/output_i2s_f32.cpp:44:176: error: narrowing conversion of '4.41176484e+4f' from 'float' to 'int' inside { } [-Wnarrowing]
const int samplefreqs[numfreqs] = { 2000, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 44117.64706 , 48000, 88200, 44117.64706 * 2, 96000, 176400, 44117.64706 * 4, 192000};
^
/Users/slexer/Documents/Arduino/libraries/OpenAudio_ArduinoLibrary/output_i2s_f32.cpp:44:176: error: narrowing conversion of '8.82352969e+4f' from 'float' to 'int' inside { } [-Wnarrowing]
/Users/slexer/Documents/Arduino/libraries/OpenAudio_ArduinoLibrary/output_i2s_f32.cpp:44:176: error: narrowing conversion of '1.76470594e+5f' from 'float' to 'int' inside { } [-Wnarrowing]
All examples form the 'original' Audio Library for the Teensy compile without any problems.
Hi All
Tested the example ino which worked fine at a SR of 44100 KHZ but doesn't work with a higher SR of 96KHZ.
The audio sounds distorted. Anybody else tested with 96K ?
Thanks
Alan
Not an issue as such - just wanted to say thank you for this library, I had a great time experimenting with it on the Teensy 3.6. Just wondering if the library will be updated for Teensy 4.0 compatibility?
I was working on an effects processor on the 3.6 but in my code I get some errors that i'd love to help with if it's in my capabilities but not sure where to start and not sure of how big a change in core architecture the 4.0 has introduced.
If I could help in any specific way just let me know and thanks again for the excellent library!
Nice library!
Though I have found a typo in a critical part of the library unless I am mistaken...
https://github.com/chipaudette/OpenAudio_ArduinoLibrary/blob/master/AudioConvert_F32.h#L80
MAX_INT = 32678.0 // Shouldn't this be 32768? :D
Also at least on Teensy 4.0 with my bench testing the arm_q15_to_float and arm_float_to_q15 functions are a bit faster.
Great work on this F.P. audio library, Chip.
I'm using Arduino 1.8.9 and Teensyduino 1.52. Until I remove the #include "DSP_Teensyduino_32.h" line from the TestEqualizer1 example, it won't compile. I don't see this file in the OpenAudio_Arduino library, so its not surprising. Compiles and works great without that line though. Am I missing something, or should the examples be edited to reflect this?
DD4WH and I have written floating point Convolution FIR filters using (FFT/iFFT) including segmented FFT routines that have very ow latencies even on FIR tap lengths up to 20K (for guitar cabinet simulation, for example). DD4WH did most of the original coding, and I ported it to a conventional PJRC audio library object and swapped in CMSIS routines for most all the processing. While the filter only accepts 16-bit stereo input/output, all the processing is in floating point, including of course the FIR coefficients.
In the past, I had tried to implement a multiband EQ using our routine and 513 tap FIR coefficients. In theory, I figured I should be able to add the filter coefficients for each individual band together, but it worked poorly. When I came across your work, I could see that you also calculate the individual filter coefficients but use a window function, which I didn't. When I use your equalizerNew routine to calculate the FIR coefficients, it looks like our filter is now working very nicely.
I'm using Teeny 4.0 and 4.1, and it sounds like your openAudio library is not completely running on them yet. But, in the future I'd like to make use of your floating point Audio library further.
Many thanks
AudioSynthWaveform_F32 in the audio designer tool shows as 0 input, but in code it can actually take 1 input used for the oscillator.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.