递归音频解决方案

时间:2019-04-21 15:41:22

标签: c recursion audio

我只想使用简单的方法来解决递归问题。我希望振幅从1到-1。这将花费不到两分钟的时间。

我只是通过一个递归解决方案来练习递归。

/* This program outputs amplitudes within a frequency of 440Hz. 
   The number of audio samples will add of up to 1024, and the highest frequency 
   We can generate is about 20KilHz. 
*/
#include<stdio.h>  
#include<math.h> 
#define PI 3.141597 
#define TwoPI (2*3.141597) 
#define SampleRate 441000
#define Frequency 440 
#define Buffer 1024
/* Recursively Generates Signal, it is called in main. */ 
/*int CalculateSignal(int Sampler){
    Sampler=0; 
    int Sample= 0; 
    Sample=sin(Frequency*TwoPI*SampleRate);

    printf("%.6f",Sample);

    if(Sampler==Buffer){

        return Sample; 
    }

    else if(Sampler<Buffer){
        return CalculateSignal(Sampler+1);
    }
}*/
int main(){

    CalculateSignal(1024);

}

0 个答案:

没有答案