Recent

Author Topic: WavvieW: the signal producer and analyzer.  (Read 2376 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
WavvieW: the signal producer and analyzer.
« on: February 12, 2021, 07:55:26 pm »
Hello.

I am happy to announce the release of WavvieW.
https://github.com/fredvs/WavvieW/releases

WavvieW analyzes the build-in noise-wave-generator-synhtesizer, audio files, input-mic and shows the result with his oscilloscope and FFT-spectrum...

It is compiled with fpc 3.2.0 and uses MSEgui widgetset.

Thanks to Wp to give me the impulse to jump back into fft (that still fascinates me).
The open source library fftw is used to calculate the fft's.
To access audio device, open source library PortAudio does the job.
And to decode wav, ogg and flac files, open source library libSndFile takes care of it.

Those libraries are dynamically loaded and included in the release.

Enjoy!

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: WavvieW: the signal producer and analyzer.
« Reply #1 on: February 12, 2021, 10:40:45 pm »
Hi Fred!

Great stuff!

And a lot of work!

And white noise - so much more enjoyable that HipHop!

After some testing some hints:

* There is a lot of royalty free music in the net, which could be used as demo audio file.
Example : https://freemusicarchive.org/genre/Rock 

* The highest oktave on the piano keyboard is too loud. It hurts.
Either start one octave down.
Or give the higher tones less volume - like a "real world piano".

* I am missing the saw tooth at the wave gen

*  When I look at the Icon I feel drunk.  Before the first beer!
It is realy unsharp!

But great work!

Winni

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #2 on: February 12, 2021, 11:54:41 pm »
Hello Winni.

Thanks for testing!

Quote
* There is a lot of royalty free music in the net, which could be used as demo audio file.
Example : https://freemusicarchive.org/genre/Rock
Thanks, I will try this.

Quote
* The highest oktave on the piano keyboard is too loud. It hurts.
Either start one octave down.
Or give the higher tones less volume - like a "real world piano".
Ok, I will check this.
But have you try to change the envelope editor (Attack, Decay, Release)?

Quote
* I am missing the saw tooth at the wave gen
Huh, I did use your code from the alsa_sound project.
Is it not the saw tooth you want?

Quote
*  When I look at the Icon I feel drunk.  Before the first beer!
It is the goal!  :D
But ok, I need inspiration for this.

Quote
And a lot of work!
Not so much, only 6 dark days and white nights not stop programming.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #3 on: February 13, 2021, 12:09:40 am »
@Winni:
Quote
* I am missing the saw tooth at the wave gen
Ooops, sorry, I see now that I forgot to add your code:
 
Code: Pascal  [Select][+][-]
  1.        for I := 0 to 359 do
  2.           SA[i] := (round((360 - i)/180) -1)*volume;   //   saw tooth wave


OK, promise for next release (and next asap commit).

Fre;D
« Last Edit: February 13, 2021, 12:11:33 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: WavvieW: the signal producer and analyzer.
« Reply #4 on: February 13, 2021, 07:13:37 pm »
Hi!

A proposal for an Icon.
Made only of parts of the screenshot

Winni

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: WavvieW: the signal producer and analyzer.
« Reply #5 on: February 13, 2021, 10:01:47 pm »
A proposal for an Icon.
Made only of parts of the screenshot
Serious? Imagine what this will look like at 16x16.

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #6 on: February 13, 2021, 10:05:08 pm »
Hello Winni.

Wow, superb, I take it (if you agree).

About the wave formula.

Here the sine wave formula:

Code: Pascal  [Select][+][-]
  1. case WaveType of
  2.       0: begin
  3.           for I := 0 to 359 do
  4.           SA[I] := round(sin(pi * I / 180.0) * volume);  // create sine wave pattern
  5.          end;

So it begins from sin(0) = 0
then pass to sin(90) = 1
then pass to sin(180) = 0
then pass to  sin(270) =-1
And finally to  sin(360) = 0

So the cycle begins from 0 to end to 0.

But with the saw tooth wave:

Code: Pascal  [Select][+][-]
  1. 2: begin
  2.           for I := 0 to 359 do
  3.           SA[i] := (round((360 - i)/180) -1)*volume;   //   saw tooth wave
  4.          end;
  5.       end;

It begins with 1 then end to -1,
So, imho, only a half cycle.

Should it not be something like this ?:

Code: Pascal  [Select][+][-]
  1. 2: begin
  2.           for I := 0 to 359 do
  3.          if i < 180 then
  4.           SA[i] := (round((360 - (i*2))/180) -1)*volume   //   saw tooth wave
  5.          else  SA[i]  := SA[359-i];
  6.          end;
  7.       end;

Fre;D
« Last Edit: February 13, 2021, 11:17:36 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #7 on: February 13, 2021, 10:07:06 pm »
Hello Wp.

You see, I am still in your mood...
And of course I dont forget your project (if you want).

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: WavvieW: the signal producer and analyzer.
« Reply #8 on: February 13, 2021, 10:34:54 pm »
But with the saw tooth wave:

Code: Pascal  [Select][+][-]
  1. 2: begin
  2.           for I := 0 to 359 do
  3.           SA[i] := (round((360 - i)/180) -1)*volume;   //   saw tooth wave
  4.          end;
  5.       end;

It begins with 1 then end to -1,
So, imho, only a half cycle.

winni's function is correct. You begin with I = 0: (360-i)/180-1 is 1. At I=180 you have (360-180)/180-1 = 0 and at the end of the cycle you have (359-360)/180-1 = almost -1. The result is a very asymmetrical wave with a long decay and an extremely fast increase. T

In your formula you multiply i by 2 - this doubles the frequency!

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #9 on: February 13, 2021, 11:07:15 pm »
But with the saw tooth wave:

Code: Pascal  [Select][+][-]
  1. 2: begin
  2.           for I := 0 to 359 do
  3.           SA[i] := (round((360 - i)/180) -1)*volume;   //   saw tooth wave
  4.          end;
  5.       end;

It begins with 1 then end to -1,
So, imho, only a half cycle.

winni's function is correct. You begin with I = 0: (360-i)/180-1 is 1. At I=180 you have (360-180)/180-1 = 0 and at the end of the cycle you have (359-360)/180-1 = almost -1. The result is a very asymmetrical wave with a long decay and an extremely fast increase. T

In your formula you multiply i by 2 - this doubles the frequency!

But with sine wave, it begins with 0 and finish with 0. (passing by + 1 and -1).

So, for tooth wave if it begins with 1 it should finish with 1 too, (passing 2x by 0). but here it finish with -1 (and pass only once by 0).

Then both wave cycles are not equals, cycle tooth wave is 1/2 cycle sine wave.

Or maybe I miss something.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

wp

  • Hero Member
  • *****
  • Posts: 11912
Re: WavvieW: the signal producer and analyzer.
« Reply #10 on: February 13, 2021, 11:39:57 pm »
At the begin of the cycle the wave is +1, at the end it is at -1. And the next point immediately begins a new cycle. The second zero transition therefore is between the last point of the first cycle and the first point of the second cyle. It is not a symmetrical triangle, it really looks like the teeth of a saw.

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #11 on: February 14, 2021, 12:21:09 am »
Hello Wp.

Here result with sine_wave, sine_trangle from alsa_sound
The sine_tooth use my code:

« Last Edit: February 14, 2021, 01:12:13 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #12 on: February 14, 2021, 12:29:30 am »
Re-hello.

I think there is a misunderstood.

Quote
* I am missing the saw tooth at the wave gen

In fact it was not missing, the "triangle" wave was a saw tooth.

And the new one I proposed is a "pyramid" wave.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: WavvieW: the signal producer and analyzer.
« Reply #13 on: February 14, 2021, 12:36:10 am »
Hi!

Thanx wp for clarifying the wave stuff:

* A Sinus wave has the first half above zero and the second half below
* The same with the a square wave - with another envelope
* Even the sawtooth wave does the same: The one half above zero and the other half below.

So from this point of view they do all the same - but with totaly different envelopes.

From the deepth of my harddisk if found a nice illustration - I think "stolen" from Wikipedia.

If there are "Non-believers" do the following:

For  the sawthooth:

Take the tone + 1. harmonic + 2. +........+8. harmonic
After 8 harmonics it looks nearly like a sawtooth.
For perfection take more.

For the square wave:

Take the tone and the next odd harmonics.
At harmonic 9 it looks like a square wave.
For perfection .....

Music, waves and math is a nice job.

Keppler played around with it.
He computed the relations of the major-axis to the minor-axis of planets and looked at them as musical intervals.
Fascinating.

Just by the way: How the human ear can be betrayed:
It does not matter if the sawtooth is a increasing or a decreasing wave.
Nobody can hear the difference.

Winni

« Last Edit: February 14, 2021, 12:38:16 am by winni »

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: WavvieW: the signal producer and analyzer.
« Reply #14 on: February 14, 2021, 12:58:54 am »
Hello Winni.

Always a pleasure and enrichment to read you.

Ok, so everybody is in agreement.

My mistake was to call a "triangle" wave for a "tooth wave".
And to call a "pyramid wave' for a  "triangle wave".

Many thanks for the graphics, no more confusion.
(And I will fix this asap, your icon is already there, and with it no more feeling drunk, only stoned ).

Fre;D
« Last Edit: February 14, 2021, 03:02:52 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018