Envy24's Raw IO Devices

OSS specific Linux discussion (x86/amd64)

Moderators: hannu, dev, cesium

twlaipeter
New Member
Posts: 6
Joined: Thu Dec 18, 2014 4:05 am
Sound Card: SQ210A+
OS: ubuntu

Envy24's Raw IO Devices

Postby twlaipeter » Thu Dec 18, 2014 4:16 am

Hi,

I am using a sound card with Envy24ht and want to play bit-perfect audio using Raw IO Devices as depicted in the envy24 oss manpage. I create the mmap device: /dev/dsp_mmap (envy24_devmask=32 in /usr/lib/oss/conf/oss_envy24.conf). I disabled the "cooked mode" and vmix in /usr/lib/oss/conf/osscore.conf. However, when I play the 16 bit 44100hz audio file using MOC (command line music console), the music is fast forwarded.

I understand that the source file must be S32_LE. However, when I use sox to change the bit-depth to 32 bit (sox input.wav -b 32 output.wav), the music is still played like fast forward. The music play normally if I enable either "cooked mode" or vmix.

How can I play music using mmap() in my settings?

Thank you for your help!

Regards,
Peter

igorzwx
Known Member
Posts: 1246
Joined: Sun Jun 28, 2009 9:31 pm

Re: Envy24's Raw IO Devices

Postby igorzwx » Thu Dec 18, 2014 8:15 pm

twlaipeter wrote:Hi,

I am using a sound card with Envy24ht and want to play bit-perfect audio using Raw IO Devices as depicted in the envy24 oss manpage. I create the mmap device: /dev/dsp_mmap (envy24_devmask=32 in /usr/lib/oss/conf/oss_envy24.conf). I disabled the "cooked mode" and vmix in /usr/lib/oss/conf/osscore.conf. However, when I play the 16 bit 44100hz audio file using MOC (command line music console), the music is fast forwarded.

I understand that the source file must be S32_LE. However, when I use sox to change the bit-depth to 32 bit (sox input.wav -b 32 output.wav), the music is still played like fast forward. The music play normally if I enable either "cooked mode" or vmix.

How can I play music using mmap() in my settings?


You may try to play some "*.wav" files with ossplay:

Code: Select all

$ ossplay -R -vvvv -d<devname> mumu.wav

and post the output here.

Petrov's plugin for DeadBeef player can also print some useful info on the terminal.
See also: _https://wiki.archlinux.org/index.php/OSS#Changing_the_Default_Sound_Output

twlaipeter
New Member
Posts: 6
Joined: Thu Dec 18, 2014 4:05 am
Sound Card: SQ210A+
OS: ubuntu

Re: Envy24's Raw IO Devices

Postby twlaipeter » Fri Dec 19, 2014 11:09 am

Many thanks, igorzwx!!!

I try to play 16 bit file but it returns that the format is not supported. Instead of using a 32 bit file, I use a 24 bit file. I am a dumb and do not know how to upload the output. However, I have taken a photo of the output as follows:-

IMG_20141219_183809.jpg
IMG_20141219_183809.jpg (131.87 KiB) Viewed 11597 times


It seems successful!!! The sound is natural and analogue. Please accept my heartfelt thanks, igorzwx!!!

May I know if I can change the 16 bit 44100 hz wav file to 24 bit file on the fly so that I can save the disk space (24 bit file is 50% larger than a 16 bit file)?

Regards,
Peter

igorzwx
Known Member
Posts: 1246
Joined: Sun Jun 28, 2009 9:31 pm

Re: Envy24's Raw IO Devices

Postby igorzwx » Fri Dec 19, 2014 3:13 pm

twlaipeter wrote:I do not know how to upload the output.


You may simly forward the output from terminal to a text file:

Code: Select all

$ ls
mumu.wav
$ ossplay -R -vvvv -d<devname> mumu.wav > ./output.txt
$ ls
mumu.wav
output.txt


twlaipeter wrote:May I know if I can change the 16 bit 44100 hz wav file to 24 bit file on the fly so that I can save the disk space (24 bit file is 50% larger than a 16 bit file)?


Petrov's plugin for DeadBeef can do the work.
However, if you want to do this from terminal...

SoX can make format conversion on the fly. It can be used as an audio player.
However, you should disable its resampler and set the proper output device

When playing a file with a sample rate that is not supported by the audio output device, SoX will automatically invoke the rate effect to perform the necessary sample rate conversion.
_http://linux.die.net/man/1/sox


SoX documentation is here: _http://sox.sourceforge.net/Docs/Documentation

You may also make some experiments with SoX, for example:

Code: Select all

$ sox input_16bit_41000Hz.wav -b 24 output.wav rate 44100
$ mediainfo output.wav


Code: Select all

$ sox input_16bit_41000Hz.wav -b 24 output.wav
$ mediainfo output.wav


You may also ask for help on the SOX forum, or Ubuntu forum.

If you want "to save the disk space", you may try to play FLACs with SoX

Waves can be compressed and decompressed with "flac"

Code: Select all

$ flac mumu.wav

Code: Select all

$ flac -d mumu.flac

twlaipeter
New Member
Posts: 6
Joined: Thu Dec 18, 2014 4:05 am
Sound Card: SQ210A+
OS: ubuntu

Re: Envy24's Raw IO Devices

Postby twlaipeter » Sat Dec 20, 2014 2:31 pm

Many thanks again, igorzwx!!!

I figure it out how I can do the conversion from 16 bit to 24 bit on the fly so that I need not convert all my wav file to 24 bit, which is not only tedious but also occupies much of my disk space. I do it by the following script:-

Code: Select all

sudo nano /usr/local/bin/music


cd /mnt/ramdisk #[I mount a ramdisk at /mnt/ramdisk and copy the wav in an album there]
sudo umount /media/sda5 #[I use boot-to-ram so that the whole os is on ram and I turn off and unplug the hard disk when playing music]
for i in *.wav #[that is the trick, inspired by sox batch processing .bat file]
do sudo sox -V4 “$i” -b 24 tmp.wav
sudo xfs_fsr tmp.wav
sudo taskset -c 0 pagecache-management.sh ossplay -vvvv -R -d/dev/dsp_mmap tmp.wav” #[I use taskset and pagecachemanagement.sh to optimise the playing]
sudo rm tmp.wav
done”

Code: Select all

sudo chmod 755 /usr/local/bin/music


When I play the wav files, I simply type "music" at prompt.

For sharing, please.

Regards,
Peter

P.S. one last question, I used to change the music player's pid by (ctl-z, chrt -f -p 85 `pgrep mocp`, fg). But when ossplay is playing, when I press "ctl-z", ossplay does not go to the background. igorzwx, can you please teach me how I can change the pid of ossplay?

igorzwx
Known Member
Posts: 1246
Joined: Sun Jun 28, 2009 9:31 pm

Re: Envy24's Raw IO Devices

Postby igorzwx » Sat Dec 20, 2014 4:14 pm

twlaipeter wrote:Many thanks again, igorzwx!!!

I figure it out how I can do the conversion from 16 bit to 24 bit on the fly so that I need not convert all my wav file to 24 bit, which is not only tedious but also occupies much of my disk space. I do it by the following script:-

Code: Select all

sudo nano /usr/local/bin/music


cd /mnt/ramdisk #[I mount a ramdisk at /mnt/ramdisk and copy the wav in an album there]
sudo umount /media/sda5 #[I use boot-to-ram so that the whole os is on ram and I turn off and unplug the hard disk when playing music]
for i in *.wav #[that is the trick, inspired by sox batch processing .bat file]
do sudo sox -V4 “$i” -b 24 tmp.wav
sudo xfs_fsr tmp.wav
sudo taskset -c 0 pagecache-management.sh ossplay -vvvv -R -d/dev/dsp_mmap tmp.wav” #[I use taskset and pagecachemanagement.sh to optimise the playing]
sudo rm tmp.wav
done”

Code: Select all

sudo chmod 755 /usr/local/bin/music


When I play the wav files, I simply type "music" at prompt.

For sharing, please.

Regards,
Peter

P.S. one last question, I used to change the music player's pid by (ctl-z, chrt -f -p 85 `pgrep mocp`, fg). But when ossplay is playing, when I press "ctl-z", ossplay does not go to the background. igorzwx, can you please teach me how I can change the pid of ossplay?


You may not need to create "tmp.wav", because SoX can play audio files (waves, FLACs, etc), converting them on the fly.

The manual is here: _http://sox.sourceforge.net/sox.html

Code: Select all

$ man sox
SoX(1)                          Sound eXchange                          SoX(1)

NAME
       SoX - Sound eXchange, the Swiss Army knife of audio manipulation

SYNOPSIS
       sox [global-options] [format-options] infile1
            [[format-options] infile2] ... [format-options] outfile
            [effect [effect-options]] ...

       play [global-options] [format-options] infile1
            [[format-options] infile2] ... [format-options]
            [effect [effect-options]] ...

       rec [global-options] [format-options] outfile
            [effect [effect-options]] ...


Playing & Recording Audio
The play and rec commands are provided so that basic playing and recording is as simple as

Code: Select all

   play existing-file.wav

and

Code: Select all

   rec new-file.wav

These two commands are functionally equivalent to

Code: Select all

   sox existing-file.wav −d

and

Code: Select all

   sox −d new-file.wav

Of course, further options and effects (as described below) can be added to the commands in either form.
_http://sox.sourceforge.net/sox.html


________________________
EDIT:

twlaipeter wrote:P.S. one last question, I used to change the music player's pid by (ctl-z, chrt -f -p 85 `pgrep mocp`, fg). But when ossplay is playing, when I press "ctl-z", ossplay does not go to the background. igorzwx, can you please teach me how I can change the pid of ossplay?


The problem might be "verbosity" of ossplay, that is, the option "-vvvv", which can be removed.

For example, the command:

Code: Select all

$ ossplay *.wav &
[1] 2682
$


does background "ossplay".

The command:

Code: Select all

$ ossplay -vvvv *.wav &
[1] 2588
$ FORM len = 104217968
01_sound_sample2_24_96.wav: Reading chunk fmt , size 16, pos 0, next 12
FMT chunk: len = 16, fmt = 0
01_sound_sample2_24_96.wav: Reading chunk data, size 104217924, pos 0, next 36
DATA chunk. Offs = 44, len = 104217924
Playing WAVE file 01_sound_sample2_24_96.wav, 24 bits/stereo/96000 Hz
Setup device S32_LE/2/96000
Time: 00:06.00 of 03:00.93 VU 0          ^C
Time: 00:08.80 of 03:00.93 VU -----      ^C
Time: 00:14.20 of 03:00.93 VU ---        ^C
Time: 00:29.20 of 03:00.93 VU -          ^C
[1]+  Terminated              ossplay -vvvv *.wav
$

also backgrounds "ossplay", but it continues to output "verbosity" on the terminal.

See: _http://www.cyberciti.biz/faq/linux-command-line-run-in-background/

twlaipeter
New Member
Posts: 6
Joined: Thu Dec 18, 2014 4:05 am
Sound Card: SQ210A+
OS: ubuntu

Re: Envy24's Raw IO Devices

Postby twlaipeter » Sat Dec 20, 2014 11:26 pm

You solve my one last problem, thanks.

As I am not sure whether sox uses the device file /dev/dsp_mmap, I will stick to ossplay which gives very good result!!!

twlaipeter
New Member
Posts: 6
Joined: Thu Dec 18, 2014 4:05 am
Sound Card: SQ210A+
OS: ubuntu

Re: Envy24's Raw IO Devices

Postby twlaipeter » Mon Dec 22, 2014 1:04 pm

Script revised:-

sudo nano /usr/local/bin/music

cd /mnt/ramdisk
sudo umount /media/sda5
for i in *.wav
do sudo sox “$i” -b 24 tmp.wav
echo “$1”
sudo xfs_fsr tmp.wav
sudo taskset -c 0 pagecache-management.sh ossplay -R -d/dev/dsp_mmap tmp.wav &
sudo chrt -f -p 85 $!
wait
sudo rm tmp.wav
done

sudo chmod 755 /usr/local/bin/music

Add "&" at the end of the command "taskset ... ossplay ..." to put it to the background, then chrt to change the priority of the ossplay. The command "wait" is then added to let ossplay in the background to finish the current wav before tmp.wav is deleted and proceeded to the next one. The sound is more refined. ^.^


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 2 guests