ff7tk  1.2.0.13
Work with Final Fantasy 7 game data
PsfFile.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009 - 2022 Arzel Jérôme <myst6re@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #pragma once
5 
6 #include <QtCore>
7 #include <ff7tkutils_export.h>
8 
9 class FF7TKUTILS_EXPORT PsfTags
10 {
11 public:
12  PsfTags();
13  explicit PsfTags(const QString &lib);
14  bool open(const QString &config);
15  QString save() const;
16  PsfTags &setLengthS(quint32 seconds);
17  inline PsfTags &setLib(const QString &lib) {return setCustom(QStringLiteral("_lib"), lib);}
18  inline PsfTags &setAuthor(const QString &author) {return setCustom(QStringLiteral("psfby"), author);}
19  inline PsfTags &setFade(int fade) {return setCustom(QStringLiteral("fade"), fade);}
20  inline PsfTags &setVolume(int volume) {return setCustom(QStringLiteral("volume"), volume);}
21  inline PsfTags &setTitle(const QString &title) {return setCustom(QStringLiteral("title"), title);}
22  inline PsfTags &setArtist(const QString &artist) {return setCustom(QStringLiteral("artist"), artist);}
23  inline PsfTags &setGame(const QString &game) {return setCustom(QStringLiteral("game"), game);}
24  inline PsfTags &setGenre(const QString &genre) {return setCustom(QStringLiteral("genre"), genre);}
25  inline PsfTags &setComment(const QString &comment) {return setCustom(QStringLiteral("comment"), comment);}
26  inline PsfTags &setYear(int year) {return setCustom(QStringLiteral("year"), year);}
27  inline PsfTags &setCopyright(const QString &copyright) {return setCustom(QStringLiteral("copyright"), copyright);}
28  inline PsfTags &setReplayGainTrack(double gain_db, double peak) {return setReplayGain(QStringLiteral("track"), gain_db, peak);}
29  inline PsfTags &setReplayGainAlbum(double gain_db, double peak) {return setReplayGain(QStringLiteral("album"), gain_db, peak);}
30  inline PsfTags &setCustom(const QString &name, int value) {return setCustom(name, QString::number(value));}
31  inline PsfTags &setCustom(const QString &name, const QString &value) {
32  _tags.insert(name, value);
33  return *this;
34  }
35 private:
36  PsfTags &setReplayGain(const QString &type, double gain_db, double peak);
37  QMap<QString, QString> _tags;
38 };
39 
40 class FF7TKUTILS_EXPORT PsfFile
41 {
42 public:
43  PsfFile();
44  PsfFile(const QByteArray &data, const PsfTags &tags);
45  static PsfFile fromAkao(const QByteArray &akaoData, const PsfTags &tags);
46  bool open(const QByteArray &data);
47  QByteArray save() const;
48  inline const QByteArray &data() const {
49  return _data;
50  }
51  inline QByteArray &data() {
52  return _data;
53  }
54  inline const QByteArray &special() const {
55  return _special;
56  }
57  inline const PsfTags &tags() const {
58  return _tags;
59  }
60  inline PsfTags &tags() {
61  return _tags;
62  }
63  QByteArray akao() const;
64 private:
65  QByteArray _special, _data;
66  PsfTags _tags;
67 };
PsfFile::tags
const PsfTags & tags() const
Definition: PsfFile.h:57
PsfTags::setVolume
PsfTags & setVolume(int volume)
Definition: PsfFile.h:20
PsfTags
Definition: PsfFile.h:9
PsfTags::setAuthor
PsfTags & setAuthor(const QString &author)
Definition: PsfFile.h:18
PsfTags::setLib
PsfTags & setLib(const QString &lib)
Definition: PsfFile.h:17
PsfTags::setCopyright
PsfTags & setCopyright(const QString &copyright)
Definition: PsfFile.h:27
PsfFile::data
const QByteArray & data() const
Definition: PsfFile.h:48
PsfTags::setGame
PsfTags & setGame(const QString &game)
Definition: PsfFile.h:23
PsfTags::setCustom
PsfTags & setCustom(const QString &name, int value)
Definition: PsfFile.h:30
PsfTags::setReplayGainAlbum
PsfTags & setReplayGainAlbum(double gain_db, double peak)
Definition: PsfFile.h:29
PsfTags::setGenre
PsfTags & setGenre(const QString &genre)
Definition: PsfFile.h:24
PsfTags::setReplayGainTrack
PsfTags & setReplayGainTrack(double gain_db, double peak)
Definition: PsfFile.h:28
PsfFile::tags
PsfTags & tags()
Definition: PsfFile.h:60
PsfFile::data
QByteArray & data()
Definition: PsfFile.h:51
PsfTags::setFade
PsfTags & setFade(int fade)
Definition: PsfFile.h:19
PsfTags::setCustom
PsfTags & setCustom(const QString &name, const QString &value)
Definition: PsfFile.h:31
PsfTags::setComment
PsfTags & setComment(const QString &comment)
Definition: PsfFile.h:25
PsfTags::setArtist
PsfTags & setArtist(const QString &artist)
Definition: PsfFile.h:22
PsfFile::special
const QByteArray & special() const
Definition: PsfFile.h:54
PsfFile
Definition: PsfFile.h:40
PsfTags::setTitle
PsfTags & setTitle(const QString &title)
Definition: PsfFile.h:21
PsfTags::setYear
PsfTags & setYear(int year)
Definition: PsfFile.h:26