Skip to content

KHR_audio_emitter: Add pitchSpeed and make audio source's data optional#239

Merged
aaronfranke merged 1 commit intoomigroup:mainfrom
aaronfranke:audio-pitch-speed
Jan 3, 2025
Merged

KHR_audio_emitter: Add pitchSpeed and make audio source's data optional#239
aaronfranke merged 1 commit intoomigroup:mainfrom
aaronfranke:audio-pitch-speed

Conversation

@aaronfranke
Copy link
Copy Markdown
Member

@aaronfranke aaronfranke commented Dec 5, 2024

This PR has 2 changes in it:

  • Add a new "pitchSpeed" property to audio sources.
    • I swear we discussed this before in Discord meetings, but I guess we forgot about it?
    • It was suggested here: KHR_audio_emitter KhronosGroup/glTF#2137 (comment)
    • I would personally find this field useful, and it's supported in Godot and WebAudio.
    • Having this property aligns with WebAudio in all but name, which calls it playbackRate: https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/playbackRate
    • I don't really care what name we use. I do think having it contain the word "pitch" is valuable because users who aren't familiar with audio may expect it to resample and don't understand why changing the playback rate would "cause the pitch to change", but even then I'm good with whatever consensus we bikeshed over this.
  • Make an audio source's audio data field optional instead of required. Two reasons:
    • This technically breaks extensions such as "OMI_audio_ogg_vorbis" because they provide their own audio data separately in a new field. But if the built-in field is empty, it's technically invalid with the spec in master.
    • Making audio data mandatory means it's not possible to define gain or pitchSpeed or autoPlay on an emitter, because it's not allowed to make a placeholder audio source with no data.
    • Making this property optional fixes both of these problems.

@yankscally yankscally self-requested a review January 3, 2025 16:26
Copy link
Copy Markdown

@yankscally yankscally left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pitchSpeed... in one way, the name is illogical, but in another way, I can eyeball it and know what it means - unlike playbackRate. In the audio realm, this has many names also, so there is no concrete naming scheme for this, it's usually whatever makes the most sense in that context.

Approved.

@aaronfranke aaronfranke merged commit b48a264 into omigroup:main Jan 3, 2025
@aaronfranke aaronfranke deleted the audio-pitch-speed branch January 3, 2025 16:52
@docEdub
Copy link
Copy Markdown

docEdub commented Apr 8, 2025

Ya "pitchSpeed" is a strange name for this. I see this and instantly wonder what units it takes. Does it take cents for a pitch? Or does it take a multiplier? It's not clear from the name alone which one it is. I feel like playbackRate or playbackSpeed would be better.

@aaronfranke
Copy link
Copy Markdown
Member Author

@docEdub Thank you for the feedback! I've opened PR #248 to rename this property.

But I am curious... what in the world are cents? Is that short for percents, where 100% is a multiplier of 1.0?

@docEdub
Copy link
Copy Markdown

docEdub commented Apr 9, 2025

@docEdub Thank you for the feedback! I've opened PR #248 to rename this property.

But I am curious... what in the world are cents? Is that short for percents, where 100% is a multiplier of 1.0?

Heh, ya "cents" are a logarithmic unit of pitch measurement that musicians use that corresponds to the way we perceive the 12 pitches used in Western music. We perceive them as linear changes up and down the pitch range even though the actual frequency rate change is logarithmic. The ear is weird like this.

See https://en.wikipedia.org/wiki/Cent_(music) for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants