How do I play a wav file from a Free Pascal application running on Linux? - linux

I have a multi-platform application written in Free Pascal. This application plays a short sound on some event. On Windows, I can do this by MMSystem and sndPlaySound('sound.wav'). However, I don't know how to do this on Linux without external libraries.
I have a solution to play it with SDL and OpenAL, but I don't want any dependency on these libraries to play one short sound. Does there exist a Linux command line player that exists on most distros by default? The file format doesn't matter; I will convert it.

mplayer is command line and graphical. You can start it on tty and pty.

You could try aplay, but that has a dependency on ALSA. Maybe sox?

The program mplayer - "the movie player" gives you the option to use a graphical user interface or to use the console. So i would imagine it has a solution to your problem.

Are you looking to BEEP, BLEEP and BOOP and BOP ( and low frequency fart) ? Use sox. If youre looking to play a file: use sox or SDL.
You need a for looped array to get a sort-of piano effect, like a song. Its ugly, messy, and cant be tweaked much like the ole PC speaker, but its passable.
Beep is probably want you want, tho. Install the package, put one on your motherboard(YEAH...no hookup? use sox), and enable the pcspkr module. (On ubuntu its blacklisted by default.) If BEEP produces nothing, try sox.
At least youll have something. Yes, you can check for loaded modules and installed packages. I believe Ive done both.

Related

How to play an AIFF sound file using Erlang?

I am trying to look for a way to play an AIFF file using Erlang.
I have found this tutorial, but it seems to be only about reading the content of the file and not actually playing it.
I suggest using the linux command "play" with "os:cmd" or "ports". It is quite ad-hoc but it is not a very uncommon command and it may do the trick.

How to play sound in lua

How to play sound in lua? Is there any simple trick how to do it?
My goal is to play some ogg (or mp3) files during playing my game, which is programmed in lua. It's running on windows.
Lua does not have any built-in sound APIs. As you are on Windows, you have these options:
Write bindings for a sound system of choice (OpenAL or something more high-level — as a separate non-Lua-specific question if you need help picking one).
Use LuaJIT2 FFI to directly access DLL functions of the sound system of choice.
Otherwise, if you do not use LuaJIT2, use Alien FFI library.
Or, indeed, use LuaCOM to play some sound (with DirectSound?), if you're familiar with COM stuff.
Lua doesn't have any native sound APIs. If there is a plugin/extension for Lua to accomplish audio control/playback, you'd have to go dig that up seperately. Or if Lua supports COM, you could speak to the Windows audio facilities directly.
proteaAudio is a pretty easy library for lua to play audio or even generate audio on the fly.
You can use the Corona library:
--Loads the selected audio (make sure the name is the same as the .wav file)
local audio1 = audio.loadSound( "audio1.wav" )
--Plays the audio on any available channel (theres up to 32 channels)
local audio1Channel = audio.play( audio1 )
source: http://docs.coronalabs.com/api/library/audio/play.html
In windows, use luacom
require('luacom').CreateObject("wmplayer.ocx").URL="my.mp3"--Need to keep host process alive, not to close.

Capturing audio input from microphone, with Haskell?

Is there a mature library that could enable audio input and output and work within Haskell? (A nice wrapper is fine, of course.)
I'm looking for something that can easily capture microphone input and, perhaps, play various audio files as well.
easily capture microphone input and, perhaps, play various audio files as well..
It will strongly depend on your OS platform: there are standard C libraries for this functionality on each OS, and you'll be looking for Haskell bindings to them (e.g. PulseAudio, etc). Look in the Sound category on Hackage:
http://hackage.haskell.org/packages/archive/pkg-list.html#cat:sound
E.g. HSndFile for audio file writing, http://hackage.haskell.org/package/HSoundFile
the module pulse-simple exposes bindings to capture sound from the microphone, see the second example at the top of the page;
https://hackage.haskell.org/package/pulse-simple-0.1.13/docs/Sound-Pulse-Simple.html
pulse audio libraries required by cabal are obtainable via cygwin (search "pulse" in the cygwin installer).
there is a also binding to sox, which looks promising.
https://hackage.haskell.org/package/sox
im sure there are other api wrappers to be found in hackage sound category.
for linux there is a binding to jack, has "unix" as a dependency, it WILL NOT build on windows...
Just in case you're not familiar with hackage: http://hackage.haskell.org/packages/archive/pkg-list.html
It looks like there is some audio-related stuff there. Not sure if there is anything that will meet your needs. But most "mature" haskell libraries will be there.
You can do it with OpenAL and ALUT. I managed to install both on Windows 8, although it wasn't exactly effortless; ALUT requires the underlying C library to be compiled manually into a DLL.
Installing OpenAL - on the other hand - is as simple as downloading the SDK and typing cabal install OpenAL in the command prompt.
With ALUT, you can create OpenAL buffers from audio files (including WAV) and memory views.
I found an example of recording and audio playback here. It should be fairly straightforward to adapt the code to your needs.
Let me know if I left something out and I'll try to elaborate.

How do I De-Ess a sound file with SoX?

I am using SoX to create slow but pitch corrected audio files. The resulting files sound pretty good, but often have a very hard "S" sound that I would like to filter out. Many desktop programs include a "De-Essing" filter that works well, but I would like to have a filter that works on the server side.
What SoX filter and parameters should I use to De-Ess an audio file?
Edit: I should add that this needs to work on Linux.
There is a LADSPA DeEsser plugin that can be used from SoX. You need to have tap plugins installed and properly configured on your system. On Archlinux this can be easily achieved with
pacman -S tap-plugins
You can specify threshold and frequency as first and second arguments. I succesfully used a variant of the following command
# -30: threshold (dB)
# 6200: hiss frequency (Hz)
sox from.wav to.wav ladspa tap_deesser tap_deesser -30 6200
The filter has a fistful of other options I did not analyzed. More details can be found here.
While far from perfect, you may be able to get sufficient results by a suitable low-pass filter. That should not affect other parts of a speech signal too much.
You could use a de-esser VST such as spitfish and a command-line VST host such as MissWatson. Sox has very limited plugin support, so if you need something more specific, you're better off going the VST route.

How to programmatically create videos?

Is there a freely available library to create a MPEG (or any other simple video format) out of an image sequence ?
It must run on Linux too, and ideally have Python bindings.
I know there's mencoder (part of the mplayer project), and ffmpeg, which both can do this.
ffmpeg is a great (open source) program for building all kinds of video, and converting one type of video (a sequence of images in this case) into other types of video.
Usually it is utilized from the command line, but that is really just a wrapper around its internal libraries. It is expressly available to be used from within another program.
There are also python bindings that wrap the c api, though this particular project doesn't seem to be getting the best support (there are probably other projects out there doing the same thing).
There's also this link where someone has used ffmpeg to do something similar to what you're looking for.
GStreamer is a popular choice. It's a full multimedia framework much like DirectShow or QuickTime, has the advantage of having legally licensed codecs available, and has excellent Python bindings.
in c++ OpenCV (open source Computer Vision library from Intel) let you create an AVI file and just push frames inside...
but it's like shooting with a cannon to a fly.
Not a library, but mplayer has the ability to encode JPEG sequences to any kind of format. It runs on Linux, Windows, BSD and other platforms and you can write a python script if you want to use it with python.
ffmpeg has an API and also python bindings, seems to be the way to go !
Thanks
ffmpeg minimal runnable C example
I have provided a full runnable example at: How to resize a picture using ffmpeg's sws_scale()?

Resources