Hi all,
I'm using Pacific Neo-Tek's Omniremote library to record and play
back IR samples, but I'm having trouble storing the samples
correctly in my database.
The IR sample is stored in a byte array, and it works fine if I pass it
straight to the playback function, but not if I write it to my db and
access it later.
I've tried using a UInt8 array and a Char array to hold the sample,
but I get the same problem with both. I'm already using another
database to store Char arrays, and I've no probs there, so I don't
know what I'm doing wrong this time...
Here's my code for writing to and retrieving from the database using
a UInt8 array:
// my Channel structure:
typedef struct {
const Char *name;
UInt16 sampleLength;
UInt8 *sample;
} Channel;
/*********************************************/
//Recording a sample:
UInt8 sample[1024];
UInt16 sampleLength;
OrLibRecordSample(ORLibRefNum, sample, 1024,
&sampleLength, 80000, 152, 10);
channel.name = "whatever";
channel.sampleLength = sampleLength;
channel.sample = sample;
channelp[0] = &channel; //add to my array of channel pointers
AddChannel(channelp[0], channelDB, index);
/********************************************************/
//AddChannel function:
static void AddChannel(Channel *channel, DmOpenRef DBref,
UInt16 index)
{
MemHandle RecHandle;
MemPtr RecPointer;
UInt16 length;
UInt16 offset = 0;
length = StrLen(channel->name) + sizeof(channel-
>sampleLength) + sizeof(channel->sample) + 1;
RecHandle = DmResizeRecord(DBref, index, length);
RecPointer = MemHandleLock(RecHandle);
DmWrite(RecPointer, offset, channel, length);
MemPtrUnlock(RecPointer);
}
/*******************************************************/
//Retrieving and playing a sample:
Channel *theChannel;
RecHandle = DmQueryRecord(channelDB, index);
RecPointer = MemHandleLock(RecHandle);
theChannel = RecPointer;
OrLibStartPlaySample(ORLibRefNum, 80000L);
OrLibPlaySample(ORLibRefNum, theChannel->sample, theChannel-
>sampleLength, 80000L, 10, false);
OrLibEndPlaySample(ORLibRefNum);
MemHandleUnlock(RecHandle);
Thanks in advance for any help you can give me with this!
Peter Briggs
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/