Hi!

Tiago, since you are the audio guy, what do you think? Is it possible to
> create the "fake" audio codec that works with PWM and DMA the way I'm
> suggesting?


Yes, the audio subsystem is created in layers. It wouldn't be a codec by
itself (like PCM), but still can be understood as an *audio decoder driver*.
Take `cs4344` audio decoder driver as an example. It receives a low-level
I2S interface peripheral to be bound to the audio codec driver at
`cs4344_initialize`
<https://github.com/apache/incubator-nuttx/blob/4ef01d98d526361b9348646dd1fd09f3faff88c0/boards/xtensa/esp32s3/common/src/esp32s3_cs4344.c#L112>.
After initialization, the PCM audio codec is created using this audio codec
at `pcm_decode_initialize`
<https://github.com/apache/incubator-nuttx/blob/4ef01d98d526361b9348646dd1fd09f3faff88c0/boards/xtensa/esp32s3/common/src/esp32s3_cs4344.c#L125>.
Instead of the `cs4344` audio interface, there would be a "generic PWM
audio codec" that received a PWM interface from the device and that
generates the signal to be sent to the PWM peripheral. All the
required translation (from PCM, for instance) would be done in this driver.

Best regards,

Em dom., 23 de fev. de 2025 às 07:10, Alan C. Assis <acas...@gmail.com>
escreveu:

> Hi Kevin,
>
> I think it is possible to create a generic audio using PWM and DMA, but it
> will require two halves design (like many drivers in NuttX).
>
> The top half will implement the high end driver to be present like an
> audio codec to the application (this way we don't need to modify existing
> applications), and the bottom half will be responsible for setting up the
> DMA channel to use with the PWM.
>
> Create a board only solution like you are thinking will work for your
> board, but if in the future you move to another arch you will need to
> reimplement it again and probably the way you are going to implement it the
> existing applications cannot be used.
>
> Tiago, since you are the audio guy, what do you think? Is it possible to
> create the "fake" audio codec that works with PWM and DMA the way I'm
> suggesting?
>
> BR,
>
> Alan
>
> On Sun, Feb 23, 2025 at 6:59 AM Kevin Witteveen <kevinwit1...@gmail.com>
> wrote:
>
>> Well that's unfortunate. It feels that this kind of system will not fit in
>> this OS without a bit of hacking.
>> I think I will implement this at board logic. Use DMAC.h device and
>> directly use it on the PWM register addresses after initializing them the
>> proper way using the PWM.h device.
>> Maybe it's possible to add this as a source file to the common RP2040
>> board
>> directory for everyone to enjoy.
>>
>> About the I2S... yeah i think i will go for that next time. I am a little
>> stuck with what I have on my PCB right now.
>>
>> Op zo 23 feb. 2025 02:20 schreef Tomek CEDRO <to...@cedro.info>:
>>
>> > Many people think about this but no solid implementation so far.. have
>> > you consider I2S audio codec?
>> > Tomek
>> >
>> >
>> > On Sun, Feb 23, 2025 at 12:07 AM Kevin Witteveen <
>> kevinwit1...@gmail.com>
>> > wrote:
>> > >
>> > > Thanks, however I'm specifically looking for audio. For example,
>> music,
>> > > samples, etc. A tone is not enough for what I'm looking for.
>> > > Or did I miss something and the audio_tone is actually more than just
>> a
>> > > tone?
>> > >
>> > > Op za 22 feb 2025 om 22:05 schreef TimH <t...@jti.uk.com.invalid>:
>> > >
>> > > > CONFIG_AUDIO_TONE?
>> > > >
>> > > > Not sure if that’s exactly what you’re after but could be?
>> > > >
>> > > > > On 22 Feb 2025, at 17:12, Kevin Witteveen <kevinwit1...@gmail.com
>> >
>> > > > wrote:
>> > > > >
>> > > > > Hi nuttx,
>> > > > >
>> > > > > I need an audio device that can generate sound using PWM on the
>> > RP2040.
>> > > > It
>> > > > > appears nothing already exists for this.
>> > > > > What would be a good way to implement this?
>> > > > >
>> > > > > My previous implementation outside NuttX was to use DMA to feed
>> > samples
>> > > > > into a PWM register. Relatively simple.
>> > > > > However, in NuttX i now need to combine the PWM implementation
>> with
>> > the
>> > > > > DMAC implementation. This is where I'm not sure how to "connect
>> them
>> > > > > together" on a proper "nuttx" way.
>> > > > > Then also have it show up as an audio device.
>> > > > >
>> > > > > in case you wonder about the concept PWM audio. It is a common
>> way to
>> > > > > generate audio. It is how class-D amplifiers work. This is because
>> > the
>> > > > duty
>> > > > > cycle of PWM when filtered becomes an analog signal. A very cheap
>> > way to
>> > > > > implement audio in systems.
>> > > > >
>> > > > > Are there any examples of projects out there that did this with
>> > Nuttx?
>> > > > > Or are there any people that have an idea how to take this project
>> > on?
>> > > > > Where do i begin? Where would i implement this? Board?
>> Architecture?
>> > > > >
>> > > > > I would appreciate any help
>> > > >
>> > > >
>> >
>> >
>> >
>> > --
>> > CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
>> >
>>
>

Reply via email to