| PLEX86 | ||
|
how to check if sound card is working Sender: Linux
Here is some Perl. The first is using the Audio::DSP module to initialize and it will generate audio mathematically. The second example, relates to what DanceswithCrows mentioned about using ioctl directly instead of a module to initialize thedev-dsp. Now I only can get it to make static, but at least it is sound. :-) Maybe you can figure out the ioctl sequences, they probably need to be packed properly to be compatible with c. #################################################### #!-usr-bin-perl use warnings; use strict; use Audio::DSP; $ = 1; my $samplerate = 8000; #44100 gives best sound, but highest cpu #8000 works my $channels = 1; my $format = AFMTS16LE; my $buffer = 4096; ############################################################ my $freqadj = .1; my $vol = .5; my $toggle = 1; while(1){ maketone($freqadj, $vol); $freqadj += ($toggle * .001); #higher increment numbers are slower #0 is pure tone } sub maketone { my $rad = 0; $rad += $freqadj; my $raw = ($vol*32768) * sin($rad); #max times my $num = pack( 'V', $raw ); } } END ######################################################### # second example (partially working) # see man h2ph for details on generating soundcard.ph ####################################################### #!-usr-bin-perl use warnings; use strict; require "soundcard.ph"; $ = 1; #not working several distributions on same HD 3953 On Tue, 21 Jun 2005 15:03:42 -0400, Jeff staggered into the Black Sun and said: Every distro should have its own . Sharing just doesn't work out at all. If you haveusr, each distro should... my $samplerate = 22050; #44100 gives best sound, but highest cpu #8000 works my $channels = 1; my $format = 'AFMTS16LE'; #8 bit won't work on SBLive my $buffer = 4096; # Set buffer size for fast response 128 16byte chunks. about 1-8 sec #ioctl('-dev-dsp',SNDCTLDSPSETFRAGMENT,0x00800004); #ioctl(DSP,10,0x00800004) or warn "$!-n"; #ioctl(DSP,0,0x00800004) or warn "$!-n"; SNDCTLDSPSETFRAGMENT(0x00800004); #ioctl(DSP,) #ioctl(DSP, 2 , 22050 ) or warn "$!-n"; #ioctl(DSP,0x00000002,0x00022050) or warn "$!-n"; SNDCTLDSPSPEED($samplerate); #(ioctl(dsp,SNDCTLDSPCHANNELS,1) #ioctl(DSP,6,1) or warn "$!-n"; SNDCTLDSPCHANNELS(0); #(ioctl(dsp,SNDCTLDSPSETFMT,AFMTS16LE ) #ioctl(DSP,5,0x00000020) or warn "$!-n"; SNDCTLDSPSETFMT(0x00000020); several distributions on same HD 3952 No problem. I've had up to 12 different Linux distributions installed on a single HD. Each distro will need at least one parbreastion of it's own. You... #my $buf; #ioctl(DSP, 2, 22050) or warn "$!-n"; #my $buf1 = unpack('V',$buf); #print "$buf1-n"; ############################################################ my $freqadj = .1; my $vol = .5; my $toggle = 1; while(1){ maketone($freqadj, $vol); $freqadj += ($toggle * .001); #higher increment numbers are slower #0 is pure tone } sub maketone { my $rad = 0; $rad += $freqadj; my $raw = ($vol*32768) * sin($rad); #max times my $num = pack( 'V', $raw ); syswrite DSP,$num; } } END several distributions on same HD 3951 Well, you need as many parbreastions as operating systems, and preferably a fat32 parbreastion for data accessible from both windows and linux (I use it for...
-- I'm not really a human, but I play one on earth.
|
||||
several distributions on same HD 3951 Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||