跨平台游戏声音API ?

时间:2022-05-31 02:37:54

Is there an API only for sound?

是否只有声音API ?

APIs such as Allegro or SDL provide too much for my needs. I simply need a library that can do something like:

诸如Allegro或SDL之类的api为我提供了太多的需求。我只需要一个可以做类似事情的库:

InitSound();
Sound *door = LoadSound("door.wav");
PlaySound(door,volume);

It would also be great if it could support compressed formats such as Vorbis or MP3.

如果它能够支持诸如Vorbis或MP3之类的压缩格式,那也很好。

11 个解决方案

#1


18  

I'm a big fan of the SFML library. It does provide additional graphics and network features, but what is relevant to this question, is that it also has neat audio package.

我是SFML库的超级粉丝。它确实提供了额外的图形和网络特性,但是与这个问题相关的是,它也有整洁的音频包。

Audio features are:

音频特性:

  • Uses hardware acceleration whenever possible
  • 尽可能使用硬件加速。
  • Can load and save standard sound formats: Ogg, WAV, FLAC, AIFF, Au, RAW, paf, 8SVX, NIST, VOC, IRCAM, W64, MAT4, MAT5 PVF, HTK, SDS, AVR, SD2, Core Audio Format, WVE, MPC2K, RF64
  • 可以加载和保存标准的声音格式:Ogg、WAV、FLAC、AIFF、Au、RAW、paf、8SVX、NIST、VOC、IRCAM、W64、MAT4、MAT5 PVF、HTK、SDS、AVR、SD2、Core Audio格式、WVE、MPC2K、RF64
  • Can load all audio resources directly from files in memory
  • 可以直接从内存中的文件加载所有音频资源
  • 3D sound spacialization
  • 3 d声音spacialization
  • Easy interface for capturing audio
  • 轻松的界面捕捉音频
  • Manages memory efficiently, so that you don't have to worry about resources lifetime or storage
  • 有效地管理内存,这样您就不必担心资源的生命周期或存储
  • Supports streaming for big files; you can even write your custom streaming class for any source (network, ...)
  • 支持大文件的流媒体;您甚至可以为任何源(网络,…)编写您的自定义流类。
  • Supports multi-channels formats (mono, stereo, 4.0, 5.1, 6.1, 7.1)
  • 支持多通道格式(单声道、立体声、4.0、5.1、6.1、7.1)

Website: http://www.sfml-dev.org/

网站:http://www.sfml-dev.org/

#2


11  

Use PortAudio. It is a portable cross-platform audio API.

使用PortAudio。它是一个便携式的跨平台音频API。

#3


8  

If you are use to using OpenGL then you might like to try OpenAL?

如果您习惯使用OpenGL,那么您可能想尝试OpenAL?

The API is very similar to OpenGL so you should feel at home.

API与OpenGL非常相似,所以您应该感觉很自在。

#4


3  

I really like SFML, it's written in C++ and follows most of the rules of good API design (RAII and so forth).

我非常喜欢SFML,它是用c++编写的,并且遵循良好API设计的大多数规则(RAII等)。

If you prefer a more "C-like" library, SDL needs to be mentioned.

如果您更喜欢“C-like”库,则需要提到SDL。

#5


2  

SDL_sound is very simple to use, and handles the decoding for you. If you used OpenAL, you would have to do the decoding yourself (last I used it, anyway). I actually prefer OpenAL for games, though.

SDL_sound非常简单,可以为您处理解码。如果你使用OpenAL,你将不得不自己进行解码(最后一次使用它,无论如何)。我更喜欢OpenAL的游戏。

#6


1  

You may want to have a look at the Kowalski project, a cross platform audio API geared towards games and similar interactive applications. It's released under the zlib license.

您可能想看看Kowalski项目,一个面向游戏和类似的交互应用的跨平台音频API。它是在zlib许可下发布的。

#7


1  

If you are looking for a professional cross-platform sound design API and authoring application, take a look at Audiokinetic Wwise. It can do much more than just play sounds. It has effects, complex sound logic system, sound layering, profiling, interactive music tools, etc... It provides Ogg Vorbis and MP3 support, and it is free for non-commercial projects.

如果您正在寻找一个专业的跨平台声音设计API和编写应用程序,请查看Audiokinetic Wwise。它不仅仅能播放声音。它有效果,复杂的声音逻辑系统,声音分层,剖析,互动音乐工具等。它提供Ogg Vorbis和MP3支持,并且它是免费的非商业项目。

#8


1  

Although it is only free for non-commercial applications, Bass is really easy to implement.

虽然它只对非商业应用程序是免费的,但是Bass确实很容易实现。

Example of usage:

使用的例子:

// initialize device at 44kHz
if (!BASS_Init(-1,44100,0,0,NULL))
{
    printf("Can't initialize device");
    return 0;
}

HSAMPLE sample;
HCHANNEL channel;

// load from disk
if( sample = BASS_SampleLoad(FALSE,"foo.wav",0,0,1,BASS_SAMPLE_OVER_POS) ) {

    // get playable channel
    channel = BASS_SampleGetChannel( sample,FALSE);

    // play
    BASS_ChannelPlay(channel,TRUE);

    // wait for playback to finish
    while( BASS_ChannelIsActive( channel ) )
         Sleep(100);

   BASS_SampleFree(sample);
}

// cleanup
BASS_Free();

#9


1  

Consider libsoundio. It does not support compression or codecs, but it does provide a robust cross platform sound API. It might be a bit low level for your needs; the library you're looking for might be built on top of libsoundio.

考虑libsoundio。它不支持压缩或编解码器,但它确实提供了一个健壮的跨平台声音API。它可能对你的需求来说有点低;您正在寻找的库可能构建在libsoundio之上。

#10


1  

I know it's an old question but anyone stumbling upon this now might like to check out FMOD

我知道这是一个古老的问题,但任何现在偶然发现这个问题的人都可能想看看FMOD

You can make use of the low-level API to start simple then make use of the more powerful features (and FMOD Studio) later-on if required.

如果需要,您可以使用低级API开始简单,然后使用更强大的特性(以及FMOD Studio)。

Here's the documentation for playing a sound, which references the samples in the API:

下面是播放声音的文档,它引用了API中的示例:

This example shows how to simply load and play multiple sounds, the simplest usage of FMOD.

这个例子展示了如何简单地加载和播放多个声音,这是FMOD最简单的用法。

I used this low-level API for a cross platform (Mac, Windows) Space Invaders clone I developed and found it very useful!

我使用这个底层的API来开发一个跨平台(Mac, Windows)的空间入侵者,我发现它非常有用!

#11


0  

Try libao http://www.xiph.org/ao/ - its very simple & supports variety of platforms. I tried it on a raspberry pi with success.

试试libao http://www.xiorg/ao/ -它非常简单,支持各种平台。我成功地在覆盆子派上尝试过。

#1


18  

I'm a big fan of the SFML library. It does provide additional graphics and network features, but what is relevant to this question, is that it also has neat audio package.

我是SFML库的超级粉丝。它确实提供了额外的图形和网络特性,但是与这个问题相关的是,它也有整洁的音频包。

Audio features are:

音频特性:

  • Uses hardware acceleration whenever possible
  • 尽可能使用硬件加速。
  • Can load and save standard sound formats: Ogg, WAV, FLAC, AIFF, Au, RAW, paf, 8SVX, NIST, VOC, IRCAM, W64, MAT4, MAT5 PVF, HTK, SDS, AVR, SD2, Core Audio Format, WVE, MPC2K, RF64
  • 可以加载和保存标准的声音格式:Ogg、WAV、FLAC、AIFF、Au、RAW、paf、8SVX、NIST、VOC、IRCAM、W64、MAT4、MAT5 PVF、HTK、SDS、AVR、SD2、Core Audio格式、WVE、MPC2K、RF64
  • Can load all audio resources directly from files in memory
  • 可以直接从内存中的文件加载所有音频资源
  • 3D sound spacialization
  • 3 d声音spacialization
  • Easy interface for capturing audio
  • 轻松的界面捕捉音频
  • Manages memory efficiently, so that you don't have to worry about resources lifetime or storage
  • 有效地管理内存,这样您就不必担心资源的生命周期或存储
  • Supports streaming for big files; you can even write your custom streaming class for any source (network, ...)
  • 支持大文件的流媒体;您甚至可以为任何源(网络,…)编写您的自定义流类。
  • Supports multi-channels formats (mono, stereo, 4.0, 5.1, 6.1, 7.1)
  • 支持多通道格式(单声道、立体声、4.0、5.1、6.1、7.1)

Website: http://www.sfml-dev.org/

网站:http://www.sfml-dev.org/

#2


11  

Use PortAudio. It is a portable cross-platform audio API.

使用PortAudio。它是一个便携式的跨平台音频API。

#3


8  

If you are use to using OpenGL then you might like to try OpenAL?

如果您习惯使用OpenGL,那么您可能想尝试OpenAL?

The API is very similar to OpenGL so you should feel at home.

API与OpenGL非常相似,所以您应该感觉很自在。

#4


3  

I really like SFML, it's written in C++ and follows most of the rules of good API design (RAII and so forth).

我非常喜欢SFML,它是用c++编写的,并且遵循良好API设计的大多数规则(RAII等)。

If you prefer a more "C-like" library, SDL needs to be mentioned.

如果您更喜欢“C-like”库,则需要提到SDL。

#5


2  

SDL_sound is very simple to use, and handles the decoding for you. If you used OpenAL, you would have to do the decoding yourself (last I used it, anyway). I actually prefer OpenAL for games, though.

SDL_sound非常简单,可以为您处理解码。如果你使用OpenAL,你将不得不自己进行解码(最后一次使用它,无论如何)。我更喜欢OpenAL的游戏。

#6


1  

You may want to have a look at the Kowalski project, a cross platform audio API geared towards games and similar interactive applications. It's released under the zlib license.

您可能想看看Kowalski项目,一个面向游戏和类似的交互应用的跨平台音频API。它是在zlib许可下发布的。

#7


1  

If you are looking for a professional cross-platform sound design API and authoring application, take a look at Audiokinetic Wwise. It can do much more than just play sounds. It has effects, complex sound logic system, sound layering, profiling, interactive music tools, etc... It provides Ogg Vorbis and MP3 support, and it is free for non-commercial projects.

如果您正在寻找一个专业的跨平台声音设计API和编写应用程序,请查看Audiokinetic Wwise。它不仅仅能播放声音。它有效果,复杂的声音逻辑系统,声音分层,剖析,互动音乐工具等。它提供Ogg Vorbis和MP3支持,并且它是免费的非商业项目。

#8


1  

Although it is only free for non-commercial applications, Bass is really easy to implement.

虽然它只对非商业应用程序是免费的,但是Bass确实很容易实现。

Example of usage:

使用的例子:

// initialize device at 44kHz
if (!BASS_Init(-1,44100,0,0,NULL))
{
    printf("Can't initialize device");
    return 0;
}

HSAMPLE sample;
HCHANNEL channel;

// load from disk
if( sample = BASS_SampleLoad(FALSE,"foo.wav",0,0,1,BASS_SAMPLE_OVER_POS) ) {

    // get playable channel
    channel = BASS_SampleGetChannel( sample,FALSE);

    // play
    BASS_ChannelPlay(channel,TRUE);

    // wait for playback to finish
    while( BASS_ChannelIsActive( channel ) )
         Sleep(100);

   BASS_SampleFree(sample);
}

// cleanup
BASS_Free();

#9


1  

Consider libsoundio. It does not support compression or codecs, but it does provide a robust cross platform sound API. It might be a bit low level for your needs; the library you're looking for might be built on top of libsoundio.

考虑libsoundio。它不支持压缩或编解码器,但它确实提供了一个健壮的跨平台声音API。它可能对你的需求来说有点低;您正在寻找的库可能构建在libsoundio之上。

#10


1  

I know it's an old question but anyone stumbling upon this now might like to check out FMOD

我知道这是一个古老的问题,但任何现在偶然发现这个问题的人都可能想看看FMOD

You can make use of the low-level API to start simple then make use of the more powerful features (and FMOD Studio) later-on if required.

如果需要,您可以使用低级API开始简单,然后使用更强大的特性(以及FMOD Studio)。

Here's the documentation for playing a sound, which references the samples in the API:

下面是播放声音的文档,它引用了API中的示例:

This example shows how to simply load and play multiple sounds, the simplest usage of FMOD.

这个例子展示了如何简单地加载和播放多个声音,这是FMOD最简单的用法。

I used this low-level API for a cross platform (Mac, Windows) Space Invaders clone I developed and found it very useful!

我使用这个底层的API来开发一个跨平台(Mac, Windows)的空间入侵者,我发现它非常有用!

#11


0  

Try libao http://www.xiph.org/ao/ - its very simple & supports variety of platforms. I tried it on a raspberry pi with success.

试试libao http://www.xiorg/ao/ -它非常简单,支持各种平台。我成功地在覆盆子派上尝试过。