private void StartSound() { float pitch; ALsetup.SLplayTone(); while (ALsetup.SLtoneupdate()) { pitch = (float)Foot.Frontfoot.CurrentMarker.xCoordinate / 100; ALsetup.SLchangepitch(pitch); } //update = new Thread(new ThreadStart(KeepPlaying)); //monitor = new Thread(new ThreadStart(Monitor)); }
private void Monitor() { float pitch = (float)Foot.Frontfoot.CurrentMarker.xCoordinate / 100; ALsetup.SLchangepitch(pitch); }
private void KeepPlaying() { int st = Environment.TickCount; float pitchparameter, distance; try { while ((ALsetup.SLtoneupdate())) { //System.Diagnostics.Debug.WriteLine("In >KeepPlaying< " + tc.ToString()); //tc++; if (stopUpdate) { Thread.CurrentThread.Abort(); } //if (Foot.Frontfoot != null) //{ if ((left.CurrentMarker != null) && (right.CurrentMarker != null)) { if (left.CurrentMarker.zCoordinate > right.CurrentMarker.zCoordinate) { distance = (float)(Math.Abs(left.CurrentMarker.xCoordinate)); } else { distance = (float)(Math.Abs(right.CurrentMarker.xCoordinate)); } //distance = (float)(Math.Abs(Foot.Frontfoot.CurrentMarker.xCoordinate)); /*} * else * { * double zL = -9999; * double zR = -9999; * if (left.CurrentMarker != null) zL = left.CurrentMarker.zCoordinate; * if (right.CurrentMarker != null) zR = right.CurrentMarker.zCoordinate; * if (zL > zR) * { * distance = (float)(Math.Abs(left.CurrentMarker.xCoordinate)); * } * else * { * distance = (float)(Math.Abs(right.CurrentMarker.xCoordinate)); * } * * }*/ //System.Diagnostics.Debug.WriteLine("Frontfoot x:" + distance); //if (distance < 450) //{ if (distance < 5) { pitchparameter = 0.005f; } else { pitchparameter = (float)(1 / (2 * Math.Log10((double)(1.1 + (distance * 0.01))) + 0.02f)); } ALsetup.SLchangepitch(pitchparameter); //} //else //{ // System.Diagnostics.Debug.WriteLine("----> Distance >450 <----"); //ALsetup.SLstoptone(); //} //if (distance < 400) ALsetup.SLplayTone(250); } else { System.Diagnostics.Debug.WriteLine("---->Frontfoot NULL<----"); } } System.Diagnostics.Debug.WriteLine("Sound. Update loop ceased:" + (Environment.TickCount - st).ToString()); } catch (NullReferenceException) { System.Diagnostics.Debug.WriteLine("Null in Foot.Frontfoot"); } catch (ThreadAbortException) { System.Diagnostics.Debug.WriteLine("Update thread has aborted"); } }