boyhagemann/wave
Composer 安装命令:
composer require boyhagemann/wave
包简介
A php package to read WAV data
README 文档
README
This package can view metadata from a wave file. It also reads the data chunks and seperates it into multiple channels. Each channel has its own amplitude values. This is useful if you want to render a waveform for instance.
How to install
You can install with composer. Use a composer.json file with the following lines:
"minimum-stability": "dev", "require": { "boyhagemann/wave": "dev-master" }
How to use
First, let's make a wave object based on a wave file:
<?php use BoyHagemann\Wave\Wave; $wave = new Wave(); $wave->setFilename('path/to/your/file.wav');
After that, if the file turns out to be a valid wave file, you can get several metadata from it.
How a wave is made
A wave file is made out of chunks; packages of data. Each chunk has its own name, size and unique data. We are actually only interested in 2 types of chunk: the Fmt and the Data chunk.
Metadata (fmt chunk)
For instance, the "Fmt" chunk contains a description of the wave file contents. To get this metadata, you can enter these lines:
$metadata = $wave->analyze()->getMetadata(); $metadata->getName(); $metadata->getSize(); $metadata->getFormat(); $metadata->getChannels(); $metadata->getSampleRate(); $metadata->getBytesPerSecond(); $metadata->getBlockSize(); $metadata->getBitsPerSample(); $metadata->getExtensionSize(); $metadata->getExtensionData();
Data chunk
This chunk contains all the actual wave data. It is build up in packages of several bytes, depending on the number of channels the wave has. All analyzed data is stored in seperate channels, depending on the number of channels of the file. To get the raw amplitudes of a file, do the following:
// Assuming we already analyzed the wave... $data = $wave->getWaveformData(); // Get the amplitude values for each channel foreach($data->getChannels() as $channel) { $amplitudes[] = $channel->getValues(); }
Analyzing
The analyzing process can be a hefty one. Normally, you scan every package in the data chunk. It can use all your php processing power and can quickly result in a maximum execution time error. To prevent this, you can set the level of detail for analysing the data. You can set the number of steps between the packages that are to be analyzed. The greater the steps, the faster the script will run. The smaller the steps, the more accurate the waveform will be. By default, the steps are set to 100, but you can alter this easily:
$wave->setSteps(10000);
boyhagemann/wave 适用场景与选型建议
boyhagemann/wave 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 220.23k 次下载、GitHub Stars 达 22, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「audio」 「waveform」 「chunk」 「wave」 「riff」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 boyhagemann/wave 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 boyhagemann/wave 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 boyhagemann/wave 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Audio waveform generator on PHP with SoX
A php package that can generate waveforms based on a WAV file
Library for manipulating audio files (validating, transcoding, and tagging)
A php package to read WAV data
Waveform generator for php 7.0
A php package to read WAV data
统计信息
- 总下载量: 220.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 24
- 点击次数: 22
- 依赖项目数: 3
- 推荐数: 3
其他信息
- 授权协议: Unknown
- 更新时间: 未知