0

そのため、サウンド ファイルをサンプルに分割し、それらのサンプルを配列に格納することで、Java でサウンド ファイルを操作しようとしています。次に、各サンプルを変更して配列をループします。Java には既にエコー フィルタがあることは認識していますが、音量を下げながらサウンド クリップ全体でさまざまな間隔でサウンドを繰り返すことで、独自のフィルタを設計する必要があります。私は現在、音量を制御する方法を持っていますが、現在のサウンドファイルの特定の遅延からサウンドを繰り返すようになると困惑しています。これは私がこれまでに持っているものです:

public void echoEffect(int delay){
   SoundSample[] sampleArray = this.getSamples(); // get array

   SoundSample sample = null;                     // current sample obj
   int value = 0;                                 // value at sample

 // loop through SoundSample objects
 for(int i = 0, index = 0; index < sampleArray.length; i++,index++)
 {
  sample = sampleArray[index];    // get current obj
  value = sample.getValue();      // get the value
  sample.setValue(value*2);       // set the value
 }
}

私がする必要があると信じているのは、メソッドを void から Sound に変更し、遅延したサウンド ファイルを返すことです。value + value[i+delay]*(サウンドを下げる分数)のようなものを返す可能性があります。

投稿ではなく新しい更新:

とにかく、これは私がこれまでに持っているもので、コードを正しく動作させることができないようで、近いことは知っていますが、サウンドファイルにエコー効果を出力する方法が必要です。現時点で私が持っているものは次のとおりです。

public void echo(int delay){
   SoundSample[] sampleArray = this.getSamples();   // get array
   //Sound target = new Sound(sampleArray.length);

   SoundSample sampleDelay = null;
   SoundSample sample = null;                       // current sample obj

   int value = 0;                                   // value at sample
   int index = 0;
   double value2 = 0;
// loop through SoundSample objects
while (index < sampleArray.length)
 {
  sample = sampleArray[index]; // get current obj
  value = sample.getValue();     // get the value      
  sampleDelay = (sampleArray[delay-index]);
  value2 = (sampleDelay.getValue()*.6);
  sample.setValue(value + (int) value2);       // set the value
  index++;                                  // increment index
 }
}

これが何らかの理由で振幅をシフトしていると思われることを教えてください... SSCCEを投稿する際の問題は、Javaで定期的に使用されていないいくつかのクラスを使用していることです。ロジックを手伝ってくれる人。サウンド ファイルのサンプルをループしてから、遅延ポイントの値をサウンドの開始点に設定しようとしていますが、音量は小さくなります。これを正しく説明している場合はIDKですが、これが簡単な修正になることを望んでいました。

4

2 に答える 2

1

それ以外の

sampleDelay = (sampleArray[delay-index]);

あなたが欲しい

sampleDelay = (sampleArray[index-delay]);

于 2013-03-20T03:32:36.313 に答える
0

以下ではないですか?

sampleDelay = (sampleArray[index*delay]);
于 2013-06-09T03:04:30.483 に答える