Understanding the timescale property
Posted: Sun Dec 02, 2018 6:08 pm
I've worked with LiveCode/Revolution for decades, not as a developer but as an educator and researcher. I have a dictionary app (of an American Indian language) that I've made that uses audio files to play examples of words in the dictionary. To do this, I take a full audiotext (as an mp3), and then cycle through the text, getting the "duration" of the snippet that represents the portion of the audiotext corresponding to the sentence I want to play for a given word. I noticed in LiveCode 9 (and perhaps earlier versions, it's been years since I played with dictionary app) that the audio snippets weren't playing properly, and with some trial-and-error, figured out that the timescale property was different than I had originally programmed for. I did not factor in timescale to calculations in my earlier version of the app, because I didn't need to. Now, on my Mac, in LiveCode 9, some audiofiles have a timescale of 22050 and others of 44100. So this seems pretty obviously to correspond to the sampling rate of the original audiofile. So I rewrote my scripts to accommodate these values, and now things work quite well. However, when I went to work with the dictionary stack in Windows 10, nothing worked in terms of the audio. Some inspection showed that the timescale in Windows 10 was
10000000
that is, 10 million. Why this number? It is the same for both 22050 audio and 44100 audio. I found that taking the measurements that worked on my Mac and multiplying them by 226 (for the 44100 audio), everything works. I haven't tested the 22050 samples yet. Here is my question:
Where is the value of 10000000 coming from in Windows, and how consistent is this across various Windows OS versions? Another possibility is that this is a value inside LiveCode itself, and the StandAlone might work differently? I would just like some clarification here.
Obviously, I now know, the way to code to allow the playing of audio snippets inside a unit audiofile is to factor the timescale into the determination of the start and endpoints of the player.
Thanks.
Rand (Minogaade) Valentine
Madison, Wisconsin
10000000
that is, 10 million. Why this number? It is the same for both 22050 audio and 44100 audio. I found that taking the measurements that worked on my Mac and multiplying them by 226 (for the 44100 audio), everything works. I haven't tested the 22050 samples yet. Here is my question:
Where is the value of 10000000 coming from in Windows, and how consistent is this across various Windows OS versions? Another possibility is that this is a value inside LiveCode itself, and the StandAlone might work differently? I would just like some clarification here.
Obviously, I now know, the way to code to allow the playing of audio snippets inside a unit audiofile is to factor the timescale into the determination of the start and endpoints of the player.
Thanks.
Rand (Minogaade) Valentine
Madison, Wisconsin