gpt4 book ai didi

c - “notestofile”功能不起作用

转载 作者:行者123 更新时间:2023-11-30 15:22:34 24 4
gpt4 key购买 nike

#include "aservelibs/aservelib.h"
#include <stdio.h>
#include <math.h>
#include <string.h>

FILE *textFilePointer;


void notetofile ();

int main()
{

int count, count2, note, vel = 0;
char choice = 'y';

printf("Welcome To Jonny Maguire's Midi record and playback application. Please Select one of the following options...\n\n");
aserveSay("Welcome To Jonny Maguires Midi record and playback application. Please Select one of the following options");
aserveSleep(8000);
while(choice != 'x')
{
for(count = 0; count <=2;)
{

printf("r to Record\np to Playback\nx to exit the program\n");
aserveSay("choose r, to record a sequence, p, to playback your recording. Or select x, at any time to exit the program");

scanf(" %c", &choice);

if(choice =='r')
{
aserveSay("you have chosen to record, play any 16 notes on the midi keyboard");
printf("You have chosen to record, please play 16 notes on the midi keyboard\n\n");

textFilePointer = fopen("recording1.txt", "w");

if(textFilePointer == NULL)
{
printf("Error Opening File!");
}
else
{
for(count2 = 1; count2 <=2; count2++)
{
//Recording 16 note data into txt file
notetofile();
}
}
}
//If P is selected, playback of the txt file
else if (choice == 'p')
{
textFilePointer = fopen("recording1.txt", "r");

if(textFilePointer == NULL)
{
printf("Error Opening File!");
}

//read until end of file and convert frequency
while(!feof(textFilePointer))
{
float frequency;
float amplitude = vel/127.0;

fscanf(textFilePointer, " %d %d\n", &note, &vel);
printf(" %d %d\n\n", note, vel);

frequency = 440 * pow(2, (note-69) /12.0);

aserveOscillator(0, frequency, amplitude, 0);
aserveSleep(500);
aserveOscillator(0, 0, 0, 0);
}
}
fclose(textFilePointer);
}
}

return 0;
}

void notestofile (int count, int count2, int note, int vel)
{
//Recording 16 note data into txt file
for (count = 1; count <= 16;)
{


note = aserveGetNote();
vel = aserveGetVelocity();


//only note on messages are sent to file
if(vel > 0)
{
fprintf(textFilePointer, " %d %d\n", note, vel);
printf("%d %d\n", note, vel);
count++;
}
}
}

我试图放入 main 中的名为“notestofile”的函数给了我错误“Apple Mach-O Linker (id) error”并且不会让我构建。该函数应该将音符编号写入文本文件,并在其位于 main 中而不是通过函数传递时起作用。预先感谢:)

最佳答案

您声明并调用 notetofile(),但定义 notestofile()。删除(或添加?)s 以修复错误。您还使用非原型(prototype)声明并在不带任何参数的情况下调用它。使用原型(prototype)可以防止这种情况发生,因此请进行更改

void notetofile ();

void notetofile(int count, int count2, int note, int vel);

关于c - “notestofile”功能不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29195230/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com