format
typescript
AudioSource.timeSamplesclass: AudioSource
description
The current sample position of the audio being played.
Sample position represents the number of sample points in the audio signal within one second. It is the basic unit of the audio clip, with each sample point corresponding to the amplitude value of the audio signal at a specific time point. It is important to note that there is a relationship between the getTimeSamples method and the getTime method. You can convert between them using the following formulas: Sample position = Time position (in seconds) * Sample rate (AudioClip.frequency) Time position (in seconds) = Sample position / Sample rate (AudioClip.frequency)
parameter
| param_name | type | description |
|---|
reture
| type | description |
|---|---|
number | The current sample position being played. |
code example
typescript
let obj = new GameObject();
let source = obj.AddComponent<AudioSource>(AudioSource);
source.timeSamples;