|
Post by vovchik on Mar 25, 2018 10:01:04 GMT 1
Dear all, Here is a miniature wav player that only has dev/dsp as a dependency (install: sudo apt-get install oss-compat and then sudo modprobe snd-pcm-oss). I still would like to fork the player and to have it read inline wav memvars that you might want to include within your own programs. The code still needs some further baconization and I would love to receive some suggestions and/or mods regarding forking, inline and further baconization. My stripped and upx'd binary weighs in at just under 20k. Thanks in advance. With kind regards, vovchik PS. For testing purposes and to spare you typing in a terminal, you can drag wav files onto the binary. Also, it works fine on my Raspberry Pi3. Attachments:bwplay_src.tar.gz (235.17 KB)
|
|
|
Post by ptitjoz on Mar 25, 2018 11:51:39 GMT 1
Hello vovchik
under Lubuntu I tried but I can not make it work.
Regards
|
|
|
Post by vovchik on Mar 25, 2018 12:50:23 GMT 1
Dear ptitjoz, The error idicates to me that you do not have a /dev/dsp device. The link to the artful package is at the top of this page: /dev/dspWith kind regards, vovchik PS. After installing the module, you may have to reboot.
|
|
|
Post by alexfish on Mar 26, 2018 10:58:22 GMT 1
Hi Vovchik
Neat, I like it
BR Alex
|
|
|
Post by Pjot on Mar 27, 2018 18:44:39 GMT 1
Hi ptitjoz,
The kernel 4.13.0-37 does not seem to have this OSS compatible module.
Alternatively, you can install the OSS Proxy Daemon instead:
Now you should have the /dev/dsp device in your system.
Lastly, you can also use the 'padsp' emulation tool as well:
HTH Peter
|
|
|
Post by rikky on Mar 28, 2018 11:22:27 GMT 1
Yes,it works, AND recognises even the usb sound card. Which is important, for this is not always the case, I noticed. met vriendelijke groet,. Rik.
|
|
|
Post by vovchik on Apr 4, 2018 15:51:45 GMT 1
Dear Rik (and all), Thanks for testing. I have now made the miniplayer read memvars (for future use, enabling embedded sounds), and have given it a dmo gui (in fltk) to play small wav samples. I have included a rather large sample library of sound effects in the archive since you may find it useful for your own projects. All the sample rates for sound effects are consistent and pretty much normalized.You should not get any unwanted pops or tears. I had to upload the "system" sound archive separately because the board does not accept files larger than 1 MB. Just copy the system arhive into the unpacked main dir (which contains the source and the sfx directory) and unpack it there. Let me know how it works for you. Have fun. With kind regards, vovchik Attachments:bwplay-gui-fltk.tar.gz (756.99 KB)
system.tar.gz (296.84 KB)
|
|
|
Post by Pjot on Apr 6, 2018 19:03:48 GMT 1
Thanks vovchik,
On my new Mint 14.3 I had to execute the resulting program as follows:
# padsp ./notebook-waveplay-fltk
This is to get the /dev/dsp device. With this command your program works out of the box :-)
Best regards Peter
|
|
|
Post by ptitjoz on Jun 23, 2018 9:18:49 GMT 1
Hello everyone bwplay is running !
Now I can hear wav sounds
./bwplay bub.wav
Playing bub.wav (403912 bytes). ----------------------------------------- PCM Header dump ----------------------------------------- chunkId[4]: RIFF chunkSize: 403904 format[4]: WAVE subChunkId[4]: fmt subChunkSize: 16 audioFormat: 1 (1 = PCM, ~1 = unknown) numChannels: 2 (1 = mono, 2 = stereo) sampleRate: 24000 byteRate: 96000 bitrate: 768000 blockAlign: 4 bitsPerSample: 16 (bytes per sample: 2) subChunkId2[4]: data subChunkSize2: 403868 ----------------------------------------- Duration: (fp sec) 4.20733 (int sec) 04 -----------------------------------------
Buf_size: 192000
All done
Now I tried hug-fltk.bac (I had to install g ++) and I have this message
>bacon -q "/home/joz/Téléchargements/bwplay-gui-fltk/hug-fltk.bac"
Converting '/home/joz/Téléchargements/bwplay-gui-fltk/hug-fltk.bac'... Converting '/home/joz/Téléchargements/bwplay-gui-fltk/hug-fltk.bac'... done, 1909 lines were processed in 0.522 seconds. Compiling '/home/joz/Téléchargements/bwplay-gui-fltk/hug-fltk.bac'... g++ `pkg-config --cflags pangocairo` `pkg-config --cflags librsvg-2.0` -Wno-deprecated -Wno-write-strings -Wno-pointer-arith -fno-strict-aliasing -fpermissive -c hug-fltk.bac.c Makefile.bacon:6: recipe for target 'hug-fltk.bac.o' failed Compiler error:
Description: file '/home/joz/Téléchargements/bwplay-gui-fltk/hug-fltk.bac' line 73: #include <FL/Fl.H> Cause: not found
>Exit code: 2
What is the problem?
Regards
|
|
|
Post by rikky on Jun 23, 2018 20:01:38 GMT 1
For fltk I do a sudo apt-get install all of the following packages. Probably an overkill, but it works. libfltk1.3-dev subversion autoconf libx11-dev libglu1-mesa-dev libasound2-dev libxft-dev libcairo2-dev librsvg2-dev For the sound, I did have a new coup de l'oeil. And I was un peu triste thinking , now I have to learn for sound engeneer also. All the bitsPerSample, subChunkSize2, pffft And then I realized, I could throw away 70 percent. This is as short as I could get it. (And I still don't understand a jota of it.) OPTION EXPLICIT TRUE OPTION PARSE FALSE PRAGMA OPTIONS -Wno-unused-result PRAGMA LDFLAGS -s PRAGMA INCLUDE <linux/soundcard.h>
ALIAS ioctl TO IOCTL ALIAS open TO SYSOPEN ALIAS close TO SYSCLOSE ALIAS write TO SYSWRITE ALIAS memset TO MEMSET ALIAS fread TO FREAD DECLARE mywav$ TYPE STRING
' ------------------ SUB PLAYWAV(STRING wavfile$) ' ------------------ OPTION MEMTYPE size_t LOCAL fd, arg, status, cnt TYPE int LOCAL f TYPE FILE* LOCAL bytes, buf_size TYPE size_t bytes = 0 ' wav header info first goes here RECORD w LOCAL numChannels TYPE uint16_t LOCAL sampleRate TYPE uint32_t LOCAL bitsPerSample TYPE uint16_t END RECORD ' declare wav header array LOCAL header TYPE unsigned char ARRAY 44 ' open wav file OPEN wavfile$ FOR READING AS f ' grab header bytes 0 to 43 (first 44 bytes) MEMSET(header, 0, 44) bytes = FREAD(header, 1, 44, f) w.numChannels = PEEK(header + 22) w.sampleRate = PEEK(header + 24) w.bitsPerSample = PEEK(header + 34) PRINT "Playing ", BASENAME$(wavfile$), " (", \ FILELEN(wavfile$), " bytes)." PRINT "-----------------------------------------" fd = SYSOPEN("/dev/dsp", O_RDWR) IF fd < 0 THEN EPRINT "Failed to SYSOPEN /dev/dsp" END 1 END IF arg = w.bitsPerSample status = IOCTL(fd, SOUND_PCM_WRITE_BITS, &arg) arg = w.numChannels status = IOCTL(fd, SOUND_PCM_WRITE_CHANNELS, &arg) arg = w.sampleRate status = IOCTL(fd, SOUND_PCM_WRITE_RATE, &arg) ' calculate buffer size buf_size = ((w.bitsPerSample / 8) * w.sampleRate * \ w.bitsPerSample * w.numChannels / 8) ' creaate buffer to hold PCM data LOCAL buf TYPE unsigned char ARRAY buf_size REWIND f ' skip header and grab real sound data SEEK f OFFSET 44 ' read and play file REPEAT ' zero the memory MEMSET(buf, 0, buf_size) bytes = FREAD(buf, 1, buf_size, f) status = SYSWRITE(fd, buf, bytes) INCR cnt UNTIL ENDFILE(f) ' clean up CLOSE FILE f SYSCLOSE(fd) PRINT "All done!" END SUB
' get file argument IF AMOUNT(ARGUMENT$) = 2 THEN mywav$ = CHOP$(TOKEN$(ARGUMENT$, 2)) END IF IF NOT(FILEEXISTS(mywav$)) THEN PRINT "Bad filespec - provide a proper 'wav' file as input." END 1 ELSE PLAYWAV(mywav$) END IF
Regards. Rik.
|
|
|
Post by vovchik on Jun 24, 2018 0:06:20 GMT 1
Dear Rik,
Thanks - and nicely done. I had to change the names of three constants since the ones you used are now apparently obsolete (SOUND_PCM_WRITE_BITS, SOUND_PCM_WRITE_CHANNELS and SOUND_PCM_WRITE_RATE).
OPTION EXPLICIT TRUE OPTION PARSE FALSE PRAGMA OPTIONS -Wno-unused-result PRAGMA LDFLAGS -s PRAGMA INCLUDE <linux/soundcard.h>
ALIAS ioctl TO IOCTL ALIAS open TO SYSOPEN ALIAS close TO SYSCLOSE ALIAS write TO SYSWRITE ALIAS memset TO MEMSET ALIAS fread TO FREAD DECLARE mywav$ TYPE STRING
' ------------------ SUB PLAYWAV(STRING wavfile$) ' ------------------ OPTION MEMTYPE size_t LOCAL fd, arg, status, cnt TYPE int LOCAL f TYPE FILE* LOCAL bytes, buf_size TYPE size_t bytes = 0 ' wav header info first goes here RECORD w LOCAL numChannels TYPE uint16_t LOCAL sampleRate TYPE uint32_t LOCAL bitsPerSample TYPE uint16_t END RECORD ' declare wav header array LOCAL header TYPE unsigned char ARRAY 44 ' open wav file OPEN wavfile$ FOR READING AS f ' grab header bytes 0 to 43 (first 44 bytes) MEMSET(header, 0, 44) bytes = FREAD(header, 1, 44, f) w.numChannels = PEEK(header + 22) w.sampleRate = PEEK(header + 24) w.bitsPerSample = PEEK(header + 34) PRINT "Playing ", BASENAME$(wavfile$), " (", \ FILELEN(wavfile$), " bytes)." PRINT "-----------------------------------------" fd = SYSOPEN("/dev/dsp", O_RDWR) IF fd < 0 THEN EPRINT "Failed to SYSOPEN /dev/dsp" END 1 END IF arg = w.bitsPerSample status = IOCTL(fd, SNDCTL_DSP_SETFMT, &arg) arg = w.numChannels status = IOCTL(fd, SNDCTL_DSP_SETFMT, &arg) arg = w.sampleRate status = IOCTL(fd, SNDCTL_DSP_SETFMT, &arg) ' calculate buffer size buf_size = ((w.bitsPerSample / 8) * w.sampleRate * \ w.bitsPerSample * w.numChannels / 8) ' creaate buffer to hold PCM data LOCAL buf TYPE unsigned char ARRAY buf_size REWIND f ' skip header and grab real sound data SEEK f OFFSET 44 ' read and play file REPEAT ' zero the memory MEMSET(buf, 0, buf_size) bytes = FREAD(buf, 1, buf_size, f) status = SYSWRITE(fd, buf, bytes) INCR cnt UNTIL ENDFILE(f) ' clean up CLOSE FILE f SYSCLOSE(fd) PRINT "All done!" END SUB
' get file argument IF AMOUNT(ARGUMENT$) = 2 THEN mywav$ = CHOP$(TOKEN$(ARGUMENT$, 2)) END IF IF NOT(FILEEXISTS(mywav$)) THEN PRINT "Bad filespec - provide a proper 'wav' file as input." END 1 ELSE PLAYWAV(mywav$) END IF
With kind regards, vovchik
|
|
|
Post by ptitjoz on Jun 24, 2018 7:57:44 GMT 1
Hello all
When I use the last source posted by Vovchik and I play bub.wav sound works but the sound is bad and works bad When I use bwplay the sound is perfect and I do not encounter this problem but the sound takes about 1 or 2 seconds. However in both cases Bacon plays me a sound that does not last the time of the wav. When I use VLC, the sound is perfect and it tells me 4 seconds
(For now I have not tried to install the suggested Rikky packages yet)
Regards
Joz
|
|
|
Post by rikky on Jun 25, 2018 7:03:45 GMT 1
It is : arg = w.bitsPerSample status = IOCTL(fd, SOUND_PCM_WRITE_BITS, &arg) arg = w.numChannels status = IOCTL(fd, SOUND_PCM_WRITE_CHANNELS, &arg) arg = w.sampleRate status = IOCTL(fd, SOUND_PCM_WRITE_RATE, &arg)
instead of: arg = w.bitsPerSample status = IOCTL(fd, SNDCTL_DSP_SETFMT, &arg) arg = w.numChannels status = IOCTL(fd, SNDCTL_DSP_SETFMT, &arg) arg = w.sampleRate status = IOCTL(fd, SNDCTL_DSP_SETFMT, &arg)
And then it works.
There are too many zeros in the wav, to make it a string to include. maybe swap them to 01's ? Would that matter for the sound? Would BaCon swallow such a string?
|
|
|
Post by ptitjoz on Jun 25, 2018 7:33:59 GMT 1
Bonjour
apparently I have the right lines Regard
|
|
|
Post by vovchik on Jun 25, 2018 8:11:31 GMT 1
Dear Rik,
I had originally used your constants in bwplay. After an upgrade I get an error:
'SOUND_PCM_WRITE_BITS_is_obsolete_use_SNDCTL_DSP_SETFMT_instead' undeclared (first use in this function)
which means that something has changed in <linux/soundcard.h>. That is why I tried the new names. And I am now getting the same weird playback that ptitjoz gets, although the output of my earlier progs was OK. Weird.
With kind regards, vovchik
|
|