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

Stereo PCM to PCM chorus 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 (void)
 the plugin main function Részletek...
 

Részletes leírás

Stereo PCM to PCM chorus plugin.

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

Definíció a(z) chorus.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) chorus.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 ( void  )

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) chorus.c fájl 26. sorában.

27 {
28  double const f_vib = 2.0;
29  int const depth = 60;
30 
31  long long int cnt = 0;
32  int write = 0, read = N / 2;
33 
34  // reopen streams as binary
36 
37  sample_t circ_buffer[N][2] = {0};
38 
39  // read samples while possible
40  while (fread(circ_buffer[write], sizeof(sample_t), 2, stdin) == 2)
41  {
42  // update read index with harmonically varying offset
43  int r = read + sin(2.0 * M_PI * f_vib / SAMPLE_RATE * cnt++) * depth;
44  if (r < 0)
45  r += N;
46 
47  // read FIFO content and add to dry signal
48  sample_t output[2];
49  for (int c = 0; c < 2; ++c)
50  output[c] = circ_buffer[r % N][c] + circ_buffer[read][c];
51 
52  // write to output
53  fwrite(output, sizeof(sample_t), 2, stdout);
54 
55  // cyclic indexing
56  write = (write + 1) % N;
57  read = (read + 1) % N;
58  }
59 
60  return 0;
61 }

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: chorus.c:17
binary_streams
#define binary_streams()
reopen standard streams as binary
Definition: binary_streams.h:17
SAMPLE_RATE
@ SAMPLE_RATE
Definition: chorus.c:16