Comments (5)
It's readonly as some channels might not want to make that property changeable via its interface, but might want to implement some other way to affect those properties - like, for instance, a channel that will fade in/out over time when triggered. If the property were required to be readwrite, that would take that opportunity away.
So, to summarise: The property doesn't need to be readwrite to work - it just needs to emit KVO notifications on changes.
from theamazingaudioengine.
I'm not sure I follow you, why would readwrite properties take away the opportunity for a channel to implement a fade in/out over time?
The problem now is that one can't have a generic id<AEAudioPlayable>
variable and set channelIsMuted on it, it will result in compilation error (assignment to readonly property). This defeats the purpose of using a protocol that can be implemented by many classes (polymorphism) and needs ugly casting hacks like this:
id<AEAudioPlayable> theChannel;
...
((AnyChannelClassThatHasReadWriteProperty*)theChannel).channelIsMuted = YES;
from theamazingaudioengine.
I designed the protocol so that the implementing class had full control over how the property was accessed - including using a secondary system to actually manipulate those values, rather than letting the 'user' manipulate them directly. So, say you have a public module that, for whatever reason, wants to perform smooth fades instead of hard boundaries when muted/unmuted. You could implement -mute and -unmute methods, or a separate boolean property 'muted', which would emit KVO for channelIsMuted at the appropriate times, leaving the actual channelIsMuted property readonly so the user can't bypass the fades or put the system into an inconsistent state.
I'm doing this in Loopy, for a concrete example; I don't want channelIsMuted to be writable, because it'll bypass the user-assigned fade settings. Instead, I have mute/unmute methods that manipulate this internally.
I suppose I can see that some projects might want external control over the mute state of all channels - I think I'd recommend making a new protocol that inherits from AEAudioPlayable and provides a readwrite channelIsMuted property, for that case.
I'm open to debate on this one - it could be that I've overthought it, although I'm presently happy with the way it is.
from theamazingaudioengine.
But couldn't an implementing class re-declare the channelIsMuted property as read-only if the author don't want the 'user' (developer) to change it? I'm not sure I understand why you need it to be read-only in the protocol.
Also, it might be better for such a fading mute property to also accept direct changes of the muted property. Maybe the developer using the class does want to mute/unmute without fading.
Yes, making a new protocol that inherits from AEAudioPlayable is what I did here, but all the AEAudioPlayable stuff bundled with TAAE does not use that protocol (of course) so I then need to cast it: id<AEAudioPlayable2> foo = (id<AEAudioPlayable2>)someStandardChannelObject;
from theamazingaudioengine.
Technically speaking, they could, but I believe this would violate the principles of a protocol, which defines the expectations one has of a class that implements it.
I guess I don't feel too strongly about it - if you do, I'm okay with accepting a pull request. This is a case of 'whoever cares more, wins' =)
from theamazingaudioengine.
Related Issues (20)
- 1.5.7 not on Cocoapods HOT 2
- Open the dome,Bluetooth speakers will automatically stop working? HOT 1
- How can I set the preferredInput? Everytime I change it, it sets it back to previous.
- Stop doesn't work if the audioDescription preferred sampleRate is different than detected
- user AEAudioController Empty my control center
- Using play through channel ,but need to delay the playing
- Prepare and begin recording
- Is TheAmazingAudioEngine possible to perform audio synthesis?
- Can only record m4a type ? HOT 1
- 请问一下theamazingaudioengine 录音的时候如何过滤扬声器声音 HOT 2
- Hi, I need to create a visualizer like ZLHistogramAudioPlot. I try to use this code
- Create ZLHistogramAudioPlot like visualizer using TheAmazingAudioEngine
- React Native version?
- regionStartTime not work
- 可以绘制音波图吗
- Crash AEUtilities.h -[AEAudioController teardown] HOT 1
- demo 不清楚怎么使用的 可以讲一下吗
- Multiple samples not playing at the same time in iOS 14 HOT 5
- `AEAudioBufferListGetLength ()` has a incorrect implementation HOT 2
- How to export modified audio file?
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 theamazingaudioengine.