Hard coded bits per sample, as it should be

CQTexperiment
Chris Moeller 2013-10-05 02:00:25 -07:00
parent 2426d7f7fd
commit ba69558a99
2 changed files with 4 additions and 7 deletions

View File

@ -28,7 +28,6 @@
int lastSection; int lastSection;
BOOL seekable; BOOL seekable;
int bitsPerSample;
int bitrate; int bitrate;
int channels; int channels;
float frequency; float frequency;

View File

@ -60,7 +60,6 @@ long sourceTell(void *datasource)
vi = ov_info(&vorbisRef, -1); vi = ov_info(&vorbisRef, -1);
bitsPerSample = vi->channels * 8;
bitrate = (vi->bitrate_nominal/1000.0); bitrate = (vi->bitrate_nominal/1000.0);
channels = vi->channels; channels = vi->channels;
frequency = vi->rate; frequency = vi->rate;
@ -84,7 +83,6 @@ long sourceTell(void *datasource)
vorbis_info *vi; vorbis_info *vi;
vi = ov_info(&vorbisRef, -1); vi = ov_info(&vorbisRef, -1);
bitsPerSample = vi->channels * 8;
bitrate = (vi->bitrate_nominal/1000.0); bitrate = (vi->bitrate_nominal/1000.0);
channels = vi->channels; channels = vi->channels;
frequency = vi->rate; frequency = vi->rate;
@ -93,11 +91,11 @@ long sourceTell(void *datasource)
[self didChangeValueForKey:@"properties"]; [self didChangeValueForKey:@"properties"];
} }
int size = frames * channels * (bitsPerSample/8); int size = frames * channels * 2;
do { do {
lastSection = currentSection; lastSection = currentSection;
numread = ov_read(&vorbisRef, &((char *)buf)[total], size - total, 0, bitsPerSample/8, 1, &currentSection); numread = ov_read(&vorbisRef, &((char *)buf)[total], size - total, 0, 2, 1, &currentSection);
if (numread > 0) { if (numread > 0) {
total += numread; total += numread;
} }
@ -108,7 +106,7 @@ long sourceTell(void *datasource)
} while (total != size && numread != 0); } while (total != size && numread != 0);
return total/(channels * (bitsPerSample/8)); return total/(channels * 2);
} }
- (void)close - (void)close
@ -130,7 +128,7 @@ long sourceTell(void *datasource)
{ {
return [NSDictionary dictionaryWithObjectsAndKeys: return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:channels], @"channels", [NSNumber numberWithInt:channels], @"channels",
[NSNumber numberWithInt:bitsPerSample], @"bitsPerSample", [NSNumber numberWithInt:16], @"bitsPerSample",
[NSNumber numberWithFloat:frequency], @"sampleRate", [NSNumber numberWithFloat:frequency], @"sampleRate",
[NSNumber numberWithDouble:totalFrames], @"totalFrames", [NSNumber numberWithDouble:totalFrames], @"totalFrames",
[NSNumber numberWithInt:bitrate], @"bitrate", [NSNumber numberWithInt:bitrate], @"bitrate",