![]() |
#151 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
@kcn1: Actually, my published code is indented to show structure. Multiple statements per line are logically related. It even the short variable names are related to their function. If you cannot follow it do to its condensation, you can expand it with Astyle (which I have mentioned in a number of my posts in the past). If my code bothers you so much that even Astyle cannot make it acceptable to you, you can just skip over the source code parts then. To make that easy for you, I have even been hiding my source inside spoiler tags so you have to go out of your way to be offended by it. Lucky for me, I am just one of many to receive your negativity lately, so it is easy to shrug off.
@twobob: No need to apologize to anybody. At least for me, I can UNDERSTAND you condensed version FAR more easily than the previous version. I am sure that others feel the same way, and if they do not, they can always expand the code out to take as much space as makes them feel happy, with robust error handling on every call, and a comment on every statement, and triple-spaced lines if that is their preference. A lot of that can be automated easily with a program called AStyle (which is even built into many programmer's editors, both for linux and for windows). |
![]() |
![]() |
![]() |
#152 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
@twobob: What format is the PCM audio file for your init program? Do you have a sample somewhere?
Regarding "GM style", I also try to avoid compiler warnings. So you cannot pack #includes on a line. Also, I had to take alsa/" out of the include to compile with my tools. Last edited by geekmaster; 07-12-2012 at 08:08 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#153 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
As knc1 himself would say to anybody who did not understand a documented library function, "RTFM"...
|
![]() |
![]() |
![]() |
#154 |
( ͡° ͜ʖ ͡°){ʇ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 took i tunder advisement
Knc has a different view on what is best for the user.
You also have a vision of what is most accessible. For my part I spent the best part of two hours making sure that everyone is satiated. Not to please anyone or a sense of admonishment, simply to ensure that if either of you is right then the end reader wins both ways. Thanks for the nudge. I made it neat and tidy. I think I will Top post this lot as this is the thrust of the thread. Thanks Guys |
![]() |
![]() |
![]() |
#155 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I think the code in your top post looks fine, for REAL (non-tutorial) code. With those 8-character indents, it may even satisfy Linus Torvalds.
![]() To teach a basic CONCEPT (other than error handling methods), I think the concept could should not be bogged down by "non-concept" error handling, and should fit the page so it can be studied and grasped without a lot of scrolling. They are two different styles for two different purposes, and both have their place. The "condensed tutorial" style I use here is actually fairly popular in research papers (of which I have read MANY in my fields of interest), which also were meant to teach a basic concept. And thanks for condensing an example for me so that I can easily grasp it. Your top post code is a bit overwhelming for me. Different strokes for different folks, as they say. Thanks. There is room here for both of us, without harsh criticism. I am not PUSHING my personal (recreational) coding style on anybody. It is very easy to reformat it using AStyle. Please do so if that makes it easier for you to comprehend. Unfortunately, AStyle does not support a condensed coding style that suits me, so going the other direction takes extra work on my part. I usually default to K&R style for commercial work. |
![]() |
![]() |
Advert | |
|
![]() |
#156 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
BTW, I had problems with your "condensed" program on both my DX and my K5. My WAV files were probably the wrong format.
![]() I have condensed the "pcm_min.c" demo from the ALSA Project website, and it works fine playing random noise (and about the same size as your demo). That code will also be a better fit to squeeze into my gmplay code, and lets me control the sound paramaters where I can see and control them in a way that suits my style. I could swear that some of those "spacey" coding styles were made for people who get paid for number of lines of code delivered, not for performance or functionality. The experts can pack more functions into less code, so LOC (Lines Of Code) is not really a valid productivity measurement anyway. And it is so easy to run though a reformatter for others, so I feel no guilt publishing it the way I like to use it. I really DO understand condensed code much faster and better than "formatted" code. Even just to study other peoples code, I condense it just so I can understand it better. I look for "functional patterns" in it, which I cannot see when I have to page through it. Last edited by geekmaster; 07-12-2012 at 09:12 PM. |
![]() |
![]() |
![]() |
#157 | |
( ͡° ͜ʖ ͡°){ʇ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
|
Pant wettingly excited. um, not about docs.
Quote:
Just not for everyone. Providing for everyone sometimes takes a bit of bending in the wind, I enjoy the breeze ![]() I quite frankly am pissing-in my pants with excitement to see if you beat me to a full in-one A V solution. Spending two hours updating the quality of my docs was not on the plan but that said I don't regret it and I updated the top post which does indeed look a little more heavy weight for the work, Happy days. Cup of tea for me I think |
|
![]() |
![]() |
![]() |
#158 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Until now, I knew very little about ALSA.
I see that you used the _hw_ functions, which are more fussy about what they support. Are they lower CPU overhead than the "non _hw_" functions (which convert formats if needed)? The pcm_min.c demo uses the "non _hw_" functions, and a modified version is working for me (for now). I may have to switch if it gets swamped by the K3 eink calls. I still do not understand buffer sizes -- just growing them until stuff works... I will have to RTFM at some point, I am sure... ![]() Your condensed code may work for me if I had a "proper" wave file... Last edited by geekmaster; 07-12-2012 at 09:52 PM. |
![]() |
![]() |
![]() |
#159 |
( ͡° ͜ʖ ͡°){ʇ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
|
well. As I understand it one layer abstracts the other.
The higher layer calls the underlying layer as far as I can tell. So you have in one blow reduced all my lines to one tidy array and a method. I went with HW as you can start it pretty much untouched (as in my code) The beautiful abbreviation demonstrated there is the evolution. I will test what I can get it down to then. EDIT: Ah I remember now it was seggying. Code:
SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 2, 44100, 0, 500000 ![]() Last edited by twobob; 07-12-2012 at 10:25 PM. Reason: I admitted that I went for the low level ones just because they are sexier to me. |
![]() |
![]() |
![]() |
#160 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
How about a pretty little utility function?
Code:
#include <stdio.h> int l;int main(int o,char **O, int I){char c,*D=O[1];if(o>0){ for(l=0;D[l ];D[l ++]-=10){D [l++]-=120;D[l]-= 110;while (!main(0,O,l))D[l] += 20; putchar((D[l]+1032) /20 ) ;}putchar(10);}else{ c=o+ (D[I]+82)%10-(I>l/2)* (D[I-l+I]+72)/10-9;D[I]+=I<0?0 :!(o=main(c/10,O,I-1))*((c+999 )%10-(D[I]+92)%10);}return o;} Details at: http://www.ioccc.org/2001/cheong.hint |
![]() |
![]() |
![]() |
#161 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
@twobob: I tested the "non _hw_" sound functions with top running, on my K5 (1.6%) and DX (0.3%). But as hawhill said, top is notoriously unreliable. |
|
![]() |
![]() |
![]() |
#162 | |
( ͡° ͜ʖ ͡°){ʇ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
|
Quote:
CoolEditPro Allows for the sample rate to be changed without resampling the sample so I was playing around with rates basically. I kept ending up with twice the length of audio I expected so double the rate is about right I think. That said I have been playing around today and once you get the buffers running right I fully expect as little as 3% cpu from the process, depending on the housekeeping. perhaps less. I don't think my half time trick will be needed, I'll roll it out if it is. Your video code ran like a demon today - with audio - kaffienne blinking away - the framework running - two ssh shells and a top running. Still perfect picture / sound no glitches. so the device can more than handle it, in less then ideal conditions. I personally think. once the drop logic is stiched to the audio, it's going to be mind staggeringly awesome. the mini pcm looks the right route. simple construct, easily melded. your 100% right imho. To that end I too shall be having a play with that instead for a while ![]() |
|
![]() |
![]() |
![]() |
#163 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
This is worth a quick read too: http://www.suse.de/~mana/alsa090_howto.html
|
![]() |
![]() |
![]() |
#164 | |
( ͡° ͜ʖ ͡°){ʇ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
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#165 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
That is also where I got my initial "ray tracer" code (the unobfuscated version). Here is the obfuscated version. It outputs to a PBM file as I recall, but I changed that to a 600x800 8-bit framebuffer, with eips updates after every scanline. Then I started moving the chrome balls around...[B]
Code:
X=1024; Y=768; A=3; J=0;K=-10;L=-7;M=1296;N=36;O=255;P=9;_=1<<15;E;S;C;D;F(b){E="1""111886:6:??AAF" "FHHMMOO55557799@@>>>BBBGGIIKK"-64;C="C@=::C@@==@=:C@=:C@=:C5""31/513/5131/" "31/531/53"[b ]-64;S=b<22?9:0;D=2;}I(x,Y,X){Y?(X^=Y,X*X>x?(X^=Y):0, I (x,Y/2,X )):(E=X); }H(x){I(x, _,0);}p;q( c,x,y,z,k,l,m,a, b){F(c );x-=E*M ;y-=S*M ;z-=C*M ;b=x* x/M+ y*y/M+z *z/M-D*D *M;a=-x *k/M -y*l/M-z *m/M; p=((b=a*a/M- b)>=0?(I (b*M,_ ,0),b =E, a+(a>b ?-b:b)): -1.0);}Z;W;o (c,x,y, z,k,l, m,a){Z=! c? -1:Z;c <44?(q(c,x ,y,z,k, l,m,0,0 ),(p> 0&&c!= a&& (p<W ||Z<0) )?(W= p,Z=c): 0,o(c+ 1, x,y,z, k,l, m,a)):0 ;}Q;T; U;u;v;w ;n(e,f,g, h,i,j,d,a, b,V){o(0 ,e,f,g,h,i,j,a);d>0 &&Z>=0? (e+=h*W/M,f+=i*W/M,g+=j*W/M,F(Z),u=e-E*M,v=f-S*M,w=g-C*M,b=(-2*u-2*v+w) /3,H(u*u+v*v+w*w),b/=D,b*=b,b*=200,b/=(M*M),V=Z,E!=0?(u=-u*M/E,v=-v*M/E,w=-w*M/ E):0,E=(h*u+i*v+j*w)/M,h-=u*E/(M/2),i-=v*E/(M/2),j-=w*E/(M/2),n(e,f,g,h,i,j,d-1 ,Z,0,0),Q/=2,T/=2, U/=2,V=V<22?7: (V<30?1:(V<38?2:(V<44?4:(V==44?6:3)))) ,Q+=V&1?b:0,T +=V&2?b :0,U+=V &4?b:0) :(d==P?(g+=2 ,j=g>0?g/8:g/ 20):0,j >0?(U= j *j/M,Q =255- 250*U/M,T=255 -150*U/M,U=255 -100 *U/M):(U =j*j /M,U<M /5?(Q=255-210*U /M,T=255-435*U /M,U=255 -720* U/M):(U -=M/5,Q=213-110*U /M,T=168-113*U / M,U=111 -85*U/M) ),d!=P?(Q/=2,T/=2 ,U/=2):0);Q=Q< 0?0: Q>O? O: Q;T=T<0? 0:T>O?O:T;U=U<0?0: U>O?O:U;}R;G;B ;t(x,y ,a, b){n(M*J+M *40*(A*x +a)/X/A-M*20,M*K,M *L-M*30*(A*y+b)/Y/A+M*15,0,M,0,P, -1,0,0);R+=Q ;G+=T;B +=U;++a<A?t(x,y,a, b):(++b<A?t(x,y,0,b):0);}r(x,y){R=G=B=0;t(x,y,0,0);x<X?(printf("%c%c%c",R/A/A,G /A/A,B/A/A),r(x+1,y)):0;}s(y){r(0,--y?s(y),y:y);}main(){printf("P6\n%i %i\n255" "\n",X,Y);s(Y);} And best of all, the IOCCC spoiler summary: http://www.ioccc.org/all/summary.txt Last edited by geekmaster; 07-12-2012 at 10:59 PM. |
![]() |
![]() |