SQ Blog

QuadraphonicQuad

Help Support QuadraphonicQuad:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

ingresman

300 Club - QQ All-Star
Joined
Apr 24, 2006
Messages
321
Location
Manchester UK
Is any one interested in hearing my work on my software SQ decoder?.
I'd be really interested in any feedback ans to use anyone as a sounding board !.
I can't really afford the software to do the work so I'll have to create my own.
My initial thoughts are to create a phase shift module and a mixer module and string these together to do the decode.
I would (based on the wendy carlos diagram):
1. rip the orignal LP to Wave format.
2. split this .wav into LT.wav and RT.wav
3. create a file called LB.wav from the LT.wav and shift it by -90degrees
4. create a file callled RB.wav from the RT.wav and shift it by -90degrees
5 load up the 4 .wav into buffers (may need the 4 channel card here) and start playback.
6. Take the output buffers from the card (taking advantage of ASIO sync)
7. create realLB.wav as LB.wav + RT.wav
8. create realRB.wav as RB.wav + LT.wav

Hopefully I can get away with not hacing the sound card and perhaps even create a 4 channel .WAV to encode itn DTS


I should have 4 files as RT.wav,LT.wav,realLB.wav and realRB.wav.

But could anyone explian what the -707 mixing really means, is it multiply the signal by .707?, does this equate to -3db.

Honest question, Am I wasteign my time here ??? at the very least I can understand how the process works a bit better.

The Microsoft direct sound API looks like it might be able to do the phase shift and mixing for me.

Regards

Kevin
 
Well I've been having a play with .wav files. As I know very little about audio files thought I'd have go at processing a .wav file in code and see whan PCM and stuff is all about.
I've written a C modue which if you give it a .wav file it will tell you things like the compression type, sample rate, channels etc.
After I got that into a fair state I enhanced it to split a stereo file into 2 monos. My test files (elected by Alice Cooper and Stool Pigeon by King Creole) split into 2 files but they both sound the same, my code looks ok but it's 23:00 in the UK and I've been at it most of the day. When I crack that loading both in KRISTAL studio should come out as the original stereo.
The next steps are to do the phase shift and create a basic 4 channel file .wav. Microsoft have a standard for multi channel .wav which I'll follow. After this I need to apply the mixing and it shoud output decoded SQ then.
I changed my mind from the original plan in the first post and I think I'll get away without getting a 4x4 sound card as I'm going straight to the sample bytes which means I have no issues with synchronisation and I think it will decode in better than real time. I'll get the DTS encoder and burn straight to CD. My PC has a 7.1 card which decoded DTS so should sound good.
So after I crack this it's off to the WEB to find out how to do phase shift in software - It look like a delay but I think I might be missing something.
I think the first thing I'll decode will be Mike Oldfield Exposed as I have that on CD as well as record and shoud be easier to get into .wav
have a good weekend everyone.
P.S I will set up a yahoo group or geocities type thing and post the code when it looks a little better.
Kevin
 
quick update from at night.
I had to fix a few little bugs but the main thing was when I was listening to the split left and right files in KRISTAL I didn't pan the left file all the way to left and the right file to the right, did that and it burst into life!, still looks a little quiet though,
So I'm now looking to get the phase shift code together.
 
So, most of my waking time is now spent thinking about phase shifts. I've read a load of stuff on it and a lot of is contradictory. What I think I need is an all-pass filter which I can emulate in software and I'm batting on with that. Having said that it looks like all-pass does a 90degree shift only which would scupper any other use for it e.g. a 60degree shift for matrix H.
Phase shift is a really confusing concept, it looks like it is a delay but for how long ? - I've still got work to do around this.
Could someone help me out on two fronts please?
Give me a clear explination of what phase shift is within a decoder and if possible could someone create me a 1 second sine wave and shift it by -90degrees and one by +90 degrees through Adobe Audition? I would at least have a reference point to test againat. If you could post it here that would be great or I can provde an email address to post it to.
Many thanks in advance and viva la SQ !
 
Looks like you're on the right path for creating a passive SQ decoder. Just one small thing though.
Looking at the equations (from http://www.rdrop.com/~dano/tunes/quad.html):
Lt = Lf + 0Rf - j0.707Lb + 0.707Rb
Rt = 0Lf + Rf - 0.707Lb + j0.707 Rb
when create the right surround mix you need to do 0.707(Lt + Rt[-90])
but when you create the left surround mix, 0.707(Lt[-90] + Rt) gives you
-Lb + 0.707Lf[-90] + 0.707Rf
so you need to invert this to get the signal for the left surround channel correctly phased.

But could anyone explian what the -707 mixing really means, is it multiply the signal by .707?, does this equate to -3db.
Yes, you need to multiply the signal by 1/root2 which is the same as attenuating by -3db
 
Last edited:
Hi Mandel,

Thanks for that stuff, I can't get to the link from work, So I'll try when I get home. Or if you get the chance could you post the contents please ?
I notice your from Sheffield, I'm in Manchester we could maybe start a North of England Quad Society !

Kevin
 
Ok guys I'm still trying to get a phase shift going but I think I've worked out how to do it.
Assumming that I've got a 16 bit value (so can be between -32768 and 32768) if I divide an indvidual sample by 32768 I should have the original sine value. If I convert this into degrees (by using pi, 360, sin and asin) I should be able to add 90 to this, re-sin it and scale it back up by multiplying by 32768. Becaue I'm only working with values I'm not bothered about time, just the actual value
Sound convluted but my intiial test does give me a audio file, quite noisey so I need to implement it a little better.
This this sound a stupid thing to do ?
Kevin
 
Ok guys,
I've been on a few boards and it seems I need to do a hilbert transformation to phase shift all frequencies in a waveform, this looks quite hard!. The all pass filter it seems only does it for a specific frequency so no good for this.
I'm away next week so wont be able to post, I'm off to see Dave Gilmour in london, quick review when i get back
Kevin
 
Looks like it has got to be a hilbert transformation, this being because an all pass filter only worls for one frequency, the hilbert works on all frequencies.
For anyone that is interested Dave Gilmour was great, I've posted as bit in the rumor mill section. Post back if you want more details
The gig was recorded and so hopefully a 5.1 mix will be done as the soundtrack.
So off to the web for hilbert again !
 
Bit a while since I posted, most of my work has ben getting a hilbert transfom to work. I tracked down some software and I've coded it up. I put the sqtones.wav through it but I've still get to test it properly.
But I think I'm nearly there
 
Hi all,
Been away but I'm back now. I've coded up the hilbert transform and done a quick test to see if it does a 90degree shift by shifting the same value twice which shoud gove me 180 shift, mix the two together and the sound shoud cancel out, it didn't which leads me to think it isn't correct. I'm posting the code if anyone wants to see it and try it out.

Code:
#define NZEROS 500
#define GAIN   1.571116176e+00

static float xv_left[NZEROS+1];

static float xcoeffs[] =
  { +0.0000000000, +0.0003214310, +0.0000000000, +0.0003252099,
    +0.0000000000, +0.0003302355, +0.0000000000, +0.0003365372,
    +0.0000000000, +0.0003441444, +0.0000000000, +0.0003530868,
    +0.0000000000, +0.0003633944, +0.0000000000, +0.0003750973,
    +0.0000000000, +0.0003882260, +0.0000000000, +0.0004028113,
    +0.0000000000, +0.0004188840, +0.0000000000, +0.0004364757,
    +0.0000000000, +0.0004556178, +0.0000000000, +0.0004763424,
    +0.0000000000, +0.0004986818, +0.0000000000, +0.0005226689,
    +0.0000000000, +0.0005483367, +0.0000000000, +0.0005757189,
    +0.0000000000, +0.0006048495, +0.0000000000, +0.0006357632,
    +0.0000000000, +0.0006684951, +0.0000000000, +0.0007030809,
    +0.0000000000, +0.0007395569, +0.0000000000, +0.0007779600,
    +0.0000000000, +0.0008183281, +0.0000000000, +0.0008606994,
    +0.0000000000, +0.0009051133, +0.0000000000, +0.0009516098,
    +0.0000000000, +0.0010002299, +0.0000000000, +0.0010510155,
    +0.0000000000, +0.0011040098, +0.0000000000, +0.0011592568,
    +0.0000000000, +0.0012168018, +0.0000000000, +0.0012766915,
    +0.0000000000, +0.0013389738, +0.0000000000, +0.0014036982,
    +0.0000000000, +0.0014709156, +0.0000000000, +0.0015406788,
    +0.0000000000, +0.0016130421, +0.0000000000, +0.0016880620,
    +0.0000000000, +0.0017657969, +0.0000000000, +0.0018463073,
    +0.0000000000, +0.0019296564, +0.0000000000, +0.0020159096,
    +0.0000000000, +0.0021051351, +0.0000000000, +0.0021974040,
    +0.0000000000, +0.0022927905, +0.0000000000, +0.0023913723,
    +0.0000000000, +0.0024932304, +0.0000000000, +0.0025984499,
    +0.0000000000, +0.0027071199, +0.0000000000, +0.0028193341,
    +0.0000000000, +0.0029351907, +0.0000000000, +0.0030547934,
    +0.0000000000, +0.0031782511, +0.0000000000, +0.0033056791,
    +0.0000000000, +0.0034371988, +0.0000000000, +0.0035729386,
    +0.0000000000, +0.0037130347, +0.0000000000, +0.0038576311,
    +0.0000000000, +0.0040068807, +0.0000000000, +0.0041609461,
    +0.0000000000, +0.0043200000, +0.0000000000, +0.0044842264,
    +0.0000000000, +0.0046538214, +0.0000000000, +0.0048289944,
    +0.0000000000, +0.0050099691, +0.0000000000, +0.0051969851,
    +0.0000000000, +0.0053902989, +0.0000000000, +0.0055901856,
    +0.0000000000, +0.0057969412, +0.0000000000, +0.0060108836,
    +0.0000000000, +0.0062323557, +0.0000000000, +0.0064617271,
    +0.0000000000, +0.0066993973, +0.0000000000, +0.0069457986,
    +0.0000000000, +0.0072013994, +0.0000000000, +0.0074667084,
    +0.0000000000, +0.0077422784, +0.0000000000, +0.0080287117,
    +0.0000000000, +0.0083266658, +0.0000000000, +0.0086368590,
    +0.0000000000, +0.0089600787, +0.0000000000, +0.0092971888,
    +0.0000000000, +0.0096491399, +0.0000000000, +0.0100169797,
    +0.0000000000, +0.0104018664, +0.0000000000, +0.0108050829,
    +0.0000000000, +0.0112280539, +0.0000000000, +0.0116723666,
    +0.0000000000, +0.0121397934, +0.0000000000, +0.0126323203,
    +0.0000000000, +0.0131521795, +0.0000000000, +0.0137018887,
    +0.0000000000, +0.0142842976, +0.0000000000, +0.0149026446,
    +0.0000000000, +0.0155606252, +0.0000000000, +0.0162624744,
    +0.0000000000, +0.0170130694, +0.0000000000, +0.0178180552,
    +0.0000000000, +0.0186840011, +0.0000000000, +0.0196185982,
    +0.0000000000, +0.0206309077, +0.0000000000, +0.0217316805,
    +0.0000000000, +0.0229337690, +0.0000000000, +0.0242526657,
    +0.0000000000, +0.0257072177, +0.0000000000, +0.0273205841,
    +0.0000000000, +0.0291215436, +0.0000000000, +0.0311463069,
    +0.0000000000, +0.0334410798, +0.0000000000, +0.0360657647,
    +0.0000000000, +0.0390994399, +0.0000000000, +0.0426486966,
    +0.0000000000, +0.0468607407, +0.0000000000, +0.0519447683,
    +0.0000000000, +0.0582084316, +0.0000000000, +0.0661234757,
    +0.0000000000, +0.0764519642, +0.0000000000, +0.0905102051,
    +0.0000000000, +0.1107845781, +0.0000000000, +0.1426030657,
    +0.0000000000, +0.1998184590, +0.0000000000, +0.3332243858,
    +0.0000000000, +0.9999636803, +0.0000000000, -0.9999636803,
    -0.0000000000, -0.3332243858, -0.0000000000, -0.1998184590,
    -0.0000000000, -0.1426030657, -0.0000000000, -0.1107845781,
    -0.0000000000, -0.0905102051, -0.0000000000, -0.0764519642,
    -0.0000000000, -0.0661234757, -0.0000000000, -0.0582084316,
    -0.0000000000, -0.0519447683, -0.0000000000, -0.0468607407,
    -0.0000000000, -0.0426486966, -0.0000000000, -0.0390994399,
    -0.0000000000, -0.0360657647, -0.0000000000, -0.0334410798,
    -0.0000000000, -0.0311463069, -0.0000000000, -0.0291215436,
    -0.0000000000, -0.0273205841, -0.0000000000, -0.0257072177,
    -0.0000000000, -0.0242526657, -0.0000000000, -0.0229337690,
    -0.0000000000, -0.0217316805, -0.0000000000, -0.0206309077,
    -0.0000000000, -0.0196185982, -0.0000000000, -0.0186840011,
    -0.0000000000, -0.0178180552, -0.0000000000, -0.0170130694,
    -0.0000000000, -0.0162624744, -0.0000000000, -0.0155606252,
    -0.0000000000, -0.0149026446, -0.0000000000, -0.0142842976,
    -0.0000000000, -0.0137018887, -0.0000000000, -0.0131521795,
    -0.0000000000, -0.0126323203, -0.0000000000, -0.0121397934,
    -0.0000000000, -0.0116723666, -0.0000000000, -0.0112280539,
    -0.0000000000, -0.0108050829, -0.0000000000, -0.0104018664,
    -0.0000000000, -0.0100169797, -0.0000000000, -0.0096491399,
    -0.0000000000, -0.0092971888, -0.0000000000, -0.0089600787,
    -0.0000000000, -0.0086368590, -0.0000000000, -0.0083266658,
    -0.0000000000, -0.0080287117, -0.0000000000, -0.0077422784,
    -0.0000000000, -0.0074667084, -0.0000000000, -0.0072013994,
    -0.0000000000, -0.0069457986, -0.0000000000, -0.0066993973,
    -0.0000000000, -0.0064617271, -0.0000000000, -0.0062323557,
    -0.0000000000, -0.0060108836, -0.0000000000, -0.0057969412,
    -0.0000000000, -0.0055901856, -0.0000000000, -0.0053902989,
    -0.0000000000, -0.0051969851, -0.0000000000, -0.0050099691,
    -0.0000000000, -0.0048289944, -0.0000000000, -0.0046538214,
    -0.0000000000, -0.0044842264, -0.0000000000, -0.0043200000,
    -0.0000000000, -0.0041609461, -0.0000000000, -0.0040068807,
    -0.0000000000, -0.0038576311, -0.0000000000, -0.0037130347,
    -0.0000000000, -0.0035729386, -0.0000000000, -0.0034371988,
    -0.0000000000, -0.0033056791, -0.0000000000, -0.0031782511,
    -0.0000000000, -0.0030547934, -0.0000000000, -0.0029351907,
    -0.0000000000, -0.0028193341, -0.0000000000, -0.0027071199,
    -0.0000000000, -0.0025984499, -0.0000000000, -0.0024932304,
    -0.0000000000, -0.0023913723, -0.0000000000, -0.0022927905,
    -0.0000000000, -0.0021974040, -0.0000000000, -0.0021051351,
    -0.0000000000, -0.0020159096, -0.0000000000, -0.0019296564,
    -0.0000000000, -0.0018463073, -0.0000000000, -0.0017657969,
    -0.0000000000, -0.0016880620, -0.0000000000, -0.0016130421,
    -0.0000000000, -0.0015406788, -0.0000000000, -0.0014709156,
    -0.0000000000, -0.0014036982, -0.0000000000, -0.0013389738,
    -0.0000000000, -0.0012766915, -0.0000000000, -0.0012168018,
    -0.0000000000, -0.0011592568, -0.0000000000, -0.0011040098,
    -0.0000000000, -0.0010510155, -0.0000000000, -0.0010002299,
    -0.0000000000, -0.0009516098, -0.0000000000, -0.0009051133,
    -0.0000000000, -0.0008606994, -0.0000000000, -0.0008183281,
    -0.0000000000, -0.0007779600, -0.0000000000, -0.0007395569,
    -0.0000000000, -0.0007030809, -0.0000000000, -0.0006684951,
    -0.0000000000, -0.0006357632, -0.0000000000, -0.0006048495,
    -0.0000000000, -0.0005757189, -0.0000000000, -0.0005483367,
    -0.0000000000, -0.0005226689, -0.0000000000, -0.0004986818,
    -0.0000000000, -0.0004763424, -0.0000000000, -0.0004556178,
    -0.0000000000, -0.0004364757, -0.0000000000, -0.0004188840,
    -0.0000000000, -0.0004028113, -0.0000000000, -0.0003882260,
    -0.0000000000, -0.0003750973, -0.0000000000, -0.0003633944,
    -0.0000000000, -0.0003530868, -0.0000000000, -0.0003441444,
    -0.0000000000, -0.0003365372, -0.0000000000, -0.0003302355,
    -0.0000000000, -0.0003252099, -0.0000000000, -0.0003214310,
    -0.0000000000,
  };

float shiftLeft(float isamp)
{ 
 float sum; int i;
 for (i = 0; i < NZEROS; i++)       xv_left[i] = xv_left[i+1];
 xv_left[NZEROS] = isamp / GAIN;
 sum = 0.0;
 for (i = 0; i <= NZEROS; i++) 
           sum += (xcoeffs[i] * xv_left[i]);
       return sum;
}
 
Last edited:
I've been doing some research on centre channel extract and by common consent it seems hard to do!. We all probably know that if you have a L and a R signal the difference is (L-R) is the difference or the stereo part. It gets interesting when you consider that CCE is the combination of the common-to-both elements between L and R i.e. L really equals Unique-to-left + common-to-both and the R is unique-to-right + common-to-both. So a mono signal is not really L+R but (2*common-to-both) + (unique-left + unique-right) Now it seems you can't isolate the unique parts via algebra so some "almost" techniques have been developed.
I'm probably way off but I would think that (L+R - (L-R)) /2 would do it, too simple really !
I'll be having a play over the next couple of weeks and perhaps I can get my passive decoder up to logic level.
Sorry if this is a bit rambly but it surprising how people have no interest in digital signal processing of quadraphonic , so I've got to let it out somewhere !!


Just as a side point kudos to the people who worked with Audition to decode properly.
 
Ok guys I have a working no-logic decoder now having used the following
Code:
leftBackSamp= (jLeft * -0.707106) + ((float) rightSamp * -0.707106);
rightBackSamp=  (jRight * 0.707106) + ((float) leftSamp * 0.707106);
to do the decoding. I'll optimise these lines by removing one of the .707106.
I've converted the sqtones.mp3 into sqtones.wav and fed it through and it sounds ok except for a whistle in the left and right back channels which doesn't appear in a real SQ sample so I'm hoping that it's just a bit of oddness from the mp3->wav conversion.
The only SQ CD I have is Mike Oldfield exposed and I've done the guilty track from it, which is 382 seconds long and took 247 to decode on my Athlon 64 3000+ laptop.
I'm going to post up the .exe onto some free web space as a beta until I tidy it up a bit, i.e. create some proper WAV classes and remove hard coded values such as 16 bit samples, i.e. make it production ready. I'll release the source code then as well. I don't think I'll ever get the quality of Audition but at least we'll have something as a community which will allow us all the preserve the quad mixes for ever at zero cost.
I'll move onto the logic parts after this and see where I get to !
It's been a rough ride but I've learned a lot of stuff.
Any one fancy a test into DTS for me ??
 
Back
Top