2016-12-11 29 views
0

実世界のビットのオーディオを使用して回路をシミュレートするには、LTSpiceのファイル入力機能を使用します。私は時間と振幅のバージョンのデータが必要ですが、どのソフトウェアパッケージが私のためにこれを行うことができますかわからない。 AudacityはMP3をWAVに変換できますが、私が見ているものからヘッダーレスのテキストファイルに変換することはできません。時間と振幅のWAVファイルをtxtファイルに変更するにはどうすればよいですか?

したがって、.WAVファイルは、時間/振幅の2列テキストファイルになります。

無料の方法はありますか?

+0

あなたはこのタスクを実行できるソフトウェアを使用しています。あなたの質問を編集して、入力と期待される出力のサンプルを提供すると、回答が得られます。 – enhzflep

答えて

0

ここではjavascriptを使用した簡単な実装です。

結果の文字列をBlobに変換する練習として残しておきます。チャンネルの選択、ステレオ結果、および処理のためにオーディオトラックの小さな部分を選択することができます。

<!doctype html> 
<html> 
<head> 
<script> 
"use strict"; 
function byId(id){return document.getElementById(id)} 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
window.addEventListener('load', onDocLoaded, false); 

var audioCtx; 

function onDocLoaded(evt) 
{ 
    audioCtx = new AudioContext(); 
    byId('fileInput').addEventListener('change', onFileInputChangedGeneric, false); 
} 

function onFileInputChangedGeneric(evt) 
{ 
    // load file if chosen 
    if (this.files.length != 0) 
    { 
     var fileObj = this.files[0]; 
     loadAndTabulateAudioFile(fileObj, byId('output')); 
    } 
    // clear output otherwise 
    else 
     byId('output').textContent = ''; 
} 

// processes channel 0 only 
// 
// creates a string that represents a 2 column table, where each row contains the time and amplitude of a sample 
// columns are tab seperated 
function loadAndTabulateAudioFile(fileObj, tgtElement) 
{ 
    var a = new FileReader(); 
    a.onload = loadedCallback; 
    a.readAsArrayBuffer(fileObj); 
    function loadedCallback(evt) 
    { 
     audioCtx.decodeAudioData(evt.target.result, onDataDecoded); 
    } 
    function onDataDecoded(buffer) 
    { 
     //console.log(buffer); 
     var leftChannel = buffer.getChannelData(0); 

     //var rightChannel = buffer.getChannelData(1); 
     console.log("# samples: " + buffer.length); 
     console.log(buffer); 

     var result = ''; 
     var i, n = buffer.length, invSampleRate = 1.0/buffer.sampleRate; 
     for (i=0; i<n; i++) 
     { 
      var curResult = (invSampleRate*i).toFixed(8) + "\t" + leftChannel[i] + "\n"; 
      result += curResult; 
     } 
     tgtElement.textContent = result; 
    } 
} 

</script> 
<style> 
</style> 
</head> 
<body> 
    <label>Select audio file: <input type='file' id='fileInput'/></label> 
    <hr> 
    <pre id='output'></pre> 
</body> 
</html> 
関連する問題