Skip to content

!examples/audio_rtttl: Implement example using RTTTL library#3633

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
linguini1:audio-rttl
Jul 13, 2026
Merged

!examples/audio_rtttl: Implement example using RTTTL library#3633
xiaoxiang781216 merged 1 commit into
apache:masterfrom
linguini1:audio-rttl

Conversation

@linguini1

@linguini1 linguini1 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This commit fixes the audio_rtttl example (which was undocumented and previously used kernel-level functions) such that now it uses the RTTTL parsing library. Contributors can implement 'players' for different types of audio sinks. Currently, PWM is supported.

BREAKING: The previous version of this example only supported a single board (Spresense) and uses public interfaces from the kernel code. Now it only uses user-space interfaces and supports any board implementing those interfaces. Users who relied on the old behaviour should submit a patch to add a new player to this application which uses the desired audio sink for the Spresense through user-space interfaces.

Impact

Can play RTTL with different devices! PWM supported for now, which a lot of
small boards have.

Closes #3621

Testing

Tested on the Rpi4B PWM-enabled audio jack. I confirm I heard the scale. I also
tested with the Simpson's example from the RTTL library and it worked.

NuttShell (NSH) NuttX-13.0.0-RC2                                                                           
nsh> audio_rttl /dev/pwm1                                                                                  
nsh> 

@linguini1

Copy link
Copy Markdown
Contributor Author

If the PR passes I'll open one to document the application & a configuration for it on the RPi4B

acassis
acassis previously approved these changes Jul 12, 2026

@acassis acassis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just confirm it still working on other boards with audio codec instead of PWM

@linguini1

Copy link
Copy Markdown
Contributor Author

Please just confirm it still working on other boards with audio codec instead of PWM

I'm not even sure how the last version worked. It appeared to be tailored to only one board and there were no docs for it.

Comment thread examples/audio_rttl/audio_rttl_main.c Outdated
Comment thread examples/audio_rttl/audio_rttl_main.c
@acassis

acassis commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Please just confirm it still working on other boards with audio codec instead of PWM

Which board are you citing?

I think spresense:fmsynth uses it because it calls fmsynth/mmlplayer_main.c calls: #include <audioutils/mml_parser.h>
So, it will work in any board with an audio codec, even on stm32f4discovery board.

@linguini1

linguini1 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Which board are you citing?

I think spresense:fmsynth uses it because it calls fmsynth/mmlplayer_main.c calls: #include <audioutils/mml_parser.h> So, it will work in any board with an audio codec, even on stm32f4discovery board.

The spresense board, which is the only one that implements the functions board_audio_power_control, etc. used by the old example. So, the example worked only for that board

I can't confirm that the example still works on the spresense board, again because there's no documentation on how to use it but I also don't have a spresense board. My goal was to make the RTTL player work for any board by using user-space interfaces instead. Anyone depending on this for spresense would have to add a patch to add a player for the spresense interfaces.

EDIT: I marked this as breaking with the quick-fix notes for people using Spresense to restore the previous behaviour.

This commit fixes the audio_rtttl example (which was undocumented and
previously used kernel-level functions) such that now it uses the RTTTL
parsing library. Contributors can implement 'players' for different
types of audio sinks. Currently, PWM is supported.

BREAKING: The previous version of this example only supported a single
board (Spresense) and uses public interfaces from the kernel code. Now
it only uses user-space interfaces and supports any board implementing
those interfaces. Users who relied on the old behaviour should submit a
patch to add a new player to this application which uses the desired
audio sink for the Spresense through user-space interfaces.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
@linguini1 linguini1 changed the title examples/audio_rtttl: Implement example using RTTTL library !examples/audio_rtttl: Implement example using RTTTL library Jul 12, 2026
@acassis

acassis commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Which board are you citing?

I think spresense:fmsynth uses it because it calls fmsynth/mmlplayer_main.c calls: #include <audioutils/mml_parser.h> So, it will work in any board with an audio codec, even on stm32f4discovery board.

The spresense board, which is the only one that implements the functions board_audio_power_control, etc. used by the old example. So, the example worked only for that board

I can't confirm that the example still works on the spresense board, again because there's no documentation on how to use it but I also don't have a spresense board. My goal was to make the RTTL player work for any board by using user-space interfaces instead. Anyone depending on this for spresense would have to add a patch to add a player for the spresense interfaces.

EDIT: I marked this as breaking with the quick-fix notes for people using Spresense to restore the previous behaviour.

Maybe @jerpelea know how this work. Sony has a great Documentation page about NuttX. A quick search didn't return anything.

@xiaoxiang781216 xiaoxiang781216 merged commit b39228c into apache:master Jul 13, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] audio_rttl application fails to compile

4 participants