0

EZAudio ( https://github.com/syedhali/EZAudio ) Objective-C ライブラリを Swift 3 に変換しようとしています。その中で「EZAudioPlayFileExample」の部分を実行しています。

Objective-C

- (void)openFileWithFilePathURL:(NSURL*)filePathURL
{
    self.audioFile = [EZAudioFile audioFileWithURL:filePathURL];
    self.filePathLabel.text = filePathURL.lastPathComponent;

    //
    // Plot the whole waveform
    //
    self.audioPlot.plotType = EZPlotTypeBuffer;
    self.audioPlot.shouldFill = YES;
    self.audioPlot.shouldMirror = YES;

    //
    // Get the audio data from the audio file
    //
    __weak typeof (self) weakSelf = self;
    [self.audioFile getWaveformDataWithCompletionBlock:^(float **waveformData,
                                                         int length)
    {
        [weakSelf.audioPlot updateBuffer:waveformData[0]
                          withBufferSize:length];
    }];
}

スイフト3

func openFileWithFilePathURL(filePathURL: NSURL) {
        self.audioFile = EZAudioFile(url: filePathURL as URL!)

        //
        // Plot the whole waveform
        //
        self.plot.plotType = .buffer
        self.plot.shouldFill = true
        self.plot.shouldMirror = true

        //
        // Get the audio data from the audio file
        //
        weak var weakSelf = self
        self.audioFile.getWaveformData(completionBlock: {(_ waveformData: Float, _ length: Int) -> Void in
            weakSelf?.plot.updateBuffer(waveformData[0], withBufferSize: length) // error in this line as Float as no subscript members
        })
    }

Float パラメーターには [0] のような添字メンバーがないことはわかっています。しかし、Objective-C コードを変換したいのです。または、ここの誰かがこのライブラリの Swift バージョンを使用しています。注: 「EZAudioPlayFileExample」が必要です。

4

1 に答える 1