/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Playing sounds with no SD card

Username:     
Password:     
             

Forum

# 1   2011-03-04 12:09:57 Playing sounds with no SD card

cowana
New member
Registered: 2011-02-14
Posts: 2

Playing sounds with no SD card

I have a Primer2, running CircleOS 4.11.

For a game I am developing, I want to add short sounds (explosions etc).  For a very low number of very short files, I don't want to have to use an SD card - I think it should be possible to store these files on the Primer2 itself.

Are there any resources/guides on doing this on the internet?  I've had a search, but everything seems to use the SD card interface.

Many thanks

Andrew

Offline

 

# 2   2011-03-06 05:30:09 Playing sounds with no SD card

atitude
Member
From: USA
Registered: 2010-12-18
Posts: 30
Website

Re: Playing sounds with no SD card

You can play audio from a table kept in (flash) memory. I suggest you check out the Circle OS source code: the message at startup "Welcome to ..." is implemented like that.

I would expect you find that you will run out of available memory rather fast. That's a good reason to reconsider using the cheap SD cards. Alternatively try synthesized sounds, such as beeps.

Offline

 

# 3   2011-03-08 10:16:26 Playing sounds with no SD card

cowana
New member
Registered: 2011-02-14
Posts: 2

Re: Playing sounds with no SD card

In OS main, the routine  AUDIO_Welcome_Msg(); is called.

This is defined in audio_spe.c, and is:

const u8 welcome_16K_8 [] =
{
#include "welcome_16k_8.h"
};

NODEBUG void AUDIO_Welcome_Msg( void )
{
    AUDIO_SetMode( AUDIO_MODE, LG_8_BITS, FRQ_16KHZ, MONO );
    AUDIO_Play(( sound_type* )welcome_16K_8, sizeof welcome_16K_8 );
}

And the elecome_16K_8 message is a .h file.

Is there some ultility (similar to BMP to LCD) I can use to convert a sound format into .h format?  Obviously the sound would be 8 bit, 16kHz.

Thanks

Andrew

Last edited by cowana (2011-03-08 10:17:29)

Offline

 

# 4   2011-03-09 07:30:26 Playing sounds with no SD card

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Playing sounds with no SD card

Hi,

There is no specific tool for converting audio files, but it exist a lot of standard tool to record and treat sounds.

Hereafter is a method to play sounds :

1 : record your audio messages with the Windows recorder or a better audio software, into ".wav" files,
2 : suppressed the wav header of the files (44 bytes), to keep only the raw data,
3 : convert files to ".h" files thanks to "bin2hex" and "hex2bin" tools (with -t option) provided with Ride,
4 : insert the ".h" into your code,
5 : call the Circle API "AUDIO_SetMode" according to your audio file format,
6 : call the Circle API "AUDIO_Play".

Yves

Offline

 

# 5   2011-03-11 09:17:42 Playing sounds with no SD card

Monermajetomi
Banned
Registered: 2011-03-11
Posts: 3

Re: Playing sounds with no SD card

I have a PNY micro SD card. When I took a video on my phone I transferred it to my computer and the video had no sound on it.

Offline

 

Board footer