Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio: Decode and RegisterFormat #3195

Open
11 tasks
hajimehoshi opened this issue Feb 11, 2025 · 1 comment
Open
11 tasks

audio: Decode and RegisterFormat #3195

hajimehoshi opened this issue Feb 11, 2025 · 1 comment
Labels
Milestone

Comments

@hajimehoshi
Copy link
Owner

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

I propose these APIs for audio:

// RegisterFromat registers audio format for Decode.
func RegisterFromat(name string, magic string, decode func(src io.Reader) (sampleRate int, length int, err error))

// Decode decodes an audio stream and returns a decoded string in 32bit float little-endian format.
// The format is detected by the magic bytes.
func Decode(src io.Reader) (stream io.Reader, format string, sampleRate int, length int, err error)

This is like image.RegisterFormat and sql.Register.

Why is this needed?

This enables to decode audio streams more easily. Users don't have to care which decoder is used.

@hajimehoshi hajimehoshi added this to the v2.9.0 milestone Feb 11, 2025
@hajimehoshi
Copy link
Owner Author

The problem is that a magic string is not enough: an Ogg container might have various data, not only Vorbis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant