简体   繁体   English

如何从 Linux 上运行的 Free Pascal 应用程序播放 wav 文件?

[英]How do I play a wav file from a Free Pascal application running on Linux?

I have a multi-platform application written in Free Pascal.我有一个用 Free Pascal 编写的多平台应用程序。 This application plays a short sound on some event.此应用程序在某些事件上播放短促的声音。 On Windows, I can do this by MMSystem and sndPlaySound('sound.wav').在 Windows 上,我可以通过 MMSystem 和 sndPlaySound('sound.wav') 来做到这一点。 However, I don't know how to do this on Linux without external libraries.但是,我不知道如何在没有外部库的情况下在 Linux 上执行此操作。

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.我有一个使用 SDL 和 OpenAL 播放它的解决方案,但我不希望对这些库有任何依赖来播放一个简短的声音。 Does there exist a Linux command line player that exists on most distros by default?默认情况下,是否存在大多数发行版上都存在的 Linux 命令行播放器? The file format doesn't matter;文件格式无关紧要; I will convert it.我会转换它。

mplayer is command line and graphical. mplayer是命令行和图形。 You can start it on tty and pty.您可以在 tty 和 pty 上启动它。

You could try aplay, but that has a dependency on ALSA.您可以尝试 aplay,但这依赖于 ALSA。 Maybe sox?也许袜子?

The program mplayer - "the movie player" gives you the option to use a graphical user interface or to use the console.程序mplayer - "the movie player"为您提供了使用图形用户界面或使用控制台的选项。 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) ?您是否在寻找 BEEP、BLEEP、BOOP 和 BOP(以及低频屁)? Use sox.使用袜子。 If youre looking to play a file: use sox or SDL.如果您要播放文件:使用 sox 或 SDL。

You need a for looped array to get a sort-of piano effect, like a song.你需要一个 for 循环数组来获得一种钢琴效果,比如一首歌。 Its ugly, messy, and cant be tweaked much like the ole PC speaker, but its passable.它丑陋、凌乱,并且不能像 ole PC 扬声器那样进行调整,但还算过得去。

Beep is probably want you want, tho. Beep 可能是您想要的,不过。 Install the package, put one on your motherboard(YEAH...no hookup? use sox), and enable the pcspkr module.安装包,在你的主板上放一个(是的...没有连接?使用 sox),并启用 pcspkr 模块。 (On ubuntu its blacklisted by default.) If BEEP produces nothing, try sox. (在 ubuntu 上,它默认被列入黑名单。)如果 BEEP 没有产生任何结果,请尝试 sox。

At least youll have something.至少你会有一些东西。 Yes, you can check for loaded modules and installed packages.是的,您可以检查加载的模块和安装的包。 I believe Ive done both.我相信这两样我都做过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM