Transpiled version (3062L) is out of date.
lib 1400149 // java-lame static LS _stickyLibs_StreamingMP3Encoder = ll(#1400149); import net.sourceforge.lame.lowlevel.*; import net.sourceforge.lame.mp3.MPEGMode; sclass StreamingMP3Encoder implements AutoCloseable { File mp3; OutputStream out; byte[] outBuffer; LameEncoder encoder; IVF3<byte[], Int, Int> onBytesWritten; AudioFormat format; int bitRate = 128; int quality = LameEncoder.DEFAULT_QUALITY; bool vbr; *() {} *(File mp3, float sampleRate) { this(mp3, javaSound_pcmSignedLittleEndianMono(sampleRate)); } *(File *mp3, AudioFormat *format) { init(); } void init ctex { MPEGMode channelMode = format.getChannels() == 1 ? MPEGMode.MONO : MPEGMode.JOINT_STEREO; encoder = new LameEncoder(format, bitRate, channelMode, quality, vbr); outBuffer = new byte[encoder.getPCMBufferSize()]; out = newFileOutputStream(mp3); } public void close { encoder.close(); dispose out; } void addData(short[] samples) ctex { byte[] pcm = byteArrayFromShorts_littleEndian(samples); int bytesToTransfer = min(l(outBuffer), l(pcm)), bytesWritten; int iPCM = 0; while (0 < (bytesWritten = encoder.encodeBuffer(pcm, iPCM, bytesToTransfer, outBuffer))) { iPCM += bytesToTransfer; bytesToTransfer = min(l(outBuffer), l(pcm) - iPCM); callF(onBytesWritten, outBuffer, 0, bytesWritten); out.write(outBuffer, 0, bytesWritten); } } }
Began life as a copy of #1019665
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1026967 |
Snippet name: | StreamingMP3Encoder (pure java version) |
Eternal ID of this version: | #1026967/27 |
Text MD5: | ec98deb7f383d7ce4c45a1b876819312 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-17 16:20:34 |
Source code size: | 1498 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 305 / 714 |
Version history: | 26 change(s) |
Referenced in: | [show references] |