百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

cmixer

> 编程语言
开源

用于游戏的便携式 ANSI C 音频混音器

197 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于游戏的便携式 ANSI C 音频混音器

cmixer

A lightweight, portable ANSI C audio mixer for games.

Features

  • Easy to use
  • Tiny: two files, around 600sloc
  • No dependencies (stb_vorbis is optional)
  • Support for wav and ogg files if stb_vorbis is used
  • Simple API for adding custom formats
  • Resampling and seamless looping
  • Per-source gain, pan and pitch control
  • Fast, fixed-point internal processing

Getting Started

The library's .c and .h files can be dropped into a project and compiled along with it. If ogg vorbis support is desired stb_vorbis.c should also be added to the project and the -DCM_USE_STB_VORBIS flag passed to the compiler.

Before use, the library should be initialized with the desired samplerate:

c
cm_init(44100);

A sound can be played by first creating a source, then calling cm_play() on that source.

c
cm_Source *src = cm_new_source_from_file("sound.wav");
cm_play(src);

When the cm_process() function is called, all the currently playing streams will be processed and mixed, the master output will be written to the provided 16bit buffer. This output is always stereo interlaced, thus the buffer length must always be an even number:

c
cm_Int16 buffer[512];
cm_process(buffer, 512);

cm_process() can safely be called from a separate thread; if more than one thread is used a lock event handler must be set:

c
static void lock_handler(cm_Event *e) {
  if (e->type == CM_EVENT_LOCK) {
    printf("acquired lock\n");
  }
  if (e->type == CM_EVENT_UNLOCK) {
    printf("released lock\n");
  }
}

cm_set_lock(lock_handler);

See doc/api.md for an overview of the API or demo for usage demos.

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言