View Single Post
Old 07-18-2012, 04:15 PM   #232
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773670
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by twobob View Post
...
BARE MINIMUM:

Code:
 #include <asoundlib.h>
 static char *device = "hw:0";                        /* playback device */
 
int main(void)
 {       
         // setup the references.
         snd_pcm_t *handle;
         snd_pcm_sframes_t frames;

         // open it.
         snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0);
         
         // init it.
         snd_pcm_set_params(handle,
                                                 SND_PCM_FORMAT_S16_LE,
                                                 SND_PCM_ACCESS_RW_INTERLEAVED,
                                                 2,  // channels
                                                 44100,  // rate
                                                 0,  // soft resample
                                                 500000);  // latency
         // write to it.
         frames = snd_pcm_writei(handle, buffer, sizeof(buffer));
         
         // close it.
         snd_pcm_close(handle);
...

MANY THANKS TO GM FOR BUILDING A VERSION THAT WORKS ON ALL SOUND ENABLED KINDLES: (ATTACHED)
You are welcome!

Although we have overlap in our projects and methods, this is still a shared effort that we are all contributing to. You continue the robust version, and I will continue the tiny minimal demo version. And thanks for getting me started on the path to full simultaneous (hopefully glitch-free) audio on all the (sound enabled) kindles.

That "minimum init" version sure looks "familiar". It is based on the same alsa example source code as the "noisy rhythms" demo (except that I condensed mine).

I still like the condensed version better, but there are plenty of folks who like all that whitespace and may actually need all those comments to tell them that the open function does "open it" and the "set params" function does "init it" and the write function does "write to it" and the close function does "close it". My version without those comments could be difficult to figure out if you do not read the function names. And variable names like "buf" might mean "buffalo" instead of "buffer" so using abbreviated variable names could also lead to misunderstanding. (just kidding folks -- perhaps)

Last edited by geekmaster; 07-18-2012 at 05:00 PM.
geekmaster is offline   Reply With Quote