Pull to refresh

Comments 4

Спасибо за перевод. В очередной раз поражаюсь огромными возможностями и гибкостью языка Wolfram. Хотелось бы узнать, возможно ли в Mathematica выполнить преобразование .waw в midi?
Ответ инженера:

I think the answer is No, since they are substantially different types of files. This can be checked with

In[1]:= Import[«ExampleData/rule30.wav»,«Elements»]
Out[1]= {Audio,AudioChannels,AudioEncoding,AudioFile,Data,Duration,Length,MetaInformation,SampleDepth,SampledSoundList,
SampleRate,Sound}
Import[«ExampleData/rule30.wav», «Sound»]

In[149]:= Export[«rule30.mid»,%]

During evaluation of In[149]:= Export::nodta: Sound[SampledSoundList[{{0.,-0.0078125,-0.0078125,-0.015625,-0.015625,-0.0078125,-0.0078125,-0.0078125,-0.0078125,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,-0.0078125,-0.0078125,-0.0078125,-0.0078125,-0.0078125,-0.0078125,0.,0.,0.,-0.0078125,-0.0078125,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.00781274,0.00781274,0.00781274,0.00781274,0.,0.,0.,0.,<<79330>>}},44100]] contains no data that can be exported to the MIDI format.
Out[149]= $Failed

In[150]:= Import[«ExampleData/rule30.wav»]

In[151]:= Export[«rule30.mid»,%]

During evaluation of In[151]:= Export::nodta: Audio[RawArray[Data Type: Integer16
Dimensions: {1,79380}], SignedInteger16,Appearance->Automatic,AudioOutputDevice->Automatic,SampleRate->44100, SoundVolume->1] contains no data that can be exported to the MIDI format.
Out[151]= $Failed

The nature of the two files is quite different. WAV files are for storing Audio information and are expressed as Sound[SampledSoundList[...]] whereas MIDI files are for storing the individual SoundNotes that provide information about the actual notes, their duration and the instruments they are played upon. In short MIDI files can be converted into Music scores whereas WAV files are digital Audio representations. So one can take MIDI files that contain score information and convert them to Audio files as in

In[1]:= Import[«ExampleData/scaleprogression.mid»]

In[2]:= Export[«scaleprogression.wav»,%]
Out[2]= scaleprogression.wav

But it is very difficult to go the other way, from the SampledSoundList to it's musical score representation. I don't know of any programs that do this, but I haven't looked into it for a number of years when I used to use the music program Sibelius. In fact the mapping from sound to score would only be a one-to-one mapping if there is one or a few Audio Channels but is more likely to be one-to-many or injective for a large number of channels because the same or similar sound could be represented by a number of different scores where multiple orchestrations result in very similar sounds.
Sign up to leave a comment.