Advertisement
Kaidul

WAV recorder

Sep 6th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. function recorder()
  2. option = 'n';
  3. option_rec = 'n';
  4. record_len = 0.7;   % Record time length in seconds
  5. sample_freq = 8192; % Sampling frequency in Hertz
  6. sample_time = sample_freq * record_len;
  7.  
  8. name = input('Enter the file name you want to save the file with: ', 's');
  9. file_name = sprintf('%s.wav', name);
  10. option_rec = input('Press y to record: ', 's');
  11. if option_rec == 'y'
  12.     while option == 'n',
  13.         input('Press enter when ready to record--> ');
  14.         record = wavrecord(sample_time, sample_freq);
  15.         input('Press enter to listen the recorded voice--> ');
  16.         sound(record, sample_freq);
  17.         option = input('Press y to save or n to record again: ', 's');
  18.     end
  19.     wavwrite(record, sample_freq, file_name);
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement