Flipping [phasor~] possible? (Read EDIT)

    Jun 09 2013 | 2:44 pm
    So, when I was writing my TB-303 emulator synth, I've done some more research on the square wave of it...
    I've seen many different ideas on the square wave. I've heard about the waveshaping that I mentioned in an earlier thread, but there is another common thought:
    The "square" wave is generated by one saw wave, flipped every-other cycle and divided by 2, to keep it between -1 and 1. I want to try doing this, so I've decided that I want to try to take 2 [phasor~] objects, one normal, one upside down, and gate the two so that one will shut off at it's 0 amplitude and the other will start at the same time. The problem is that I don't know how to invert the wave.
    The thought has crossed my mind of simply taking a [buffer~] object, loading it with this sort of modified saw wave, and driving that with [mtof], but I see this as no challenge and, if it's possible, I want to manually create the wave by using the description above. The whole reason I love Max is because it gives me challenges to solve. However, I need guidance with most of these challenges.
    EDIT: My other, probably better idea, is to use [tri~] in the same way as I was going to use [phasor~]. I've tried gating the signals, but I don't know how to gate them to every-other cycle. This is my new problem.

    • Jun 09 2013 | 2:58 pm
      invert = abs(x-1)
      depending on what you exactly want to achieve you might wanna add a multiply by -1 to flip to the negative side.
    • Jun 09 2013 | 3:02 pm
      I get a "No such object" error for your [expr~] object.
      EDIT: I understand what you were doing now, but I can't figure out how to do it. I tried using [snapshot~] to change [phasor~] into numbers. Then, I used the [expr] object with your expression. After that, I put a [line~] object to try and change those numbers to a signal. This didn't work. Nonetheless, I've run into a new problem. Please read my EDT in the original post.
    • Jun 09 2013 | 3:39 pm
      this does the same with standard objects:
      From your edits I get the feeling your MSP knowledge is very basic. Did you do the tutorials? That should clarify a lot. For example, there's totally no need for converting the phasor signal 'to numbers'.
    • Jun 09 2013 | 5:14 pm
      I've been doing the tutorials as I need them, but they are difficult for me to understand, sometimes. Maybe I just need to go over them more than once. I'll give them a look again. Thanks.
    • Jun 09 2013 | 7:05 pm
      the help files and the reference pdf/html are most of the time much more helpful than the tutorial patches could ever be.
      btw, i would build simple oscillators around cycle~ or wave~, and not phasor~.
      usign max objects and try things with numbers to find your way for the audio signal layout is a good idea, even experienced users do that sometimes. with numbers it is much better to have visual control over whats happening.
    • Jun 09 2013 | 7:18 pm
      sure, but you probably don't wanna model an analog synth through the message scheduler instead of the DSP ;)
    • Jun 10 2013 | 4:09 am
      I have successfully completed the synth that I was working on. It doesn't model the actual wave very well, as it uses [phasor~] as the original oscillator, but it seems to model it better than most of the TB-303 emulators that I've seen. Most people seem to do no research on the synth and, unfortunately, use the antialiased [rect~] wave for the square. While this SOMEWHAT does the job, it doesn't do it in the same way that the original accomplishes it's "square" wave. If anyone would care to have a look at my synth and give me some feedback on what I should add etc., you can download it here: http://www.maxforlive.com/library/device/1723/tb-305
      Thanks for any feedback and all the help you guys have given me! =) Hopefully, as time goes on, I won't have to ask for so much help with my patches.
    • Jun 10 2013 | 8:07 am
      Certainly a nice analog-modeling exercise. Though to say it's better than most emulators is a bit overarching, no? Or are you just looking at M4L emulators? Though not an expert on 303 matters I think a lot is to be gained in the filter. As Wetterberg commented on maxforlive.com, there's the plopping and to me it doesn't sound quite right.
      Isn't the 303 filter 3-pole (18dB/oct)? If you're so much in recreating the true analog waveform then you should also be after the true analog filter response hé.
      An awesome emulator is http://d16.pl/phoscyon
    • Jun 10 2013 | 11:02 pm
      I read somewhere (can't remember where) that the filter is a 4-pole lowpass. I may be wrong, so I'll look into it some more. That site you directed me to seems to think otherwise, so I think I'll change that. Also, I never really meant that my wave emulation was "better" than anyone else's. I just noticed that most of the people posting their devices on maxforlive.com were posting true square waves, rather than even attempting to recreate what the original actually does. So, yes, I was only looking at M4L emulators.
      I am, however, very concerned with that "thump" on the release phase of the filter envelope. I've searched for ways to solve the problem, but I haven't found anything. At first, I figured that I would make the filter's [adsr~] signal never go to 0, but that proved to create more problems than it solved. One question I have about this is the recreation of this bug. Under how many different circumstances will it occur and what are these circumstances? The only one I've found/noticed is this:
      When the resonance is high and the amplitude envelope's release is greater than that of the filter's envelope release, it causes the filter to quickly sweep to 0 and thus creates an annoying "thump".
      I think what I'm going to do is use the amplitude envelope's release a "global" release as a quick-fix. Hopefully, I'll be able to fix it so that both will be fully functional, but until then, I want to release a synth with as few bugs as possible.
      EDIT: Wikipedia seems to suggest that it's a 4-pole filter. This is turning out to be a more confusing project than I originally thought. I'm probably going to stick with the 4-pole, lowpass filter, because I can get fully-interactive frequency and resonance controls. I haven't quite figured out a method to do the same with a 3-pole filter. I've tried using [filterdesign], but that doesn't allow me to adjust the resonance. I've also used [onepole~] fed into [biquad~] to recreate a 3-pole filter, but the resonance control isn't fully adjustable this way. If there's any way I can recreate a 3-pole filter with fully interactive frequency and resonance controls, please, let me know. Before you ask, yes, I have done research on doing this. I've used the object explorer in Max, looked at references and help files, and read tutorials. I can't seem to find this information anywhere.
    • Jun 11 2013 | 12:26 pm
      From what I read, design wise it's indeed 4-pole but with 1 detuned pole to avoid self-oscillation, which also makes it sound more like a 3-pole filter.
      Thing is, biquad, onepole, etc are all specific filter designs. The 303's diode ladder filter is another one. There is not 1 universal lo-pass filter. The challenge here is to find/develop a digital filter model that matches the 303's sonically. I'm not enough of an MSP/DSP-ninja to advise you on that...
    • Jun 11 2013 | 2:18 pm
      Oli Larkin has posted a diode ladder model. I don't know offhand if it has the detuned pole however, but it could be modified.
    • Jun 12 2013 | 11:59 am
      Peter, have you got a link to that model? I noticed that you mentioned it in the comments of the maxforlive.com "Device Details" screen, and I've been looking around, but I can't seem to find it anywhere. I'll keep looking, but unless this forum is set up in some weird way, I've looked everywhere I should have.
      EDIT: After re-searching the forums, I think I've found it. The only problem is that I don't have [gen~], so I can't modify that code. Is there any way I could re-write the modified bit of code elsewhere and use it in [gen~] that way? Otherwise, I'm afraid someone might have to describe the whole idea of how to implement this kind of filter using, say, [filterdesign]. Although, I'm not entirely sure how to change the frequency in real-time with this, nor can I figure out how to change the resonance at all.
      Just to make sure, these are the posts that you're talking about, right?
    • Jun 12 2013 | 5:14 pm
      Yeah, those are the ones. You could write it as a C/C++ external, but gen~ is way easier.
      Try it out and see how it sounds; my recollection is that it had a nice nasty edge to it. I think Ollie's just doing some of the filter calculations at control rate (in expr) to be more efficient, but you could rewrite them using MSP objects.
    • Jun 15 2013 | 10:11 am
      Making a square geometrically is a bad idea unless you like aliasing artefacts.... The only way to get a 'clean' digital square is by summing sines...
    • Jun 15 2013 | 1:34 pm
      You..... have...... made a 303 ? ...... for max ? Speechless.
      You my friend are my favorite person in this forum as of now (;
      just a quick question - I am unfamiliar with amxd files and dont use live - will it work as a normal max msp object ?
    • Jun 15 2013 | 5:30 pm
      You can also make alias-suppressing oscillators using other algorithms. Send a sine wave through a *~ into tanh~ and you'll have a bandlimited square wave, depending on the multiply value which scales inverse to the frequency. (This was in an ICMC paper on distortion synthesis a few years back IIRC)
      With a little trickery, you can get PWM and it will also accommodate FM!
    • Jun 16 2013 | 2:27 am
      >You….. have…… made a 303 ? …… for max ? Speechless.
      >You my friend are my favorite person in this forum as of now (;
      >just a quick question – I am unfamiliar with amxd files and dont use live – will it work as a >normal max msp object ?
      By replacing the Live objects for regular Max/MSP objects, I don't see why it wouldn't work with the full version of Max. It isn't the greatest representation of it, but I did my best with everything. The only thing that it doesn't have that the real thing does have is an "Env Amount" knob, but I'm sure someone could let you know how to do that.
      Here is the main patch:
      And here are the two subpatchers you'll need:
      Also, the way I made the "square" wave in this isn't a geometric square. It's two saw waves flipped every-other cycle. It still has aliased artifacts, but it isn't as bad as a geometrical square. I don't really see why you're thinking that I was using a geometrical square to actually generate sound, to be honest.
      There is one last question I have before I can call this project concluded; Mathematically, it seems that, by flipping this saw wave every-other cycle, the "square" wave I'm generating would be an octave down from the saw wave. However, when I multiply the frequency coming into it by 2, it sounds like it's an octave up. What I'm saying is, it sounds like it's in-tune, but it doesn't mathematically make sense to me. Could anyone explain?