![]() |
#1 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Audio (video) - Kindle. Getting it up and running, Code level.
Latest Update:
Spoiler:
"Audio - Kindle - Linux. Getting it up and running, Code level." This thread is about the quest to get some audio action on the Kindle - direct via code. If this is not something you are interested in. Stop reading now. Thanks OUTPUT OF THE PROJECT There are now a wealth of links on these threads to pretty much everything I could find about alsa as it stands today. It's not an impressive list of resources all in out there and hopefully this guide will serve to AT LEAST get sound in your applications in a singular direction without too much grind. There is a useful overview of the PCM interface that is a bit scary but not a terrible read here http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html STEP ONE: INIT MY ALSA There are a few simple demos freely available from the Alsa project. We have used these as part of the basis of the explanations here. Hopefully in a clear enough manner to get you going. BARE MINIMUM: Spoiler:
That's an absolute bare minimum example. The further examples demonstrate better error handling and alternate setup methods. All are succinct. One of the more succinct demonstrations for initialising a sound device is here but the actual how and why of what's happening is not clear, plus much of the code can be elided for use on the kindle, so to this end here are two reworked versions of that demo. It's enough to get you going in about 5 minutes flat. Here is the (Astlye compliant) discursive version of the code with additional notes and highlighting of important areas: (In the preferred style of Knc1) Spoiler:
INIT ALSA - CHOP FU And here is that demo again but this time squished: (In GM's preferred compressed style) Spoiler:
ACKNOWLEDGMENTS Many thanks to: The excellent assistance of GeekMaster, Knc1, NiLuJe and others and notably the KeK project, without which this project would still be stuck in no-x-compile-land. All of the work regarding video is completely down to the work of Geekmaster and you can find the thread dedicated to that here geekmaster kindle video player , currently it is without audio. Perfect for the thrust of this thread: "Providing support and documentation to enable sound for the kindle." Testing continues but I can report decent beta results on a 3. WORK DONE SO FAR Spoiler:
TODO: Spoiler:
The application outlined below is a simple tone generator demonstrating access the kindles alsa layer. It's a more fun demo than the previous top-post and people like fun. A more general purpose initialisation codeset - possibly called "Kradle" - is in the wings, somewhere, one day. DEMO APPLICATION: tones Frankly I'm amazed it works at all. so if it blows up your kindle? Don't blame me. Source: Spoiler:
This is in essence the demo from Alsa with a few bits of musicality chucked in. Notably the use of numeric constraints to limit to pleasant range, multi-step offsets linked an overall counter to give us motion and loops, etc. It's basic stuff, chuck in a Pi here and a > there and you're off. You want to be looking at the second half of the function generate_sine, Feel free to hack, I added notes. FEEDBACK I'm interested in any random output it may have on your kindles that I can fix up. INSTALL Copy it to your device somewhere. RUNNING THE APPLICATION Launch it via SSH, Launchpad or whatever. EXAMPLE simple usage: ./tones EXAMPLE advanced usage: ./tones -f 4000 -D hw -c 2 -v -r16000 -mdirect_write Usage: tones [OPTION]... -h,--help help -D,--device playback device -r,--rate stream rate in Hz -c,--channels count of channels in stream -f,--frequency sine wave frequency in Hz -b,--buffer ring buffer size in us -p,--period period size in us -m,--method transfer method -o,--format sample format -v,--verbose show the PCM setup parameters -n,--noresample do not resample -e,--pevent enable poll event after each period UNINSTALL Just delete the file. OTHER THOUGHTS This tones application is just a simple demo, fiddling about with sines via the alsa interface to show we now can do direct access, and how to have a play, don't expect "Kuitar Hero", "Kubase" or "Kuake" just yet. It's a silly demo. The final overall aim of the "Kradle" project is simple: Give us enough information to implement sound support in other applications, Thanks. MANY THANKS TO GM FOR BUILDING A VERSION THAT WORKS ON ALL SOUND ENABLED KINDLES: (ATTACHED) Last edited by twobob; 01-30-2013 at 08:12 AM. Reason: Added some content information and more up to date info on the thread. |
![]() |
![]() |
![]() |
#2 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Borrowed from Lupines:
https://www.mobileread.com/forums/sho...d.php?t=204275 Now, if you are REALLY brave and want to compile it from scratch here are the instructions on how to build it from source. INSTRUCTIONS FOR THE CROSS COMPILER cross compiler instructions for ARM from here: http://wiki.debian.org/BuildingCross...Cross_Compiler ---------------------------------------------------------- COMPILING INSTRUCTIONS FOR alsa-lib Since the Kindle works under ALSA for audio, you must have a cross compiled version of alsa-lib-1.0.13. I believe a newer version of the ALSA libs could be used. I just tried this one and it works (Other than an init lag, which seems to affect all version of alsa with this card) # wget http://gd.tuwien.ac.at/opsys/linux/a...1.0.13.tar.bz2 # bunzip2 alsa-lib-1.0.13.tar.bz2 ; tar -xvf alsa-lib-1.0.13.tar # cd alsa-lib-1.0.13 # ./configure --with-audio=alsa --prefix=/usr/local/arm-linux --host=arm-linux CC=arm-linux-gnueabi-gcc \ GCC=arm-linux-gnueabi-g++ CFLAGS=-DEMBEDDED CFLAGS="-I/usr/local/arm-linux/include" \ LDFLAGS="-L/usr/local/arm-linux/lib" LD_LIBRARY_PATH="/usr/local/arm-linux/lib" # make # make install ------------------------------------------------- Notes about the card For the interested: cat /proc/asound/cards Spoiler:
So its an Alsa-sound installation with some interesting bits and bats of settable params. Specifically: Access to some basic 3D audio emulation and potentially some filtering (By all accounts this often does nothing) Automated Volume leveling and some fancy ADSR enums around it Also uses some sort of target function which looks intriguing (which could serve as a compressor limiter expander possibly mis-used correctly) Settings for ADC / DAC inversion with single side inversion (that may allow for phase effect tricks such as cancellation to be done without code) Mic Boost is included which may actually come in handy. no doubt horrible. A mono volume-joined noise gate - which is a nice bonus. If anyone has any experience with these on the kindle wade in here. The last time I played with this stuff was a decade ago. Looks like there are some ways to make what is there do some cool stuff with a bit of thought. would be nice to have something that provide for direct DSP pumping in place. http://tldp.org/HOWTO/Alsa-sound-6.html has a run down of much of info I have re-covered here. the alsamixer and alsactl apps are also present. as yet untested them. Assuming the alsamixer operates "as well" as it does on my main Slackware system: It will be flaky and have odd muting behavior. Have to see. Comforting to find an alsa setup under the hood. Last edited by twobob; 01-30-2013 at 08:17 AM. Reason: Legibility and some notes about alsa. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
And the manufacturer's repository tree for that device:
http://opensource.wolfsonmicro.com/c...ed10c4;hb=HEAD |
![]() |
![]() |
![]() |
#4 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
ls of /dev/snd
[root@kindle snd]# ls controlC0 pcmC0D0c pcmC0D0p timer p is playback c is capture And from Knc1's docs: Code:
#define WM8960_RATES SNDRV_PCM_RATE_8000_48000 #define WM8960_FORMATS \ (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ SNDRV_PCM_FMTBIT_S24_LE) Code:
static struct snd_soc_dai_driver wm8960_dai = { .name = "wm8960-hifi", .playback = { .stream_name = "Playback", .channels_min = 1, .channels_max = 2, .rates = WM8960_RATES, .formats = WM8960_FORMATS,}, .capture = { .stream_name = "Capture", .channels_min = 1, .channels_max = 2, .rates = WM8960_RATES, .formats = WM8960_FORMATS,}, .ops = &wm8960_dai_ops, .symmetric_rates = 1, }; Last edited by twobob; 04-19-2013 at 09:30 PM. Reason: added documentary citation |
![]() |
![]() |
![]() |
#5 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
![]() It would be nice to know the default format for the raw sound stream (e.g. 8-bit mono 44.1KHz, or whatever). I suppose that is in the other settings you dumped. No time to check right now... |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
etc/asound.conf
The device is a Kindle 3.
Again for the interested: vi /etc/asound.conf Spoiler:
also [root@kindle /]# cat /proc/asound/pcm 00-00: WM8960 HiFi WM8960-I2S-0 : : playback 1 : capture 1 and [root@kindle /etc]# arecord --list-devices (or) aplay --list-devices Spoiler:
[root@kindle /etc]# aplay --list-pcms Spoiler:
Perhaps a buffer size there. perhaps not. so some interesting info. Standard 44.1k 16bit setup in the main. Version of Alsa: http://www.linuxfromscratch.org/blfs.../alsa-lib.html offers the exact version of ALSA used: ALSA Library-1.0.13 Writing direct to /dev/snd/pcmxx0 It's not possible to write directly to the interface as that operation is deprecated, AFAIK on some systems this can be bypassed through the use of an application. DirectfB usr/share/directfb-1.2.0 contains cursor.dat perhaps an indication that the box runs http://directfb.org/downloads/Core/D...2.0-rc1.tar.gz DirectFB offers some interesting options according to their site. I'll have to look it over in depth, this may or may not indicate audio extensions AFAIK, which isn't far. I don't know haven't got it to compile yet. stumbled on the lib support. not available for my system easily. ho hum SDL: SDL support is not planned in the near future for kindles. Go figure. People have run it embedded AIUI though. More info on Alsa There are various excellent notes - and various reasonable ones - littering the net. http://www.sabi.co.uk/Notes/linuxSoundALSA.html seems fairly decent for entry-concept level stuff. and the ubiquitous http://www.alsa-project.org/alsa-doc...lib/index.html Examples of code I am no code genius, but I can expand on the work of others. I am aiming to provide decentish, full duplex support one day, and in the short term enough documentation that people can get the sound working. Last edited by twobob; 07-10-2012 at 07:20 PM. Reason: added some sense, code tags etc |
![]() |
![]() |
![]() |
#7 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
it's a start
EDIT: You can find examples on the ASLA ORG page
Last edited by twobob; 07-05-2012 at 03:09 PM. Reason: I like editing, added ref |
![]() |
![]() |
![]() |
#8 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I have used SDL on my K3. I even built it to use a default library path of /mnt/us/SDL, so I did not need to set a library search path. I did have to add an eink update call to the SDL page flipping code, and I also removed sound support (because of my never having succeeded in getting ALSA support working -- why I am interested in your stuff.
![]() We are lacking in simple sound support for native mode apps around here. I like SIMPLE monolithic (single .c file) demo programs so that absolute beginners can compile them with tcc, with a minimum of fuss and bother. Thanks a lot for being the local "sound guy". I am trying to be the "animation guy". Together we can make a complete team (except for other game-design stuff, like artists, map makers, 3D modellers, script writers, and all that other stuff that indy gamers do themselves). We need you. ![]() P.S. I consider SDL to be a bit heavy for a kindle (for the simple demos at least). But it is great for cross-platform stuff. Last edited by geekmaster; 07-03-2012 at 03:17 AM. |
![]() |
![]() |
![]() |
#9 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
I am considering other access layer methods as using the alsa headers is very linux specific. I imagine VS users may hate me. but in the interim alsa it is. Perhaps I could post the project file when it's complete.
I did fiddle about going pure C. I'll go back to style considerations after the meat and veg. I fiddled with getting aplay and arecord to do "things" today. back the raw I think. Build the tools and they will come. Well, some of them anyways ![]() |
![]() |
![]() |
![]() |
#10 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
It has taken a relatively long time (months) to get the tools we have together where they can accelerate the development effort. The more tools we get the faster the progress should be (if amazon would quite throwing sand in the gears).
|
![]() |
![]() |
![]() |
#11 | |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
― Napoleon Bonaparte |
|
![]() |
![]() |
![]() |
#12 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
Murphy's Law Book Two, More Reasons Why Things Go Wrong. (Directors cut)
1) Because they can. 2) Goto 1 |
![]() |
![]() |
![]() |
#13 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#14 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
For My Ref. Basically "aplay" implemented in C
I think the original code was named "alsa wave".
If I could find out the author I would credit it. I just tweaked it to use the right devices (and a seggie) It's public domain stuff anyways. just basic setup and header stuff. Code:
// A simple C example to play a mono or stereo, 16-bit 44KHz // WAVE file using ALSA. This goes directly to the first // audio card (ie, its first set of audio out jacks). It // uses the snd_pcm_writei() mode of outputting waveform data, // blocking. // // Compile as so to create "salsa": // gcc -lasound -B /usr/include -o salsa salsa.c // // Run it from a terminal, specifying the name of a WAVE file to play: // ./salsa wave.wav // Tweaked by Twobob to work on the kindle //#include <stdio.h> or tcclib perhaps (however its not required) #include <stdlib.h> #include <unistd.h> // Include the ALSA .H file that defines ALSA functions/data #include <alsa/asoundlib.h> #pragma pack (1) /////////////////////// WAVE File Stuff ///////////////////// // An IFF file header looks like this typedef struct _FILE_head { unsigned char ID[4]; // could be {'R', 'I', 'F', 'F'} or {'F', 'O', 'R', 'M'} unsigned int Length; // Length of subsequent file (including remainder of header). //This is in Intel reverse byte order if RIFF, Motorola format if FORM. unsigned char Type[4]; // {'W', 'A', 'V', 'E'} or {'A', 'I', 'F', 'F'} } FILE_head; // An IFF chunk header looks like this typedef struct _CHUNK_head { unsigned char ID[4]; // 4 ascii chars that is the chunk ID unsigned int Length; // Length of subsequent data within this chunk. This is in Intel reverse byte // order if RIFF, Motorola format if FORM. Note: this doesn't include any // extra byte needed to pad the chunk out to an even size. } CHUNK_head; // WAVE fmt chunk typedef struct _FORMAT { short wFormatTag; unsigned short wChannels; unsigned int dwSamplesPerSec; unsigned int dwAvgBytesPerSec; unsigned short wBlockAlign; unsigned short wBitsPerSample; // Note: there may be additional fields here, depending upon wFormatTag } FORMAT; #pragma pack() // Size of the audio card hardware buffer. Here we want it // set to 1024 16-bit sample points. This is relatively // small in order to minimize latency. If you have trouble // with underruns, you may need to increase this, and PERIODSIZE // (trading off lower latency for more stability) #define BUFFERSIZE (2*1024) // How many sample points the ALSA card plays before it calls // our callback to fill some more of the audio card's hardware // buffer. Here we want ALSA to call our callback after every // 64 sample points have been played #define PERIODSIZE (2*64) // Handle to ALSA (audio card's) playback port snd_pcm_t *PlaybackHandle; // Handle to our callback thread snd_async_handler_t *CallbackHandle; // Points to loaded WAVE file's data unsigned char *WavePtr; // Size (in frames) of loaded WAVE file's data snd_pcm_uframes_t WaveSize; // Sample rate unsigned short WaveRate; // Bit resolution unsigned char WaveBits; // Number of channels in the wave file unsigned char WaveChannels; // The name of the ALSA port we output to. In this case, we're // directly writing to hardware card 0,0 (ie, first set of audio // outputs on the first audio card) static const char SoundCardPortName[] = "hw"; // For WAVE file loading static const unsigned char Riff[4] = { 'R', 'I', 'F', 'F' }; static const unsigned char Wave[4] = { 'W', 'A', 'V', 'E' }; static const unsigned char Fmt[4] = { 'f', 'm', 't', ' ' }; static const unsigned char Data[4] = { 'd', 'a', 't', 'a' }; /********************** compareID() ********************* * Compares the passed ID str (ie, a ptr to 4 Ascii * bytes) with the ID at the passed ptr. Returns TRUE if * a match, FALSE if not. */ static unsigned char compareID(const unsigned char * id, unsigned char * ptr) { register unsigned char i = 4; while (i--) { if ( *(id)++ != *(ptr)++ ) return(0); } return(1); } /********************** waveLoad() ********************* * Loads a WAVE file. * * fn = Filename to load. * * RETURNS: 0 if success, non-zero if not. * * NOTE: Sets the global "WavePtr" to an allocated buffer * containing the wave data, and "WaveSize" to the size * in sample points. */ static unsigned char waveLoad(const char *fn) { const char *message; FILE_head head; register int inHandle; if ((inHandle = open(fn, O_RDONLY)) == -1) message = "didn't open"; // Read in IFF File header else { if (read(inHandle, &head, sizeof(FILE_head)) == sizeof(FILE_head)) { // Is it a RIFF and WAVE? if (!compareID(&Riff[0], &head.ID[0]) || !compareID(&Wave[0], &head.Type[0])) { message = "is not a WAVE file"; goto bad; } // Read in next chunk header while (read(inHandle, &head, sizeof(CHUNK_head)) == sizeof(CHUNK_head)) { // ============================ Is it a fmt chunk? =============================== if (compareID(&Fmt[0], &head.ID[0])) { FORMAT format; // Read in the remainder of chunk if (read(inHandle, &format.wFormatTag, sizeof(FORMAT)) != sizeof(FORMAT)) break; // Can't handle compressed WAVE files if (format.wFormatTag != 1) { message = "compressed WAVE not supported"; goto bad; } WaveBits = (unsigned char)format.wBitsPerSample; WaveRate = (unsigned short)format.dwSamplesPerSec; WaveChannels = format.wChannels; } // ============================ Is it a data chunk? =============================== else if (compareID(&Data[0], &head.ID[0])) { // Size of wave data is head.Length. Allocate a buffer and read in the wave data if (!(WavePtr = (unsigned char *)malloc(head.Length))) { message = "won't fit in RAM"; goto bad; } if (read(inHandle, WavePtr, head.Length) != head.Length) { free(WavePtr); break; } // Store size (in frames) WaveSize = (head.Length * 8) / ((unsigned int)WaveBits * (unsigned int)WaveChannels); close(inHandle); return(0); } // ============================ Skip this chunk =============================== else { if (head.Length & 1) ++head.Length; // If odd, round it up to account for pad byte lseek(inHandle, head.Length, SEEK_CUR); } } } message = "is a bad WAVE file"; bad: close(inHandle); } printf("%s %s\n", fn, message); return(1); } /********************** play_audio() ********************** * Plays the loaded waveform. * * NOTE: ALSA sound card's handle must be in the global * "PlaybackHandle". A pointer to the wave data must be in * the global "WavePtr", and its size of "WaveSize". */ static void play_audio(void) { register snd_pcm_uframes_t count, frames; // Output the wave data count = 0; do { frames = snd_pcm_writei(PlaybackHandle, WavePtr + count, WaveSize - count); // If an error, try to recover from it if (frames < 0) frames = snd_pcm_recover(PlaybackHandle, frames, 0); if (frames < 0) { printf("Error playing wave: %s\n", snd_strerror(frames)); break; } // Update our pointer count += frames; } while (count < WaveSize); // Wait for playback to completely finish if (count == WaveSize) snd_pcm_drain(PlaybackHandle); } /*********************** free_wave_data() ********************* * Frees any wave data we loaded. * * NOTE: A pointer to the wave data be in the global * "WavePtr". */ static void free_wave_data(void) { if (WavePtr) free(WavePtr); WavePtr = 0; } int main(int argc, char **argv) { // No wave data loaded yet WavePtr = 0; if (argc < 2) printf("You must supply the name of a 16-bit mono WAVE file to play\n"); // Load the wave file else if (!waveLoad(argv[1])) { register int err; // Open audio card we wish to use for playback if ((err = snd_pcm_open(&PlaybackHandle, &SoundCardPortName[0], SND_PCM_STREAM_PLAYBACK, 0)) < 0) printf("Can't open audio %s: %s\n", &SoundCardPortName[0], snd_strerror(err)); else { switch (WaveBits) { case 8: err = SND_PCM_FORMAT_U8; break; case 16: err = SND_PCM_FORMAT_S16; break; case 24: err = SND_PCM_FORMAT_S24; break; case 32: err = SND_PCM_FORMAT_S32; break; } // Set the audio card's hardware parameters (sample rate, bit resolution, etc) if ((err = snd_pcm_set_params(PlaybackHandle, err, SND_PCM_ACCESS_RW_INTERLEAVED, WaveChannels, WaveRate, 1, 500000)) < 0) printf("Can't set sound parameters: %s\n", snd_strerror(err)); // Play the waveform else play_audio(); // Close sound card snd_pcm_close(PlaybackHandle); } } // Free the WAVE data free_wave_data(); return(0); } [root@kindle us]# aplay -D plughw:0,0 mono.wav Playing WAVE 'mono.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono and bash-4.1$ ./salsa ~/mono.wav provide audio functionality, via alsa, except this we can control the guts of. (the port used to play through is "hw") Many thanks. Heartening however to get something, functional, in c, that emulates the current access to sound (aplay) in a programmable way. Your thoughts so far. thanks Last edited by twobob; 07-09-2012 at 04:01 PM. Reason: updating stuff, added updated pcm name details |
![]() |
![]() |
![]() |
#15 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
There is a project here:
https://www.mobileread.com/forums/sho...d.php?t=174066 that stalled over problems with the Kindle alsa implementation. Until they hit that snag - they were making good progress in getting VoIP working on the Kindle. Myself - I don't need a book that will make a telephone call. But since that mountain was there, the members of that thread where climbing it. ![]() Last edited by knc1; 07-04-2012 at 11:19 AM. |
![]() |
![]() |
![]() |
Tags |
stupid root mistakes |
|