DaemonForums  

Go Back   DaemonForums > Miscellaneous > General software and network

General software and network General OS-independent software and network questions, X11, MTA, routing, etc.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 31st May 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default .wav file playing very fast on unix, fine on win

hello,
I have some lessons I recorded with a digital recorder. I need to listen to them and I would like to do it on unix, which has become my os for everyday work. The lessons have been converted with a software from their (LG) format, to .wav (software only works on windows, of course). The problem is, the files work perfect on windows (I use jetaudio) but once on unix they go very fast and they are just unusable. I'v tried mplayer, aucat, xmms, all with no avail.
mplayer's output while playing:
Code:
Audio file file format detected.
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 8000 Hz, 1 ch, s16le, 128.0 kbit/100.00% (ratio: 16000->16000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
ao2: 8000 Hz  1 chans  s16le [0x9]
AO: [sun] 8000Hz 1ch s16be (2 bytes per sample)
Video: no video
Starting playback...
any idea?
Reply With Quote
  #2   (View Single Post)  
Old 31st May 2009
Oko's Avatar
Oko Oko is offline
Fsck Surgeon
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 758
Thanked 36 Times in 32 Posts
Default

Quote:
Originally Posted by gosha View Post
hello,
I have some lessons I recorded with a digital recorder. I need to listen to them and I would like to do it on unix, which has become my os for everyday work. The lessons have been converted with a software from their (LG) format, to .wav (software only works on windows, of course). The problem is, the files work perfect on windows (I use jetaudio) but once on unix they go very fast and they are just unusable. I'v tried mplayer, aucat, xmms, all with no avail.
mplayer's output while playing:
Code:
Audio file file format detected.
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 8000 Hz, 1 ch, s16le, 128.0 kbit/100.00% (ratio: 16000->16000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
ao2: 8000 Hz  1 chans  s16le [0x9]
AO: [sun] 8000Hz 1ch s16be (2 bytes per sample)
Video: no video
Starting playback...
any idea?
Two possibilities. Either you have a problem with the sampling rate in which case you will have to learn how to use your audio beyond basics or
you have a crappy AC97 audio chipset so the serious Unix applications
have a problem with it. Remedy is to have real audio card.
Reply With Quote
  #3   (View Single Post)  
Old 31st May 2009
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 506
Thanked 39 Times in 39 Posts
Default

FWIW, this has happened to me on an audio stream before, and I use a Turtle Beach Santa Cruz audio card (which is pretty good). Mine was a one-off, so I listened to that stream on a Windows box. It has not recurred.
Reply With Quote
  #4   (View Single Post)  
Old 31st May 2009
BSDKaffee's Avatar
BSDKaffee BSDKaffee is offline
Real Name: Jason Hale
Coffee Addict
 
Join Date: May 2008
Location: Wintersville, Ohio
Posts: 212
Thanked 36 Times in 34 Posts
Default

Does this happen just for WAV files or do mp3s/ogg/videos/etc work?
Do other WAV files work correctly or is it just these ones you made?

From what I gather so far, this sounds like a driver issue (sampling rate problem). It would help if you tell us what OS and version you are using and tell us what audio hardware you have. Running the audio through an OSS-compatible sound system would probably be the most reliable thing to do. If your OS doesn't use OSS, you can install OSS from: http://www.opensound.com/oss.html. In the meantime as a workaround your could try using the -speed option with mplayer; it has a range from 0.01-100. E.g. the following command will cut the playback rate by half:
$ mplayer -speed 0.5 myfile.wav
The following will speed up playback x2 and is great for making a new "Alvin and the Chipmunks" album :
$ mplayer -speed 2 myfile.wav
Reply With Quote
  #5   (View Single Post)  
Old 31st May 2009
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

How about converting it to mp3/ogg using lame or an ogg enc? That might work.
Reply With Quote
  #6   (View Single Post)  
Old 31st May 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

thank you all
I have OpenBSD on a macmini ppc (g4), the first that came out in 2005. Everything workes just fine with "regular" audio files, that is the copies of my cds, but these files even if converted to mp3 will run fast.
Anyway I used the -speed option in mplayer as suggested by bsdkaffee and it works, but with
-speed 0.1

I would like to understand what the problem is about. Audio is integrated.

Thanks a lot
Reply With Quote
  #7   (View Single Post)  
Old 1st June 2009
Oko's Avatar
Oko Oko is offline
Fsck Surgeon
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 758
Thanked 36 Times in 32 Posts
Default

Quote:
Originally Posted by gosha View Post
thank you all
I have OpenBSD on a macmini ppc (g4), the first that came out in 2005. Everything workes just fine with "regular" audio files, that is the copies of my cds, but these files even if converted to mp3 will run fast.
Anyway I used the -speed option in mplayer as suggested by bsdkaffee and it works, but with
-speed 0.1

I would like to understand what the problem is about. Audio is integrated.

Thanks a lot
Learn about Lame and about audio in general on your hardware platform.
Reply With Quote
  #8   (View Single Post)  
Old 1st June 2009
BSDKaffee's Avatar
BSDKaffee BSDKaffee is offline
Real Name: Jason Hale
Coffee Addict
 
Join Date: May 2008
Location: Wintersville, Ohio
Posts: 212
Thanked 36 Times in 34 Posts
Default

I noticed mplayer was using the sun output driver. First I would try using oss instead:
$ mplayer -ao oss somefile.wav

Failing that, I would suggest using mplayer to resample the WAV files since they seem to be the problem. Since scaling the playback x0.1 worked, try this:
$ mplayer -speed 0.1 -srate 8000 -ao pcm:file=somefile-resampled.wav somefile.wav
That will scale back the playback rate and keep the sample rate at 8000Hz and write a new file based on that. If it works, I'm sure you could write a small script to batch convert all of the files. I would try playing one of those new files back on your Windows box and see if it sounds right.

Keep in mind, WAV files behave a little differently than mp3's so an mp3 might be fine while a WAV file may sound messed up. Let's find out whether your files are the culprit or if it is a driver issue. I found a file very similar to the type you have as far as sample rate goes (8000Hz 16bit PCM). It should sound like a normal person talking. Try downloading this audio file and see if it plays correctly: http://www.nch.com.au/acm/8k16bitpcm.wav. If that doesn't sound right, then it probably isn't your files.

Last edited by BSDKaffee; 1st June 2009 at 11:41 AM.
Reply With Quote
  #9   (View Single Post)  
Old 1st June 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

Code:
mplayer -ao oss
does not work
Code:
mplayer -speed 0.1 -srate 8000 -ao pcm:file=somefile-resampled.wav somefile.wav
does not work either.
Before posting I did try to convert the file to mp3 with lame, but with no good results.
I downloaded the file, and has the exact behaviour of my on files.

Quote:
Learn about Lame and about audio in general on your hardware platform.
Audio is poorly supported on this platform, the driver does not even support volume control, which I acheive through mplayer -softvol. My mixerctl output only gives this (if it is of any use):
Code:
$ mixerctl 
outputs.select=headphones
outputs.master=0,0
record.source=
record.record=0,0
Reply With Quote
Old 1st June 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

well
I've found out what causes the problem. It's this:
AUDIO: 8000 Hz
I've tried playing the file with audacity, and it woks fine. If I reencode it using
Project Rate (Hz) 44100
which I see is the rate of all my mp3 files, then it sounds correct.
Now I have to find out how to do this from the command lline

Any one is patient enough to tell me what this "rate" consists of?
Reply With Quote
Old 1st June 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

how silly, I just changed this
$ mplayer -speed 0.1 -srate 8000 -ao pcm:file=somefile-resampled.wav somefile.wav
to this:
$ mplayer -speed 0.1 -srate 44100 -ao pcm:file=somefile-resampled.wav somefile.wav
and it's fine
Thanks a lot

ps. it works also without the -speed option
$ mplayer -srate 44100 -ao pcm:file=somefile-resampled.wav somefile.wav

so, once again, what does this "rate" exactly do?
Reply With Quote
Old 1st June 2009
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,062
Thanked 198 Times in 156 Posts
Default

-srate is sample rate:
http://en.wikipedia.org/wiki/Sample_rate
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Old 1st June 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

The conversion software you used on Windows created a broken file, now that you know 44100 Hz is the proper rate.. everything should be fine.

Quote:
Originally Posted by mplayer(1)
-srate <Hz> Selects the output sample rate to be used (of course sound cards have limits on this). If the sample frequency selected is different from that of the current media, the resample or lavcresample audio filter will be inserted into the audio filter layer to compensate for the difference. The type of resampling can be controlled by the -af-adv option. The default is fast resampling that may cause distortion.
Reply With Quote
Old 2nd June 2009
BSDKaffee's Avatar
BSDKaffee BSDKaffee is offline
Real Name: Jason Hale
Coffee Addict
 
Join Date: May 2008
Location: Wintersville, Ohio
Posts: 212
Thanked 36 Times in 34 Posts
Default

Quote:
Originally Posted by BSDfan666 View Post
The conversion software you used on Windows created a broken file, now that you know 44100 Hz is the proper rate.. everything should be fine.
That doesn't seem to be the case. That file I asked gosha to download and test didn't appear to work properly either and it is 8000 Hz as well. Coming from a digital recorder which I presume is mostly intended for voice, 44100 Hz would be overkill and create much larger files. This sounds to me like a driver problem where the codec may not be able to handle 8000 Hz. 44100 Hz is popular since that is what audio CDs use and subsequently most ripped mp3s. Running the audio through a sound server like esd or arts might also "fix" things.

I also found an older somewhat relevant thread on the openbsd-ppc mailing list pertaining to this: http://archive.netbsd.se/?ml=openbsd...7-11&t=5745835. Depending on which driver is used, it appears resampling might be the best option.
Reply With Quote
Old 2nd June 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

Quote:
44100 Hz would be overkill and create much larger files.
yeah!
I didn't check when recoded the files, I just checked and, for example, a file went from 58.4 M to 322 M. That's quite too much. I think I'll listen to them with the -speed option

Or, I downloaded arts from the packages but can't really grasp what it is exactly and if it is worth the effort. I tried
Code:
artsplay filename.wav
and it plays fine, but to stop playing I have to kill the artsd process.
Question: would artsd allow me to have volume control?

I have quite a lot of files I would like to convert and be able to listen to anywhere.
How should I resample the files? I've read the man page of mplayer, but the relevant parts (option -af and resample) are a bit cryptic to me.
Reply With Quote
Old 2nd June 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

if it is of any help, this is the audioctl output:
Code:
$ audioctl -a             
name=AOA
version=
config=aoa
encodings=slinear:16,slinear_be:16,slinear_le:16*,ulinear_be:16*,ulinear_le:16*,mulaw:8*,alaw:8*,slinear:8*,ulinear:8*
properties=full_duplex
full_duplex=0
fullduplex=0
blocksize=2048
hiwat=8
lowat=1
output_muted=0
monitor_gain=0
mode=
play.rate=44100
play.channels=1
play.precision=16
play.encoding=slinear_be
play.gain=0
play.balance=32
play.port=0x2
play.avail_ports=0x3
play.seek=0
play.samples=0
play.eof=0
play.pause=0
play.error=0
play.waiting=0
play.open=0
play.active=0
play.buffer_size=32768
record.rate=44100
record.channels=1
record.precision=16
record.encoding=slinear_be
record.gain=0
record.balance=32
record.port=0x0
record.avail_ports=0x7
record.seek=0
record.samples=0
record.eof=0
record.pause=0
record.error=0
record.waiting=0
record.open=0
record.active=0
record.buffer_size=32768
record.errors=0
also, if I try to change the play.rate, it does not work:
Code:
$ audioctl play.rate=8000 
play.rate: -> 44100
does not work as root either.
Reply With Quote
Old 2nd June 2009
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 552
Thanked 14 Times in 13 Posts
Default

Quote:
Originally Posted by gosha View Post
yeah!
I didn't check when recoded the files, I just checked and, for example, a file went from 58.4 M to 322 M.
Note that (44.1/8) * 58.4 = 322 (approx.).

The idea that the file had originally been sampled at 44.1kHz and had a bad wav header identifying it as 8kHz never made sense to me because it didn't fit the originally described symptom. If such a file were played at the 8kHz instructed by a faulty wav header, then it would sound too slow (think: anti-chipmunk [apologies to David Seville] ) rather than too fast.

Quote:
I have quite a lot of files I would like to convert and be able to listen to anywhere.
How should I resample the files? I've read the man page of mplayer, but the relevant parts (option -af and resample) are a bit cryptic to me.
You could take a look at the sox package (the name stands for SOund eXchange). It is a very useful command-line utility that deals only with sound. I find the option syntax much less cryptic and faster to understand than mplayer. It can convert between audio files of different types, re-sample, play, record and many other things.

Last edited by IdOp; 2nd June 2009 at 03:23 PM. Reason: spelling
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Playing a CD. maxrussell FreeBSD General 2 22nd July 2009 07:24 PM
hard disk: avail 0 capacity 100% is it fine to use it like this? gosha General Hardware 13 17th June 2009 03:53 PM
A Brief History of the BSD Fast Filesystem, Kirk McKusick ai-danno Off-Topic 0 9th March 2009 05:59 AM
Network connection works fine, and then... snes-addict OpenBSD General 8 20th October 2008 11:13 PM
Score a free domain (it will be gone fast) 18Googol2 Off-Topic 8 15th August 2008 07:39 AM


All times are GMT. The time now is 07:07 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick