ghnotgood commented on PR #3477:
URL: https://github.com/apache/nuttx-apps/pull/3477#issuecomment-4449455519
@raiden00pl I have reverted git clone to the Makefile. The rtttl-c is
published under both, MIT or Apache-2.0 licenses.
@cederom I have put very simple example in Kconfig already. I have put an
example with printing frequencies and durations in the PR summary. The problem
with an example that makes actual sound is that the board I am working on does
not have a simple way to make a sound (like PWM) so I am not able to test it.
When considering `audio_rttl` example, I believe it could be rewritten with
`rtttl-c` like:
```
/****************************************************************************
* apps/examples/audio_rtttl-c/audio_rtttl-c.cxx
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdio.h>
#include <arch/board/board.h>
#include <arch/chip/audio.h>
#include <audioutils/rtttl.h>
#include "audio_rtttl-c.h"
/****************************************************************************
* Private Functions
****************************************************************************/
void play_sound(struct rtttl_tone sound)
{
board_audio_tone_generator(1, -40, soud.frequency_100hz / 100);
usleep(sound.duration_us * 1000L);
}
/****************************************************************************
* Public Functions
****************************************************************************/
extern "C" int main(int argc, FAR char *argv[])
{
/* Set I/O parameters for power on. */
if (!board_audio_power_control(true))
{
printf("Error: board_audio_power_control() failure.\n");
return 1;
}
printf("Start Audio RTTL player\n");
rtttl_play(g_song, play_sound);
/* Sound off. */
if (!board_audio_tone_generator(0, 0, 0))
{
printf("Error: board_audio_tone_generator() failure.\n");
return 1;
}
/* Set I/O parameters for power off. */
if (!board_audio_power_control(false))
{
printf("Error: board_audio_power_control() failure.\n");
return 1;
}
printf("Done.\n");
return 0;
}
```
But please note that I am not able to test it, because I do not have cxd56xx.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]