I decided to make a version of AudioStream that works with float32_t instead of int16_t for use in an SDR project based on a Teensy 4.
I just got it to work, but not in a very elegant way. I need it to work alongside the normal AudioStream system, which required a bit of ugly hacking. I hope there is a more elegant way to get the two to work together.
I think the issue I have is that there is a software interrupt that drives a large part of the AudioStream action and now I need the interrupt to call both the original software_isr() routine in AudioStream.cpp as well as my new software_isr_float() routine in my new file AudioStreamFloat.cpp. The interrupt is set up in AudioStream.cpp like this:
(Strangely enough IRQ_SOFTWARE is 70, which is "Reserved" in table 4-2 in the i.MXRT1060 datasheet. But this is probably irrelevant to this discussion.)
Here is the corresponding code in AudioStreamFloat.cpp:
Depending on the order in which objects are allocated, either one of these routines may run last and that takes over the interrupt so that the other kind of AudioStream does not get any calls to its software_isr routine.
Right now my solution is to add a call to software_isr() at the end of software_isr_float() and make sure I allocate all my objects using the original AudioStream system before I allocate the objects using AudioStreamFloat.
I guess this could be solved either if there is a way to set up a separate interrupt to call software_isr_float() without interfering with the interrupt calling software_isr(), or if there is a way to make it so that both routines are called by the same interrupt. I am also open to other suggestions on how to solve this issue in a more elegant way than what I have today. I would prefer not to modify the original AudioStream.cpp/AudioStream.h files.
Per
I just got it to work, but not in a very elegant way. I need it to work alongside the normal AudioStream system, which required a bit of ugly hacking. I hope there is a more elegant way to get the two to work together.
I think the issue I have is that there is a software interrupt that drives a large part of the AudioStream action and now I need the interrupt to call both the original software_isr() routine in AudioStream.cpp as well as my new software_isr_float() routine in my new file AudioStreamFloat.cpp. The interrupt is set up in AudioStream.cpp like this:
Code:
bool AudioStream::update_setup(void)
{
if (update_scheduled) return false;
attachInterruptVector(IRQ_SOFTWARE, software_isr);
NVIC_SET_PRIORITY(IRQ_SOFTWARE, 208); // 255 = lowest priority
NVIC_ENABLE_IRQ(IRQ_SOFTWARE);
update_scheduled = true;
return true;
}
(Strangely enough IRQ_SOFTWARE is 70, which is "Reserved" in table 4-2 in the i.MXRT1060 datasheet. But this is probably irrelevant to this discussion.)
Here is the corresponding code in AudioStreamFloat.cpp:
Code:
bool AudioStreamFloat::update_setup(void)
{
if (update_scheduled) return false;
attachInterruptVector(IRQ_SOFTWARE, software_isr_float);
NVIC_SET_PRIORITY(IRQ_SOFTWARE, 208); // 255 = lowest priority
NVIC_ENABLE_IRQ(IRQ_SOFTWARE);
update_scheduled = true;
return true;
}
Depending on the order in which objects are allocated, either one of these routines may run last and that takes over the interrupt so that the other kind of AudioStream does not get any calls to its software_isr routine.
Right now my solution is to add a call to software_isr() at the end of software_isr_float() and make sure I allocate all my objects using the original AudioStream system before I allocate the objects using AudioStreamFloat.
I guess this could be solved either if there is a way to set up a separate interrupt to call software_isr_float() without interfering with the interrupt calling software_isr(), or if there is a way to make it so that both routines are called by the same interrupt. I am also open to other suggestions on how to solve this issue in a more elegant way than what I have today. I would prefer not to modify the original AudioStream.cpp/AudioStream.h files.
Per