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 <QCoreApplication>
8 
9 #include "Record.h"
10 
11 #define HL_INFINITE_RECORD -1
12 #define HL_TRANSPORT_LOCKOUT_MS 200
13 
14 namespace hula
15 {
20  {
21  READY,
22  RECORDING,
23  STOPPED,
24  PLAYING,
25  PAUSED
26  };
27 
33  class Transport {
34 
35  Q_DECLARE_TR_FUNCTIONS(Transport)
36 
37  private:
38  TransportState state;
39  bool canRecord;
40  bool canPlayback;
41  bool initRecordClicked;
42 
43  protected:
44  Record *recorder;
45 
46  public:
47  Controller *controller;
48 
49  public:
50  Transport();
51  virtual ~Transport();
52 
53  bool record(double delay, double duration);
54  bool record();
55  bool stop();
56  bool play();
57  bool pause();
58  void discard();
59 
60  Controller *getController() const;
61 
62  void exportFile(std::string targetDirectory);
63 
64  bool hasExportPaths();
65 
66  TransportState getState() const;
67  std::string stateToStr(const TransportState state) const;
68  };
69 }
70 
71 #endif // HL_TRANSPORT_H
bool record()
Overload of record with no delay and infinite record time.
Definition: Transport.cpp:61
Extra class for managing the state of the application and all audio related processes.
Definition: Transport.h:33
bool pause()
Enter the paused state for playback or recording.
Definition: Transport.cpp:113
bool hasExportPaths()
Checks if there are files in the export paths which means recording has happened and there are no fil...
Definition: Transport.cpp:216
Controller * getController() const
Get the controller instance.
Definition: Transport.cpp:181
<hlaudio/hlaudio.h>
bool stop()
Enter the stopped state for playback or recording.
Definition: Transport.cpp:69
TransportState getState() const
Return the current state of the Transport object.
Definition: Transport.cpp:147
virtual ~Transport()
Delete the controller we created.
Definition: Transport.cpp:234
Class for Recording audio and abstracting OS specific stuff.
Definition: Record.h:13
Wrapper around translation functions for Qt.
Definition: Controller.h:10
Central component of the audio backend.
Definition: Controller.h:18
bool play()
Playback previously recorded audio.
Definition: Transport.cpp:91
void discard()
Reset transport states and delete captured audio files from system temp folder.
Definition: Transport.cpp:197
Transport()
Construct a new instance of the Transport class.
Definition: Transport.cpp:13
std::string stateToStr(const TransportState state) const
Convert an enum of type TransportState to a presentable string.
Definition: Transport.cpp:157
TransportState
Available states for the recording/playback logic of the application.
Definition: Transport.h:19