background image
C H A P T E R 1 2
Special-Purpose Objects for Data Storage and Retrieval
Using Special-Purpose Data Storage Objects
The following code fragment adds sound sample data to an empty VBO and
demonstrates the use of the
function to undo those changes:
// create a temporary soup
mySoup := RegUnionSoup('|foo:myApp:mySig|,
{name: "foo:myApp:mySig", indexes: '[]}) ;
// get a soup entry that is a sound
anEntry := mySoup:AddToDefaultStoreXmit('{sndFrameType: nil,
compressionType: nil,
userName: nil}, nil) ;
// make a VBO to use for the samples
myVBO := GetDefaultStore():NewCompressedVBO('samples,5000,nil, nil);
// grab some samples from ROM and fill in most of sound frame
romSound := Clone(ROM_FunBeep) ;
anEntry.sndFrameType := romSound.sndFrameType ;
anEntry.samplingRate := romSound.samplingRate ;
anEntry.dataType := romSound.dataType ;
anEntry.compressionType := romSound.compressionType ;
anEntry.samples := myVBO ;
// put the samples in the VBO
BinaryMunger(myVBO, 0, nil, romSound.samples, 0, nil) ;
// write the VBO to the soup
EntryChangeXmit(anEntry, nil);
onException || do
:Notify(kNotifyAlert, "My App", "Sorry, can't save changes.");
// listen to the sound to verify change
// change the sound
BinaryMunger(anEntry.samples,0, nil, ROM_PlinkBeep.samples, 0, nil);
PlaySound(anEntry) ;
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна