Further to my thread Hairy output on R4 DAC the discussion has moved on from the initial problem to a wider discussion so I requested this new thread to be created.
Just been adding a timer to my wave form generator, with the help of
Under the Hood: Arduino UNO R4 - Timers - Phil Schatzmann. Although he says you can't get CD speed sampling (44.1KHz) with the audio tool kit There was no problem with the timer. I suspect it was without @susan-parker magic direct access methods. The big problem, as I see it, with the analogWave library is that if you change the scaling of the samples (volume) it just reduces the peak value. What needs to happen is that the DC bias at the mid range point needs to be maintained, if you are going to avoid the thump you get when a new note starts.
So I have been playing about with frequency and volume controls variables in the loop function as the wave plays. You can do that almost instantly unlike the analogWave library, which needed a minimum of about 50mS delay fefore any changes will take place.
At the moment I have just been seeing what they do. Here is a video of some 'effects' you can get with my odd ball wave function.
Nice video.
I am currently running in loop() code for a sine and a cosine by direct calculation (NOT lookup tables) which is clocking in at 226kHz.
This includes floating-point amplitude adjustment (not just shifts).
Would be slightly faster without the pin set/clear calls at 83nS each.
Of course there isn't anything else happening...
Next to put it in a timer-interrupt - maybe 96kHz to start with.
As the post thing prompts, maybe we should change the thread?
Thanks again @susan-parker for all the code. I have it up and running on my minima and I am starting to get my head around the direct register access.
I noticed that in your DAC setup code, you have the following
// *DAC12_DAVREFCR = 0x06; // D/A VREF Control Register - Select External Vref; set VREFH&L pins used for LED
A few, hopefully simple, questions.
Can you use the voltage on the minima AREF pin as the external reference voltage for the DAC Or is the external voltage reference in the code comments from somewhere else?
If it is from somewhere else do you know of a way to supply a reference voltage to the DAC?
Hi,
The DAC uses different reference source setup and pins to the ADC.
On the Minima the DAC references are on the RxLED and TxLED pins. If you unsolder the two LED resistors R14 and R15 you can provide external reference into the DAC.
Yes, they are teeny!
Hope this helps
Looking at the RA4M1 datasheet I note that sadly the Serial Sound Interface Enhanced (SSIE) is only available on the 100-pin package, see pin-lists section 1.7
However the SSIBCLK is available on P112 i.e. D10, so that might be useful if one wants to generate an audio-specific clock for something... maybe?
Unfortunately, I have discovered that it needs the GPT321 for an internal clock source, so not really worth doing until I get a 100-pin version of the RA4M1.
Have added the frequency changes cause by inharmonicity for strings, e.g. piano, etc. where the 3rd and higher harmonics are actually slightly higher than expected because of the effect of string-stiffness affects the node-points.
This is nominally the same tone as per the previous post's image, which has locked harmonics such as with a flute.
I think that answer ignored the fact that a piano has multiple strings and so can not be expected to have all the harmonics fixed to one fundamental, as there is more than one. This is because all the strings can't be tuned without instruments beyond that a piano tuner uses. And even if they were they would not stay that way for long.
This is also for single (metal) strings per note e.g. guitar as well - not because there are multiple strings for the same note, which is another complication.
What I am testing is how far I can push the RA4M1 processor, which is of course quite slow compared to many other 32bit offerings, with doing some sort of real-world waveform-synthesis application at CD speed samples at 44.1kHz
Also I am currently generating 10 sines at 25bit accuracy per loop through direct calculation - not using any form of lookup table - including scaling their respective amplitudes - before adding them all together.
I can also generate a bit-clock close enough to get a 44.1kHz frame rate with the standard 12.0 MHz clock to get a reliable PLL lock in the Audio DAC