Jump to content

Recommended Posts

Posted

i'm trying to use audio with ugfx, to be more precise, i want use a piezo buzzer controlled with pwm, i looked example play-vs1053, but not understand how to selected the type of hardware to use (VS1053,pwm,adc), in this example is loaded the file audio, played etc, but how to set the port where to send 'audio'?

there are other simple audio example with pwm? maybe i'm wrong but i not see

thanks

Posted

There is an existing PWM driver for the GAUDIO playback module. You can find the driver in /drivers/gaudio/pwm/.

The entire hardware configuration (eg. what pins, which PWM peripheral etc.) happens through the board file - the same as all the pin configurations for the display happen through the GDISP board file.

All you need to do is copying the board file template that you can find in the drivers directory to your project directory and implementing those four functions and you are ready to go. Note that the readme in the drivers directory contains some more information.

Also note that when copying the template to your project directory you have to rename it so it doesn't say "_template" anymore. The file must be named gaudio_play_board.h.

Let us know should you have any other questions.

~ Tectu

Posted

Have a look at the olimex SAM7EX256 board as an example. This is a supported board and it uses PWM audio.

You should be using the play-wave demo. The vs1053 audio controller is a chip that is capable of decoding complex file formats like mp3. That is why it has its own demo - to demonstrate those extra capabilities. The pwm audio (and most other audio codecs) can only accept pcm data. Play-wave is the demo that converts a .wav file into pcm data and feeds it to the audio sub-system.

If you want to decode more complex audio file formats than wave files you will need to either use a decoding library or upgrafe your hardware to use a specialist chip like the vs1053.

Posted

ok, done, but i have problem to load the file from ROM

gfxBufferAlloc is ok

when i try to open the file with gfileOpen, function fail (tryed with 'r' & 's')

i have used the same file on the example dir of demos\modules\gaudio\play-vs1053\

ronfs_files.h & romfs_allwrong.h

then included the file on the main.c with #include "romfs_files.h" (the bin file become more big, so datas are on the rom)


#define GFILE_NEED_NATIVEFS FALSE
#define GFILE_NEED_ROMFS TRUE

#define GFX_USE_GAUDIO TRUE
#define GFX_USE_GFILE TRUE
#define GAUDIO_NEED_PLAY TRUE
#define GAUDIO_NEED_RECORD FALSE
#define GQUEUE_NEED_BUFFERS TRUE
#define GQUEUE_NEED_GSYNC TRUE

.....

if (!gfxBufferAlloc(4, 512))
{
errmsg = "Err: No Memory";
goto theend;
}

repeatplay:
// Open the wave file
if (!(f = gfileOpen(MY_PLAY_FILE, "r")))
{
errmsg = "Err: Open WAV";
goto theend;
}

Posted

Is the definition of MY_PLAY_FILE correct?

This should be a #define that matches the name of the file in romfs_allwrong.h

Also romfs_files.h should not be included in your main.c

It should be automatically included by ugfx because you have turned on the romfs system in your gfxconf.h

The easy way to tell is to add a #warning into romfs_files.h

You will then be able to see any time it is included

Posted

Best way from here is to debug into the gfileOpen in order to discover why it is not finding your file. Given that you get no warning displaying (you did do a make clean?) I suspect that the romfs code is not been included for some reason.

Posted

the function ROMOpen not found the file in ROM, all the parameters seems good, so i think the files are not included on compilation

there are some particular things to do, to use GFILE functions? maybe i forgot some particular, i have enabled this 'flags'


#define GFILE_NEED_NATIVEFS FALSE
#define GFILE_NEED_ROMFS TRUE

#define GFX_USE_GAUDIO TRUE

on chibios (3.0.3) i do nothing, to compile i use makefile, maybe this do some difference? compilation not show errors, and firmware correctly work

Posted

At this stage we will need a copy of your project to be able to help you more. Please cut out any code not relevant to this discussion and then zip the project and add it to a forum post.

When we get a few minutes we will look at it. It may be a few days however as we are currently very busy.

Posted

found the problem, is a path problem, i put an absolute path on include inside gfile\gfile_fs_rom.c (i know is really not good idea, but i want found the problem), and now the file is found, read, and i hope also played

on the makefile there are the path to the files romfs_files.h, so i not understand why is not included... must investigate more

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...