diff --git a/src/lib/audio/audio-util.js b/src/lib/audio/audio-util.js index 2a4c3bb190cf9d8ea182fd7e50b69504e686cf75..e4470b2b38700a124c956d86a301f412b15e2c1a 100644 --- a/src/lib/audio/audio-util.js +++ b/src/lib/audio/audio-util.js @@ -70,11 +70,8 @@ const downsampleIfNeeded = (samples, sampleRate, resampler) => { if (duration * 22050 * 2 < SOUND_BYTE_LIMIT) { return resampler({samples, sampleRate}, 22050); } - // If encodeable at 11khz, resample and call submitNewSamples again - if (duration * 11025 * 2 < SOUND_BYTE_LIMIT) { - return resampler({samples, sampleRate}, 11025); - } - // Cannot save this sound even at 11khz, refuse to edit + // Cannot save this sound at 22khz, refuse to edit + // In the future we could introduce further compression here return Promise.reject('Sound too large to save, refusing to edit'); }; diff --git a/test/unit/util/audio-util.test.js b/test/unit/util/audio-util.test.js index 876cf71e42cdb77b3bb572bd4de3bded73033c39..f8a32e5c9eb78d03d2330b2142fde2448562360f 100644 --- a/test/unit/util/audio-util.test.js +++ b/test/unit/util/audio-util.test.js @@ -66,16 +66,8 @@ describe('downsampleIfNeeded', () => { expect(resampler).toHaveBeenCalledWith({samples, sampleRate}, 22050); expect(res).toEqual('TEST'); }); - test('downsamples to 11025 if that puts it under the limit', async () => { - samples.length = 44100 * 7 * 60; - const resampler = jest.fn(() => 'TEST'); - const res = await downsampleIfNeeded(samples, sampleRate, resampler); - expect(resampler).toHaveBeenCalledWith({samples, sampleRate}, 11025); - expect(res).toEqual('TEST'); - }); - test('fails if resampling would not put it under the limit', async () => { - samples.length = 44100 * 8 * 60; + samples.length = 44100 * 4 * 60; try { await downsampleIfNeeded(samples, sampleRate, null); } catch (e) {