Mathematica: Upravujte a ukladajte súbory WAV
S Wolfram Mathematica môžete importovať, analyzovať, upravovať a exportovať súbory WAV. Poviem vám ako.
Importujte súbory WAV do Mathematica
Jednoduchým príkazom „audio = Import [cesta, príkaz]“ môžete importovať údaje zo súborov WAV do Mathematica. Musíte zadať cestu a príkaz. Pomoc pre jednoduché zadanie cesty je uvedená v galérii obrázkov. Rôzne prvky súboru WAV môžete načítať pomocou nasledujúcich príkazov:
- "Prvky" ukazujú, ktoré informácie o súbore WAV môžete importovať do Mathematica
- „Audiokanály“ vás informujú o počte kanálov vložených do súboru WAV.
- "SampleRate" vydáva vzorkovaciu frekvenciu
- „AudioEncoding“ označuje spôsob kódovania vzoriek. Hodnota sa spravidla pohybuje medzi „Integer16“ a „Integer32“, tj celými číslami so 16 až 32 bitmi. Je možné kódovať od 4 do 64 bitov.
- „Dáta“ je matica, ktorá obsahuje RAW údaje kanálu v každom riadku. Varovanie: Pretože táto matica obsahuje všetok zvukový materiál, niekedy môže byť veľmi veľká. Je možné načítať súbory až do 4 GB. Tu by ste určite mali použiť znak „;“ potlačí výstup údajov. Pretože ste dali matici názov „audio“, môžete s ňou aj naďalej pracovať.
- Pri použití „Zvuku“ Mathematica načíta súbor vrátane zobrazenia priebehu a spektra a malého prehrávača na prehrávanie zvuku.
- Pri „Pravidlách“ sa všetky informácie importujú do matice. Šesť riadkov obsahuje „AudioChannels“, „AudioEncoding“, „Data“, „SampledSoundList“, „SampleRate“ a „Sound“ v tomto poradí. Upozornenie: Táto matica je výrazne väčšia ako samotný zvukový súbor, takže by ste mali určite na výstupe údajov s znakom „;“. potlačiť.
Analyzujte a upravujte súbory WAV v Mathematica
Dáta RAW importované pomocou položky „Data“ je možné používať a editovať v Mathematica rovnako ako v akejkoľvek inej tabuľke. Nasledujúce príkazy sú zvlášť zaujímavé pre zvukový materiál:
- Teraz môžete zobraziť akúkoľvek hodnotu v "audio" matici a zmeniť ju podľa vášho želania.
- „Dimenzie [zvuk]“ vám poskytne počet riadkov a stĺpcov, tj počet vzoriek na kanál.
- Pomocou "area = Take [audio [[X, All]], {start value, end value}];" môžete odstrániť časť kanála X.
- "Spektrum = Fourier [oblasť];" vykoná Fourierovu analýzu tejto časti.
- Spektrálne komponenty môžete tiež ľubovoľne meniť.
- "Re [spektrum]", "Im [spektrum]", "Abs [spektrum]" a "Arg [spektrum]" vydávajú skutočnú časť, imaginárnu časť, amplitúdu a fázu spektrálnych komponentov.
Exportujte súbory WAV z Mathematica
Ak chcete, aby manipulované zvukové údaje boli znova súborom WAV, jednoducho zadajte príkaz „Export [cesta, príkaz]“. Na správne nastavenie súboru WAV použite nasledujúce príkazy:
- Pred exportom by ste mali použiť výraz „audio / = Max [Abs [audio];]“ na | 1 | normalizovať. Hodnoty nad 1 a pod -1 sú prepísané.
- „SampleRate“ -> 44100 “exportuje zvukový materiál rýchlosťou 44100 vzoriek za sekundu.
- "" AudioEncoding "->" Integer16 "" kóduje zvukový súbor so 16 bitmi na vzorku.
- Pomocou zvukových kanálov -> 2 “môžete zabezpečiť, aby sa exportovali iba prvé 2 kanály, aj keď zvukový materiál obsahuje viac kanálov.
Tipy na Wolfram Alpha nájdete tu. Ako pracovať s programom Audacity. vysvetlíme tu.
Najnovšie videá
Zadávanie ciest v Mathematica je trochu únavné: cesty sú uzavreté v úvodzovkách a priečinky nie sú oddelené znakom lomky "/", ale dvoma spätnými lomkami "\\". Jednoducho skopírovanie cesty z Prieskumníka tu nefunguje.
Najjednoduchší spôsob je použiť „Vložiť“ -> „Filepath“
„vybrať ... "filePath
"zvoľte ...">
"filePath
"zvoľte ..." />
"zvoľte ..." />
a prejdite sem v okne prieskumníka na požadovaný súbor. Mathematica potom zaznamená správnu cestu k súboru.