{"_id":"@_mehrad/lamejs","_rev":"1-4489c78834bb37bbf07905a55cafb4d7","name":"@_mehrad/lamejs","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.1":{"name":"@_mehrad/lamejs","version":"1.2.1","description":"Pure JavaScript MP3 Encoder","main":"src/js/index.js","directories":{"doc":"doc","test":"test"},"scripts":{"test":"node src/js/Tests.js"},"repository":{"type":"git","url":"git+https://github.com/zhuker/lamejs.git"},"keywords":["mp3","encoder","audio","webaudio"],"author":{"name":"Alex Zhukov"},"license":"LGPL-3.0","bugs":{"url":"https://github.com/zhuker/lamejs/issues"},"homepage":"https://github.com/zhuker/lamejs#readme","dependencies":{"use-strict":"1.0.1"},"gitHead":"8955f41dcae36ca3ad3688931292a175db403245","_id":"@_mehrad/lamejs@1.2.1","_nodeVersion":"14.19.0","_npmVersion":"6.14.16","dist":{"integrity":"sha512-D3ol8omO95b4rNWjmOmwTn8nH5ndOZsoVR/Zng0XEE41lK7CZGSz7cHUy4C/ncSI5s12o5OKocfRAPGqfZDVYQ==","shasum":"c2cf76a8d48552e4ff61042c009f08f34475e9da","tarball":"https://registry.npmjs.org/@_mehrad/lamejs/-/lamejs-1.2.1.tgz","fileCount":146,"unpackedSize":6458580,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiPaxYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoj1Q//c8C3D8B87NVa21TiMD+VdvSwVgB6Ctf/0eQJzL216gQBcwOG\r\nqnLAh2R8WpAckFstI3B+++hNpCVeYqkUXj0L/R3SEOjlsiTu5y+JZPM3Fg17\r\nIERwmWSTMpwbwp9oLVj+i6r+HIW+rBmDj+RhJ75Jew1lTgPiSwMmE89qOfcw\r\nKAW8GhOccWloDDWuUk7wPH7mvCZptJA4EfWxTqPoqvRu3LWbM/ifD15dr1sw\r\nZ8+yPD34rWAIfEAe9+V//LH3252uVkZ4ftBB5MKlUAxT/MKnyYrMNjX6LlGM\r\nUmHsn1/n6QB8NBqgewLSinQKCejY9t8drj1B81aGvVaGNF2d7dEvwhaDJt4G\r\n6QkY0+X4t077kKxKyLiOfoqsL2RGpe0cYJVfampFg+y3nX4q6D51MBsRX0SB\r\nw54Qsgq+ubm7KYHN22zvh+GN8jC75SABPG1N83hYoyNVf5UhCRDE2JS3oEr4\r\n365YCHMhDd4QaF0eSTzm0mzVywE3R4lIlC8aHJSC2US/Y5ZxXZDSfmOXxL6b\r\nilzp5PBqwRy3a1/0EPk0Z6r66zagGJH2KmeoAIqRer0Q3qLEimtJGtN2Pod2\r\nI1IPVgI2AIUayqlGMwRYLQXYcjefXoY9R1TGtuDUCvQCPEIdwuQ09vrjCZEP\r\noDWm7eQUNp+e80JecxQZYJnqgQQ1Q4nmKY4=\r\n=HRBr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHoCq4urY4mYWpvdp0+mj8oohuXDu45yh7auigZM4LquAiATSJ5Vy5PSsoeCu42MOq/JYTAA5M9HZdI/Q5PoA14NxA=="}]},"_npmUser":{"name":"_mehrad","email":"mehrad.meraji@gmail.com"},"maintainers":[{"name":"_mehrad","email":"mehrad.meraji@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lamejs_1.2.1_1648208984513_0.5301876202200511"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-25T11:49:44.452Z","1.2.1":"2022-03-25T11:49:44.750Z","modified":"2022-04-04T10:51:32.782Z"},"maintainers":[{"name":"_mehrad","email":"mehrad.meraji@gmail.com"}],"description":"Pure JavaScript MP3 Encoder","homepage":"https://github.com/zhuker/lamejs#readme","keywords":["mp3","encoder","audio","webaudio"],"repository":{"type":"git","url":"git+https://github.com/zhuker/lamejs.git"},"author":{"name":"Alex Zhukov"},"bugs":{"url":"https://github.com/zhuker/lamejs/issues"},"license":"LGPL-3.0","readme":"# lamejs\nFast mp3 encoder written in JavaScript.\nOn my machine it works 20x faster than realtime (it will encode 132 second long sample in 6.5 seconds) both on node and chrome.\nlamejs is a rewrite of jump3r-code which is a rewrite of libmp3lame.\n\n## Installation\n\nTo install via Bower or npm, simply do the following:\n\n```bash\n$ bower install lamejs --save\n```\n\n```bash\n$ npm install lamejs\n```\n\n# Quick Start\n\n```javascript\n<script src='lame.all.js'></script>\n<script>\nvar mp3Data = [];\n\nvar mp3encoder = new lamejs.Mp3Encoder(1, 44100, 128); //mono 44.1khz encode to 128kbps\nvar samples = new Int16Array(44100); //one second of silence replace that with your own samples\nvar mp3Tmp = mp3encoder.encodeBuffer(samples); //encode mp3\n\n//Push encode buffer to mp3Data variable\nmp3Data.push(mp3Tmp);\n\n// Get end part of mp3\nmp3Tmp = mp3encoder.flush();\n\n// Write last data to the output data, too\n// mp3Data contains now the complete mp3Data\nmp3Data.push(mp3Tmp);\n\nconsole.debug(mp3Data);\n</script>\n```\n\nTo use lamejs in Node.js build, you can install it from `npm`:\n\n```\nnpm install lamejs\n```\n\nThen use it:\n\n```\nvar lamejs = require(\"lamejs\");\n```\n\n# Real Example\n\nEither see [example.html](https://github.com/zhuker/lamejs/blob/master/example.html) for full example of wav file encoding in browser or use this:\n\n```javascript\n<script src='lame.all.js'></script>\n<script>\nchannels = 1; //1 for mono or 2 for stereo\nsampleRate = 44100; //44.1khz (normal mp3 samplerate)\nkbps = 128; //encode 128kbps mp3\nmp3encoder = new lamejs.Mp3Encoder(channels, sampleRate, kbps);\nvar mp3Data = [];\n\nsamples = new Int16Array(44100); //one second of silence (get your data from the source you have)\nsampleBlockSize = 1152; //can be anything but make it a multiple of 576 to make encoders life easier\n\nvar mp3Data = [];\nfor (var i = 0; i < samples.length; i += sampleBlockSize) {\n  sampleChunk = samples.subarray(i, i + sampleBlockSize);\n  var mp3buf = mp3encoder.encodeBuffer(sampleChunk);\n  if (mp3buf.length > 0) {\n      mp3Data.push(mp3buf);\n  }\n}\nvar mp3buf = mp3encoder.flush();   //finish writing mp3\n\nif (mp3buf.length > 0) {\n    mp3Data.push(new Int8Array(mp3buf));\n}\n\nvar blob = new Blob(mp3Data, {type: 'audio/mp3'});\nvar url = window.URL.createObjectURL(blob);\nconsole.log('MP3 URl: ', url);\n</script>\n```\n\n# Stereo\n\nIf you want to encode stereo mp3 use separate sample buffers for left and right channel\n\n```javascript\n<script src='lame.all.js'></script>\n<script>\nmp3encoder = new lamejs.Mp3Encoder(2, 44100, 128);\nvar mp3Data = [];\n\nleft = new Int16Array(44100); //one second of silence (get your data from the source you have)\nright = new Int16Array(44100); //one second of silence (get your data from the source you have)\nsampleBlockSize = 1152; //can be anything but make it a multiple of 576 to make encoders life easier\n\nfor (var i = 0; i < samples.length; i += sampleBlockSize) {\n  leftChunk = left.subarray(i, i + sampleBlockSize);\n  rightChunk = right.subarray(i, i + sampleBlockSize);\n  var mp3buf = mp3encoder.encodeBuffer(leftChunk, rightChunk);\n  if (mp3buf.length > 0) {\n    mp3Data.push(mp3buf);\n  }\n}\nvar mp3buf = mp3encoder.flush();   //finish writing mp3\n\nif (mp3buf.length > 0) {\n    mp3Data.push(mp3buf);\n}\n\nconsole.log(mp3Data);\n</script>\n```\n","readmeFilename":"README.md"}