Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 07-18-2012, 11:06 AM   #226
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
ALSACTL - Let's have a peek then

SO..... in order to maintain the thread OT. The FFT Debate - and work tranche has been shoveled across to Reworking FFT code
================================================== ========

Back to the crux of the thread: Making the sound setup do things we want!
Let's have a quick play with alsactl

Let's have a look at a vaguely relevant man page http://linux.die.net/man/1/alsactl
okay, done that? onwards...

The version on the kindle is wee bit old:
Code:
[root@kindle bin]# alsactl --version
alsactl version 1.0.13
So we best bear that in mind - as there are a few bugs out there that have been noted in several versions subsequent to this, which does not preclude their undiscovered existence in this version...

Code:
[root@kindle root]# alsactl store -f /mnt/us/opt/sound/alsactl.state 
(I added .txt to the version attached. .TXT is "required" so it could be uploaded here. the name is inconsequential can be changed or used as is)

Here's the output of my alsactl.state - AS IS unamended on a k3gWifi
(the popular name used is asound.state, I prefer my name. call it what you want)

Spoiler:
Code:
state.mx35luigi {
	control.1 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 2
		comment.range '0 - 63'
		iface MIXER
		name 'Capture Volume'
		value.0 23
		value.1 23
	}
	control.2 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 2
		iface MIXER
		name 'Capture Volume ZC Switch'
		value.0 false
		value.1 false
	}
	control.3 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 2
		iface MIXER
		name 'Capture Switch'
		value.0 false
		value.1 false
	}
	control.4 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 2
		comment.range '0 - 255'
		iface MIXER
		name 'Playback Volume'
		value.0 249
		value.1 249
	}
	control.5 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 2
		comment.range '0 - 127'
		iface MIXER
		name 'Headphone Playback Volume'
		value.0 0
		value.1 16
	}
	control.6 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 2
		iface MIXER
		name 'Headphone Playback ZC Switch'
		value.0 false
		value.1 false
	}
	control.7 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 2
		comment.range '0 - 127'
		iface MIXER
		name 'Speaker Playback Volume'
		value.0 0
		value.1 16
	}
	control.8 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 2
		iface MIXER
		name 'Speaker Playback ZC Switch'
		value.0 false
		value.1 false
	}
	control.9 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 5'
		iface MIXER
		name 'Speaker DC Volume'
		value 0
	}
	control.10 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 5'
		iface MIXER
		name 'Speaker AC Volume'
		value 0
	}
	control.11 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 1
		iface MIXER
		name 'PCM Playback -6dB Switch'
		value false
	}
	control.12 {
		comment.access 'read write'
		comment.type ENUMERATED
		comment.count 1
		comment.item.0 'No Inversion'
		comment.item.1 'Left Inverted'
		comment.item.2 'Right Inverted'
		comment.item.3 'Stereo Inversion'
		iface MIXER
		name 'ADC Polarity'
		value 'No Inversion'
	}
	control.13 {
		comment.access 'read write'
		comment.type ENUMERATED
		comment.count 1
		comment.item.0 None
		comment.item.1 '32Khz'
		comment.item.2 '44.1Khz'
		comment.item.3 '48Khz'
		iface MIXER
		name 'Playback De-emphasis'
		value None
	}
	control.14 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 1
		iface MIXER
		name 'ADC High Pass Filter Switch'
		value false
	}
	control.15 {
		comment.access 'read write'
		comment.type ENUMERATED
		comment.count 1
		comment.item.0 'No Inversion'
		comment.item.1 'Left Inverted'
		comment.item.2 'Right Inverted'
		comment.item.3 'Stereo Inversion'
		iface MIXER
		name 'DAC Polarity'
		value 'No Inversion'
	}
	control.16 {
		comment.access 'read write'
		comment.type ENUMERATED
		comment.count 1
		comment.item.0 High
		comment.item.1 Low
		iface MIXER
		name '3D Filter Upper Cut-Off'
		value High
	}
	control.17 {
		comment.access 'read write'
		comment.type ENUMERATED
		comment.count 1
		comment.item.0 Low
		comment.item.1 High
		iface MIXER
		name '3D Filter Lower Cut-Off'
		value Low
	}
	control.18 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 15'
		iface MIXER
		name '3D Volume'
		value 0
	}
	control.19 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 1
		iface MIXER
		name '3D Switch'
		value false
	}
	control.20 {
		comment.access 'read write'
		comment.type ENUMERATED
		comment.count 1
		comment.item.0 Off
		comment.item.1 Right
		comment.item.2 Left
		comment.item.3 Stereo
		iface MIXER
		name 'ALC Function'
		value Off
	}
	control.21 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 7'
		iface MIXER
		name 'ALC Max Gain'
		value 7
	}
	control.22 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 15'
		iface MIXER
		name 'ALC Target'
		value 4
	}
	control.23 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 7'
		iface MIXER
		name 'ALC Min Gain'
		value 0
	}
	control.24 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 15'
		iface MIXER
		name 'ALC Hold Time'
		value 0
	}
	control.25 {
		comment.access 'read write'
		comment.type ENUMERATED
		comment.count 1
		comment.item.0 ALC
		comment.item.1 Limiter
		iface MIXER
		name 'ALC Mode'
		value ALC
	}
	control.26 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 15'
		iface MIXER
		name 'ALC Decay'
		value 3
	}
	control.27 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 15'
		iface MIXER
		name 'ALC Attack'
		value 2
	}
	control.28 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 31'
		iface MIXER
		name 'Noise Gate Threshold'
		value 0
	}
	control.29 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 1
		iface MIXER
		name 'Noise Gate Switch'
		value false
	}
	control.30 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 2
		comment.range '0 - 127'
		iface MIXER
		name 'ADC PCM Capture Volume'
		value.0 0
		value.1 0
	}
	control.31 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 7'
		iface MIXER
		name 'Left Output Mixer Boost Bypass Volume'
		value 2
	}
	control.32 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 7'
		iface MIXER
		name 'Left Output Mixer LINPUT3 Volume'
		value 2
	}
	control.33 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 7'
		iface MIXER
		name 'Right Output Mixer Boost Bypass Volume'
		value 2
	}
	control.34 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 7'
		iface MIXER
		name 'Right Output Mixer RINPUT3 Volume'
		value 2
	}
}


As ever filled with much unexciting dross, but there are maybe a few goodies in there for us to twiddle:

To determine exactly which thing each setting refers to look under the name attribute for example: mx35luigi {control.1 is in fact: name 'Capture Volume'.

The type of access this value has is defined as read write for all controls
The complete valid enumeration set is not available with the document.

Setting the default values for some of the things could come in handy.
Some of them have two value attributes. (some, seemingly with duped info.)
Others have more obvious - single - value settings.

The count of expected values is self-described under comment.count
For example: 2

The expected values Types are conveniently self-describing and can be found under comment.type
For example: INTEGER
Where enumerations are used - i.e: ENUMERATED
then a comment.item.[0indexing++] scheme is used:
For example:
comment.item.0 ALC
comment.item.1 Limiter

This is further backed up by a range attribute comment.range
For example '0 - 63'

The interface is shared by all iface MIXER and this more than likely refers to something in the alsa.conf somewhere.

That covers the schema for the document I believe.

So, what does this let us do? well if we have a quick look at the alsactl --help

Code:
Usage: alsactl <options> command

Available options:
  -h,--help       this help
  -f,--file #     configuration file (default /etc/asound.state or /etc/asound.names)
  -F,--force      try to restore the matching controls as much as possible
  -d,--debug      debug mode
  -v,--version    print version of this program

Available commands:
  store <card #>  save current driver setup for one or each soundcards
                  to configuration file
  restore<card #> load current driver setup for one or each soundcards
                  from configuration file
We can see a restoration option is available for the now-amended files with our new make-it-more-awesome values ; )

Next steps?

a)Decide what make-it-more-awesome values we need - if any

b) check the restore doesn't exhibit strange behavior and works as expected.

That about wraps it up for how-to Store and fiddle around.



We can amend the values and using the alsactl restore [blah]
Attached Files
File Type: txt alsactl.state.txt (6.0 KB, 196 views)

Last edited by twobob; 07-18-2012 at 11:16 AM. Reason: added a man ref.
twobob is offline   Reply With Quote
Old 07-18-2012, 12:32 PM   #227
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
Spoooky weirdness.

For no reason that I can fathom the soundcard decided to play the buffer at the wrong rate.

The next time (after digging around for erronous code) it played at the right rate.
And all subsequent times

Here there may be dragons.
twobob is offline   Reply With Quote
Advert
Old 07-18-2012, 12:39 PM   #228
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
Spoooky weirdness.

For no reason that I can fathom the soundcard decided to play the buffer at the wrong rate.

The next time (after digging around for erronous code) it played at the right rate.
And all subsequent times

Here there may be dragons.
That is why I like talking directly to hardware chip registers (i.e. "bare metal"). You can skip most of that hidden weirdness buried in libraries. But I have been bitten at the low level by hardware initialization workarounds caused by parasitic transistors in the hardware, and you can see "interesting" hardware glitch workarounds in u-boot, and most device driver code too.

Anything with the complexity level of modern hardware devices and software libraries (like alsa) is going to be plagued with hidden weirdness in the seldom explored corners, that clever programming can usually hide from the consumer (in most "general usage" cases). But then again, it is those very weird behaviors that can often be exploited to root a device and add features to it.
geekmaster is offline   Reply With Quote
Old 07-18-2012, 03:39 PM   #229
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
root 19 -1 24340 13m 988 S 27.6 5.4 0:27.38 Balsamic

Running without any Graphics updates, looping the video thread insanely.
(I'll try one with the thread elided next for sanity)

circa 25% Cpu usage on a 44100 File running in stereo.
twobob is offline   Reply With Quote
Old 07-18-2012, 03:43 PM   #230
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
root 19 -1 16148 13m 976 S 1.0 5.4 0:01.24 Balsamic

1% without the stupidly looping thread.

2% at a peak occasionally.

Plays solid now with no seggies.

I think we can call that "Done".

NOTE: if someone wants to implement mmap that may indeed yield better results. But one caveat of mmap is you MUST use the hw level Pcm_writei callls otherwise all advantages are lost as the "Helper" methods of the the newer "higher level" functions do not manage the memory shifting in the way you might think.
twobob is offline   Reply With Quote
Advert
Old 07-18-2012, 04:10 PM   #231
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
...
NOTE: if someone wants to implement mmap that may indeed yield better results. But one caveat of mmap is you MUST use the hw level Pcm_writei callls otherwise all advantages are lost as the "Helper" methods of the the newer "higher level" functions do not manage the memory shifting in the way you might think.
Thanks for the tip, or I may well have succumbed to that trap.
geekmaster is offline   Reply With Quote
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
Old 07-18-2012, 05:19 PM   #233
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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 tend to agree your abbreviated version has merit and should probably get a top-post mention at some point on this thread when it has reached it's logical end. I just went with the Alsa examples for now, tidy it up later.

Very happy to be involved in this project, what little that can be offered by my camp is freely given.

Today I shall be mainly wasting many many many hours getting demos and configs configured.
Oh I already did. : \ Hehehe

I'm on with multiple rate / channel / bit support actually. dull but ultimately rewarding.

Come the day I can see and hear some stuff on this thing (aside from the crazy squiggle graphics I been making from the audio streams) neatly synced? That will be a great thing and a great day.
twobob is offline   Reply With Quote
Old 07-18-2012, 10:10 PM   #234
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
indexer = 4096*(playcount * WaveChannels * (WaveBits/16) * 2);

should sort the multi - bit - channel - rate issue.
Where 4096 is the maximum amount of frames the card will allow stacked.

Should handle most - normalish - rate wav files now - mono or stereo - 8 or 16 bit.

I changed the call to the thread - now with a NULL message Type.
(The thread warning about the messageType being of an inconsistent type still puzzles me, I have checked it against the parent method, NULL seems the least unhappy)

I'll post my silly test code here in a moment.
No more seggies through running off the end of the file or threads not ending together

while (4096*(playcount)< WaveSize)
Sorted that out.

Last edited by twobob; 07-18-2012 at 10:13 PM. Reason: added support specifications
twobob is offline   Reply With Quote
Old 07-18-2012, 11:24 PM   #235
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
In the absence of FFT

EDIT:

I AM WORKING ON THE FP ERROR AT THE MOMENT...
It seems happier called via SSH for some reason I can't fathom yet.

Does not like MyTs for some reason...

so as reported below until I crack this bug YMMV.

END EDIT


Like GM said - use your imagination....

So I did.

I give you "Balsamic" Version 0.0.0.1

Features: (Almost none

Plays a 8 or 16 bit WAV file
(most normal uncompressed rates should work okay) in mono or stereo.

Does a music to visual display (Nothing mind blowing but it's fairly matrix)
THAT IS UNIQUE FOR EACH SONG. (It should appear linked to the track content)
That is LINKED TO THE MUSIC (I had to make a few sacrifices - FFT one day)
THAT does UNIQUE things per play of a song (or I think it does possibly lol)
(perhaps a RANDOM might now hurt but I like the purity of being modulated data-driven)

that's about it for now.
Enjoy.

Thanks to Knc1 for helping me get where I am with the project so far.
Kek has been a huge help, so has he on many levels - not least of which helping me getting the thing compiled.

Thanks to GM for access to his library for the video and assistance with the tech aspects of this - and other related - projects. Apologies for the clear and present abuse of the code mate. ; )

I have included the original - pre remix master - of a track called "Nameless Road To Nowhere" by Mr Dodo. Don't worry, I've got the rights and Matt won't mind.
Enjoy. Any track will do

(Note: I did not shamelessly include one of my own tunes, nor did I post the remix I did of this tune... Just saying like. If you want my stuff go dig in my sigi, ta.)

Balsamic. Feel free to mash it up to pieces, it's only code. I added notes : )

USAGE: ./Balsamic noise.wav

Spoiler:
Code:
#include <sched.h>
#include <errno.h>
#include <getopt.h>
#include <asoundlib.h>
#include <math.h>
#include <pthread.h>
// HEAD WELDs
//====================================================
// gmplay 1.5a - geekmaster's kindle video player
// Copyright (C) 2012 by geekmaster, with MIT license:
// http://www.opensource.org/licenses/mit-license.php
//----------------------------------------------------
// Tested on DX,DXG,K3,K4main,K4diags,K5main,K5diags.
//----------------------------------------------------
#include <sys/ioctl.h>     // ioctl
#include <sys/mman.h>     // mmap, munmap
#include <stdio.h>       // printf
#include <stdlib.h>     // malloc, free
#include <linux/fb.h>  // screeninfo
#include <sys/time.h> // gettimeofday
#include <unistd.h>  // usleep
#include <string.h> // memset, memcpy
#include <fcntl.h> // open, close, write
#include <time.h> // time
#include <math.h>
#include <memory.h>
// THIS VERSION JUST FEEDS THE VIDEO IN FROM THE AUDIO FOR LOAD TESTING.
// USE A LONG AUDIO FILE.
typedef unsigned long u64;
typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;
u32 __invalid_size_argument_for_IOC; // ioctl.h bug fix for tcc
//----- eink definitions from eink_fb.h and mxcfb.h -----
typedef signed char prog_int8_t;
#define EU3 0x46dd
#define EU50 0x4040462e
#define EU51 0x4048462e
#define NUM_THREADS 3
#define VOLUME_BOUND 100
struct update_area_t {int x1,y1,x2,y2,which_fx;u8 *buffer;};
struct mxcfb_rect {u32 top,left,width,height;};
struct mxcfb_alt_buffer_data {u32 phys_addr,width,height;
struct mxcfb_rect alt_update_region;};
struct mxcfb_update_data {struct mxcfb_rect update_region;
u32 waveform_mode,update_mode,update_marker;int temp;uint flags;
struct mxcfb_alt_buffer_data alt_buffer_data;};
struct mxcfb_update_data51 {struct mxcfb_rect update_region;
u32 waveform_mode,update_mode,update_marker;
u32 hist_bw_waveform_mode,hist_gray_waveform_mode;
int temp;uint flags;struct mxcfb_alt_buffer_data alt_buffer_data;};
//----- function prototypes -----
void gmplay4(void);
//void gmplay8(void); suppose I should really fix this now for a proper demo....
int getmsec(void);
int gmlib(int);
//----- gmlib global vars -----
enum GMLIB_op {GMLIB_INIT,GMLIB_CLOSE,GMLIB_UPDATE,GMLIB_VSYNC};

u8 *fb0=NULL;     // framebuffer pointer
int fdFB=0;      // fb0 file descriptor
int teu=0;      // eink update time
u32 fs=0;      // fb0 stride
u32 MX=0;     // xres (visible)
u32 MY=0;    // yres (visible)
u32 VY=0;   // (VY>MY): mxcfb driver
u8 ppb=0;  // pixels per byte
u32 fc=0; // frame counter
#define FBSIZE (600/8*800)

//====================================
// gmlib - geekmaster function library
// op (init, update, vsync, close)
//------------------------------------
int gmlib(int op) {
	static struct update_area_t ua={0,0,600,800,21,NULL};
	static struct mxcfb_update_data ur={
			{0,0,600,800},257,0,1,0x1001,0,{0,0,0,{0,0,0,0}}};
	static struct mxcfb_update_data51 ur51={
			{0,0,600,800},257,0,1,0,0,0x1001,0,{0,0,0,{0,0,0,0}}};
	static int eupcode; static void *eupdata=NULL;
	struct fb_var_screeninfo screeninfo;
	if (GMLIB_INIT==op) { teu=getmsec(); fdFB=open("/dev/fb0",O_RDWR);
	ioctl(fdFB,FBIOGET_VSCREENINFO,&screeninfo);
	ppb=8/screeninfo.bits_per_pixel; fs=screeninfo.xres_virtual/ppb;
	VY=screeninfo.yres_virtual; MX=screeninfo.xres; MY=screeninfo.yres;
	ua.x2=MX; ua.y2=MY; ur.update_region.width=MX; ur.update_region.height=MY;
	fb0=(u8 *)mmap(0,MY*fs,PROT_READ|PROT_WRITE,MAP_SHARED,fdFB,0); // map fb0
	if (VY>MY) { eupcode=EU50; eupdata=&ur; ur.update_mode=0;
	if (ioctl(fdFB,eupcode,eupdata)<0) { eupcode=EU51; eupdata=&ur51; }
	} else { eupcode=EU3; eupdata=&ua; }
	system("eips -f -c;eips -c"); sleep(1);
	} else if (GMLIB_UPDATE==op) {
		if (ioctl(fdFB,eupcode,eupdata)<0) system("eips ''");  // 5.1.0 fallback
	} else if (GMLIB_VSYNC==op) { while (teu>getmsec()) usleep(1000); // fb0 busy
	} else if (GMLIB_CLOSE==op) { gmlib(GMLIB_UPDATE); sleep(1); // last screen
	system("eips -f -c;eips -c"); munmap(fb0,MY*fs); close(fdFB);
	} else { return -1; }
	return 0;
}
//====================================
// getmsec - get msec since first call
// (tick counter wraps every 12 days)
//------------------------------------
int getmsec(void) {
	int tc; static int ts=0; struct timeval tv;
	gettimeofday(&tv,NULL); tc=tv.tv_usec/1000+1000*(0xFFFFF&tv.tv_sec);
	if (0==ts) ts=tc;
	return tc-ts;
}

// 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;

// 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' };

snd_pcm_t *playback_handle;

unsigned int i,j;
int err;

// Frame count stuff for playback head tracking
int playcount;
int indexer;
int here;  // My fave name for a variable. utterly obscure
int frameCount;
int totalCount;
int BLACK_RATIO = 700; // This sets the total amount of sweeps between "wipes" - well kinda ;)
//==================================
int holderx, holdery;


#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()


// ====================================================================
// END DEFINITIONS AND HEADERS
/*
 *
 *  FOR THE MAIN METHODS THAT DO THINGS
 *
 *  JUMP TO THE END OF THE FILE
 *
 *  gmplay4 AND playback_callback
 *
 *  Are where the action is.
 *
 *  In the next section we setup the waves
 *
 *  and other dull stuff : )
 *
 *  */


/********************** 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.
 */

// END WELD

FILE_head				head;

FORMAT	format;

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]))
				{


					// 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);
}


/*********************** free_wave_data() *********************
 * Frees any wave data we loaded.
 *
 * NOTE: A pointer to the wave data be in the global
 * "WavePtr".
 */

// Do this last.  // NO REALLY!
static void free_wave_data(void)
{
	if (WavePtr) free(WavePtr);
	WavePtr = 0;
}




/*******************************************
 *
 * THIS IS WHERE THE ACTION IS
 *
 * THE VALUES ARE COMMENTED TO
 *
 * GET SOME NEW EFFECTS ETC TRY
 *
 *  TWIDDLING : )
 *
 ******************************************** */

// TODO RE-ADD GMPLAY8 CONDITIONALLY

// gmplay4 - play video on 4-bit fb0
//----------------------------------
void gmplay4(void) {

	// Some example debug stuff  // dump this in the While loop if you need Output.
	//	printf ("DVAL: %f",&delayed);
	//	printf (" PURE: %u\n",pure);
	// SETUP BLAH

	frameCount = 0;
	u32 i,x,y,b,p,off=(MY/2-400)*fs+MX/4-150;
	// u8 fbt[FBSIZE];//fbsize=FBSIZE;   // Now redundant - will be permanently deprecated in next confirmation pass


/*
 *
 * OKAY HERE WE GO
 *
 *
 *  */

// Until the song is over
	while (4096*(playcount)< WaveSize)
	{

		// This is essentially a number from "The future" - divided down to give us a rougher granularity

		int pure = ( (WavePtr[frameCount+64]) +1 / 8 ) * 8   ; // Don't div by 0 // Rough out the lumps with int maths


// by playing with the modulos you can determine how much "noise" to leave washing around
		if (frameCount %20==0)
		{
			for (y=0;y<800; y++) for (x=0;x<600;x+=8) {

				// Paint it black.?
				// By playing with the
				if (frameCount % BLACK_RATIO < (BLACK_RATIO/2))
				{ 	b=0; 	}
				else

				{
				//we can make different patterns for every song in this way

				b=WavePtr[frameCount];  // "Random" integer val;
				}

				// GM indexy wangler
				i=y*fs+x/2+off;

				// Splat it in
				fb0[i] = fb0[i+1] = fb0[i+2] = fb0[i+3] = b;

			} fc++; // gmlib(GMLIB_UPDATE);   // Let's be cheeky and slip this one through...
		}

		else


		if (frameCount %6==0)
		{

			// well read it and figure it out - Given the comments above it's pretty simple...
			for (y=0;y<800;y++) for (x=0;x<600;x+=(8+(frameCount%pure))) {

				// Let's do something automagically weird and kooky lookin anyways
				b=WavePtr[((frameCount)+600/(8))*y+(x/8)%(WaveSize-1)];


				// GM uber carvery
				i=y*fs+x/2+off;
				p=(b&1)*240; b>>=1; fb0[i]=p|(b&1)*15; b>>=1;
				p=(b&1)*240; b>>=1; fb0[i+1]=p|(b&1)*15; b>>=1;
				p=(b&1)*240; b>>=1; fb0[i+2]=p|(b&1)*15; b>>=1;
				p=(b&1)*240; b>>=1; fb0[i+3]=p|(b&1)*15;
			} fc++; gmlib(GMLIB_UPDATE);
		}

		else
		{
			// Chill.
			usleep(50);

		}
		frameCount++;
	}
}

/*******************************************
 *
 * THIS IS WHERE THE Audio ACTION IS
 *
 * THE VALUES ARE COMMENTED TO
 *
 * GET SOME NEW EFFECTS ETC TRY
 *
 *  TWIDDLING : )
 *
 ******************************************** */



// let's make this multiplier permanent. no point working it out over and over and it's "fixed" by this point.
// splat it into main after the wave load pass
int frameMultiplier; // = playcount * WaveChannels * (WaveBits/16) * 2;

int
playback_callback (snd_pcm_sframes_t nframes)
{

	//Debug example tests:
	//	printf("CH:%i\n",WaveChannels);
	//	printf("Bits:%i\n",WaveBits);
	//	printf("Rate:%i\n",WaveRate);

	playcount++;

//	indexer = 4096*(playcount * WaveChannels * (WaveBits/16) * 2);

	indexer = 4096 * playcount * frameMultiplier;

	if ((err = snd_pcm_writei (playback_handle, WavePtr+indexer, nframes)) < 0) {
		fprintf (stderr, "write failed (%s)\n", snd_strerror (err));
	}
	return err;

}


/*
 * Minimal Tweak factor from here on in
 *
 * ******************************************
 *
 * MUDANE CODING DULLNESS RESUMES
 *
 * ******************************************
 *
 * */


// Showtime
main (int argc, char *argv[])
{
	register int err;    // Just in case ey...
	int i;
	gmlib(GMLIB_INIT);

	char *wavename = argv[1];

	if (!waveLoad(wavename))
	{

	//	printf("error: %i\n",err);
	}
	else
	{

		printf("Loaded: %s\n", wavename);

	}

	snd_pcm_sw_params_t *sw_params;
	snd_pcm_sframes_t frames_to_deliver;

	if ((err = snd_pcm_open (&playback_handle, "plughw", SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
		fprintf (stderr, "cannot open audio device plughw (%s)\n",
				snd_strerror (err));
		exit (1);
	}

// There are far better ways of doing this...
	if (NULL==argv[2])
	{
		if ((err = snd_pcm_set_params(playback_handle,
				SND_PCM_FORMAT_S16_LE,
				SND_PCM_ACCESS_RW_INTERLEAVED,
				WaveChannels,
				WaveRate,
				1,
				1000000)) < 0) {   /* 1sec */
			printf("Playback open error: %s\n", snd_strerror(err));
			exit(EXIT_FAILURE);
		}
	}
	else
	{
		if ((err = snd_pcm_set_params(playback_handle,
				SND_PCM_FORMAT_S16_LE,
				SND_PCM_ACCESS_RW_INTERLEAVED,
				WaveChannels,
				atoi(argv[2]),
				1,
				1000000)) < 0) {   /* 1sec */
			printf("Playback open error: %s\n", snd_strerror(err));
			exit(EXIT_FAILURE);
		}
	}


	/* tell ALSA to wake us up whenever 4096 or more frames
		   of playback data can be delivered. Also, tell
		   ALSA that we'll start the device ourselves.
	 */

	if ((err = snd_pcm_sw_params_malloc (&sw_params)) < 0) {
		fprintf (stderr, "cannot allocate software parameters structure (%s)\n",
				snd_strerror (err));
		exit (1);
	}
	if ((err = snd_pcm_sw_params_current (playback_handle, sw_params)) < 0) {
		fprintf (stderr, "cannot initialize software parameters structure (%s)\n",
				snd_strerror (err));
		exit (1);
	}
	if ((err = snd_pcm_sw_params_set_avail_min (playback_handle, sw_params, 4096)) < 0) {
		fprintf (stderr, "cannot set minimum available count (%s)\n",
				snd_strerror (err));
		exit (1);
	}
	if ((err = snd_pcm_sw_params_set_start_threshold (playback_handle, sw_params, 0U)) < 0) {
		fprintf (stderr, "cannot set start mode (%s)\n",
				snd_strerror (err));
		exit (1);
	}
	if ((err = snd_pcm_sw_params (playback_handle, sw_params)) < 0) {
		fprintf (stderr, "cannot set software parameters (%s)\n",
				snd_strerror (err));
		exit (1);
	}

	/* the interface will interrupt the kernel every 4096 frames, and ALSA
		   will wake up this program very soon after that.
	 */

	if ((err = snd_pcm_prepare (playback_handle)) < 0) {
		fprintf (stderr, "cannot prepare audio interface for use (%s)\n",
				snd_strerror (err));
		exit (1);
	}


	// SETUP THE SCREEN

	pthread_t threads[NUM_THREADS];
	int rc;
	long t =0;

//	gmlib(GMLIB_INIT);

	// Make a thread

	printf("Balsamic Main: creating Video thread %ld\n", t);
	printf("Wave size %d\n",(int)WaveSize);
//	char *message1 = "Video Thread";

	// This is the thread.
	// I'll be damned if I can get it to swallow that 4th argument without moaning.
	rc = pthread_create(&threads[t], NULL, gmplay4 ,NULL);

	if (rc){
		printf("ERROR; return code from pthread_create() is %d\n", rc);
		exit(-1);
		// FOOFED!!!
		i=getmsec()/100; printf("%d frames in %0.1f secs = %2.1f FPS\n",
				fc,(double)i/10.0,(double)fc*10.0/i);
		gmlib(GMLIB_CLOSE);

	}


	// Might as well fix it here...
	frameMultiplier = WaveChannels * (WaveBits/16) * 2;

	/*
	 *
	 * THE "MAIN" LOOP
	 *
 	 */


	// Ditch this when we run out of data.
	while (4096*(playcount )< WaveSize ) {

		if ((err = snd_pcm_wait (playback_handle, 1000)) < 0) {
			fprintf (stderr, "poll failed (%s)\n", strerror (errno));
			break;
		}

		/* find out how much space is available for playback data */

		if ((frames_to_deliver = snd_pcm_avail_update (playback_handle)) < 0) {
			if (frames_to_deliver == -EPIPE) {
				fprintf (stderr, "an xrun occured\n");
				break;
			} else {
				fprintf (stderr, "unknown ALSA avail update return value (%d)\n",
						(int)frames_to_deliver);
				break;
			}
		}

		if (	frames_to_deliver > 4096 ){ frames_to_deliver = 4096;}

		/* deliver the data */

		if (playback_callback (frames_to_deliver) != frames_to_deliver) {
			fprintf (stderr, "playback callback failed\n");
			break;
		}
	}


	printf("Finishing\n");
	free_wave_data();

	i=getmsec()/100; printf("%d frames in %0.1f secs = %2.1f FPS\n",
			fc,(double)i/10.0,(double)fc*10.0/i);

	gmlib(GMLIB_CLOSE);
	snd_pcm_close (playback_handle);

	// Let's just be extry certain
	system("eips -f -c;eips -c");

	exit (0);
}
Attached Files
File Type: gz Balsamic.tar.gz (282.1 KB, 152 views)
File Type: gz noise.wav.tar.gz (11.23 MB, 162 views)

Last edited by twobob; 07-19-2012 at 11:05 PM. Reason: added bug report info
twobob is offline   Reply With Quote
Old 07-18-2012, 11:56 PM   #236
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
Like GM said - use your imagination....

So I did.

I give you "Balsamic" Version 0.0.0.1
...
It is an interesting visual effect. Congratulations on getting video and sound working. On my K3 it gets a repeatable floating point exception at 28.4 to 29.0 seconds. It is interesting up to that point though. This will be a neat platform to try other visual effects on. You can get inspiration from some of the nicer WinAmp visual-effects plug-ins. We can use some code from my newtrix demo too (synchronized to sound, of course).

You may want to duplicate the copyright line and add your own name (so we are both listed).

Last edited by geekmaster; 07-18-2012 at 11:59 PM.
geekmaster is offline   Reply With Quote
Old 07-19-2012, 12:01 AM   #237
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
To avoid sound problems (like this floating point exception), I am tempted to just pipe sound through GMPLAY out STDOUT to aplay for the next version of my video player. But I really like "more portable" direct sound control if simple and reliable. At least all the kindles have aplay...

Instead of full FFT, you can get an FFT-like demo by just using the time between zero-crossings as an index into an array of bucket counters, then periodically plot the values in the bucket (zero-cross period vs. counts). The visible effect is much like you would get with an FFT spectrograph, but with very little code. I did that on an Apple-2 ages ago. I will do that on my kindle if you don't do it. I may do it even if you DO do it.

And yes, you really SHOULD keep the 8-bit framebuffer code working too. I would break their loops and call them to do each single frame. Then your custom code can be OUTSIDE gmplay4 and gmplay8 where it belongs.

Last edited by geekmaster; 07-19-2012 at 12:10 AM.
geekmaster is offline   Reply With Quote
Old 07-19-2012, 11:09 PM   #238
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
Quote:
Originally Posted by geekmaster View Post
It is an interesting visual effect. Congratulations on getting video and sound working. On my K3 it gets a repeatable floating point exception at 28.4 to 29.0 seconds. It is interesting up to that point though. This will be a neat platform to try other visual effects on. You can get inspiration from some of the nicer WinAmp visual-effects plug-ins. We can use some code from my newtrix demo too (synchronized to sound, of course).

You may want to duplicate the copyright line and add your own name (so we are both listed).
Hi, thanks for testing, it is vastly appreciated.

I noticed that today via myts. it was testing okay via SSH. I'm looking into it.
Spent all day analysing docs. the least exciting thing in the world possibly.

Back to the grind in the AM. the face is calling me!

Re the code and copyrights, I promise to make the final version proper and tidy . the 0.0.0.1 should really have been called:

THE PRE PRE PRE ALPHA STILL A RIGHT BLOODY MESS BECAUSE ITS **AM AND I'M TIRED! RELEASE

Bloody hobbyists ey. : ) I'll tidy it up. Cheers
twobob is offline   Reply With Quote
Old 07-20-2012, 11:10 AM   #239
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
Hmm. I can't seem to get it to dump via SSH.

Only unhappy in myTs... This should probably tell me something.
Working on it..

EDIT: Okay I can get it seg at will via gdb.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1084507280 (LWP 5166)]
0x0000a840 in gmplay4 () at ../Balsamic.c:96
96 ../Balsamic.c: No such file or directory.
in ../Balsamic.c

So it is actually dumping inside the vid call seemingly, and running it via gdb does in fact allow the entire track to keep playing and just the video thread to halt.

Must be looking for a value that doesn't exist or not exiting the video thread early enough.

It's something stupid anyway, not related to audio solidity as far as I can make out so far so happy days on that - I'll rip the graphics and see if it still dumps.


And Backtrace gives us...

(gdb) bt
#0 0x0000a840 in gmplay4 () at ../latency.c:96
#1 0x400389c8 in start_thread () from /lib/libpthread.so.0
#2 0x4019c4e8 in clone () from /lib/libc.so.6
Backtrace stopped: frame did not save the PC

Hmm. perhaps I should have built it -g... *does some research* EDIT: hmm i built it -g3


Ahh this looks a lot like:

http://stackoverflow.com/questions/7...braries-on-arm
Did we build the shared library -fomit-frame-pointer ??? Umm...

*scratches head* - I'll try dumping the optimisations in the build EDIT: Nope that didn't help -O0 and -g3 Better check the alsa libs build. sigh...

Last edited by twobob; 07-20-2012 at 12:14 PM. Reason: added some extry thoughts.
twobob is offline   Reply With Quote
Old 07-20-2012, 02:20 PM   #240
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299993
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
rebuilding with --static gives us

Program received signal SIGSEGV, Segmentation fault.
[Switching to LWP 12827]
0x0000b708 in gmplay4 () at ../Balsamic.c:83
83 ../Balsamic.c: No such file or directory.
in ../Balsamic.c
(gdb) bt
#0 0x0000b708 in gmplay4 () at ../Balsamic.c:83
#1 0x00094a60 in start_thread ()
#2 0x000e2588 in ?? ()

hmmm

EDIT: AHH! That old chestnut.

Starting program: /mnt/us/opt/sound/Balsamic kalia.wav
warning: Cannot initialize thread debugging library: unknown thread_db error '22'
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Balsamic Main: creating Video thread 0

Sigh. Gah. I really really have got to do a 32 bit build this is driving me nuts.

Last edited by twobob; 07-20-2012 at 02:32 PM. Reason: added AHH!
twobob is offline   Reply With Quote
Reply

Tags
stupid root mistakes


Forum Jump


All times are GMT -4. The time now is 03:43 AM.


MobileRead.com is a privately owned, operated and funded community.