Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recorder cannot record more than 1 time if audio is played after recording (iOS) #15

Open
speggos opened this issue Aug 21, 2018 · 2 comments

Comments

@speggos
Copy link

speggos commented Aug 21, 2018

Hello, first of all thank you for the wonderful library! I am making an app which needs DSP and this has been such a life saver.

I'm having an issue with the recorder. Here is a high level of what the app is should be doing:

  1. Record audio
  2. Play a sound
  3. Record audio again

In step 3, I am getting nothing sent to the recorder's event listener (specifically, one empty buffer ( [] ) upon starting recording, and another upon ending recording)

Here is my code:

Starting Recording:

this.Recorder = require('react-native-recording').default;

        this.Recorder.init({
            bufferSize: constants.bufferSize,
            sampleRate: constants.sampleRate,
            bitsPerChannel: constants.bitsPerChannel,
            channelsPerFrame: constants.channelsPerFrame,
        });

        this.Listener = this.Recorder.addRecordingEventListener((data) => {
        	console.log('New data!', data.length)
        });

		this.Recorder.start();

Stopping recording:

this.Recorder.stop();
this.Recorder = null;
this.Listener.remove();
this.Listener = null;

Playing the sound (happens after stopRecording() )

let sound = new Player(soundTypeFiles[soundType], {autoDestroy: true});
sound.volume = 0.5;
sound.play(sound.destroy());

The first run of recording returns buffers as expected. The sound plays as expected. However, when I try to record audio again, here is my console:

  1. Start recording
    New data!, 0
    ...nothing

  2. Stop recording
    New data!, 0

This is fully functional on android, and I'm not sure what to do on this issue. Any help is appreciated :)

@oguzkaganeren
Copy link

oguzkaganeren commented Aug 25, 2018

recordStart = () => {
   	this.Listener = this.Recorder.addRecordingEventListener((data) => {
       	console.log('New data!', data.length)
       });
   	Recording.start()

   }

	recordStop = () => {
		this.listener.remove();

	}

I fixed it with the code. (you should remove this.listener from inside of componentDidMount )

@speggos
Copy link
Author

speggos commented Sep 4, 2018

Fixed this by playing audio using a different method ('MultiRoute'), do not know what was causing the issue on a low level, must be something to do with resources not being released.

This can be closed, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants