Using knowledge gained from the ultimate vlogging mic & knowledge of its mane use patterns, the plan for replacing the venerable Zoom took shape. Basically, merge the microphone preamp of 7 years with the AK4524 circuit. Make it permanently phantom powered, with XLR inputs. The AK4524 can be used as a differential ADC by combining its 2 channels & it's not a huge drop from the PCM4222.
Based on the use pattern, it also needs a way to monitor 2 channel audio from another digital source without recording it. Maybe this audio could be injected from WIFI. Another circuit will record TOSLINK output from the computer, at a different samplerate than the microphone audio. This should allow it to be used for the ultimate narration of screen captures, as well as ASMR audio & rocket launches.
It's been a long time coming, with many questions. Switchable phantom power & input jacks? Just buy a better Zoom? The Zoom was never used to record stereo from electret condensers since bootlegging, 8 years ago. The gootube has eliminated any need for bootlegging & any concerts worth it are better shot with the DSLR. Its only line output recordings were from tape. The tape deck needs to be restored, to do that again. There's a lot more information about restoring tape decks than 8 years ago & the need to do it. Perhaps switchable input modes are important. The connector style & phantom power would be changed with molex connectors & jumpers.
The PCM4222 is sort of a pain because it requires an antialiasing filter outside the chip & an external DAC for monitoring. Not sure the guys building ultimate recorders out of them are getting any better results from them, because the noise from the slightest analog chain knocks it down below 14 bits. They never ever show a waveform of a biased DC offset captured by them.
Beyond a certain point, it's easier just to invest in a better Zoom. The H2 from 8 years ago was always a piece of junk. There are better Zooms, for a price, but for the limited applications, it's not worth the price.
Plotted some waveforms comparing the noise of various configurations in differential mode. All were magnified to 1/262144 per Y pixel. With all the junk beyond what was connected to the Zoom, it still outperformed the Zoom. The Zoom doesn't have a gain control or phantom power, but does have some passives, so it's like the AK4524 with no preamp.
Disconnected successively more components, starting with the microphones & ending with just the op-amps to isolate the noise sources.
The noise is over the air, not over the power rails.
There is 60Hz line noise from the bench & 10Hz wifi noise from the pi.
In differential mode, turning off wifi offers no improvement beyond using txpower 5. In single ended mode, turning it off knocks out significant noise.
Powering off a battery, LM317, 78L05, RC filter made no difference.
Unplugging the phantom power circuit from the op-amp causes the largest reduction in noise.
Moving the PI farther away from the preamp, reducing txpower to 5, & using differential mode are going to be the standard use case & the keys to acceptable noise levels. This gives the following waveforms at 1/262144 per Y:
With these measures, the system is at least as good as the Zoom was in its best days. It's important to remember no other audio interface in the world uses wifi. Though the noise is horrendous in single ended mode, it's acceptable because the preamp is the only subject of concern, it's the same circuit that was used with the Zoom, & it's never going to be used in single ended mode.
Would only complain that it's nowhere close to the ASMR videos of others & the headroom is reduced when combining the differential signals digitally. You wouldn't notice the headroom except when listening to fully saturated levels. The next steps would involve a new phantom power circuit, shrinking the wires in the preamp, using digital pots, disabling wifi, moving the entire ADC chain inside the microphone, optical outputs, adding pilot lights to the JFETs.
Kept what was there from 7 years ago. Made the amplifier section output differential signals. Of course, there are sections where the pairs aren't close together & this is where the RF gets in. At least it worked as designed. Considering the preamp, a Zoom H6 would be smaller & easier to use.
A few more software bug fixes & it finally captured microphones with the monitoring working perfectly in both channels. Another change made the MANE volume control all the mane/I2S3 levels & the AUX volume control all the aux/I2S2 levels. It now requires both faders to adjust a stereo volume, but it's more intuitive. Also, the 2 channel mode using ADCs as differential pairs (L+/- R+/-) now has to write a separate file for each channel. A bit more effort could make every mode write a single file, but it's hardly ever going to be used.
Like the Zoom H2, the ADC board has no input protection. To protect it from 48V pops, the preamp has spudger diodes. The TLV320AIC32 in the Zoom simply blew up when plugged into phantom power.
The output of the ADC is a bit quieter than it was on the Zoom, because of the larger voltage range. The preamp already does 100x. The ADC can provide additional gain, but it has to be a GUI option.
The real problems show up in the L/L R/R mode. Here, the differential pairs subtract away the microphone signal & sum the RF. The RF is highly suppressed in the +/- modes, but still there. The RF getting into the preamp is awful. It's probably why others put thousands of parts into their preamps & pilot lights in their JFETs.
The mane feature of the GUI is the setting for mixing the 4 ADC's. Mixing down before writing was deemed necessary, since the storage goes from 10 hours for a single channel to 2 hours for 4 channels & multiple files with differential pairs are a pain. The mixing for storage is a completely different set of equations from the mixing for monitoring.
The VU meters still show the independent levels of the 4 ADCs. The top 2 are the AUX I2S & the bottom 2 are the mane I2S. The board layout led to the mane I2S always being the higher number on every list.
The 2 monitoring volumes are applied differently, depending on the mixing formula. The easiest way to figure out how they're mixed is by listening & tweeking the faders.
The mane trend is the use of the ADCs in the AK4524 as either a differential pair, an averaged pair, or 2 discrete channels. It should be obvious from the GUI. Each I2S needs to write to its own file because of synchronization problems. The Zoom H2 had the same problem.
After a heroic programming session, the file writer was upgraded to a 16 second buffer which writes as soon as it has data instead of in 1 second chunks. The SPI buffer was increased to 1/18 second, which was the maximum the STM32 could easily fit. More draconian measures could get it to 1/11. Unfortunately, its core coupled memory isn't accessible to DMA, which would have doubled the SPI buffer.
With all that going for it, it still overran once when recording 4 channels for 40 minutes. Don't expect to ever record 4 channels, except for testing the other modes. The next step would be recording to USB storage or moving the whole PI to a faster SD card.
It still only does 48khz & only uses the AK4524 as the source for I2S2. Have never ever used 96khz, despite it being on the Zoom H2. The biggest value was 24 bits. The problem is moving the ultimate stereo amplifier to a commercial 96khz DAC would give up the external tap for I2S. It would be a matter of swapping the TOSLINK between 1 board purely for capturing it & a board for listening to it or somehow splitting the TOSLINK. A USB soundcard would be the hardest to sniff.
The next matter is the preamp.
The thought occurred of dumping 48V phantom power & replacing the microphone electronics with op-amps boosting directly to line level. These mics are virtually free, have been replaced by USB versions & it would reduce the noise. It would require exposing some kind of gain adjustment, but the metal enclosure is absolutely required to stop interference. It's not for stopping singers from accessing the bass rolloff switch. A preamp conversion would be a lot of work splitting mane hairs for a truly meaningless difference.
Capturing PC audio in software sounds like a good idea until you have to monitor the PC audio in the phones. That would require a mixing board & a bunch of wires. The easiest way is capturing TOSLINK on the same board as the microphone & mixing it in software. Sometimes, the best way to do more in software is more custom hardware.
The trick is the AUX I2S clock is going to drift away from the mane I2S or be at a totally different sample rate. The only solution is to record different files for each I2S & take nearest neighbor samples for the monitoring.
Otherwise, rediscovered the raspberry pi's largest SPI buffer is 4096 bytes. You need to add spidev.bufsiz=32768 to /boot/cmdline.txt to expand it.
The 1st audio file recorded open circuits & showed -86.6, -87.6, -87.4, -88.08 dB for the maximums & -99.4, -99.8, -99.8, -100 dB for the RMS. They strangely got quieter as they went down the board, but were all good enough.
4 channels magnified to 1/262144 per Y.
When recording different files for the 2 I2S streams, it overruns all the time, even at 48khz. CPU usage is 5%. In typical ext4 fashion, it frequently locks up while doing an extended write. Mutex locking the 2 file writers doesn't help. The maximum SPI buffer size which can fit in the ARM is 12296 bytes. It needs some minimal mixing instead of writing the full ADC output & a more optimized buffer algorithm. Partitioning the flash into a raw area might be required.
In testing the DAC, the single ended output voltage is roughly 1.1 - 3.9 with the center at 2.5. The DAC is 20 bits, so you need to write -0x80000 to 0x7ffff. The ARM was configured with I2S_Standard = I2S_Standard_MSB, I2S_DataFormat = I2S_DataFormat_32b, I2S_CPOL = I2S_CPOL_Low. The AK4524 was configured with I2S mode 1. The I2S->DR register is written as well as read with most significant 16 bits 1st. The ADC spits out the sample left justified & the DAC takes it in right justified. In 96khz mode, the AK4524 drives I2S at twice the bit clock as 48khz mode but the format is the same.
Unfortunately, to minimize noise on the 5V rail, the headphone amplifier is powered by the 3.3V rail & it's DC coupled to the DAC. At least for the 440Hz test tone, the AD8604 dumps loads of current & 100% volume is far too loud. 50% volume is required to get below 3.3V & that is also quite loud. May just risk using the 5V rail rather than make an AC coupled headphone amplifier. Other ideas are shifting the midpoint in software to 2.2V, giving roughly 75% volume. The output does seem to be DC coupled to the DAC. It also has an intermittent problem of not initializing the left DAC after an ARM reboot until being power cycled.
Didn't notice any noise with the 3.3V power. Differential output definitely isn't necessary for a simple headphone monitor.
Once the usual GPIO snafus were fixed, attention turned to using the AK4524's built in DAC for monitoring. Banging on this discontinued chip isn't so bad when you consider guys are going around building computers out of 6502's.
C11 didn't work as I2S3ext_SD. Only B4 did. The datasheet had a buried nugget about aux function GPIO_AF_I2S3ext having to be selected for C11 while the aux function was GPIO_AF_SPI3 for B4. No amount of register banging could send data out of C11. What did help was printing the contents of SPI3->I2SCFGR & I2S3ext->I2SCFGR to verify the key registers were being set correctly. Also review the I2S_FullDuplexConfig, I2S_Init functions. Once full duplex is enabled, you have to use I2S3ext registers to send or receive data using the ext_SD pin & the I2S3 registers to access the SD pin. Both pins can be inputs or outputs.
The timing of when to send what 16 bits to the DR register to reconstruct 2 channel 24 bit samples is a bit tricky. Similar to a state machine which uses the channel side bit & a counter to sort the 16 bit reads from the DR register, another state machine must use the same bits to sort 16 bit writes. Not sure how people do it with DMA, but it definitely must be done with polling to downmix the 4 input channels & monitor audio without latency.
It was disappointing to find that the ARM was bad. VCAP went only to 0.5V & it wouldn't boot. Shorting it to VDD got it to start. Reflowing it a few times got it to 1.2V but it still wouldn't boot. Hopefully, it was a solder ball, but the ARM was replaced with a working chip. It's a big deal when an STM32F4 dies because they're still $10 a piece, to this day. A whole raspberry pi is less, but it doesn't have triple I2S ports.
The complete PI section was attached. Another high voltage lead is required for the preamp. The 24 bit vlogging mic was cannibalized.
The 1st analog board came together, in its test harness. It's not as ambitious as some past quad copter boards, but presents challenges in signal quality. Made every effort to star ground the analog grounds, separate the analog grounds from the digital grounds & copy the 5V filtering discovered on the single channel board. Although it still has an extra I2S port, decided it would be better to develop something in software using Jack to record the computer than capture the TOSLINK output.
To save money on clothing, the decision was made to etch the Zoom replacement & the additional board for the ultimate vlogging mic on the same day. The zoom replacement undergoes continual evolution like everything else.
but converges on a mane ADC board which attaches to interchangeable front ends. The mane board exposes its spare I2S pins for an arbitrary I2S source. The lower ADC also provides a DAC for monitoring, so it's always connected & has to be the one taking input from any 2 channel front end. The upper ADC has to share its I2S pins with the aux input. They're obsolete ADC's, but easy & good enough. Digital & analog grounds were carefully starred.
The PI connects on the left. The front end connects on the right. The whole thing takes only 1.5" x 2", manely because of cost. Fully equipped with a front end, battery, & PI, it should be much smaller than a Zoom.
The 5V regulator is a pain. Need to test the impact of 5V power supply on the noise, again. The answer is FUGGEDABOUTIT. You can't use the PI's 5V for audio. The AK4524 actually drops its 5V to 3V internally. Its DAC is centered on 1.5V & the ADC is centered on 1V, but no further testing of the ranges was done. The theory behind powering the op-amp headphone driver off the digital 3.3V was the DAC only going from 0-3V. This would be much better off the 5V analog, but need to test the impact on the ADC.
It needs a dual balanced mic front end. Someday, it'll have a dual, unbalanced electret front end & a quad line input. The front ends are going to need their own microcontrollers, have a single UART wire for controlling pots, 3.3V digital, digital ground or just use analog pots & skip all that. They'll need 5V analog voltage & analog ground.
The audio inputs are wired to be balanced pairs. To use them without balancing, just leave 1 disconnected. Each goes to its own ADC with the summing in software.
It took a while to realize that all the STM32's can be programmed with just 2 wire "SWD" instead of the full JTAG port. This nugget came from tearing down a brushless gimbal & already having discovered the SWD mode inside an NRF51 dev kit. It saves immensely on board space.