CUHK-CMD / timbre-visualization-on-ios

Sounds are hard to understand and explain 🎵
https://apps.apple.com/hk/app/soundsgood/id1597764029
0 stars 1 forks source link

Store a period of audio data #4

Closed IamMrandrew closed 2 years ago

IamMrandrew commented 2 years ago

Currently on Sound view, amplitude of audio are stored only on audio.lastAmplitude

  1. We want to start recording(Storing audio data into a variable) when a button is clicked (Can be a temporary button for now).
  2. And stop when the button is clicked again

Report document Presentation slides

JohnYeung-dojjy commented 2 years ago

So the recording does not have a time limit? If so this is my proposed implementation: (in AudioViewModel.swift

// update the last captured amplitude
    self.audio.lastAmplitude = Double(amplitude[0])
    if (self.isRecording){
        self.audio.recordedAmplitudes.append(self.audio.lastAmplitude) // store the Amplitude data
    }
func recordingToggle(){ // triggered when user click the record button
        if (!self.isRecording){ // clear the recorded audio when user starts a new recording
            self.resetRecording()
        }
        self.isRecording.toggle()}

    func resetRecording(){
        self.audio.recordedAmplitudes = []
    }
IamMrandrew commented 2 years ago

@JohnYeung-dojjy I think this might work. Let's try😂