Jul 3, 2010 at 9:37pm
I want to write a +~ object that won’t distort – i.e., if the result of adding the signals > 1, it outputs 1.
Is the code for max objects available? It would sure be easier to tweak the existing +~ than to code from scratch.
Unless anyone has any other ideas, or there’s an object that does this that I’ve missed?
Jul 3, 2010 at 9:48pm
I’m not sure I understand what you mean by distort. It will currently return results of > 1 with linearity. If you mean won’t let audio distort your sound card by clipping the output to 1, then you’ll be distorting the audio before it reaches your sound card, and in much the same way.
If you want a +~ that will stop not allow output of that excedes 1 or -1 then just put a [tanh~ ] after a standard [+~ ] object. This will soft-clip and sound less like digital clipping.
You can just put a [clip~ -1 1 ] after your [+~ ] to get the behaviour you desire……however if you use this with audio it *will* distort if your addition exceeds +/-1.
If you go to the download section you can get the Max5 SDK, which will walk you through writing externals, and I imagine it has code examples for standard objects.
Jul 3, 2010 at 10:34pm
1) There seems to be a fundamental misunderstanding of how MSP works. MSP works with 32-bit floating point samples, giving you a range FARFARFARFARFARFARFARFAR greater than [-1 .. 1] to work with intermediate calculations. You can +~, *~, -~ and anything else to your heart’s content. As long as you scale it back to [-1 .. 1] before going to the DACs, you’re fine.
What you want to do will *add* distortion to a signal.
2) The SDK for coding objects in C is available on this very web site. But I’d get point #1 sorted out before starting coding in C.
Jul 4, 2010 at 6:31am
if you want your signal to never reach zero the louder you get above zero, try to search the forum for atan distortion.
It sounds more ‘analog’
Jul 4, 2010 at 3:13pm
peter: that was not what he meant, but adding 2 signals with 25 bits integer would
Jul 5, 2010 at 9:54am
Hi everyone, thanks for your comments, there’s some really useful information there, much appreciated! All the best, M
You must be logged in to reply to this topic.