Digitális hangminták
Gaga
Típusdefiníciók | Enumerációk | Függvények
vibrato.c fájlreferencia

Stereo PCM to PCM vibrato plugin. Részletek...

#include <stdio.h>
#include <math.h>
#include "binary_streams.h"

Ugrás a fájl forráskódjához.

Típusdefiníciók

typedef float sample_t
 type of a single sample
 

Enumerációk

enum  { SAMPLE_RATE = 44100, N = SAMPLE_RATE / 10 }
 

Függvények

int main (int argc, char **argv)
 the plugin main function Részletek...
 

Részletes leírás

Stereo PCM to PCM vibrato plugin.

Szerző
P. Fiala
Dátum
2020-12-07

Definíció a(z) vibrato.c fájlban.

Enumerációk dokumentációja

◆ anonymous enum

anonymous enum
Enumeráció-értékek
SAMPLE_RATE 

the sample rate

size of the FIFO

Definíció a(z) vibrato.c fájl 14. sorában.

15 {
16  SAMPLE_RATE = 44100,
17  N = SAMPLE_RATE / 10
18 };

Függvények dokumentációja

◆ main()

int main ( int  argc,
char **  argv 
)

the plugin main function

Paraméterek
argcnumber of command line arguments
argvargument vector
Visszatérési érték
int zero for success

<frequency of vibrato

<vibrato depth

Definíció a(z) vibrato.c fájl 26. sorában.

27 {
28  double const f_vib = 2.0;
29  int const depth = 60;
30  if (argc >= 3)
31  {
32  sscanf(argv[1], "%lf", &f_vib);
33  sscanf(argv[2], "%d", &depth);
34  }
35 
36  sample_t circ_buffer[N][2] = {0};
37 
38  // reopen streams as binary
40 
41  long long int cnt = 0;
42  int write = 0, read = N / 2;
43 
44  while (fread(circ_buffer[write], sizeof(sample_t), 2, stdin) == 2)
45  {
46  int r = read + sin(2.0 * M_PI * f_vib / SAMPLE_RATE * cnt++) * depth;
47  if (r < 0)
48  r += N;
49  fwrite(circ_buffer[r % N], sizeof(sample_t), 2, stdout);
50 
51  write = (write + 1) % N;
52  read = (read + 1) % N;
53  }
54 
55  return 0;
56 }

Hivatkozások binary_streams, N és SAMPLE_RATE.

sample_t
float sample_t
type of a single sample
Definition: amplify.c:11
N
@ N
Definition: vibrato.c:17
SAMPLE_RATE
@ SAMPLE_RATE
Definition: vibrato.c:16
binary_streams
#define binary_streams()
reopen standard streams as binary
Definition: binary_streams.h:17