Linux play wav files

mpc / mpd on linux: how to play local wav file

I am trying to add a local file to mpd ( through mpc ) and play it . my platform is OpenWRT embedded linux . so, from the man page, it states:

mpc add Add a song to the current playlist 
root@OpenWrt:~/.mpd# mpc add /usr/share/baresip/ring.wav error adding /usr/share/baresip/ring.wav: directory or file not found 
root@OpenWrt:~/.mpd# mpc add file:///usr/share/baresip/ring.wav error adding file:///usr/share/baresip/ring.wav: Access denied 

Check out this thread: ubuntuforums.org/showthread.php?t=2105007 It says something about updating your database.

2 Answers 2

Your second attempt was almost right. The problem you had was that mpd will only allow file: URLs to be passed to it via a local connection, which it enforces by requiring you to connect on its unix-domain socket. So, in your mpd.conf you need to have a line like this:

bind_to_address "/run/mpd/socket" 

(depending on your system you may want to change /run to /var/run — the version I quote is correct for recent versions of debian or ubuntu but others may be different).

Then, you need to set up your environment to point to that socket:

export MPD_HOST=/run/mpd/socket 

when you do this, mpc add or mpc insert can successfully accept a file: URL:

$ mpc insert "file:///data/incoming/files/111_scorpions_-_the_zoo.mp3" $ mpc next Scorpions - The Zoo [playing] #23/39 0:00/5:30 (0%) volume: n/a repeat: off random: off single: off consume: off $ 

On a mac with mpd installed through brew, I can’t look up the unix socket in the typical /private/var/run location or anywhere else in the system. Should I look into generating a unix socket myself?

@SviatoslavZalishchuk — yes; without an mpd.conf file (and as far as I can see the install script for ‘brew’ doesn’t produce one) it will default to not generating a unix socket; you’ll need to create a config file and tell it where to put the socket.

Thanks for the prompt reply. Btw, is there a way to generate it from the shell? Or it can only be done through system layer with C/python/etc.

with an appropriate config file (see github.com/andrewrk/mpd/blob/master/doc/mpdconf.example for an example file to start from and man mpd.conf for documentation), mpd will create the socket itself.

Читайте также:  Linux lite based on

Yep, it did indeed. Previously when I tried to write that into /private/var/run/mpd.socket it apparently failed due to insufficient permissions, but gave «Connection Refused» instead. I have configured that to write the socket into user’s home directory, set MPD_HOST, MPD_PORT variables to be exported in my .bashrc, so that they could be picked up by mpc and referenced in ncmpcpp. Now everything is in order, ncmpcpp manages the playlist and I configured ranger to open audio mime type files with mpc by default using the «mpc insert «/path/» && mpc next» trick. Thank you, Jules!

i did not find out how to play wav..but i forgot i found the solution (for mp3) and posted it here: https://forum.openwrt.org/viewtopic.php?id=41022

however, since stackoverflow always shows up top on google search i am pasting the same solution here in case it helps someone as well :

/etc/mpd.conf should be something approximately like this:

music_directory "/tmp" playlist_directory "~/.mpd/playlists" db_file "~/.mpd/database" log_file "/tmp/mpdlog" pid_file "~/.mpd/pid" state_file "~/.mpd/state" sticker_file "~/.mpd/sticker.sql" user "root" group "root" bind_to_address "127.0.0.1" log_level "verbose" auto_update "yes" auto_update_depth "3" follow_outside_symlinks "yes" follow_inside_symlinks "yes" 
  1. /etc/init.d/mpd restart
  2. copy MP3 ( wav does not seem to work ) file to /tmp folder ( because music directory is the /tmp folder )
  3. mpc update
  4. mpc add file.mp3 ( adding /tmp/file.mp3 will NOT work )
  5. mpc play

Источник

How to Listen to WAV Files on Ubuntu

There are a number of available media file types all over the internet, each of them having their own features and disadvantages. Thanks to the community that powers the Linux platform, there are a number of available apps that are able to play the majority of them for you.

What is WAV?

WAV (Waveform Audio File Format) is an audio file format. WAV is an IBM and Microsoft standard file format for storing an audio bitstream on the PC platform. There are a lot of available unpopular file formats and WAV is one of them.

Using WAV files hold a few disadvantages. For example, WAV file format has a size limitation – up to 4GB. Some programs even lower the limit – up to 2GB. Uncompressed WAV files also tend to be larger, making them not suitable for sharing over the internet. However, for retaining the sound quality, WAV is very powerful. That’s why it’s only used when disk space isn’t a bottleneck.

However, there are a number of media players you can use to play a WAV file.

Playing WAV file

For playing a WAV file, there are a number of available players. Check out the best media players for Ubuntu. Almost all the media players are available for other Linux distros as well. WAV, despite not being used as widely as MP3 or others, all the players in the list supports the file format. You won’t have any trouble listening to WAV files.

Читайте также:  Основные характеристики ос linux кратко

In the following demo, I’ll be using Rhythmbox – one of the most popular music players for Linux distros. Start Rhythmbox –

Now, go to File >> Add Music. You can also use the keyboard shortcut “Ctrl + O”.

Search for the WAV music file you need to listen to.

The music is there! Select the music and click the “Play” button.

Voila! Enjoy your favorite music!

Источник

Play MP3 or WAV file via the Linux command line

Solution 1: If you want to use the App set as preferred, from the directory containing the MP3 file, use : From : If you know the application you want the MP3 file to be opened with, for example, : or VLC media player: Solution 2: means «change directory». You can install it in Ubuntu with: Solution 2: The command from the package will play any file format supported by using the default audio device, e.g You may need to install extra packages to gain support for all formats, for example on Ubuntu 11.04 the MP3 support is not available until you install .

Play MP3 or WAV file via the Linux command line

mpg123 is a command-line utility which plays mp3 files. You can install it in Ubuntu with:

sudo apt-get install mpg123 

The play command from the sox package will play any file format supported by sox using the default audio device, e.g

$ play something.mp3 $ play something.wav 

You may need to install extra packages to gain support for all formats, for example on Ubuntu 11.04 the MP3 support is not available until you install libsox-fmt-mp3 .

The most standard way to play a WAV file in Linux is using the aplay command, which is part of the ALSA system.

aplay [flags] [filename [filename]] . aplay a.wav 

Links: (Wikipedia) (aplay man page)

(Both in Fedora and in Ubuntu/Mint it is part of the alsa-utils package)

This does not require any additional packages to your Linux installation like sox or mplayer or vlc, just the basic ALSA which is a part of any system nowadays.

Batch convert mp3 files to wav using sox, It sounds like you’re running into a problem with spaces in the filename. If you have a file named «My Greatest Hits.mp3», your command will

Play MP3 or WAV file via the Linux command line (10 Solutions!!)

Convert mp3 file to wav? using the command line?

Using ffmpeg — installed by default
ffmpeg -i input.mp3 output.wav 
Alternative — mpg123
sudo apt-get install mpg123 
mpg123 -w output.wav input.mp3 

Playing Audio Files From the Linux Command Line, Learn to play audio files from the Linux command line. MP3, Ogg Vorbis, Musepack, MPEG-4/AAC, FLAC, ALAC, WavPack, Wav, and WMA.

Читайте также:  Linux com port driver

Play sound in someone else’s session from command line

make sure the target computer is on, or you are able wake it from the LAN, log in via SSH, and run the command. You might have to scp those executables necessary to invoke the command.

Or, show him how laptops have sleep settings.

Log in to his computer by ssh. In his computer, do the following commands.

sudo apt-get update sudo apt-get install festival echo "Wake up, anvil brain. Turn off the computer. Now!" | festival --tts 

Read audio file — MATLAB audioread, load handel.mat filename = ‘handel.flac’; audiowrite(filename,y,Fs);. Read only the first 2 seconds and specify the data and

Which command should I use to open an MP3 file?

If you want to use the App set as preferred, from the directory containing the MP3 file, use xdg-open :

xdg-open - opens a file or URL in the user's preferred application 

If you know the application you want the MP3 file to be opened with, for example, rhythmbox :

cd means «change directory». A file is not a directory so a cd will not work on your mp3. To open a `.mp3 you need to start a music or video player. The method @heemayl uses will open the player you have set as the default.

If you want you can also use aplay . The command

will play the mp3 from command line and stop when it is done playing. «aplay» is probably the lightest music player around since it does not have a GUI (and can also work on a server >:-D )

If you want to run an MP3 file with a particular application, then run it like:

 application_name audio_file_name 

For example, if you want to run in the MPlayer application then install it using:

 sudo apt-get install mplayer 

Then run the audio file using the command:

 sudo apt-get install mpg123 mpg123 abcd.mp3 
 sudo apt-get install sox play abcd.mp3 
sudo apt-get install vlc vlc abcd.mp3 

How can I play a sound from the command line in macOS?, There is a built-in tool: afplay . The man page does not document all of its options, which can be found via afplay -h :

Источник

Оцените статью
Adblock
detector