Reply to Message

View discussion in a popup

Replying to:
MiMenl
Enthusiast
Enthusiast

So here we go Part 1

The post will be setup in the following way.

  • Intro into the environment.
  • Background story .
  • Problem descriptions.
  • Fixes implemented.
  • Conclusion.

Intro into the environment

Since last year we are running a large VDI project within a hospital and we chose VMware Horizon as our main VDI solution, next to Horizon we use DEM for personalization and saving user settings and currently run Window 10 VDI’s. we use Instant clones to provide VDI’s to end users and try to use application virtualization as much as possible. Aslo Tap And go was one of the key points to switch to VDI

During the project we had some nice let’s call it challenges and one of the challenges mainly focused around sound, and I mean SOUND in every aspect.

Background story

This is just a  description (sum up) about the things we encountered here everything looks like it came in at once but in reality things emerged during the project. As always fixing something on the left might always break something at the right.

So there were where after some hard work finally able to roll out VDI’s to the business everything seemed cool, the tests were successful and we had full confidence we build something nice.

But after a short while the first issues started popping up (this article will only focus on sound issues though).

One of the first issues that we heard of was the fact that sound was inconsistent. Some employees had loud sounds other employees could not get the sound loud enough and the last group didn’t get sound all. The irony here is actually quite fun once you fix the issues.

So once we fixed this we ran into something else the sound was always to loud, well just reset it or change it after log on this worked but settings didn’t get saved (many things about this already on the internet). So we went for the log on log of task approach, this seemed to work fine for a while, at least for the people that worked all day at the same desktop from which they never disconnected to their VDI. This was basically the type of user that we started rolling out VDI’s too at start. But then we started rolling out VDI’s to nurses , and if you can say one thing here is that they don’t stay at one spot for a long time. They switch clients a lot since the VDI moves with them. The nursing PC’s are all turned to Kiosk PC’s and there the new issue came up. On every reconnect to the VDI session the sound level was increased to 100%. This might not really look like a big issue and during the day it didn’t matter that much but imagine the following scenario.

You are sleeping as a patient the nurse comes to check on you. But since it’s the night shift in which they also spend a lot of time waiting the nurse decided to watch a nice action movie on Netflix. She turned her sound to 20 % so no one can hear it before she started doing her checkups. She swipes out (tap and go / disconnect her session oh and leaves Netflix running just before that action scene were a bomb explodes) She than takes a mobile card moves it to the patients room, swipes her card connects to her session, sounds are raised to 100 % Netflix still playing bomb explodes and all patients are awake. Not really the wakeup call you would like. So this needs to be fixed (I hear you think but NO blocking Netflix is not an option).

And then  for the final part of the story corona happened, nothing too big since the VDI’s can be used from home too so this was quite easy except for the part were video conferencing became hot. So there come the microphones and webcams, and the issues of the microphone not being loud enough and still some devices not playing sound on the wanted levels.

So see here the challenge we had to face, and even the answers on some things that they could not be fixed (which for now doesn’t seem true) but depends on policies since the solution will involve some programming and making use of third party tools some of them were already mentioned in prior posts but I will name them again.

Below I will try to list the different issues in a more point like manner.

Problem descriptions pointed :

  • High/low sound volume, no sound at all.
  • Microphone not boosted.
  • 100% sound level reset at reconnect.

Fixes Implemented:

General notice : a lot of my solutions are programmed in VB.net I just like it and it saves me time compared to finding my way around in PowerShell. I do think the solutions can also be achieved in PowerShell but this is something you need to do yourself, at least the VB code might give you some general ideas about how to script it.

I will add the source code to the projects were possible so it can be changed and compiled, the community edition of VB.net should be sufficient. I can also provide the compiled binaries but I rather not due to the fact they are .exe files and that always is tricky. (and I didn’t fully read the rules so it might not even be allowed)

 

High/low sound volume, no sound at all.

Trouble shooting this issue was actually quite easy, apparently horizon takes over settings  from the base system when it comes to sound, making the VDI sound relative to current level of the sound volume settings of the client PC

  1. Ex. You put your base system om 50 % in this case sound in the VDI at 100 % is still 50 % of the systems possible volume. Same goes for muting muting your base system will not give you sound trough VDI. And since we run kiosk pc’s users cannot change this themselves. So this needed to be changed by IT.

Our approach.

Since we needed to change a lot of systems it needed to be done in a scripted way. We run W10 as base OS and sound is not easily managed programmatically due to the fact settings are stored in driver classes and not in registry luckily there is a nice tool from NirSoft called SoundVolumeView.( https://www.nirsoft.net/utils/sound_volume_view.html) this tool allows you to set the volume of different devices.

Even though the tool can do a lot for you it would still ask a lot of manual work at least in our environment. We are using a lot of different hardware and drivers so the sound device might be called different on different machines, it is not always clear were sound devices are connected (back port / front port) so lots of options to tackle.

The tool however also has a nice option /scomma <Filename> which lets you export all the devices on a machine to a csv file, this file can then be used to set all the devices to a certain level 100 % in our case. The tool however does not have an option to do this by itself so here we need to create a custom application/ script.

Module Module1

    Sub Main()

        'declare variables and prepare some things for later use.

        Dim strsourcepath As String = "\\test-path\\"

        Dim strAppname As String = "SoundVolumeView.exe"

        Dim strIstFolder As String = ""

        Dim strSolFolder As String = ""

        Dim strCompname As String = My.Computer.Name

        Dim commandlimeargs As String() = Nothing

        Dim strfilename As String = ""

        Dim srFilereader As System.IO.StreamReader = Nothing

        Dim p As New Process()

        Dim pStartInfo As New ProcessStartInfo()

        Dim pset As New Process()

        Dim psetStartInfo As New ProcessStartInfo()

        Dim strLine As String = ""

        Dim strsplit As String() = Nothing

        Dim strDeviceName As String = ""

        Dim bDebug As Boolean = False

        Try

            'create a filename to use for saving the csv file (computername_date_without spaces and :slightly_smiling_face:

            strfilename = strCompname & "_Audio_" & Date.Now

            strfilename = Replace(strfilename, " ", "_", 1,, CompareMethod.Text)

            strfilename = Replace(strfilename, ":", "-", 1,, CompareMethod.Text)

            commandlimeargs = Environment.GetCommandLineArgs()

            'check for arguments and take proper action

            For i = 0 To commandlimeargs.Length - 1

                If commandlimeargs(i).ToLower.ToString = "-path" Then

                    strsourcepath = commandlimeargs(i + 1)

                End If

                If commandlimeargs(i).ToLower.ToString = "-debug" Then

                    bDebug = True

                End If

            Next i

            'set folder location for file storage

            strIstFolder = strsourcepath & "\" & "Ist\"

            strSolFolder = strsourcepath & "\" & "Sol\"

            'peroare process to launch SoundVolumeView.exe

            pStartInfo.FileName = strsourcepath & "\" & strAppname

            If bDebug = True Then

                Console.WriteLine("Creating file : " & strIstFolder & strfilename & ".csv")

            End If

            'set parameters for SoundVolumeView.exe to create csv file

            pStartInfo.Arguments = "/scomma " & strIstFolder & strfilename & ".csv"

            'hide SoundVolumeView.exe window

            p.StartInfo.CreateNoWindow = True

            p.StartInfo = pStartInfo

            ' start process

            p.Start()

            p.WaitForExit(60000) ' wait for the process to finish and continue after 60 seconds if process isn't finished

            'prepare cvs file for reading

            srFilereader = New System.IO.StreamReader(strIstFolder & strfilename & ".csv")

            'read cvs file to prefprm actions

            While srFilereader.Peek > -1

                strLine = srFilereader.ReadLine

                strsplit = Split(strLine, ",", , CompareMethod.Text)

                'check for device entries

                If strsplit(1).ToLower.ToString = "device" Then

                    If bDebug = True Then

                        Console.WriteLine("Found device : " & strsplit(0).ToString)

                    End If

                    'prepare process to set volume based on csvfile entries

                    psetStartInfo.FileName = strsourcepath & "\" & strAppname

                    If bDebug = True Then

                        Console.WriteLine("Settig volume to 100 % for device : " & strsplit(0).ToString)

                    End If

                    'set volume of device

                    psetStartInfo.Arguments = "/setvolume " & Chr(34) & strsplit(0).ToString & Chr(34) & " " & "100"

                    pset.StartInfo = psetStartInfo

                    pset.Start()

                    pset.WaitForExit(60000)

                    If bDebug = True Then

                        Console.WriteLine("Unmuting device : " & strsplit(0).ToString)

                    End If

                    'unmute device

                    psetStartInfo.FileName = strsourcepath & "\" & strAppname

                    psetStartInfo.Arguments = "/Unmute " & Chr(34) & strsplit(0).ToString & Chr(34)

                    pset.StartInfo = psetStartInfo

                    pset.Start()

                    pset.WaitForExit(60000)

                    If bDebug = True Then

                        Console.WriteLine("Finished configuring device : " & strsplit(0).ToString)

                    End If

                End If

            End While

            If bDebug = True Then

                Console.WriteLine("Creating file : " & strSolFolder & strfilename & ".csv")

            End If

            'create csv file containing results

            pStartInfo.Arguments = "/scomma " & strSolFolder & strfilename & ".csv"

            p.StartInfo.CreateNoWindow = True

            p.StartInfo = pStartInfo

            p.Start()

            p.WaitForExit(60000)

            Threading.Thread.Sleep(10000)

            srFilereader.Close()

        Catch ex As Exception

            Console.WriteLine("Something went wrong see error description below :")

            Console.WriteLine(ex.ToString)

            Threading.Thread.Sleep(10000)

        End Try

    End Sub

End Module

To create this program start a new console application in vb.net call it SetBaseVolumes and copy the above code to module1.vb

The application has a couple of command line arguments and needs some setup.

-path <path>  the specified path will be used as path to look for the SoundVolumeView.exe file.

-debug will show information in the command prompt else it will just stay black till the process is finished.

Setup:

In the folder that is specified with the path parameter create 2 subfolders :

Sol and Ist.

Your folder setup would look like this :

Path

Path\sol

Path\ist

The folders are used to store the csv file prior to setting values and after so you can check if things changed from a central location.

The application will be compiled to SetBaseVolumes.exe

It is advised to store the executable on a network share and also create a network folder to store the SoundVolumeView.exe also create the ist and sol folder in this directory.

Make sure the program runs under a user with network access we use Altiris with a service account to achieve this, and push a job to all machines.

The syntax could be something like this \\appfolder\setbasevolumes.exe -path \\destfolder\csv

Don’t add the final \ to the destination path this is added by the program.

Working :

The first part of the code is used to declare some variables and prepare some things to launch the processes in a proper way.

Step 1 create a filename based on computer name and time stamp

Step 2 create csv file with all devices for the machine it is run on

Step 3 read csv and set volumes

Step 4 create file with results.

I added some minor comments to the code but feel free to ask questions if needed.

The end result will be that all connect devices on the base (client kiosk pc) will have the volume level set to 100 % and if the device was muted it will be unmuted.

This will only work for connected devices so make sure all the things needed by the end user are plugged in.

So that was part 1 of the solution covering the sound levels of the base machine which seem to be used by horizon as relative sound levels.

Microphone not boosted.

So after we fixed the sound issues of the base system the microphone issue popped up. This also seems related to the base system since VMWare uses the microphone array in the VDI which basically seems to use the local machine settings for the microphone.

We would also like to set this scripted but this device is not listed in the CSV.

Apparently the “Microphone Boost” or “Microfoonversterking” is a virtual device which can be set by SoundVolumeView.exe but with a slightly different command line option.

In this case we used :

soundvolumeview.exe /setvolumedecibel “[device name]” 24

This will set it to the maximum boost.

Keep in mind that depending of the OS language this device name will change in this case

Microfoonversterking = Dutch

Microphone Boost = English

This command should also be run from the pc that needs the setting and the microphone should be plugged in.

Once these setting are done you can manage your sound levels within the VDI by using the master volume and in applications the microphone array settings.

This kind off covered the first two issues from the issue list (for us) so up to the next one.

The sound reset on reconnect. (part 2)

It's not code it's spaghetti, and who doesn't like pasta ?