#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <ao/ao.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include "sndfile.h"
#pragma comment(lib,"libsndfile-1.lib")
#define PI 3.14;
using namespace std;
Mã:
void playfile( ) {
// Mo File
printf("
Nhap ten file: ");
char fileread[120]="";
scanf("%s",fileread);
SF_INFO sndInfo;
SNDFILE *sndFile = sf_open(fileread, SFM_READ, &sndInfo);
if (sndFile == NULL) {
fprintf(stderr, "Loi mo file '%s': %s
", fileread, sf_strerror(sndFile));
// return 1;
}
#define BUF_SIZE 4096
ao_device *device;
ao_sample_format format;
int default_driver;
int *buffer;
int buf_size;
int sample;
//float freq = 440.0;
int i;
/* -- Initialize -- */
ao_initialize();
/* -- Setup for default driver -- */
default_driver = ao_default_driver_id();
memset(&format, 0, sizeof(format));
/* format.bits = 16;
format.channels = 2;
format.rate = 44100;
format.byte_format = AO_FMT_LITTLE;*/
/* -- Open driver -- */
device = ao_open_live(default_driver, &format, NULL /* no options */);
if (device == NULL) {
fprintf(stderr, "Error opening device.
");
}
/* -- Play some stuff -- */
buf_size = sndInfo.format/8 * sndInfo.channels * sndInfo.samplerate;
buffer = calloc(buf_size,sizeof(char));
for (i = 0; i < sndInfo.format; i++) {
//sample = (int)(0.75 * 32768.0 *
//sin(2 * M_PI * freq * ((float) i/format.rate)));
/* Put the same stuff in left and right channel */
//buffer[4*i] = buffer[4*i+2] = sample & 0xff;
// buffer[4*i+1] = buffer[4*i+3] = (sample >> 8) & 0xff;
}
ao_play(device, buffer, buf_size);
/* -- Close and shutdown -- */
ao_close(device);
ao_shutdown();
//return 1;
}
em code xong chạy nó báo lỗi. thay đủ kiểu dạng từu int tới float rồi àm vẫn bị. bác nào sửa dùm em cái [IMG]images/smilies/21.gif[/IMG] [IMG]images/smilies/17.gif[/IMG]
Error 14 error C2664: 'ao_play' : cannot convert parameter 2 from 'int *' to 'char *'
View more random threads:
Vệ sinh cá nhân là một phần quan yếu của sức khỏe nam giới. Dùng dung dịch vệ sinh mỗi ngày mang lại nhiều ích, giúp loại bỏ vi khuẩn và vi sinh vật gây hại, giúp khu vực cơ quan sinh dục luôn sạch...
Gel vệ sinh cu, bạn trai có nên...