[Speex-dev] Help decompressing Speex audio

Clifton Craig clifton.craig at gmail.com
Mon May 3 13:23:21 PDT 2010


One more thing. The original example decompresses the file to roughly 74924 while my example decompresses to 37440. Like I said, it's about half the expected size and it plays at twice the speed. It's like I'm missing every other sample. I suspect the following code in copyOggPacketToSpeexBitstream:
	/*Copy Ogg packet to Speex bitstream*/
	speex_bits_read_from(&bits, (char*)oggPacket.packet, oggPacket.bytes);
	int numberOfFrames = [[audioAttributes valueForKey:@"framesPerPacket"] intValue];
	for (int i=0;i!=numberOfFrames;i++) {
		short int decodedData[MAX_FRAME_SIZE];
		speex_decode_int(theSpeexDecoder, &bits, decodedData);
		int blockSize = [[audioAttributes valueForKey:@"decodeBlockSize"] intValue];
		short int rawBlock[blockSize];
		for (int count=0; count < blockSize; count++) {
			rawBlock[count] = le_short( decodedData[count] );
		}
		if ([delegate respondsToSelector:@selector(audioWasDecoded:)]) {
			NSData *delegatesData = [NSData dataWithBytes:rawBlock length:blockSize];
			[delegate performSelector:@selector(audioWasDecoded:) withObject:delegatesData];
		}
	}

but I don't see anything wrong here. What am I missing???


Clifton Craig
Software Engineer
http://codeforfun.wordpress.com
clifton.craig at gmail.com

On May 3, 2010, at 4:15 PM, Clifton Craig wrote:

> I have an audio file compressed by JSpeex that I'm trying to decompress on the iPhone. I've been trying to work from the speexdec example in an attempt to port the core logic to ObjC. I have a class that does the decode and passes the result back to another class. (currently the other class is a unit test.) My other class is writing the converted output to disk. I compare the results of my rewrite against the result of running the same file against the speexdec.c example. I've gotten pretty far as the audio is decompressing. My problem is that the converted output is half the size that is generated by the original speexdec.c example. It plays, but it appears to play at double the speed. I'm certain that there is something I am missing in my algorithm and if someone could lend a hand I'd be so appreciative. I'm attaching my unit test as well as my rewritten example in ObjC
> 
> 
> 
> Clifton Craig
> Software Engineer
> http://codeforfun.wordpress.com
> clifton.craig at gmail.com
> 
> <MQSpeexDecoderTest.m><MQSpeexDecoder.h><MQSpeexDecoder.m>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20100503/69f114cd/attachment.htm 


More information about the Speex-dev mailing list