al_create_sample create double lengthen sample
I may be wrong but I'm currently playing with ex_record and ex_record_name to make myself a little recorder.
When just copy pasting the pasta and expanding the examples max_seconds, I ended with file that are the double of the file I currently save.
I digged up in the A5 sources and found that it isn't using the ALLEGRO_AUDIO_DEPTH (INT16 or whatever) in the sample size allocation.
My application or the example or the al_create_sample is wrong, but I had to divide samples by two to have the right amount of bytes saved.
Does anyone have a light for me ?
1/* Recorder is created like that: */
latency , /* 10 seconds buffer space */
latency , /* configure the fragment size to give us the given
6 latency in seconds */
frequency, /* samples per second (higher => better quality) */
ALLEGRO_AUDIO_DEPTH_INT16, /* 2-byte sample size */
ALLEGRO_CHANNEL_CONF_2 /* stereo */
12/* running values:
20/* I save the sample like in the examples */
date_str , "./output/%d/%s/%s"
, local_time ->
tm_year + 1900
, time_split[ 4 ]
, time_split[ 3 ] );
command , "mkdir -p %s"
, date_str ->
command ) );
date_str , "/" );
date_str , qvstudio ->
selected_title ] );
date_str , "_" );
date_str , time_split[ 2 ] );
date_str , "H" );
date_str , time_split[ 1 ] );
date_str , "M" );
date_str , time_split[ 0 ] );
date_str , "S" );
date_str , ".wav" );
35/* finished recording, but haven't created the sample yet */
spl = al_create_sample(
record_buffer ) / 2
, /* HERE NOTICE THE /2. WITHOUT IT I GOT 2x LENGTH ! */
ALLEGRO_AUDIO_DEPTH_INT16 , ALLEGRO_CHANNEL_CONF_2 , false );
, spl );
45/* qvstudio variable struct for type reference */
47#define MIN_SAMPLE_VAL 0x8000
48#define MAX_SAMPLE_VAL 0x7fff
50/*! Quiniou Studio Config structure */
53 /* DISPLAY */
54 /*! path to ttf font file */
55 const char *
56 /*! path to ttf font file */
58 /*! path to ttf font file */
60 /*! path to background picture */
63 /*! size for little text output */
65 /*! size for normal text output */
67 /*! size for huge text output */
69 /*! Screen W size */
71 /*! Screen H size */
73 /*! Internal loop freq */
76 /*! The 3 loaded fonts with their respective sizes */
77 ALLEGRO_FONT *font[ 3 ];
78 /*! Acutal display */
79 ALLEGRO_DISPLAY *
80 /*! Event queue */
81 ALLEGRO_EVENT_QUEUE *
82 /*! Timer */
83 ALLEGRO_TIMER *
85 /*! RECORDER */
87 /*! fragment from recorder */
89 /*! recording buffer , stores up to max_seconds of audio */
90 int16_t *
91 /*! points to the current recorded position */
93 /*! points to the end of the buffer */
95 /*! recording flag */
97 /*! Recording frequancy (44100,48000,96000) */
99 /*! Maximum size of sample */
101 /*! recorder internal buffer */
103 /*! Latency */
105 /*! Computed volume for current input */
108 /*! Loaded title list */
109 char *
NB_MAX_TITLES + 1 ];
110 /*! number of loaded titles */
What is the type of qvstudio->record_buffer?
It's an int16_t *. The structure of qvstudio is described in the latter part of the source.
I polished it a bit. It now uses float32 depth, but I still have to divide by two at the end if I don't wan't an add on of white of the same length .
Not sure if this is the problem here, but are you accounting for stereo vs mono recording? If you're expecting mono and you're using a stereo buffer for recording that might explain your sample being twice as long as you expect it to be.
I'm recording in stereo. I think the error may be in my own code. I'll post the recording parts here later in the day, I'm currently at work.
Bump for reply.
Thou shalt not lock open threads!
Thread #616105. Printed from Allegro.cc
I'll post what I got today. I have some cosmetics to do before posting something.