3

フィルターを適用した後に音声ファイルを保存するのはとてもイライラします。フィルターは AVAudioPlayerNode にのみ適用されます。これは、プレーヤーでの再生中にフィルターを適用するのに最適であることを意味しますが、これを保存するにはどうすればよいですか? 私はこの 3 日間とても苦労しています。これらの以下のコードは私が使用している、

engine = [[AVAudioEngine alloc] init];

 - (void)setupEQ
{
      NSLog(@"setupEQ");

      unitEq = [[AVAudioUnitEQ alloc] initWithNumberOfBands:12];
      unitEq.globalGain = 3.0;
      AVAudioUnitEQFilterParameters *filterParameters;
      filterParameters = unitEq.bands[0];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 31;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_31.5hz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[1];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 63;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_63hz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[2];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 125;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_125hz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[3];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 250;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_250hz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[4];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 500;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_500hz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[5];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 1000;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_1khz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[6];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 2000;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_2khz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[7];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 4000;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain =[[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_4khz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[8];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 8000;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain = [[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_8khz"] floatValue];
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[9];
      filterParameters.filterType = AVAudioUnitEQFilterTypeParametric;
      filterParameters.frequency = 16000;
      filterParameters.bandwidth = 1.0;
      filterParameters.gain =[[[filter_arr objectAtIndex:index_filter] objectForKey:@"filter_freq_16khz"] floatValue];
      filterParameters.bypass = FALSE;


      filterParameters = unitEq.bands[10];
      filterParameters.filterType = AVAudioUnitEQFilterTypeLowPass;
      filterParameters.frequency = 16857;
      filterParameters.bypass = FALSE;

      filterParameters = unitEq.bands[11];
      filterParameters.filterType = AVAudioUnitEQFilterTypeHighPass;
      filterParameters.frequency = 205;
      filterParameters.bypass = FALSE;

      [engine attachNode:unitEq];
}







audioFile = [[AVAudioFile alloc] initForReading:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@",[self audio_file_path:mp3FileName]]] error:&playerError];
            [self setupPlayer];
            [self setupEQ];

            AVAudioMixerNode *mixerNode = [engine mainMixerNode];
            [engine connect:audio_player_node to:unitEq format:audio_file.processingFormat];
            [engine connect:unitEq to:mixerNode format:audio_file.processingFormat];

これらは正常に動作するサンプルです。しかし、どうすればこれと同じ周波数でオーディオ ファイルを保存できますか? 音声ファイルは mp3 形式である必要があります。Appleでは、保存ファイルをm4aとしてのみ対象としています。

4

1 に答える 1