SynthMaker

change pulse wave to digital pulse

Archive · 2012 9 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

tester ·

My brain is falling asleep, and I don't think anymore tonight.

I'm looking for a small piece of schematic, that will change pulse wave to digital pulse (pure rectangular signal -1 to 1).

I know - aliasing 😉 It's for testing something modulation related on specific kind of slow FM. Precise switch is required.

cyto ·

in code...

streamin in; streamout dPulse; dPulse=((in>=0)&1)|((in<0)&-1);

...or even better (in asm)...

streamin in; streamout dPulse; int mask1=1606418432; int mask2=1065353216; stage0; movaps xmm0,mask1; pslld xmm0,1; movaps mask1New,xmm0; stage2; movaps xmm0,in; orps xmm0,mask2; andps xmm0,mask1New; movaps dPulse,xmm0;

-cyto

tester ·

Thanks!

I see you like coding 😉

From the perspective of SM (and then - exported files) performance - is there a difference between using regular codes or ASM codes in schematic?

tester ·

Hmm... I'm having the same problem with glitches here. Above is digital switch (the same on both - code and ASM), below - analog input. How can it be solved in code? In the same way like with glitches I had previously? Or maybe a matter of display this time?

martinvicanek ·

Hey tester,

strange, when I feed either cyto's code or ASM comparator with a band limited square wave, I get a "perfect" square wave out as expected. (I put quotes because the signal is not suited for audio due to heavy aliasing). So is it possible that you have some sort of filter or other processing between the comp output and the scope?

cyto ·

tester wrote: I see you like coding 😉

Yes, Ido 🙂

After thinking about this, here is an even better way... (for some reason I always instinctively go to integers to mask values, but you can achieve the same thing with floats and you save the "stage 0" shift)

streamin in; streamout dPulse; float one=1.0; float negOne=-1.0; movaps xmm0,in; orps xmm0,one; andps xmm0,negOne; movaps dPulse,xmm0;

And regarding the "glitches" you're experiencing: it must be your environment, because any of these code snippets will only produce 1s and -1s.

tester wrote: From the perspective of SM (and then - exported files) performance - is there a difference between using regular codes or ASM codes in schematic?

Obviously code is a lot easier to implement as you don't need to keep track of each individual operation that's going on. And a well written code will run quite efficiently. However, when the code gets "compiled," it often has redundant operations. SM has a tendency to only use the bare minimum of registers needed to execute, so you get a lot of movement in and out of memory for data that could easily be kept in the registers. I don't know if you have figured this out, but if you connect a "text" box to the "s" output of the code primitive, you can see how SM will "compile" the code into assembly.

For my own personal projects, I almost always program in assembly in SM. Even with the limited amount of opcodes available to us, it offers a lot more flexibility. I was initially daunted by those little green boxes and all the cryptic operations. But after deciding to dive in, it proved to be a lot easier than I imagined. It does require a certain mindset, but once you grasp a couple basic principles it's not too bad.

-cyto

tester ·

Thanks for explanation.

I'm rather a visual dataflow fellow right now; on my daily basis I work with audible sound itself, so I just follow what I hear, compare to what I know and adjust to what it should be. 😉

The glitches are probably due to way of displaying waves (cool edit) - maybe some auto-curvature between points.

infuzion ·

tester wrote: The glitches are probably due to way of displaying waves (cool edit) - maybe some auto-curvature between points.

Or due to "intersample peaks". Also be careful with Nyquest wrapping if used directly for audio & you don't bandlimit well.

tester ·

I'ts for slow modulators and switches - values less than 200Hz.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.