-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathcreaperproject.cpp
More file actions
132 lines (113 loc) · 4.48 KB
/
creaperproject.cpp
File metadata and controls
132 lines (113 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/******************************************************************************\
* Copyright (c) 2020-2026
*
* Author(s):
* pljones
*
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
\******************************************************************************/
#include "creaperproject.h"
/**
* @brief operator << Write details of the STrackItem to the QTextStream
* @param os the QTextStream
* @param trackItem the STrackItem
* @return the QTextStream
*
* Note: unused?
*/
QTextStream& operator<< ( QTextStream& os, const recorder::STrackItem& trackItem )
{
os << "_track( "
<< "numAudioChannels(" << trackItem.numAudioChannels << ")"
<< ", startFrame(" << trackItem.startFrame << ")"
<< ", frameCount(" << trackItem.frameCount << ")"
<< ", fileName(" << trackItem.fileName << ")"
<< " );";
return os;
}
/******************************************************************************\
* recorder methods *
\******************************************************************************/
using namespace recorder;
// Reaper Project writer -------------------------------------------------------
/**
* @brief CReaperItem::CReaperItem Construct a Reaper RPP "<ITEM>" for a given RIFF WAVE file
* @param name the item name
* @param trackItem the details of where the item is in the track, along with the RIFF WAVE filename
* @param iid the sequential item id
*/
CReaperItem::CReaperItem ( const QString& name, const STrackItem& trackItem, const qint32& iid, int frameSize )
{
QString wavName = trackItem.fileName; // assume RPP in same location...
QTextStream sOut ( &out );
sOut << " <ITEM " << '\n'
<< " FADEIN 0 0 0 0 0 0" << '\n'
<< " FADEOUT 0 0 0 0 0 0" << '\n'
<< " POSITION " << secondsAt48K ( trackItem.startFrame, frameSize ) << '\n'
<< " LENGTH " << secondsAt48K ( trackItem.frameCount, frameSize ) << '\n'
<< " IGUID " << iguid.toString() << '\n'
<< " IID " << iid << '\n'
<< " NAME " << name << '\n'
<< " GUID " << guid.toString() << '\n'
<< " <SOURCE WAVE" << '\n'
<< " FILE " << '"' << wavName << '"' << '\n'
<< " >" << '\n'
<< " >";
sOut.flush();
}
/**
* @brief CReaperTrack::CReaperTrack Construct a Reaper RPP "<TRACK>" for a given list of track items
* @param name the track name
* @param iid the sequential track id
* @param items the list of items in the track
*/
CReaperTrack::CReaperTrack ( QString name, qint32& iid, QList<STrackItem> items, int frameSize )
{
QTextStream sOut ( &out );
sOut << " <TRACK " << trackId.toString() << '\n';
sOut << " NAME " << name << '\n';
sOut << " TRACKID " << trackId.toString() << '\n';
int ino = 1;
foreach ( auto item, items )
{
sOut << CReaperItem ( name + " (" + QString::number ( ino ) + ")", item, iid, frameSize ).toString() << '\n';
ino++;
iid++;
}
sOut << " >";
sOut.flush();
}
/**
* @brief CReaperProject::CReaperProject Construct a Reaper RPP "<REAPER_PROJECT>" for a given list of tracks
* @param tracks the list of tracks
*/
CReaperProject::CReaperProject ( QMap<QString, QList<STrackItem>> tracks, int frameSize )
{
QTextStream sOut ( &out );
sOut << "<REAPER_PROJECT 0.1 \"5.0\" 1551567848" << '\n'
<< " RECORD_PATH \"\" \"\"" << '\n'
<< " SAMPLERATE 48000 0 0" << '\n'
<< " TEMPO 120 4 4" << '\n';
qint32 iid = 0;
foreach ( auto trackName, tracks.keys() )
{
sOut << CReaperTrack ( trackName, iid, tracks[trackName], frameSize ).toString() << '\n';
}
sOut << ">";
sOut.flush();
}