1 | lib 1400149 // java-lame |
2 | static LS _stickyLibs_javaLame_wavToMP3_mono = ll(#1400149); |
3 | |
4 | import net.sourceforge.lame.lowlevel.*; |
5 | |
6 | static void javaLame_wavToMP3_mono(File wav, File mp3) ctex { |
7 | long time = sysNow(); |
8 | temp WAVDecoder decoder = new(newFileInputStream(wav)); |
9 | time "Decode WAV" { |
10 | byte[] pcm = byteArrayFromShorts_littleEndian(decodeWAVToMonoSamples(decoder, wav)); |
11 | } |
12 | LameEncoder encoder = new(javaSound_pcmSignedLittleEndianMono(decoder.sampleRate)); |
13 | |
14 | temp FileOutputStream out = new(mp3); |
15 | byte[] buffer = new byte[encoder.getPCMBufferSize()]; |
16 | int bytesToTransfer = min(l(buffer), l(pcm)), bytesWritten; |
17 | int currentPcmPosition = 0; |
18 | while (0 < (bytesWritten = encoder.encodeBuffer(pcm, currentPcmPosition, bytesToTransfer, buffer))) { |
19 | currentPcmPosition += bytesToTransfer; |
20 | bytesToTransfer = min(l(buffer), l(pcm) - currentPcmPosition); |
21 | out.write(buffer, 0, bytesWritten); |
22 | } |
23 | encoder.close(); |
24 | done2_always_timeFirst(time, "Pure-Java-converted " + wav + " to " + mp3); |
25 | } |
download show line numbers debug dex old transpilations
Travelled to 11 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019665 |
Snippet name: | javaLame_wavToMP3_mono - uses some default bit rate |
Eternal ID of this version: | #1019665/7 |
Text MD5: | d598428e6aa3f6c3abe6d1700dbe9d84 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-16 23:36:51 |
Source code size: | 1045 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 290 / 332 |
Version history: | 6 change(s) |
Referenced in: | [show references] |