Home Forums DIY Amplifiers and Electronics How do you do positional audio on the fly?

  • How do you do positional audio on the fly?

  • SteveM

    Member
    December 5, 2021 at 11:51 pm

    I’m working on a project where we need to move sound around a room in real time. We have four ceiling mounted corner speakers.  We want to have a sound effect, say a thunderstorm, originate from the south east corner of the room, move to the center of the room, then exit the north east corner. The position of the audio would be controlled by an iPad. Moving your finger round the surface of the iPad would move the sound. This is very similar to how you can adjust the audio balance on some cars.  

    I am assuming you would have to use some sort of DSP to do this but know nothing about DSP and how it could be run through a touch screen.  If anyone has some idea’s please let me know. 

    Thanks

  • ajc9988

    Member
    December 6, 2021 at 1:39 am
    Posted by: @stevem

    I’m working on a project where we need to move sound around a room in real time. We have four ceiling mounted corner speakers.  We want to have a sound effect, say a thunderstorm, originate from the south east corner of the room, move to the center of the room, then exit the north east corner. The position of the audio would be controlled by an iPad. Moving your finger round the surface of the iPad would move the sound. This is very similar to how you can adjust the audio balance on some cars.  

    I am assuming you would have to use some sort of DSP to do this but know nothing about DSP and how it could be run through a touch screen.  If anyone has some idea’s please let me know. 

    Thanks

    I’m not a coder so cannot tell you how to code or implement. But, one way you could try is to write the code to have the direction pad set so that the center engages the sound from all speakers, then do a relative sliding scale so that when your finger is closer to a speaker, it effects an SPL slider (volume slider) for the individual speaker. This is not a perfect solution, but you can then play at relative distance on the square for relative volume level. Put cutoffs so past a certain point, it no longer will deliver any signal to the speaker in the opposite area (so that about 2/3 of the way in one direction on the pad cuts off playing out of the speaker in the corner that far away) while slowly increasing in the corner for 1/3 away, varying in volume depending on distance.

    Instead of thinking squares on a pad, you could do volume level by relative position through circles overlaying the touchpad. So, you will have aa arc for each speaker, with how far out that arc is set to zero volume (so if ever outside of the circle for each speaker, the speaker plays nothing). Then, have the volume increase if touching between the outside of the circle with touching the corner or a designated point representing the speaker as 100% or whatever is needed.

    You may need to play with the size of the circle or the scale for how much volume, adjust for if center point or left to right movement or front to back.

    I’m just spitballing. So don’t take that as gospel. Just use the software to act as a gui interface to the sound output to the speakers, with a split per speaker recognized by the OS.

     

    Edit:

    I realized you do not always have a volume level per speaker on an OS (or you attach it to a dsp doing the volume level per speaker, but you get that).

    You can also work with a left/right fade with pumping front and back volume as if channels. In other words, if you have a fade dimmer for sliding directional side to side,  and a front to back fade, you could allow the signal to play louder and use the fade two directions to control signal direction and intensity. It is very similar to doing a volume slider per speaker with representational position for relative volume per speaker, but it comes with slight differences on outcome in effects.

    Sorry, just trying to think similar to how sound effects on a soundboard are done through pushing volume in different places to draw attention. Volumes and fades are what came to mind. The code is to convert the position in a square over to a relative position of a slider (regardless of volume or fade). Then, it can either be done through a lookup table by creating a grid on the square touchpad or through an algorithm for extrapolation of relative position to convert position to relative desired amounts on each slider effected. This can also be done by varying volume sliders and fade sliders simultaneously.

    Once again, I cannot code, just am good at giving descriptions on ways I think it could be done.

  • TVOR-Ceasar

    Member
    December 6, 2021 at 3:04 am

    Not sure how to implement it in software, but understanding how you would do it in hardware might help.

    I think the easiest way to understand is to use 4 potentiometers in a joystick configuration – 2 opposite each other for left/right and (90°) 2 opposite each other for front/back. The opposing pairs would be wired so that when the joystick is all the way to one side, one pot would be at 100% (full signal) while the other would be at 0% (full ground). That way when the joystick is at a full corner, only that channel gets (2) 100% of the signal- 100% either left or right, and 100% either front or back. Then there’d be a way to either sum them together or further steering. Here’s a rough sketch:

    Many joysticks only use 2 potentiometers and voltage levels determine position 0=full left, 50%=center and 100%=right, same with front/rear.

    So, in software, you’d have to define the screen area and, I am assuming here as I don’t program for such things, what row/column would be the 4 corners. Then left/right would be defined by the column value while front/rear would be determined by the rows: low to high and vice-versa accordingly to set the % direction for each direction. Then you would read the cursor, compare the values to each direction, sum the 4 quadrants ( you might need to have a scaler – divide by 2 ), then apply those values to the volume control for each output. 

    At least that’s the way I see it. Hope I haven’t confused you.

    *Edit: Since you would be calculating the % in one direction, the opposite direction would be 100% (or 1 if not converted to %) – the first calc’d %. I think that would save you a tick or two in calc time.

    **Edit: Thinking further about it, you really only need to calculate 1 set of percentages, everything else can be obtained from those 2.
    FL: calc cursor position % for front (“A”) and left (“B”) in relation to 100%
    FR: Front % (“A”) and (100%-left percent (“B”))
    RL: (100%-front percent (“A”)) and left (“B”)
    RR: (100%-front percent (“A”)) and (100%-left percent (“B”))

  • TVOR-Ceasar

    Member
    December 6, 2021 at 3:42 am

    You know, my mind must be fried – I’ve been working all week and weekend.

    The signal come in through the wiper and out through the ends where they are connected as the individual quadrants.

    This is the direct way to do it in hardware. In software, you still need to calculate individual values from the cursor position within the program/app window. 

    That’s it, I’m done for the night.

  • TVOR-Ceasar

    Member
    December 6, 2021 at 2:49 pm

    You know what, just disregard my hardware analogies and go with the thought process behind the software explanation. What I thought was clear last night now looks like sleep deprived hallucinations. Even I’m somewhat confused by what I wrote! LOL  

  • SteveM

    Member
    December 6, 2021 at 6:25 pm

    @tvor-ceasar Ok first off Thank You for what I can only thing was a blast of sleep induced brilliance! I have to say from a 30 thousand foot view what you wrote makes perfect sense. You are controlling the volume of each speaker by calculating the distance and overlap of the sonic zones as your finger moves across the four corners of the tablet. I say tablet but the joystick would work just the same. Unfortunately I do not have that type of programing background. Ask me to write a multidimensional database and I’m your man. But this… WOOSH right over my head. This is a good programing outline but I was hoping that there was a DSP solution to start with that programing could then be applied to.  As I have seen something similar does with car audio maybe I should also ask there? 

    P.S. Thank you very much by the way.  You evidently understand this process much more than I.  🙂

     

  • ajc9988

    Member
    December 6, 2021 at 7:24 pm

    @stevem – The simplest way (which can be done in DSP or software if the OS has a per speaker connection) would be a Look Up Table grid array for the sliders for volume or fade.

    Now, for the square, it can be mapped to different dots in the square area for the lookup table.

    You then assign each intersection a name. Then, you assign for each name positions on each slider, with those positions being 1-100%. That way, as you touch the gui square, it then codes to translate and set each volume slider or fade slider between left/right and front/back to the value set in the lookup table for each slider.

    This then means as you slide and activate each grid point on the gui, the program accesses the LUT, then applies the value of the LUT to each slider for the last activated point on the grid array.

    For doing an algorithm, you convert the values in the LUT to a more sliding scale rather than a pure grid point basis with the math interpolating the values between the grid points.

    I can’t code, but I don’t know a better way to spell out roughly what the program does.

  • SteveM

    Member
    December 6, 2021 at 9:20 pm

    @ajc9988 Yes I understand what you are saying.  That you bind the volume for each channel to a look up table that the application would then reference.  My issue is that I need to find an application that would do it.  I do not mind scripting any code that would be needed but I have no idea where to even start.  I thought there may be some sort of software dsp that I could hook up to an amp or something like that.  Unfortunaly I am not a sonic engineer so I’m just treading water on this so far.  Trying to get enough information to figure out what parts I need then figure out how to connect the parts. 

  • ajc9988

    Member
    December 6, 2021 at 9:36 pm

    @stevem – Ah, got ya. Reach out to Analog Devices Inc.

    https://www.analog.com/en/design-center/evaluation-hardware-and-software/evaluation-boards-kits/EV-21593-EZKIT.html#eb-overview

    Talk to them about their sample products like the one above. Then ask questions about creating the software program in their programming studio CrossCore Embedded studio. Ask if they have any coding examples of gui interfaces and describe adjusting volume and/or fade sliders using a LUT like I described. Ask what else you would need to setup the device, including if a JTAG is needed.

    I didn’t know if you were looking for a simple application type design or if you wanted to more do product development.

    CCES and SigmaStudio for SHARC, working together, should allow for it, or you can code python for a microcontroller to control the signal delivered to the SHARC DSP (or other DSP), thereby having the per channel control done on something like a developer board.

    If given more time, I am sure I could generate more options of what platforms and code that could be used.

  • ajc9988

    Member
    December 6, 2021 at 9:39 pm

    @stevem Another way is to use a raspberry pi with DAC, define the multiple outputs (speakers) in it, then use python or C/++ to code the interface, although then you have to setup network access from another device, etc.

    If willing to do that, that is a perfectly acceptable solution, I would think

  • SteveM

    Member
    December 7, 2021 at 8:04 pm

    @ajc9988

    Posted by: @ajc9988

    Reach out to Analog Devices Inc.

    I have contacted them and they are looking into it.  Thank you for pointing me in the right direction. 

    Another question if you have time.  In your second response you said…

    Posted by: @ajc9988

    Another way is to use a raspberry pi with DAC,

    I know little if anything about this type of sonic manipulation, so my apologies for the most basic of questions but… are you referring to a hardware DAC connected to a pi or a software DAC running on a pi? I didn’t think you could program a hardware DAC, at least not the type I have. So I have to assume you are talking about a software DAC? If so I didn’t know they made software DACs and do you have one you would suggest. Windows if there is a windows based open source one I would love to fool around with it. Or am I way off base in my conclusion

  • ajc9988

    Member
    December 7, 2021 at 10:14 pm

    @stevem – Glad ADI is looking into it! They have been helpful when I’ve contacted them in the past.

    As for how to do it with the RPi and DAC HAT.

    First, you need a DAC or DACs that can stack so that you have 4 channels of audio out. A normal DAC HAT has stereo out, left and right channel. But, as you said, you need 4 outputs, not 2.

    You then have to dig deeper into the Linux implementation of their audio drivers and the tree overlay for signal routing. ElliotDesigns and I talked in the DSP thread ( https://toidsdiyaudio.com/community/postid/7781/ ) about using an RPi as a FIR filter DSP for implementation in an active speaker or for a system. From that post (and the links therein) moving forward, we discussed a bit while I was researching running down that line on what to do.

    In it, you will see that you can setup signal processing for a crossover on a RPi, then having the signal go out per channel. If you modify that information, you can control it for a per-speaker output, meaning you just need a DAC and the driver tree overlay to be lined up to control the multi-channel output. Once you have that setup in RPi, it is then just setting up for independent control of volume per channel.

    After you work that part out, then it is writing the code for the LUT and verifying that works. Then you have to setup either an internet or bluetooth access to the RPi where it then can control the program, followed by creating an app for your android phone for the gui interface after it sinks to the RPi over ethernet or bluetooth.

    So, it really depends how involved you want to get with this project. But, remember, every road is walked with a first step. Start by looking through that thread and at the links to different ways to implement DSP on the RPi for adding a FIR filter or an active crossover. During that time, keep your eye out to focus specifically on information for controlling the DAC output per channel. That should give you a rough start to see if you want to try to go through all of that to then develop the apps needed.

    Hope that helps.

  • SteveM

    Member
    December 8, 2021 at 5:57 am

    @ajc9988 Oh that does help, quite a bit.  I’ll do as suggested and start with the links.  Thank you very much for the time you have taken to explain all this to me.  It is much appreciated. If you should ever have computer problems please do not hesitate to ask me for help.  Hardware or software. 

  • ajc9988

    Member
    December 8, 2021 at 7:44 am

    @stevem – I just realized the post I tagged didn’t have the link to CamilleDSP from github.

    https://github.com/HEnquist/camilladsp

    https://github.com/HEnquist/camilladsp/blob/master/backend_wasapi.md#configuration-of-devices

    For the first link, look for its implementation of Gain, Volume, and Loudness. 

    The second link is WASAPI, discussing camilleDSP in relation to a Windows API. In case you want to take it that way. I didn’t look at the Windows implementation much, so you’ll get to read through and see if you want to use anything related to that.

    And that sounds wonderful. I’m a techie from way back, better with hardware than software. But if I ever need anything, I’ll definitely ask! Thank you for that.

  • SteveM

    Member
    December 8, 2021 at 8:19 am

    @ajc9988 I’m retired now but up until a short while ago I was a cloud software and hardware implementations manager for a managed service provider.  That’s middle management speak for the guy they call when the internet don’t work right. I mostly worked on web development for SharePoint/Office 365, SQL, HTML and so on for large companies. But I started out making desktops and servers. And still do, just don’t get paid for it any more.  🙂 

Viewing 1 - 15 of 20 replies

Start of Discussion
0 of 0 posts June 2018
Now