audio injector octo (cs42448) running! #324
Replies: 2 comments 2 replies
-
Well done! Unfortunately I'm not familiar with the Octo Audio Injector and cannot say, if the I2S sound driver of Circle is able to work with it with 8 channels. That means perhaps 2 channels will work on the hardware side, but not 8? I guess this code supports 8 channels. But perhaps you've already done the necessary update to the driver. What I can say is, that the class Unfortunately I'm currently do not have much time left and would like to concentrate on the USB audio support, I'm working on. I thought about, if it is already the time to go to a variable number of channels, but this would create another much more workload and there is already enough. My goal is to create a new Circle release still this year, perhaps we can go to more channels later next year. I would expect your contribution of a CS42448 driver then. |
Beta Was this translation helpful? Give feedback.
-
Good news, got it to work. All 6ch in and 8ch out. The modification is once again super simple. I didn't even have to touch any of the DMA voodoo. @rsta2 I guess i'll wait until the new circle version to clean this all up and contribute. Good luck in implementing usb audio, looking forward to using that! For other people trying to use the octo: As a quick hack i changed the following sections in SoundBaseDevice.c: // around line 253, inside function 'int CSoundBaseDevice::Write (const void *pBuffer, size_t nCount)'
if (m_nWriteChannels == 2)
{
ConvertSoundFormat (Frame+m_nHWSampleSize, pBuffer8);
pBuffer8 += m_nWriteSampleSize;
}
else if (m_nWriteChannels == 8)
{
ConvertSoundFormat (Frame+m_nHWSampleSize, pBuffer8);
pBuffer8 += m_nWriteSampleSize;
ConvertSoundFormat (Frame+(m_nHWSampleSize*2), pBuffer8);
pBuffer8 += m_nWriteSampleSize;
ConvertSoundFormat (Frame+(m_nHWSampleSize*3), pBuffer8);
pBuffer8 += m_nWriteSampleSize;
ConvertSoundFormat (Frame+(m_nHWSampleSize*4), pBuffer8);
pBuffer8 += m_nWriteSampleSize;
ConvertSoundFormat (Frame+(m_nHWSampleSize*5), pBuffer8);
pBuffer8 += m_nWriteSampleSize;
ConvertSoundFormat (Frame+(m_nHWSampleSize*6), pBuffer8);
pBuffer8 += m_nWriteSampleSize;
ConvertSoundFormat (Frame+(m_nHWSampleSize*7), pBuffer8);
pBuffer8 += m_nWriteSampleSize;
}
else
{
memcpy (Frame+m_nHWSampleSize, Frame, m_nHWSampleSize);
} // inside function 'int CSoundBaseDevice::Read (void *pBuffer, size_t nCount)'
if (m_nReadChannels == 2)
{
ConvertReadSoundFormat (pBuffer8, Frame);
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+m_nHWSampleSize);
pBuffer8 += m_nReadSampleSize;
}
else if (m_nReadChannels == 8)
{
ConvertReadSoundFormat (pBuffer8, Frame);
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+m_nHWSampleSize);
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+(m_nHWSampleSize*2));
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+(m_nHWSampleSize*3));
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+(m_nHWSampleSize*4));
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+(m_nHWSampleSize*5));
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+(m_nHWSampleSize*6));
pBuffer8 += m_nReadSampleSize;
ConvertReadSoundFormat (pBuffer8, Frame+(m_nHWSampleSize*7));
pBuffer8 += m_nReadSampleSize;
}
else
{
if (m_bLeftChannel)
{
ConvertReadSoundFormat (pBuffer8, Frame);
}
else
{
ConvertReadSoundFormat (pBuffer8, Frame+m_nHWSampleSize);
}
pBuffer8 += m_nReadSampleSize;
} Also remove the asserts checking for the number of channels as stated in the first comment in this discussion. Then in the config.h of sample 34-soundbasedevice, change: #define WRITE_CHANNELS 8 |
Beta Was this translation helpful? Give feedback.
-
Hi!
I got the octo running by creating a class for the cs42448 which initialised the chip over i2c and is able to start and configure the fpga clock on the board. The cs42448 is set up to send 8 channel TDM instead of regular 2 channel i2s. Then I set up an i2s TXRX device, and created a drain that just reads the input and dumps to the output. I did these modifications in the 42-i2sinput sample.
If anybody wants to use the octo, I could not for the life of me get it to work reliably when it was not on top of the pi connected as a hat. Because the octo was at another place in my enclosure, i first tried to connect all the required pins using dupont cables, but that didn't work out. Even with very short cables. The i2c communication was very flakey. The only way it worked was to put it on top of the pi.
I only had to do some minor modifications to circle to make it work:
assert (1 <= nChannels && nChannels <= 2);
#define SOUND_HW_CHANNELS 2
to#define SOUND_HW_CHANNELS 8
The drain is working, i hear what appears to be a perfectly correct stereo output from the input (my phone playing music). So i'm already very happy! However I want to get all of the 8 channel out, and 6 channel in working. I tried poking around, changing some other channel related stuff in i2ssoundbasedevice, but I don't really know what i'm doing. Right now, with the modifications above, if i plug in some audio on channel 3, and listen to the output of channel 3 i hear low rumble noise that gets louder when there's a beat in the music, but only on channel 3. When i change the cable to input 4, the same applies for output 4. So, the same for channel 4, 5 and 6. Note that if nothing is plugged into channel 3, there is no noise. So something about the 8 channels is definitely working. It sounds like there are missing a lot of bits per sample. I tried changing the WRITE_CHANNELS to 8 already (and removing the asserts in soundbasedevice.cpp), but the result is kind of weird. The output on channels 1 & 2 becomes the same (so the music sounds mono) but no distortion or anything else, and the other channels still experience the same low rumble noise when testing the input (same as before).
this is the drain code:
This is in the config.h:
Is there anybody who could help me figure it out?
@rsta2 I see your making changes to the sound api on the development branch. I need to clean up the cs42448 class, because now it's hacked together. I suppose when i want to contribute the code, i'll hold of refactoring until the new soundbasedevice api is finalised and contribute then?
Beta Was this translation helpful? Give feedback.
All reactions