BUG: Piezo Driver

I think I’ve found a bug in the Piezo driver at [url]http://code.tinyclr.com/project/18/piezo-speaker/[/url]

In the 2nd Play method overload, which takes an array of frequencies and an array of durations:

            public void Play(int[] freqs, int[] durations_mSec)
                if (freqs.Length != durations_mSec.Length)
                    throw new ArgumentException("Arrays must be of the same length.");
                for (int i = 0; i < freqs.Length; i++)
                    Play(freqs[i], durations_mSec[0]);

the looping code that calls into the other Play overload uses the integer 0 rather than i inside the loop. As a result, the code will always use the first duration_mSec value in the array, rather than the one that corresponds to the current loop iteration. I think the correct line should be:

Play(freqs[i], durations_mSec[i]);

Good catch!


Happy to help. I was worried that someone was going to tell me that this was a known issue, discovered long ago, and then I’d have to hang my head and go stand in the newbie corner. :wink:

Glad to be able to contribute in some small way to the community.