Recent

Author Topic: Generate sawtooth waves?  (Read 708 times)

Ramses

  • New Member
  • *
  • Posts: 41
Generate sawtooth waves?
« on: January 31, 2021, 04:51:45 am »
Hi!

 i am actually working on a signal generator based on a raspberry board, actually with "uos" i have generated sinusoidal and square wave, but now i need to generate sawtooth waves, is there any way to generate that with UOS, or maybe with other library?

Thanks!

Ramses

  • New Member
  • *
  • Posts: 41
Re: Generate sawtooth waves?
« Reply #1 on: February 02, 2021, 06:05:14 pm »
Finally, i found an answer by myself: i can generate sawtooth signal with "alsa_sound"

So you can consider this thread as closed.  :)


CM630

  • Hero Member
  • *****
  • Posts: 951
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Generate sawtooth waves?
« Reply #2 on: February 02, 2021, 10:51:59 pm »
Well, posting some sample code would not hurt.
Лазар 2,2,0RC1 32 bit; FPC3,2,2; rev 65419 on W10 64bit.

lucamar

  • Hero Member
  • *****
  • Posts: 4157
Re: Generate sawtooth waves?
« Reply #3 on: February 02, 2021, 11:47:24 pm »
A simple search for "generate wave" in this forum gives inmediattely this thread: Generate square / sinusoidal waves (started by the same OP as this one) where wave generation is quite thoroughly discussed and some examples pointed out.

You can also find some examples/links to info in the wiki. Starting form the Game Development might be a good idea.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Ramses

  • New Member
  • *
  • Posts: 41
Re: Generate sawtooth waves?
« Reply #4 on: February 03, 2021, 12:39:07 am »
Well, posting some sample code would not hurt.

Sure, here is an exemple that work :

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,alsa_sound;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.  
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. begin
  34.  
  35.   //function ALSAbeep(frequency, duration, volume: cint; warble: Boolean;
  36.   //WaveType: cint; CloseLib : boolean): Boolean; // WaveType: 0=sine, 1=square, 2=tooth
  37.  
  38.   ALSAbeep(40, 10000, 100, true,2, true);
  39. end;
  40.  
  41. end.
  42.                
  43.  

 

TinyPortal © 2005-2018