Skip to content
/ MP3 Public
forked from vincentcr/lame-wasm

lame mp3 encoding library wrapper, with binary compiled to web assembly

Notifications You must be signed in to change notification settings

code4fukui/MP3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MP3.js

MP3.js is a mp3 encoder ES module for web and Deno by JavaScript and WebAssembly forked from lame-wasm

demo

usage

import { MP3 } from "https://code4fukui.github.io/MP3/MP3.js";

const freq = 440;
const sampleRate = 44100;
const sec = 5;
const len = (sec * sampleRate) >> 0;
const vol = 0.5;

const buf = new Float32Array(len);
for (let i = 0; i < len; i++) {
  const th = (i * freq / sampleRate) * (2 * Math.PI);
  buf[i] = Math.sin(th) * vol;
}

const mp3bin = await MP3.encode([buf], {
  vbrQuality: 5, // 0-9 default 5
  sampleRate, // default 44100
  debug: true, // boolean
});
console.log(mp3bin, mp3bin.length);

dependencies

build

deno run -A https://code4fukui.github.io/bin2js/bin2js.js src/lame_native.wasm

About

lame mp3 encoding library wrapper, with binary compiled to web assembly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 47.9%
  • TypeScript 23.1%
  • C 13.0%
  • HTML 8.2%
  • Makefile 7.8%