Exemplo n.º 1
0
int main()
{
    int n, i;
    scanf("%d", &n);
    for (i=0; i<n; i++)
    {
        int amp, freq, j;
        scanf("%d%d", &amp, &freq);
        for (j=0; j<freq; j++)
        {
            print_wave(amp);
            if (i!=n-1 || j!=freq-1)
                putchar('\n');
        }
    }

    return 0;
}
Exemplo n.º 2
0
/**
 * Output a sine wave according to the specified parameters to the standard output.
 * 
 * gensine <MONO | STEREO> <frequency> <bit-size> <sample rate> <amplitude> <duration>
 */
int main(int argc, char* argv[])
{
	int args_error;
	int samples_per_cycle;
	int number_of_samples;
	
	SinePropPtr spptr;
	
	/*handle the command line arguments*/
	if(argc != NUM_ARGS)
	{
		fprintf(stderr, "You must enter all 6 parameters.\n");
		return 1;
	}
	
	spptr = (SinePropPtr)malloc(sizeof(SineProp));
	
	/*Load and check the command like arguments. (argv+1) to skip the first arg*/
	if((args_error = load_check_args((argv+1), spptr)) != 0)
	{
		free(spptr);
		return 1;	/*An error has occurred.*/
	}
	
	samples_per_cycle = (spptr->sample_rate) / (spptr->frequency);
	number_of_samples = (spptr->sample_rate) * (spptr->duration);
	/*Print the header output*/
	print_header(spptr->sample_rate, number_of_samples, 
				spptr->mono_or_stereo, spptr->bit_size);
	
	/*Generate and print the wave*/
	print_wave(spptr);
	
	free(spptr);
	
	return 0;
}