Recent

Author Topic: Soft Synthesizer  (Read 10095 times)

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Soft Synthesizer
« on: January 28, 2013, 01:42:38 pm »
I attached a little demo (250 lines) of software synthesizer. It requires PortAudio library to run. You can get it here http://www.portaudio.com/ or in repositories of your Linux distro.

The demo stores wave in a lookup table. It opens PortAudio stream and callback function feeds the audio data periodically.
You can modify frequency (4 octaves in halftones), volume, balance, amount and layout of higher harmonics. Also there's a simple stereo effect based on 1% difference in frequency of left and right channel.
PortAudio bindings are bundled.
I hope it will work for you  :)
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Soft Synthesizer
« Reply #1 on: January 28, 2013, 02:06:28 pm »
Nice, wanna try it but :
Quote
/usr/bin/ld: cannot find -lportaudio
  :'(

EDIT : Ooops,
Quote
It requires PortAudio library to run
:
Ok, i have to copy it in /usr/lib ? (you are welcome to use Lazdyn_portaudio.pas from UOS for dynamic loading)
« Last Edit: January 28, 2013, 02:17:50 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

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Soft Synthesizer
« Reply #2 on: January 28, 2013, 02:39:48 pm »
I have PortAudio in /usr/lib64.
If you install it from Repo (better) it should be done automatically. If you download it yourself, you should copy it there (as a "sudo") and then run "sudo ldconfig" in console - system will rescan dyn. libraries.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: Soft Synthesizer
« Reply #3 on: January 28, 2013, 05:18:02 pm »
I guess it can only be made to work on x64
cause I could not get it to work on my 32 bit Linux :(
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Soft Synthesizer
« Reply #4 on: January 28, 2013, 05:32:40 pm »
No idea, I have no 32-bit system. The code is very short and there is nothing special. It uses CTypes.
I have PA bindings from here, IRC: http://sourceforge.net/projects/humus/files/external/portmedia/
There is a demo: "testpasine.pas" which you can test to see where is problem.
My demo is in fact only an extension of this bundled demo.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: Soft Synthesizer
« Reply #5 on: January 28, 2013, 05:47:19 pm »
Ok thanks Blaazen.

I will check it owt :)
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Soft Synthesizer
« Reply #6 on: January 28, 2013, 06:00:45 pm »
Quote
I have PA bindings from here, IRC: http://sourceforge.net/projects/humus/files/external/portmedia/
There is a demo: "testpasine.pas" which you can test to see where is

And here one testpasine.pas working for Lazarus :
http://www.lazarus.freepascal.org/index.php/topic,17521.msg96750.html#msg96750

And i would say :

Quote
Thanks to the c2delphi.exe portaudio.c portaudio.pas Team for PortAudio bindings
(I have got the same result.)

@Blaazen : Are you angry with me ?
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

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Soft Synthesizer
« Reply #7 on: January 28, 2013, 08:27:19 pm »
Quote
@Blaazen : Are you angry with me ?
No.
You mean that I didn't use your version of bindings ?
I downloaded the other version some time ago.
I'm more interested in old-fashioned synthesizers than ogg and mp3 players so simple audio output is enough for me.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Soft Synthesizer
« Reply #8 on: January 28, 2013, 08:54:37 pm »
Quote
No.
   :) ;)

Quote
You mean that I didn't use your version of bindings ?

More or less, have you seen all the prob for users to install static libraries to test your program ?

Quote
I'm more interested in old-fashioned synthesizers than ogg and mp3 players so simple audio output is enough for me.

It would be so great if you can add your synthesizers part in UOS  :-[
EDIT:
Code: [Select]
function AddFromSynth(Frequency:cint; Duration:CDouble; Output:integer;...;...)
« Last Edit: January 28, 2013, 09:13:20 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: Soft Synthesizer
« Reply #9 on: January 28, 2013, 10:43:48 pm »
Ok, it is working.
Whaouw, superb and the stereo effect, brilliant.   ;)

PS1: Stop does not work on my 32 bit linux :-X

PS2: For those who do not have the static libraries, here the dynamic loading version of Blaazen's synth:https://sites.google.com/site/fiensprototyping/DynSynthDemo.tar.gz


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

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: Soft Synthesizer
« Reply #10 on: January 28, 2013, 11:43:17 pm »
Confirmed working on my Linux Mint 14 x86

Good job blaazen

Im not sure if it has something to do with portaudio but
it does it on every wav file gitters at the begining, also
when i try to load a .mid file it freezes up.  Should it also
play mid files ?

The freeze does not give an error btw, but just the app freezes not
my destop enviroment
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Soft Synthesizer
« Reply #11 on: January 28, 2013, 11:56:25 pm »
@ PS1: Stop does not work on my 32 bit linux

You can try "Pa_AbortStream" instead. Pa_CloseStream may cause the problem: http://portaudio.com/docs/v19-doxydocs/start_stop_abort.html

@ wjackson153
What do you mean "... it does it on every wav file gitters at the begining ..."?
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Soft Synthesizer
« Reply #12 on: January 29, 2013, 12:18:41 am »
Ooops, i get it, in main form, stop button cover the trackbar and when i click on it, in fact i click on trackbar.

Ok, Stop works (but the layout of main form is strange, the buttons are on same top than last trackbar and also for checkboxes).

But that is a detail. Congratulation and i see that you perfectly know and understand digital audio.  ;D
« Last Edit: January 29, 2013, 12:27:16 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

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Soft Synthesizer
« Reply #13 on: January 29, 2013, 12:29:10 am »
Oh, I see now with GTK2. I designed it in Qt and did not test elsewhere.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: Soft Synthesizer
« Reply #14 on: January 29, 2013, 12:41:08 am »
Quote
I designed it in Qt and did not test elsewhere.

Yep, i just try it with Qt and layout is perfect.

Humm, is that normal ?( im not talking about your beautiful synth but about Qt <> GTK2 conversion  :-X )
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