Message Boards Message Boards

0
|
6021 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How do you change the properties of a "Sound" item?

Posted 9 years ago

If you have a "Sound" item which has been generated previously, is there any way to alter its parameters, such as the sample number, or the timing. I would like to try to modify available sound files for different effects.

POSTED BY: John Eustace
3 Replies

Are you looking to import wav files and work with their raw data? You can import a wav files data this way:

Import[ "ExampleData/rule30.wav" , "Data"]

Or

Import[ "ExampleData/rule30.wav" , "SampledSoundList"]

You can get the number of audiochannels, the encoding scheme, and the sample rate by:

Import[ "ExampleData/rule30.wav" , "AudioChannels"]

Import[ "ExampleData/rule30.wav" , "AudioEncoding"]

Import[ "ExampleData/rule30.wav" , "SampleRate"]

If this is what you wanted, ignore my warning below.

I am not sure that I agree with that. A sound object is the same as any other object in Mathematica, and hence it should be subject to anything that you might want to do with it.

Not exactly. Sound expressions are different than most expressions in Mathematica. They have undefined/undocumented internal structure which may change. There are other expressions like this such as InterpolatingFunction and maybe even DateObject to some degree. These expressions are abstraction layers. In most languages, the internals of these would be inaccessible so that you couldn't break the abstraction layer.

POSTED BY: Sean Clarke

I am not sure that I agree with that. A sound object is the same as any other object in Mathematica, and hence it should be subject to anything that you might want to do with it. It is a matter of signal processing. I have no issue with opening and image file and manipulating every piece of information in that file, just to see what happens. I am interested in doing the same sort of thing with a sound file. I certainly can find a commercial music/sound editing package, either freeware, or for a cost. I want to be able to do similar things in Mathematica, and know what every action that I take is doing, and not just rely on someone else's code to do the work for me.

I have already looked into the InputForm of certain .wav files and found the attributes listed in the files. Now I can determine which parts are the sound data and which parts are the operational parameter, such as sample rates, channel numbers, bit depths and such.

POSTED BY: John Eustace

From a software engineering point of view, doing this is a bad idea. A Sound expression isn't meant to be modified in this way and doesn't present any defined methods for doing this. By opening up the internals of a sound expression, you're playing with essentially undocumented internal code which is subject to change in the future.

You want to change all of this before making it into a Sound expression.

That said, you can see the internal structure of a Sound expression by running InputForm on it. The internals will depend on the kind of specification you have given it. MIDI and sampled waveforms have very different structure that has to be handled differently.

Internally, it appears to use a SampledSoundFunction with a CompiledFunction for waveforms. Manipulating this would mean manipulating a CompiledFunction or uncompiling it in some way.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract