Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Crossfeed Plugin For Winamp 2.x (Read 7893 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Crossfeed Plugin For Winamp 2.x

I've been working a crossfeed plugin for the past few weeks and I've gotten to the point where my ears are completely satisfied. I would greatly appreciate any feedback you have. (You may be asking what crossfeed filters do, so here's the five second overview: crossfeed filters are used to reduce listening fatigue caused by the unnatural stereo image provided by headphones.)

The plugin was designed with these goals in mind:
1. Reducing the super-stereo effect of headphones without destroying the stereo image
2. Keeping the frequency response as close to the source as possible
3. Subtlety
4. Ease of configuration

Thanks in advance for your help! You can download the plugin from this page.

Crossfeed Plugin For Winamp 2.x

Reply #1
I didn't listen to the plugin, since I use speakers, but I took a look at the code - one little comment:

Casting from float to short is VERY expensive, taking many CPU cycles.  It probably doesn't really matter for your plugin, since it doesn't take too many CPU cycles anyway, but for maximum performance, I would do

Code: [Select]
inline short Float2Short(float SampleValue)
{
       int r;
       SampleValue *= 32768.0f;  // this could be done using inline asm also, but I didn't for reasons of clarity
       __asm {
               fld SampleValue
               fistp r
       }
       return (short)((r==(short)r) ? r : (r>>31)^0x7FFF);  // this just clips the output at +32767 and -32768 (should be faster than using 2 ifs)
}


An added bonus to this method is that it rounds, and your original truncates (although to get really hardcore you really should perform dithering+noise shaping.  I've written a C++ class for this if you're interested - it's very simple to use, and it performs 9th order noise shaping).

Crossfeed Plugin For Winamp 2.x

Reply #2
Thanks for the tip! I was planning on optimizing for speed eventually.


Crossfeed Plugin For Winamp 2.x

Reply #4
The plugin sounds wonderful! The treble volume with the plugin enabled now sounds comparable to the original, and it's nice that the output has an overall volume closer to the original.

I can't tell if the crossfeed itself has improved (it was good to begin with). Center-balanced, stereo-recorded sounds seem to be a little more "forward" (out of my head) compared to your earlier plugin version, and fully-panned instruments are even more "out-of-ear", and the sound overall more "open". But these observations could be due to the more balanced treble.

I'm trying to decide whether I like the medium or high preset better. Maybe I'll build myself a medium-high preset and recompile it, or something, just for kicks.

I wish I could understand C++ syntax (so far I've only taken a couple of Java courses in school) to see what's going on behind the scenes. Maybe after some sleep I'll be able to magically understand it.

Thanks for sharing your work, Trelane!

Crossfeed Plugin For Winamp 2.x

Reply #5
JAZ:
There's no license yet, but if you can use the sources, then by all means use them! The only thing I really ask is that you let me know how you're using them (not because I'm a mean oppressive fellow, but because I'm a curious fellow ). Good luck!

SometimesWarrior:
Thanks for the compliments! The difference between this version and older versions isn't extremely evident unless the music contains a lot of ambient qualities.

In a future version, I may make user-definable presets possible (with adjustable lowpass, delay, crossfeed amount, and treble boost). I'm not exactly sure how I'll make it work, since only certain combinations yield good results.

If you decide to tweak the current presets, let me know what settings you use. I spent a lot of time tweaking the low mode, but didn't spend too much time tweaking the medium and high modes.

Thanks!

Crossfeed Plugin For Winamp 2.x

Reply #6
Did anyone have trouble with the HA forums today?  It wasn't working at all for me this afternoon.

Anyway, for those who are interested, I've optimized Crossfeed, and my version seems to be considerably faster.  Test results (run on my P-III 866 with WinXP):

Just decoding MP3 in Winamp - 45.8x realtime

Processing with "reference" binary - 23.1x
Processing with my optimized version - 32.1x

I've also created a version that performs dithering + 9th order noise-shaping for all those people who really care about stuff like that (uh, like me).  It runs at 24.1x for me.

All the source code and binaries for both versions are available at http://www.cs.indiana.edu/~cshei/my_crossfeed.zip

If you give it a try, let me know what you think!  The output of the undithered version is always ± 1 away from the "reference" binary and that's just because I round and the original truncates.

Crossfeed Plugin For Winamp 2.x

Reply #7
Cool! I used your optimization tip from last night in my version (not released yet). I was going to fix the memory allocations, but I completely forgot about them!

Code: [Select]
SampleValue *= 0.97f * 32768.0f; // What's 0.97f there for?


Reduces volume to closely match the source (the 3 dB treble boost increases the volume a little bit).

Code: [Select]
if (F == 44100 || R == 16 || Ch == 2)


Doh! Thanks for pointing that one out, I wouldn't have noticed it otherwise. Quite an embarrassing mistake!

The dithered version is nice, but I'm not too sure it's necessary for this type of processing. But as you said, it's a matter of personal preference.

Anyway, thanks for taking the time to hax0r my code! I plan on cleaning things up soon (making a nice crossfeed class, support for other sampling rates and bit depths, better configuration, etc.).  I wanted to ask you if you knew of any online optimization resources. I need some improvement in this area. Thanks

Crossfeed Plugin For Winamp 2.x

Reply #8
I can't think of any online optimization resources off the top of my head (I'll look for some), but a great site about musical DSP applications is http://www.musicdsp.org/ (they've also got a great mailing list).  Another good site is http://www.dspguru.com/ (related to the comp.dsp newsgroup, if I remember correctly).  Finally, try http://developer.intel.com/ - it has some good stuff too (and some nice MMX/SSE examples).  Also, I've noticed that Visual C++ .NET is usually faster than Visual C++ 6.0, so if you can get ahold of that (not a problem for me, since IU has site licenses for just about every Microsoft product, available to students/faculty/staff for $5/CD - Visual Studio .NET only cost me $25), it would provide a bit of a speed increase (also take a look at the Intel C++ Compiler - it's even faster [but more expensive - $100 for an student license]).

Crossfeed Plugin For Winamp 2.x

Reply #9
Cool stuff Trelane!

Just tried out your plugin for the first time and it works quite nicely.  Thanks

Crossfeed Plugin For Winamp 2.x

Reply #10
[deleted]

Crossfeed Plugin For Winamp 2.x

Reply #11
The first instinct is to use a high setting that's noticable right away, but this usually leads to bad results on almost all music. One of the ways I tested was listening to music from my collection where there's a lot of hard left/hard right panning (Les Claypool/Primus does a lot of this). I didn't test whether I could hear an immediate difference or not, I tested whether or not I got sick of using headphones. In my experience, the low setting was plenty.

None of the settings will ever be "transparent," because of the nature of mixing two similar signals with a delay. I tried to get the output to sound as pleasant as possible though. Low should provide the best results for most types of music.

Try low for awhile and let me know what you think. Thanks!

Crossfeed Plugin For Winamp 2.x

Reply #12
I think this plugin really does make it easier to listen to music with headphones - yesterday, I listened for 3 hours at our school's Music Library with the "low" setting, and I didn't get tired of listening at all!  I've noticed that with speakers, there isn't much of a noticeable effect, but hey, it isn't designed for speakers anyway.

Crossfeed Plugin For Winamp 2.x

Reply #13
I have a bit of tinnitus (from an unfortunate experience with cap gun caps in my youth (oh the good ol' days    )) so my ears are extra sensitive. I don't know if this makes me more sensitive than others to headphone fatigue but this is definitely something that I notice after only a short time listening to headphones. I've actually been looking at HeadRoom's  headphone amp which attempts to correct this problem but have so far resisted buying it.

Your Crossfeed plugin is a great solution. I have been hoping someone would make this for quite a while. I can instantly tell the difference when listening to music on my headphones and this makes listening to music for long periods much more pleasurable for me. Now I can record Crossfeed versions of my favorite CDs to use in my portable player!

Great job.

Crossfeed Plugin For Winamp 2.x

Reply #14
Quote
I've also created a version that performs dithering + 9th order noise-shaping for all those people who really care about stuff like that (uh, like me). It runs at 24.1x for me.


What is dithering and 9th order noise shaping?
I'm familiar with the general concept of dithering (eg. graphics files). How does this apply to the above plugin?

Thanks!

Crossfeed Plugin For Winamp 2.x

Reply #15
Thanks for your compliments! I was also looking into buying a headphone amplifier with a built-in crossfeed circuit, but I could never get my hands to pry open the ol' wallet...

About dithering:
Internally, the plugin converts the audio data from 16 bit integers to 32 bit floating-point numbers for processing. After processing, the data is converted back. Dither is applied before the conversion back to 16 bit integers.

Hope this helps!

Crossfeed Plugin For Winamp 2.x

Reply #16
Quote
Quote
I've also created a version that performs dithering + 9th order noise-shaping for all those people who really care about stuff like that (uh, like me). It runs at 24.1x for me.


What is dithering and 9th order noise shaping?
I'm familiar with the general concept of dithering (eg. graphics files). How does this apply to the above plugin?

Thanks!

As Trrelane said, the plugin converts from 16->32-bit for internal processing.  On the way back from 32->16-bit, if you don't dither, the truncation error is correlated with the audio signal, which is bad (for example, a low amplitude sine wave turns into something like a square wave - harmonic distortion).  Dithering applies a small amount of white noise before converting from 32->16-bit, which prevents the error signal from being correlated with the audio signal.  Then, the error signal is just white noise, which is less bothersome than a correlated error signal.  The simple explanation is that the noise-shaping then shapes the white error signal according to the way we hear - our ears are most sensitive around 3kHz so the noise shaping shapes the spectrum of the error signal to have less power around 3 kHz and more power in the upper frequencies, where it is less audible.  This way, we get the benefits of dithering (the decorrelation from the audio signal) without much of an increase in the noise floor.  Although I will admit that 9th-order noise shaping is probably overkill (a lower-order would probably be enough) for a plugin like this, it definitely doesn't hurt to perform it (especially because with headphones, you can probably hear softer sounds better than with speakers because some headphones block outside sounds).  Proper dithering + noise-shaping is very important when producing music (most commercial CDs are dithered + noise-shaped - if you know where to look, you can usually find signs of it).

Crossfeed Plugin For Winamp 2.x

Reply #17
Thanks for the info re: dithering. Almost makes me want to go back to school to learn more about signal processing  .

Crossfeed Plugin For Winamp 2.x

Reply #18
Quote
Thanks for the info re: dithering. Almost makes me want to go back to school to learn more about signal processing  :) .

Well, you could still pick up some DSP books and study them.  Actually, at IU, I'm not an engineering major or anything - we don't even have an engineering school (for that, you'd have to look at our main rival, Purdue University - an excellent engineering school).  I just play around with DSP for fun.  I'm a Computer Science and Math major, so it's easy for me to pick up signal processing concepts - after all, it's basically just writing programs and bunch of math.  The Fourier Transform is covered in the Differential Equations course here, and understanding stuff like the z-transform is easy enough for me because I have studied (and will continue to study) a lot of math here.  Our Music Library also happens to have quite a few books on DSP, as well as many AES Journals, so I'm always in the Music Library reading something about DSP (and listening to music with this great Crossfeed plugin B)).

Crossfeed Plugin For Winamp 2.x

Reply #19
Small world. I graduated from Purdue last year in electrical engineering  . I am more on the hardware side, RF, fiber optics, that kind of thing. Good luck at IU.