Sign in to follow this  
Evil Steve

Unity WAV files and sampler chunks

Recommended Posts

Hi all, I'm trying to add a loop point to a WAV file so I can run it through one of the Nintendo DS tools to convert it into a usable format. That's done by adding a sampler ("smpl") chunk to the wave file. I've written a tool to add sampler chunks myself, and it's worked fine up till now - I think that was just luck. Now when I try to run this WAV file through my tool, I get the oh-so-helpful error message: "waveconv: Unexpected exception" (And that's after I turned on "verbose" mode, grr). So, is there something fancy I need to do to add a sampler chunk to a wave file? Here's the code I currently have:
#pragma pack(push, 1)
struct SamplerChunk
{
	DWORD chunkID;			// 'smpl'
	long chunkSize;

	long dwManufacturer;
	long dwProduct;
	long dwSamplePeriod;
	long dwMIDIUnityNote;
	long dwMIDIPitchFraction;
	long dwSMPTEFormat;
	long dwSMPTEOffset;
	long cSampleLoops;
	long cbSamplerData;

	// Sample loop data
	long dwIdentifier;
	long dwType;
	long dwStart;
	long dwEnd;
	long dwFraction;
	long dwPlayCount;
};
#pragma pack(pop)

// Snip...
// Write sample chunk
SamplerChunk theChunk;
ZeroMemory(&theChunk, sizeof(theChunk));
theChunk.chunkID = s_dwSmplChunkHeader;
theChunk.chunkSize = sizeof(theChunk) - 8;
theChunk.dwSamplePeriod = (DWORD)(1000000000.0 / (double)format.nSamplesPerSec);
theChunk.dwMIDIUnityNote = 60;
theChunk.cSampleLoops = 1;

// Set loop point
theChunk.dwStart = 0;
theChunk.dwEnd = dwDataSize-1;


I assume that something has to be a multiple of something else, but I don't know what. I've had a look at various sites and not found anything relevant on any sites. Alternatively, can anyone recommend a free program I can use to add a loop point to a wave file and export a sampler chunk? I'm not sure what forum this should go in either (Since Music and Sound is under "The creative side"), so I've just bunged it here. Mods, feel free to move it if you think it belongs somewhere else. Cheers, Steve

Share this post


Link to post
Share on other sites
Hi,

Did you find any solution for that?
Because I'm looking for the same thing : a software that could add the sampler chunk for me.
Else, do anybody has an answer?

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this