-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Soundsource API to reading float samples #6947
Comments
Commented by: rryan Definitely agree and it would allow higher precision soundsources.
|
Commented by: jfagan1
|
Commented by: rryan Hi James, In this case we're referring to the SoundSource base class as the API and You'll see that the read() method reads SAMPLE's which is just a typedef The rest of Mixxx (e.g. CachingReader -- src/cachingreader.cpp) uses Hope that helps, On Wed, Apr 17, 2013 at 12:22 AM, James Fagan wrote:
|
Commented by: jfagan1 Thank you RJ Ryan your post was very helpful. I have just finished going through all of the files that use soundSourceProxy and have changed them accordingly. I then compiled the new changes successfully and I believe I have properly changed everything but I am a little unsure how to test to check that original float samples are not being converted. |
Commented by: ywwg As a start, can you create a diff of your work so I can see what you've changed? If you're using a bzr checkout the "bzr diff" command should generate a file we can use. Just attach it to this bug and I'll take a look. |
Commented by: jfagan1 I have attached a txt of the diff result text file. Let me know if you need anything else. Thanks |
Commented by: daschuer Hi James, Thank you for the patch. I am afraid this will neither work, nor compile. Are your fermilar with setting a up a C++ project? What is your operating First of all you should set up a powerful build environment. The basic steps are described here: If you have the choice, setup your build environment using Linux for Than you should try to setup gdb, that you are able to single step thought If you get stuck, please ask. Kind regards, Daniel
|
Commented by: jfagan1 Hey Daniel, Thank you for all the useful tips. I am currently using Ubuntu and I normally do not use an IDE, just kate and geedit. I have used eclipse before with java so maybe I can give that a try. I have followed the steps in the link you provided and set up mixxx with linux with no issues. When I tried to compile the code it was unsuccessful due to errors. I could of sworn it compiled fine yesterday but I apologize for posting something that does not compile. I will be sure to continue working on this ASAP. Also, I am familiar with gdb but I am unfamiliar how to retrieve your files from your trunk. Thanks, |
Commented by: daschuer Hi James, Ah fine, that you are setup so far. I have just put some additional hints about eclipse to our Wiki The other thing is getting familiar with bazaar If you want to provide a patch next time it is best using bzr from the The solution of this Bug should include to move the call to And .. please assign the bug to yourself
|
Commented by: jfagan1
Thanks, |
Commented by: daschuer Hi James, often the underlying sound source Libs have a internal converter. So a first step is to call SampleUtil::convert() from the sound Source itself and remove it from everywhere else in Mixxx. The second step is to find out how to receive CSAMPLES from the underlying libs to get rid of the SampleUtil::convert() calls within the libraries. http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a4582d93c2c2e60e12be3d74c5fe00b96 |
Commented by: rryan Hi James, Every sound API's results get passed through convert() by CachingReader. This does nothing but re-interpret the signed 16-bit samples as floating point. The values of the samples themselves do not change in this conversion. There's no need to detect whether a file is natively encoded in floating point samples or signed 16-bit samples. Currently, every SoundSource implementation produces s16 samples no matter what the native file format is. You just need to change our use of each API to produce float samples instead of s16 samples. For SoundSourceMp3, as Daniel mentioned, madScale is that conversion step. It takes a mad_fixed_t sample and produces a signed integer. One easy way to accomplish what you're looking to do is to just make something like madScale return a float. This would implicitly convert the calculated s16 value to float upon return because of C++ type coercion. However, this is wasteful. Ideally you will find a way to convert a mad_fixed_t directly to a float rather than mad_fixed_t -> s16 -> float. Daniel suggested looking at the libmad documentation / code to figure out how to do this. Hope this helps, |
Commented by: jfagan1 Hey all, I have been doing a lot of research on fixed and floating point numbers and have learned the following: A floating point number has 1 bit for sign followed by 8 bits for exponent and a 23 bit mantissa To convert a 32 bit mad_fixed_t to a 32 bit float I have created a new madScale function in soundsourcemp3.cpp that I included in mp3.patch. The good news is that when I run mixxx and drag an mp3 onto the deck I do hear the song playing but the problem is that I also have a lot of extra noise in the background as well. I have determined that the problem is how I am assigning an exponent value to the float. I orignally thought the value for the exponent binary would be a constant but I have determined that is very wrong. What I am a having a lot of trouble determining is how I can manipulate the mad_fixed_t to determine the 8 bit exponent necessary for floating point. The chart below represents the realtionship I am trying to find a function for: Mad_fixed_t value 8 bit Exponent binary for Float I have attached a patch file with my new additions and in my madScale function I have included numerous comments explaining my thought process for each line. I believe that once I find out how to properly assign the 8 bit exponent then madScale should work properly. If you have any questions about my function or thought process please feel free to ask. Thanks, |
Commented by: jfagan1 I have attached the .cpp of the detailed example to this comment. |
Commented by: jfagan1 I apologize for making so many posts but I have accidently hid comment #14 and since I left the page there was no way for me to unhide it. Also I have made more progress since posts #13 and #14 and I would like to edit or even delete them so that no one wastes time trying to help me fix an outdated problem. If there is a way to edit a post could someone please tell me how?, that way I could update my progess in the same comment so it doesnt make a mess on launchpad. As of right now I have got passed the error mentioned in post 14 and issues in post 13 and when I run mixxx and drag an mp3 onto the deck the song does play but there is still some noise but definitely much less then before so I must be close. I have attached the my newest patch file with my additons to madScale. Also the attached file in post #15 is still an up to date example of going through my code. Once again I appologize for posting so many times back to back but I realized how to fix the problem in post #14 a little bit after I posted it and I didnt want anyone to waste time trying to help me. Thanks, |
Commented by: daschuer Hi James, It looks like you learned a lot about bit interpretation of different data types.
|
Commented by: daschuer
http://freedesktop.org/software/pulseaudio/doxygen/sample.html maybe there is somewhere a downscaling to 1 .. -1 we could eliminate. |
Commented by: jfagan1 Hey Daniel, Thanks so much for clearing that up, I tested your (Better Solution) and every mp3 I tried played correctly! I can't believe all I had to do was use the mad_f_todouble method. I orignally had that in my earlier attempts but I ruled it out because I wasn't hearing any sound but that *= 0x0800 was the trick. I honestly don't undertand why that was necessary but I can look into the downscaling thing you mentioned to see why. As for all the other soundsources I am having trouble finding what I need to change. Just to test out where I am at I tried importing and playing various file types and seeing if they play correctly. I was able to play .flac sucessfully but .ogg, aiff, and .m4a all produced some sort of static. Also if you could calrify what types of files I need to test for each soundSource that would aslo be a huge help. Earlier you also mentioned that the solution of this Bug should include to move the call to SampleUtil::convert() into the SoundSources if required. For soundSource mp3 all I changed was the madScale method and changed SAMPLE to CSAMPLE but do I still need to call convert somewhere? or is madScale what you meant by convert? Thanks again for all your help, James |
Commented by: daschuer Hi James, Did you also test "Faster solution". Something like this should finally move to trunk. I am not sure if you finaly got the point with moving convert. So here a pseudo code example, which reads a German String "msgDe" from an external Library "getMsgLib()" and prints a translated English version to terminal.
// Now a more complex version similar to SoundsourceMp3. Lets say the external library speaks French.
|
Commented by: daschuer Sorry I have accidentally hit Enter, so the Second example was unfinished. // Now a more complex version similar to SoundsourceMp3. Lets say the external library speaks French.
You see, convert is gone and there is no also msgDe reqired. So you see, moving convert will produce allays a working version without knowledge of the Languages (Sound source interns) |
Commented by: jfagan1 Hey Daniel,
Thanks, |
Commented by: daschuer Hi James, it would be nice if you could provide a straight forward patch first, which includes the convert move solution like This way we have a working solution and can finish tis long thread. The other optimizations can be done with a new bug. --
--
-- |
Commented by: jfagan1 Hey Daniel,
Thanks, |
Commented by: daschuer
|
Issue closed with status Fix Released. |
Reported by: daschuer
Date: 2013-03-18T11:31:55Z
Status: Fix Released
Importance: Wishlist
Launchpad Issue: lp1156569
Tags: easy, soundsource
Attachments: differences.txt, mp3.patch, newMp3.patch, [step by step of testing input with my madScale function](https://bugs.launchpad.net/bugs/1156569/+attachment/3684229/+files/step by step of testing input with my madScale function), [Newest version of my patch](https://bugs.launchpad.net/bugs/1156569/+attachment/3684285/+files/Newest version of my patch), workingMp3.patch, [mp3 is done, everything else still needs convert moved and optimized](https://bugs.launchpad.net/bugs/1156569/+attachment/3692117/+files/mp3 is done, everything else still needs convert moved and optimized)
All samples read from a specific sound source are immediately converted from S16 Samples to float samples.
Some track encoding formats original have float samples. In this case we have two unnecessary sample conversations.
The text was updated successfully, but these errors were encountered: