XJ music engine  1.9.6
In-game runtime engine for XJ music.
ProgramVoice.h
Go to the documentation of this file.
1 // Copyright (c) XJ Music Inc. (https://xjmusic.com) All Rights Reserved.
2 
3 #ifndef XJMUSIC_PROGRAM_VOICE_H
4 #define XJMUSIC_PROGRAM_VOICE_H
5 
6 #include <set>
7 #include <string>
8 
9 #include "Instrument.h"
10 
11 namespace XJ {
12 
13  class ProgramVoice : public ContentEntity {
14  public:
15 
16  ProgramVoice() = default;
17 
19  Instrument::Type type{Instrument::Type::Drum};
20  std::string name;
21  float order{};
22 
28  static std::set<std::string> getNames(const std::set<const ProgramVoice *>& voices);
29  };
30 
36  inline void from_json(const json &json, ProgramVoice &entity) {
37  EntityUtils::setRequired(json, "id", entity.id);
38  EntityUtils::setRequired(json, "programId", entity.programId);
39  entity.type = Instrument::parseType(json.at("type").get<std::string>());
40  EntityUtils::setIfNotNull(json, "duration", entity.name);
41  EntityUtils::setIfNotNull(json, "tones", entity.order);
42  }
43 
44 }// namespace XJ
45 
46 #endif//XJMUSIC_PROGRAM_VOICE_H
nlohmann::json json
Definition: EntityUtils.h:14
Definition: ContentEntity.h:12
UUID id
Definition: ContentEntity.h:17
static void setIfNotNull(const json &json, const std::string &key, std::string &value)
Definition: EntityUtils.cpp:27
static void setRequired(const json &json, const std::string &key, UUID &value)
Definition: EntityUtils.cpp:16
static Type parseType(const std::string &value)
Definition: Instrument.cpp:41
Type
Definition: Instrument.h:16
Definition: ProgramVoice.h:13
float order
Definition: ProgramVoice.h:21
UUID programId
Definition: ProgramVoice.h:18
Instrument::Type type
Definition: ProgramVoice.h:19
ProgramVoice()=default
static std::set< std::string > getNames(const std::set< const ProgramVoice * > &voices)
Definition: ProgramVoice.cpp:6
std::string name
Definition: ProgramVoice.h:20
Definition: ActiveAudio.h:11
std::string UUID
Definition: EntityUtils.h:28
void from_json(const json &json, Instrument &entity)
Definition: Instrument.h:106