简体   繁体   中英

How to Change Sound Wave Swift

I found how to create Sound wave From FDWaveformView Pods , but I can't modify to create a this type of wave screenshot below:

Here is what I am trying to do:

屏幕截图一

The screenshot is taken from Iphone:

屏幕截图秒

This code creates sine wave but I need to create pulse waves:

    soundWaveView.delegate = self
    soundWaveView.alpha = 0.0
    soundWaveView.audioURL = mainTrackURL
    soundWaveView.zoomSamples = 0 ..< soundWaveView.totalSamples / 3
    soundWaveView.doesAllowScrubbing = false
    soundWaveView.doesAllowStretch = false
    soundWaveView.doesAllowScroll = false
    soundWaveView.wavesColor = UIColor(red: 46/255, green: 188/255, blue: 191/255, alpha: 1)
    soundWaveView.progressColor = UIColor(red: 251/255, green: 237/255, blue: 101/255, alpha: 1)
    do {
        try AVAudioSession.sharedInstance().setActive(true)
        playerSoundWave = try AVAudioPlayer(contentsOf: mainTrackURL!, fileTypeHint: AVFileType.mp4.rawValue)
        songTotalTime = Double((playerSoundWave?.duration)!)
    }
    catch let error {
        print(error.localizedDescription)
    }

Question: How to modify or create sound wave?

Can someone please explain to me how to create and modify sound wave, i've tried to modify but no results yet. Any help would be greatly appreciated.

Thanks in advance.

I found how to create Sound wave From FDWaveformView Pods , but I can't modify to create a this type of wave screenshot below:

Here is what I am trying to do:

屏幕截图一

The screenshot is taken from Iphone:

屏幕截图秒

This code creates sine wave but I need to create pulse waves:

    soundWaveView.delegate = self
    soundWaveView.alpha = 0.0
    soundWaveView.audioURL = mainTrackURL
    soundWaveView.zoomSamples = 0 ..< soundWaveView.totalSamples / 3
    soundWaveView.doesAllowScrubbing = false
    soundWaveView.doesAllowStretch = false
    soundWaveView.doesAllowScroll = false
    soundWaveView.wavesColor = UIColor(red: 46/255, green: 188/255, blue: 191/255, alpha: 1)
    soundWaveView.progressColor = UIColor(red: 251/255, green: 237/255, blue: 101/255, alpha: 1)
    do {
        try AVAudioSession.sharedInstance().setActive(true)
        playerSoundWave = try AVAudioPlayer(contentsOf: mainTrackURL!, fileTypeHint: AVFileType.mp4.rawValue)
        songTotalTime = Double((playerSoundWave?.duration)!)
    }
    catch let error {
        print(error.localizedDescription)
    }

Question: How to modify or create sound wave?

Can someone please explain to me how to create and modify sound wave, i've tried to modify but no results yet. Any help would be greatly appreciated.

Thanks in advance.

I found how to create Sound wave From FDWaveformView Pods , but I can't modify to create a this type of wave screenshot below:

Here is what I am trying to do:

屏幕截图一

The screenshot is taken from Iphone:

屏幕截图秒

This code creates sine wave but I need to create pulse waves:

    soundWaveView.delegate = self
    soundWaveView.alpha = 0.0
    soundWaveView.audioURL = mainTrackURL
    soundWaveView.zoomSamples = 0 ..< soundWaveView.totalSamples / 3
    soundWaveView.doesAllowScrubbing = false
    soundWaveView.doesAllowStretch = false
    soundWaveView.doesAllowScroll = false
    soundWaveView.wavesColor = UIColor(red: 46/255, green: 188/255, blue: 191/255, alpha: 1)
    soundWaveView.progressColor = UIColor(red: 251/255, green: 237/255, blue: 101/255, alpha: 1)
    do {
        try AVAudioSession.sharedInstance().setActive(true)
        playerSoundWave = try AVAudioPlayer(contentsOf: mainTrackURL!, fileTypeHint: AVFileType.mp4.rawValue)
        songTotalTime = Double((playerSoundWave?.duration)!)
    }
    catch let error {
        print(error.localizedDescription)
    }

Question: How to modify or create sound wave?

Can someone please explain to me how to create and modify sound wave, i've tried to modify but no results yet. Any help would be greatly appreciated.

Thanks in advance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM