|
|
#151 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
@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).
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() |
|
|
|
|
|
#152 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
@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.
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() Last edited by geekmaster; 07-12-2012 at 08:08 PM. |
|
|
|
|
Enthusiast
|
|
|
|
#153 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
As knc1 himself would say to anybody who did not understand a documented library function, "RTFM"...
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() |
|
|
|
|
|
#154 |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,143
Karma: 5329011
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|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
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
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set |
|
|
|
|
|
#155 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
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.
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() |
|
|
|
|
|
#156 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
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.
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() Last edited by geekmaster; 07-12-2012 at 09:12 PM. |
|
|
|
|
|
#157 | |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,143
Karma: 5329011
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|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
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
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set |
|
|
|
|
|
|
#158 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
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...
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() Last edited by geekmaster; 07-12-2012 at 09:52 PM. |
|
|
|
|
|
#159 |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,143
Karma: 5329011
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|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
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
I'll update the docs with the shorthand.
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set 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 |
|
Embedded Cheerleader
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,260
Karma: 3921781
Join Date: Feb 2012
Device: K0
|
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
__________________
"Hack is just a four letter word." - - With apologies to B. Dylan - -> JB on BD |
|
|
|
|
|
#161 | |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
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.
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() |
|
|
|
|
|
|
#162 | |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,143
Karma: 5329011
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|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
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 hehehe copycat.
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set |
|
|
|
|
|
|
#163 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
This is worth a quick read too: http://www.suse.de/~mana/alsa090_howto.html
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() |
|
|
|
|
|
#164 | |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,143
Karma: 5329011
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|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
Quote:
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set |
|
|
|
|
|
|
#165 |
|
Всё гениальное просто.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,028
Karma: 6382209
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
|
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
__________________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
![]() Last edited by geekmaster; 07-12-2012 at 10:59 PM. |
|
|
|
![]() |
| Tags |
| stupid root mistakes |
| Thread Tools | Search this Thread |
|