Re: The Synthizer Thread

OK, got simple sound playback working. Thinking about the API design a bit more, though, I wonder how terrible of an idea this is?:

  • Create a context.

  • Create a source from the context.

  • Create a generator from the source (I.e. source.new_streaming_generator, source.new_buffer_generator, ...).

  • Add and remove the generator from the source as needed. Optionally just have methods like source.add_streaming_generator that handle creating the generator and adding it automatically.

This has a couple benefits. I can add a Drop impl on generators that removes them from the source automatically, and they don't outlive their sources. Also, by only supporting creation and not actually returning the source, I can prevent adding the same generator to multiple sources. This also clarifies the shape of the API a bit, for me anyway, as there is only one path to create sound--Context-->Source-->Generator.

The obvious down side is that generators can't be reused. Not sure how big of an issue this is likely to be, though, or if the benefits of not being able to misuse the API counteract those. I suppose I could also leave in the current way of doing things, though if there is no significant drawback to tying generator lifetimes to sources then I'd rather that be the one and only way.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to