HulaLoop
Simple cross-platform audio loopback and recording.
Transport.h
1 #ifndef HL_TRANSPORT_H
2 #define HL_TRANSPORT_H
3 
4 #include <hlaudio/hlaudio.h>
5 #include <string>
6 
7 #include "Record.h"
8 
9 #define HL_INFINITE_RECORD -1
10 
11 namespace hula
12 {
16  enum TransportState
17  {
18  RECORDING,
19  STOPPED,
20  PLAYING,
21  PAUSED
22  };
23 
29  class Transport {
30  private:
31  TransportState state;
32  bool recordState = true;
33  bool playbackState = false;
34 
35  protected:
36  Record *recorder;
37 
38  public:
39  Controller *controller;
40 
41  public:
42 
43  #ifndef NDEBUG
44  Transport(bool dryRun);
45  #endif // END NDEBUG
46 
47  Transport();
48  virtual ~Transport();
49 
50  bool record(double delay, double duration);
51  bool record();
52  bool stop();
53  bool play();
54  bool pause();
55 
56  Controller *getController() const;
57 
58  void exportFile(std::string targetDirectory);
59 
60  TransportState getState() const;
61  std::string stateToStr(const TransportState state) const;
62  };
63 }
64 
65 #endif // HL_TRANSPORT_H
bool record()
Overload of record with no delay and infinite record time.
Definition: Transport.cpp:66
Extra class for managing the state of the application and all audio related processes.
Definition: Transport.h:29
bool pause()
Enter the paused state for playback or recording.
Definition: Transport.cpp:112
Controller * getController() const
Get the controller instance.
Definition: Transport.cpp:193
<hlaudio/hlaudio.h>
bool stop()
Enter the stopped state for playback or recording.
Definition: Transport.cpp:74
TransportState getState() const
Discard any recorded audio and reset the state.
Definition: Transport.cpp:157
virtual ~Transport()
Delete the controller we created.
Definition: Transport.cpp:208
Definition: Record.h:8
Definition: Controller.h:11
Central component of the audio backend.
Definition: Controller.h:19
bool play()
Playback previously recorded audio.
Definition: Transport.cpp:94
Transport()
Construct a new instance of the Transport class.
Definition: Transport.cpp:12
std::string stateToStr(const TransportState state) const
Convert an enum of type TransportState to a presentable string.
Definition: Transport.cpp:167