News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Vibrato testbed

Started by NoCforMe, August 13, 2022, 01:42:50 PM

Previous topic - Next topic

NoCforMe

This was a fun li'l project: a test of the effect of vibrato on sounds.

For those who aren't musicians, a quick once-over: Vibrato is the constant, slight varying of a frequency (not amplitude) of a sound to make it more musical. It's a technique used by players of practically all instruments (except of course piano or other instruments where the pitch can't be varied) and vocalists. Not to be confused with tremolo, which is variation of intensity (amplitude).

This program generates a sine wave at a selected frequency, then applies vibrato of another (much slower, of course) frequency against it to vary the pitch. Works pretty well. Of course, a pure sine wave is a rather unmusical sound, but you can still gauge the effect of vibrato on it. You can vary both the frequency and the intensity (amplitude) of the vibrato "wave". Crank the amplitude up and it sounds like a siren ...

You can save the sound to a .WAV file if you like if you want to see the waveform. Not all that interesting, but it was the first time I ever tried to write such a file and it worked the first time out. (Pretty simple format.)

The program is a "dialog-as-program" one.

Lessons learnt here:

  • Using radians instead of degrees (the native unit of the FPU)
  • Trackbar scaling
  • .WAV file writing
Assembly language programming should be fun. That's why I do it.

quarantined

Sounds like an interesting project.

Now you need to take a wave file as input, and add vibrato to it...  :biggrin:

Biterider

Hi NoCforMe
Cool project. Runs fine here (Win10 Home).  :thumbsup:
Would be nice if you could change the settings and hear the change without pressing <stop> and <run> over and over again.  :icon_idea:

Biterider

Siekmanski

Creative coders use backward thinking techniques as a strategy.

jj2007

That's a remarkable little project, compliments :thumbsup:

Quote from: Biterider on August 13, 2022, 05:51:09 PM
Would be nice if you could change the settings and hear the change without pressing <stop> and <run> over and over again.

Indeed. You could prepare two samples, with and without vibrato, and change "on the fly" when user clicks the checkbox.

daydreamer

great :thumbsup:
add sawtooth wave and square wave forms too ?dont those sound "more" vibrato?
using radians are not only a fpu thing,the circuitry are based on same math that an alternative SSE library taylor series and alternative formulas are based on radians
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

NoCforMe

Quote from: jj2007 on August 13, 2022, 07:02:20 PM
That's a remarkable little project, compliments :thumbsup:

Quote from: Biterider on August 13, 2022, 05:51:09 PM
Would be nice if you could change the settings and hear the change without pressing <stop> and <run> over and over again.

Indeed. You could prepare two samples, with and without vibrato, and change "on the fly" when user clicks the checkbox.

Good suggestion. That's about as far as I'd want to go making it fancy. It would be a lot of work to make it able to change the sound on the fly as others have suggested. Would be nice, but I'm not going to go there.
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: daydreamer on August 13, 2022, 10:03:46 PM
great :thumbsup:
add sawtooth wave and square wave forms too ?dont those sound "more" vibrato?

Not more vibrato, but harmonically richer. Did you know that if you keep adding odd harmonics to a sine wave you end up with a square wave? Try my demo attached below to see this in action.

Quoteusing radians are not only a fpu thing,the circuitry are based on same math that an alternative SSE library taylor series and alternative formulas are based on radians

Since we're on the FPU here, a minor rant:

In using the FPU in this program I once again had to scratch my head: why the hell can't I use 80-bit reals in any operations without first loading them (FLD)? This seems stupid to me; every other instruction allows you to load the other (smaller) float types (32 and 64-bit): why not 80-bit? Is this by design? because of the original 8087 design? a hardware limitation?

It's a pain in the ass to use 80-bit reals; you have to load them, and therefore you've got to be really careful not to run out of those 8 registers (this bit me in the ass, and I only noticed it when I logged some results and saw that they were "ERROR"). Got to make sure to use FSTP and FISTP to pop those registers. Anyone know why this is? (Raymond?)

It's also a pain in the ass if you use Raymond's FPU library, which expects things to be in an 80-bit real, which means conversion.

BTW, regarding using radians versus degrees, I find it not as nice, because with degrees (which can be an integer instead of a float), it's very easy to know when you're come around to the beginning of the cycle again (0°). With radians you have to look for 2π, not as easy to do (as it has to be a float).
Assembly language programming should be fun. That's why I do it.

hutch--

Could you do the fp code in SSE2 instead of the old x87 instructions ? REAL8 is 64 bit which is lower resolution than 80 bit x87 but it may have more than enough precision for working with sound.

NoCforMe

Yes, but not quite ready to tackle a new instruction set.

Yes, thought about it and 64-bit floats would probably be good enough for this program. But I went for max precision ...
Assembly language programming should be fun. That's why I do it.

hutch--

It might be worth a play, the scalar double instruction set are a pleasure to use after working with the old x87 instructions.

NoCforMe

I'll give it a try one of these days.
Assembly language programming should be fun. That's why I do it.

Vortex


daydreamer

#13
tried create sawtooth curve
I tried the old math y=constant *x line,but also added y=y mod maxaltitude before draw it
looks like sawtooth when drawed,but dont know how to make it correct to sound freqency you want?
...
calculate wavelength from hz
chop of in x direction when reached wavelength and start with y=startvalue

is this sawtooth looking right?
mov xpcurve,0
  mov ypcurve,400+64
@@L2saw:
    mov ebx,ypcurve
    add ebx,-1
    ;and ebx,63
    ;mov edx,256
    mov edx,0
    add edx,ebx
   
    mov ypcurve,edx
   

invoke drawtriangle,xpcurve,ypcurve,10,10
    mov ecx,xpcurve
    add ecx,1
    mov xpcurve,ecx
    ;x= xcurve mod wavelength
    xor edx,edx
    mov eax,ecx
    div wavelength
    .IF edx==0
    mov ebx,400+64;miny
    mov ypcurve,ebx
    .ENDIF
    mov ecx,xpcurve
    .IF ecx<1024
    jmp @@L2saw
    .ENDIF
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

NoCforMe

I'll look into that shortly; shouldn't be too hard. Working on another project at the moment. I appreciate your interest.
Assembly language programming should be fun. That's why I do it.