Allegro.cc - Online Community

Allegro.cc Forums » The Depot » Rotating stereo sound again

This thread is locked; no one can reply to it. rss feed Print
Rotating stereo sound again
Johan Halmén
Member #1,550
September 2001

Um... "again" refers to this.
Anyway, I picked up that thing again and thought of doing a test application for it. The binary and source are attached.

What the application does is it takes the stereo sound wave, treats it as a sound wave graph in 3D (x is time axis, y is left channel, z is right channel). Then it rotates the graph around x axis, which makes all instruments with their own stereo panoration oscillate back and forth in the stereo field.

Only the following controls have some functionality:
play, load, quit, Direction, Transition, Number of rotations, Do the twist

What you do is you load a wav file (stereo, 16 bit), then you mark a section (drag in the wave), then you click "Do the twist". The sound in the section will turn around in the stereo field the desired number of times.

0-360 means a full rotation. This is the only working. 0-180-0 means a halfway rotation, the turning back. I don't actually know why I put it there in the gui. I might not implement it.

The smooth transition is supposed to mean a slow start of the rotation.

My intention was to create a plugin for Audacity, but I never got the plugin SDK to work.

{"name":"598496","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/a\/aaf60b33942ff7def309338992b401f3.png","w":806,"h":532,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/a\/aaf60b33942ff7def309338992b401f3"}598496

Allegro doesn't have a function for saving a sample, but I guess it shouldn't be difficult to create a binary chunk that meats the specifications of a wav file.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Ron Novy
Member #6,982
March 2006
avatar

Something like a stereo width effect with the ability to do proper rotation?
Like Adobe Audition's Stereo Width effect (it can rotate the stereo field)?

Rotating using sin and cos can give undesirable results like inverting the signal when rotated too far... In reality what you are actually doing here is rotating the phase of the two signals at 90 degrees from each other and mixing them together. In stereo music and broadcast, phase problems are to be avoided, but it's common for an audio engineer to adjust the rotation of a stereo track to center it before mixing and mastering...

On a side note, panning stereo and rotating stereo fields are quite different, but still cool to play with...

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Johan Halmén
Member #1,550
September 2001

Yes, this is a very synthetic effect. When I've rotated 90°, left has become right and right has become phase inverted left. You hear the individual instruments move, sometimes in opposite directions. And sometimes their directions become undeterminable, obviously due to the phase errors.

And in this rough hack the seam between the untouched sound and the twisted sound might get a glitch.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Thomas Fjellstrom
Member #476
June 2000
avatar

Not sure you care:

moose@natasha:~/rotapan/rotapan$ g++ *.cpp -o rotspan `allegro-config --libs`
rotapan.cpp: In static member function ‘static void rotapan::twist(SAMPLE*, int, int, int, int):
rotapan.cpp:82: error: cast from ‘short unsigned int*’ to ‘int’ loses precision
rotapan.cpp:83: error: cast from ‘short unsigned int*’ to ‘int’ loses precision

append:

#SelectExpand
1moose@natasha:~/rotapan/rotapan$ gdb ./rotspan 2GNU gdb 6.8-debian 3Copyright (C) 2008 Free Software Foundation, Inc. 4License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 5This is free software: you are free to change and redistribute it. 6There is NO WARRANTY, to the extent permitted by law. Type "show copying" 7and "show warranty" for details. 8This GDB was configured as "x86_64-linux-gnu"... 9(gdb) run 10Starting program: /home/moose/rotapan/rotapan/rotspan 11[Thread debugging using libthread_db enabled] 12[New Thread 0x7f21d824e710 (LWP 13687)] 13[New Thread 0x7f21d4412950 (LWP 13694)] 14ALSA lib rawmidi_hw.c:233:(snd_rawmidi_hw_open) open /dev/snd/midiC0D0 failed: No such file or directory 15[New Thread 0x7f21d322c950 (LWP 13699)] 16 17Program received signal SIGSEGV, Segmentation fault. 18[Switching to Thread 0x7f21d824e710 (LWP 13687)] 190x0000000000402bb5 in rotapan::twist (snd=0x0, type=1, dir=1, ttype=1, n=1) at rotapan.cpp:77 2077 s = (unsigned short*)snd->data; 21(gdb) bt 22#0 0x0000000000402bb5 in rotapan::twist (snd=0x0, type=1, dir=1, ttype=1, n=1) at rotapan.cpp:77 23#1 0x0000000000402aae in main (argc=1, argv=0x7fffe037b608) at main.cpp:164 24(gdb)

Note, I'm on a 64bit system.

append2:

And trying to fix the problem makes it do absolutely nothing (if it doesn't freeze first!).

The crash log was from a couple files I thought were valid, but a new file loaded fine. but nothing happened when I pressed play or do the twist (except the one time it froze up).

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Johan Halmén
Member #1,550
September 2001

It might crash if you try to play without first loading a wav. And I guess not all 16 bit stereo wavs are the same. IIRC some might have signed shorts, some unsigned shorts. I've treated the sound data as unsigned short, zero level being 32768.

And I've might have done some unconventional things to get to the sound data, which not all compilers digest. When marking the sound section, I get a section in the range of 0-700 (the width of the bitmap). These are ints. I have to convert them to pointers to the unsigned shorts in the (void*)sample->data. I bet there's a proper way to do this.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Just curious, are you trying to emulate a Leslie speaker? There's a button to click under the image to hear a piano played through a Leslie speaker.

They all watch too much MSNBC... they get ideas.

Tobias Dammers
Member #2,604
August 2002
avatar

Probably not. The most interesting thing about a leslie speaker is how it creates spaciousness using the Doppler effect. The typical stereo image in leslie recordings is achieved using two microphones, each picking up a different phase of the rotation (typically they are placed at an angle, so that they are not directly facing each other); the total effect is one where you have four signals, two on each channel, and each with a different rotation phase. It is also common to put the speaker into an enclosure that adds room acoustics, like a bathroom (strong short reverb), adding even more spaciousness to the sound without producing long reverb tails.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Johan Halmén
Member #1,550
September 2001

I believe the Leslie speakers were originally only developed for the acoustic effect in live performances. Placing microphones around the speaker when making recordings must be a newer thing, kind of further development or a new implementation of the original idea.

My original idea of this effect was an effect I would imagine one could achieve by placing the acoustic band on a theatre stage with a circular rotating floor. They would stand at the front hemi-circle, facing to the audience. Then the floor would start rotating and all players would move to the right, while the right most would quickly start moving to the left, behind all others. After 90° all members would be on the right side. Half of them would be at the rear quarter. After another 90° all would stand on the rear hemi-circle. And so on. Each time they pass the starting position, the stereo sound would be the original. At some point in my effect the stereo image is very obscure, but you could imagine that to be due to the members standing at the rear hemi-circle - and maybe facing in the wrong direction. Not that that would be a true analogy to the phase errors in my effect.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Ron Novy
Member #6,982
March 2006
avatar

I think a better method might be this...

Treat each channel (left and right) as a mono. Use separate pan faders for both using a -3dB or -6dB pan law. [1] Make the left and right pan faders opposites of each other. This will sound a bit different, but won't invert the phase of the signals...

The wiki page should explain it all ;D

[edit]
I guess the key there is to make sure the pan formula never returns a negative...

You could also design a 3D mixer where you position tracks in certain spots on a grid, set the amount of rotation and then calculate the panning based on there position over time. If you do decide to create something like this for music I wouldn't include the volume at distance or I would at least make an option you can turn on/off. It just doesn't sound that great with music a lot of the time.

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Johan Halmén
Member #1,550
September 2001

But panning still does nothing else than raises or lowers the volume of left or right channel, making everything move in the same direction at same time. In my effect all start moving in one direction, but after a while some instruments start moving in the opposite direction while the oters still move in the original direction.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Ron Novy
Member #6,982
March 2006
avatar

If the stereo track was recorded with the mics close together it should work well as long as their levels are set correctly. Techniques such as coincident pair, x-y and Mid-Side should be ok with stereo field rotation, but something with the mics spaced further apart will sound odd...

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Tobias Dammers
Member #2,604
August 2002
avatar

Placing microphones around the speaker when making recordings must be a newer thing, kind of further development or a new implementation of the original idea.

Dates back to the 1960's. Most of the classic Hammond recordings have been played through a Leslie (or similar equipment).

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Go to: