Having a look at the frequency representation again in Soundbooth showed a reduction/cutoff above 16kHz for certain sounds (not all). I then compressed the file using Foobar2000 1.1.9 to a lame mp3 with the settings:Įncoding settings : -m j -V 0 -q 0 -lowpass 24 -vbr-new -b 32 attained was around ~27kHz (which seems acceptable given my sound card, cartridge and phono stage). I had a look at the frequency representation in Adobe Soundbooth CS5 and noted that the max. It is just a minor modification of the above code with lame_t being an array of size NTHREADS.I recorded some vinyl using Goldwave 5.25 under win 7 pro 圆4 and saved the files as a 24/96 un-compressed Windows Wave file. If anyone is interested, I can add the code. The code compiles and runs without problems, but the resulting file contains no sound. I tried that, using the threads to encode mutually exclusive bits of the original wav file. I also thought that a workaround might be to create a lame_t object for each thread. I thought that this would only be reading, so no problem, but I seem to be mistaken. The problem seems to be that the global lame_t structure is accessed by several threads at the same time. I did not find any hints if this is possible or not. Maybe someone knows if lame can not be used in this way in parallel code. Pthread_mutex_lock(data->mutexForReading) ĭata->items_read = fread(data->pcm_buffer, 2*sizeof(short int), data->n_samples, data->wav_file) Ĭout first_sample n_samples items_read (data->mp3_buffer) mutexForReading) ĭata->mp3_bytes_to_write = lame_encode_buffer_interleaved(data->lame,įwrite(data_ptr.mp3_buffer, data_ptr.mp3_bytes_to_write, 1, mp3) ĭata_ptr.mp3_bytes_to_write = lame_encode_flush(lame, data_ptr.mp3_buffer, data_ptr.mp3_buffer_size) Unsigned long offset = 40 + 2 * 2 * data->first_sample flushbits ResvSizefinished encodingįor referernce, I attach the code that I am using, that compiles just fine. It has several possible causes:90% LAME compiled with buggy version of gcc using advanced optimizations 9% Your system is overclocked 1% bug in LAME encoding libraryfinished encoding When I run my code in parallel mode, I get a lot of errors such as Internal buffer inconsistency. My code works for 1 thread (no parallel execution), it also works if I delay the thread creation in parallel mode (such that there is no parallel execution, but the data structures are arrays). I use one global lame_t structure that is used for the encoding in each thread. Taking care that each thread has a unique bit of the pcm track that it transcodes. I am greating one lame_t pointer, and have several threads doing bits of the conversion, I am now trying to use the same approach using posix threads to speed up encoding. I have successfully used libmp3lame in the way mike seymour proposed. Write = lame_encode_buffer_interleaved(lame, pcm_buffer, read, mp3_buffer, MP3_SIZE) Write = lame_encode_flush(lame, mp3_buffer, MP3_SIZE) Read = fread(pcm_buffer, 2*sizeof(short int), PCM_SIZE, pcm) Here is a working example I knocked together (just the basic functionality, no error checking): #include It takes slightly more than 4-5 lines to encode a file, but not much more. Lame really isn't difficult to use, although there are a lot of optional configuration functions if you need them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |