/* digitar.h * Fri Jun 18 18:04:12 PDT 2010 Kevin Karplus */ #ifndef DIGITAR_H #define DIGITAR_H #define SAMPLE_RATE (44100) /* sampling rate in samples/second * 44100 is the stanard sampling rate for CD recordings */ #define SEMITONE (1.05946309436) /* ratio of frequencies in well-tempered tuning */ /* fixed-point representation for phase (and frequency) * has FIXED_POINT_SHIFT bits after the binary point */ typedef int fixed_point; #define FIXED_POINT_SHIFT (8) #define FIXED_POINT_SCALING (1<table[i] by x, updating wav->sum_table * returns x */ short int update_table(struct wavetable *wav, int i, short int x); /* Fill wav with +-amplitude (in range 0..32767) * then decay for decay_passes full passes */ void pluck(struct wavetable *wav, int amplitude, int decay_passes); /* play num_samples long note at frequency f_Hz * into array out, using wavetable wav * Decay rate is given in decays/sample (0 <= decay_rate ) * * returns where out pointer would have to be for next note. */ short int* decay_note(struct wavetable*wav, float f_Hz, float decay_rate, int num_samples, short int *out); /* play num_samples long note at frequency f_Hz * into array out, using wavetable wav * Decay rate is given in decays/sample (0 <= decay_rate ) * * probability of bow slipping in (delta_v/v)^2/force * (clipped at 1, of course) * bow_velocity should be fairly small (100? 1000?) * bow_force should be fairly small (10.?) */ void bow_note(struct wavetable*wav, float f_Hz, float decay_rate, float bow_force, int bow_velocity, int num_samples, short int **out_p); #endif