2018-05-17 03:14 PM
Hello, I am currently studying computer science, I must perform a project during my year.
I work on a STM32F7G46.
I have sampled a given curve and thanks to it generate sound. I am at the point where I have tables of coordinates of a sampled curve but I am blocked, or do I have to send these tables? in 0xC0000000?
Any help is welcome, thank you.2018-05-17 10:53 PM
I work on a STM32F7G46.
I guess you mean the F746G.
Hello, I am currently studying computer science,...
So you can expected to read and understand the datasheet + reference manual of said controller.
I have sampled a given curve and thanks to it generate sound.
What external device ?
For plain analogue output, you could use the DAC.
Keep in mind that the output sample rate is supposed to match the input rate.
I would use a timer to trigger the output.
Any help is welcome, thank you.
You should get at least some idea how to do it (and tackle similar problems), else it would be futile ...
How about your experience with microcontrollers at all ?
2018-05-18 02:59 AM
Yes ,
meyer.frank
is right ,Timer ouput-compare with interrupt enabled, that will give you a serving time-base for your data stream.
on each interrupt, you place the pointed data into the DAC, then increment the pointer to the next data point.
at what rate ( Hz) was the data recorded ?
2018-05-18 03:25 AM
Thanks for your answers,
To be honest i have no experience with
microcontrollers, that's why it's so hard for me.
I will explain more precisely what i would like to do :
I'm sampling a curve at 48Khz.
So I got two arrays of coordinates (x,y) of a curve.
Thanks to these arrays i would like to
generate sound on the STM32F7.
what informations are needed to generate sound ?
Where i am supposed to write these informations and how ?
2018-05-18 03:52 AM
You will have to study our answers some more, because every concept you need is described there.
You will need to study
DAC outputs.
Output Compare functions of a Timer
Data Rate in Recording = Data Rate of Playback.
X and Y is Voltage over time...( I guess)
Y is usually Time which is conceptually transposed into 'clicks'
You have to generate the 'Clicks' at the same rate of recording.
Clicks come from the Output Compare generating interrupts.
Here inside the 'Click' interrupt, is where you serve the new data value ( X ) into the DAC and increment the pointer.
Click Time is the OutputCompare value in Timer counts.
The Count Rate is determined by the timer input clock and prescalers, ( hence the Reference manual suggestion by
meyer.frank
)2018-05-18 04:18 AM
A Cortex M7 (including the STM32F7) is not really the best choice to start. But it seems that was not your decision.
To be honest i have no experience with
microcontrollers, that's why it's so hard for me.
I still recommend to download the Reference Manual and the Datasheet of said part, and read them carefully. They will give you an idea about the capabilities of the MCU, and possible solutions. And reading/understanding such documents is the 'daily bread' of an embedded SW engineer.
So I got two arrays of coordinates (x,y) of a curve.
I guess you mean one array with two coordinates (indices), keeping multiple sampled sequences.
Extracting the sample you want/need to play should not be too difficult.
what informations are needed to generate sound ?
For instance what do you mean with 'generate sound'.
The most obvious would be the DAC peripheral. Or you have an external amplifier IC, driven with I2S.
My first suggestion - set up a DMA channel that feeds the sample data to the DAC. The DMA itself is triggered by a timer at a 48kHz rate.
While I personally don't like CubeMX, I would strongly recommend it in your case.
2018-05-18 05:02 AM
No, not Output Compare, that's too difficult,
just use timer overflow interrupt.
the OutputCompare function was a bum steer
:(
2018-05-18 06:21 AM
thank you both for your help,
First of all i will read all the documentations you talk me about.
I will explain you the entire project.
I make an interface on the stm32f7 where a user can draw a Curve
by moving control points (red points in the picture) of a bezier curve (as you can see in the picture).
Then, thanks to the Bezier equation, I sample the curve at 48kHz and i put the coordinate of the 48 000 samples in two arrays, one for X which represents time and Y which represents voltage.
But now I would like to generate the sound correpsonding to the curve drawny by the user.
Thanks again !
2018-05-22 12:40 AM
Then, thanks to the Bezier equation, I sample the curve at 48kHz and i put the coordinate of the 48 000 samples in two arrays, one for X which represents time and Y which represents voltage
For sample output, the 'X coordinate' is implicit.
Then, thanks to the Bezier equation, I sample the curve...
Bezier interpolations are for graphics, not sound. I hope you are aware that such second / third order functions create spectral artifacts in the output.
But now I would like to generate the sound correpsonding to the curve drawny by the user.
The only noteworthy point here is to get the user input, and make it into samples. The rest is the same.
Not sure what the real use case is, though.