Comments (3)
I'm unsure of the exact reasoning, but I can tell you for me, std::pair is kind of annoying to deal with, .first
and .second
don't really specify what the members mean, plus AttributePair
is self documenting in a way.
&std::get<0>(attrs.front())
is way less readable than &attrs.front().mAttribute
in my opinion. I don't really have an easy place to figure out what conceptual member I'm std::get
ing. mAttribute
makes this easy, I'm getting a reference to the attribute part of the attribute pair array. It also has the added bonus of auto-completing in the IDE so I technically have less to type (not that this is a reason to change it).
This is a common pattern outside of this repo as well, and even in other languages.
from alure.
The AttributePair
struct, besides giving more descriptive names to the members, helps guarantee the attribute and value are stored in a trivially copyable type, essentially meaning the raw data can be accessed (std::pair
is rather complicated when it comes to being trivial). The reason for this is the same reason the attributes need null termination, because it's passed directly to OpenAL without further interpretation. OpenAL itself requires either a null attribute list, or a contiguous sequence of integers representing a series of {attribute, value}
pairs that ends with a 0
attribute. If the array given to Alure doesn't have the null termination, it needs to be copied to ensure there is one.
The reason std::unordered_map
can't be used is because of that contiguous layout requirement. Also, despite its name, an unordered_map
does have ordering, just that the app can't rely on any particular order (it uses hashed keys, where the hashing algorithm is implementation-defined).
from alure.
Thank you both for the prompt explanation! My mind now settled so I can continue on wrapping this in Cython. I guess I can close the issue at this moment.
from alure.
Related Issues (20)
- Sample offset should be set only after attaching source to buffer? HOT 1
- Capture and real-time support HOT 7
- How to fill buffers with data not from files HOT 14
- Golang port/interface? HOT 6
- feature request: direct modification of spatial locations HOT 4
- Invalid Source ID (getSampleOffsetLatency) HOT 7
- Why couldn't (or shouldn't) buffers clean themselves? HOT 4
- Please add 3D sound example HOT 5
- I am having troubles with include path for OpenAL headers HOT 4
- Is std::out_of_range suitable for out of range floating points? HOT 2
- fill buffer with data not from file but of a known format HOT 6
- How to safely use Context::precacheBuffersAsync? HOT 2
- Alure libraries can't be linked dynamically on Windows HOT 8
- Questions about the project state HOT 2
- Why does Alure have different include files and which files should we use? HOT 2
- set3DSpatialize HOT 10
- kcat.strangesoft.net site is gone HOT 11
- "alure" prefixed functions not declared or defined in this repository HOT 2
- Crash after playing multiple sources simultaneously HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alure.