Advertisement
aDempster

record.cpp

Oct 23rd, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include "Chopper.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. #include <thread>
  7. #include <chrono>
  8.  
  9. void wait(int milliseconds){
  10.     std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
  11. }
  12.  
  13. int main(){
  14.     Chopper recorder;
  15.     std::vector<RtAudio::DeviceInfo> devInfo = recorder.getDevices();
  16.  
  17.     int index = 0;
  18.     for ( auto &i : devInfo ) {
  19.         std::cout << index << ": " << i.name << std::endl;
  20.         index++;
  21.     }
  22.  
  23.     int devNum;
  24.     std::cout << "Type the device number you wish to use: ";
  25.     std::cin >> devNum;
  26.     recorder.setDevice(devNum);
  27.  
  28.     std::string inp;
  29.  
  30.     recorder.startRecording();
  31.     std::cout << "\nRecording Started. This will not be included in the wav file." << std::endl; // It's actually almost 2 seconds from when this line prints to when the hardware starts recording
  32.     std::cout << "\nType anything and then press enter to mark the start of the wav file: ";
  33.     std::cin >> inp;
  34.     std::cout << "Recorded start time" << std::endl;
  35.     unsigned int start = getTimeMillis();
  36.  
  37.     std::cout << "\nType anything and the press enter to mark the end of the wav file: ";
  38.     std::cin >> inp;
  39.     std::cout << "Recorded stop time" << std::endl;
  40.     unsigned int end = getTimeMillis();
  41.  
  42.     std::cout << "\nThe wav file is ended, but this will record until you specifically stop it by typing something: ";
  43.     std::cin >> inp;
  44.     recorder.stopRecording();
  45.     std::cout << "Recording stopped" << std::endl;
  46.  
  47.     recorder.chopAudio("final.wav", start, end);
  48.     std::cout << "\nFile Rendered" << std::endl;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement