Mathematica: Rediger og gem WAV-filer
Med Wolfram Mathematica kan du importere, analysere, redigere og eksportere WAV-filer. Vi fortæller dig hvordan.
Importer WAV-filer til Mathematica
Med den enkle kommando "audio = Importer [sti, kommando]" kan du importere data fra WAV-filer til Mathematica. Stien og kommandoen skal citeres. Hjælp til nem stiindtastning gives i billedgalleriet. Du kan indlæse forskellige elementer i WAV-filen med følgende kommandoer:
- "Elements" viser dig hvilke oplysninger om WAV-filen du kan importere til Mathematica
- "AudioChannels" informerer dig om antallet af kanaler, der er integreret i WAV-filen.
- "SampleRate" udsender prøvehastigheden
- "AudioEncoding" angiver, hvordan prøverne kodes. Som regel ligger værdien mellem "Integer16" og "Integer32", dvs. heltal med 16 til 32 bit. Kodning fra 4 til 64 bit er mulig.
- "Data" er en matrix, der indeholder RAW-data fra en kanal i hver linje. Advarsel: Da denne matrix indeholder alt lydmateriale, kan det undertiden være meget stort. Filer op til 4 GB kan indlæses. Her skal du bestemt bruge ";" undertrykke output af dataene. Da du gav matrixen navnet "lyd", kan du fortsætte med at arbejde med den.
- Brug af "Sound" Mathematica indlæser filen inklusive bølgeform og spektrumvisning og en lille afspiller til at afspille lyden.
- Med "Regler" importeres al information til en matrix. Seks linjer indeholder "AudioChannels", "AudioEncoding", "Data", "SampledSoundList", "SampleRate" og "Sound" i denne rækkefølge. Advarsel: Denne matrix er betydeligt større end selve lydfilen, så du skal bestemt sende dataene med en ";" undertrykke.
Analyser og rediger WAV-filer i Mathematica
RAW-dataene, der importeres ved hjælp af "Data", kan bruges og redigeres i Mathematica som enhver anden tabel. Følgende kommandoer er især interessante for lydmateriale:
- Du kan nu vise en hvilken som helst værdi i "lyd" -matrixen og ændre den, som du ønsker.
- "Dimensioner [lyd]" giver dig antallet af rækker og kolonner, dvs. antallet af eksempler pr. Kanal.
- Brug af "område = Tag [lyd [[X, alle]], {startværdi, slutværdi}];" du kan fjerne en del af kanal X.
- "Spectrum = Fourier [område];" foretager en Fourier-analyse af denne del.
- Du kan også ændre spektralkomponenter når du vil.
- "Re [spektrum]", "Im [spektrum]", "Abs [spektrum]" og "Arg [spektrum]" udsender den reelle del, den imaginære del, amplitude og fase af de spektrale komponenter.
Eksport af WAV-filer fra Mathematica
For at gøre de manipulerede lyddata til en WAV-fil igen skal du blot indtaste "Eksporter [sti, kommando]". Brug følgende kommandoer til at indstille WAV-filen korrekt:
- Før du eksporterer, skal du bruge "audio / = Max [Abs [audio];]" på | 1 | normalisere. Værdier over 1 og under -1 tilsidesættes.
- "" SampleRate "-> 44100" eksporterer lydmaterialet med 44100 prøver i sekundet.
- "" AudioEncoding "->" Integer16 "" koder lydfilen med 16 bit pr. Prøve.
- Med "" AudioChannels "-> 2" kan du sikre dig, at kun de første 2 kanaler eksporteres, selvom lydmaterialet indeholder flere kanaler.
Du kan finde tip til Wolfram Alpha her. Sådan arbejder du med Audacity-programmet. vi forklarer her.
Seneste videoer
Det er en smule kedeligt at indtaste stier i Mathematica: stier er indkapslet i anførselstegn, og mapper adskilles ikke med et skråstregsymbol "/", men med to tilbageslag "\\". Kopiering af stien fra Explorer fungerer ikke her.
Den nemmeste måde er at bruge "Indsæt" -> "Filepath
"vælg ... "filepath
"vælg ...">
"filepath
"vælg ..." />
"vælg ..." />
og naviger her i explorervinduet til den ønskede fil. Mathematica noterer derefter filstien i den rigtige stavemåde.