sergree / matchering

🎚️ Open Source Audio Matching and Mastering
https://pypi.org/project/matchering/
GNU General Public License v3.0
1.29k stars 151 forks source link

MemoryError: Unable to allocate array with shape (13755436,) and data type float64 #18

Closed JiaxiangBU closed 4 years ago

JiaxiangBU commented 4 years ago
Here is the error information. ```python import matchering as mg # Sending all log messages to the default print function # Just delete the following line to work silently mg.log(print) ``` ```python mg.process( # The track you want to master target='../music_file/torch.wav', # Some "wet" reference track reference='../music_file/juanzhulian.wav', # Where and how to save your results results=[ mg.pcm16('my_song_master_16bit.wav'), mg.pcm24('my_song_master_24bit.wav'), ] ) ``` Please give us a star to help the project: https://github.com/sergree/matchering ---------------------------------------- Loading and analysis Loading the TARGET file: '../music_file/torch.wav'... The TARGET file is loaded TARGET audio length: 12900720 samples (0:04:52) Audio clipping is detected in the TARGET file. It is highly recommended to use the non-clipping version Loading the REFERENCE file: '../music_file/juanzhulian.wav'... The REFERENCE file is loaded REFERENCE audio length: 14971904 samples (0:05:11) Resampling REFERENCE audio from 48000 Hz to 44100 Hz... The REFERENCE audio was resampled ---------------------------------------- Matching levels The maximum size of the analyzed piece: 661500 samples or 15.00 seconds Normalizing the REFERENCE... The REFERENCE was normalized. Final amplitude coefficient for the TARGET audio is: -0.0495 dB Calculating mid and side channels of the TARGET... The TARGET will be didived into 20 pieces One piece of the TARGET has a length of 645036 samples or 14.63 seconds Calculating RMSes of the TARGET pieces... Extracting the loudest pieces of the TARGET audio with the RMS value more than average -11.3945 dB... The current average RMS value in the loudest pieces is -9.3542 dB Calculating mid and side channels of the REFERENCE... --------------------------------------------------------------------------- MemoryError Traceback (most recent call last) in 9 results=[ 10 mg.pcm16('my_song_master_16bit.wav'), ---> 11 mg.pcm24('my_song_master_24bit.wav'), 12 ] 13 ) ~/miniconda3/lib/python3.7/site-packages/matchering/core.py in process(target, reference, results, config, preview_target, preview_result) 75 need_default=any(rr.use_limiter for rr in results), 76 need_no_limiter=any(not rr.use_limiter and not rr.normalize for rr in results), ---> 77 need_no_limiter_normalized=any(not rr.use_limiter and rr.normalize for rr in results), 78 ) 79 ~/miniconda3/lib/python3.7/site-packages/matchering/stages.py in main(target, reference, config, need_default, need_no_limiter, need_no_limiter_normalized) 177 reference_mid_loudest_pieces, reference_side_loudest_pieces,\ 178 target_divisions, target_piece_size, reference_match_rms\ --> 179 = __match_levels(target, reference, config) 180 181 del target, reference ~/miniconda3/lib/python3.7/site-packages/matchering/stages.py in __match_levels(target, reference, config) 50 reference_mid_loudest_pieces, reference_side_loudest_pieces,\ 51 reference_match_rms, *_\ ---> 52 = analyze_levels(reference, 'reference', config) 53 54 rms_coefficient, target_mid, target_side = get_rms_c_and_amplify_pair( ~/miniconda3/lib/python3.7/site-packages/matchering/stage_helpers/match_levels.py in analyze_levels(array, name, config) 146 name = name.upper() 147 debug(f'Calculating mid and side channels of the {name}...') --> 148 mid, side = lr_to_ms(array) 149 del array 150 ~/miniconda3/lib/python3.7/site-packages/matchering/dsp.py in lr_to_ms(array) 64 mid = np.copy(array[:, 0]) 65 array[:, 0] -= array[:, 1] ---> 66 side = np.copy(array[:, 0]) 67 return mid, side 68 <__array_function__ internals> in copy(*args, **kwargs) ~/miniconda3/lib/python3.7/site-packages/numpy/lib/function_base.py in copy(a, order) 788 789 """ --> 790 return array(a, order=order, copy=True) 791 792 # Basic operations MemoryError: Unable to allocate array with shape (13755436,) and data type float64

Is my wav file is too long? I am new for this package.

du -sh torch.wav
50M     torch.wav
du -sh juanzhulian.wav
58M     juanzhulian.wav

I run it on an Ubuntu system.

sergree commented 4 years ago

Hello, @JiaxiangBU!

I think it is OOM (Out of memory). How much RAM does your machine have? 4 GB recommended.

JiaxiangBU commented 4 years ago

It is 2G. I will change another machine to try.

image

sergree commented 4 years ago

I added information about this requirement in the readme. thanks for this