@@ -446,33 +446,38 @@ void modernize_(Patch& patch)
446446
447447 for (Patch::Channel& c : patch.channels )
448448 {
449- const bool isInternalChannel = c.type == ChannelType::PREVIEW || c.type == ChannelType::MASTER;
449+ /* 1.1.0
450+ Let's put non-group channels into the relevant tracks. */
451+ if (patch.version < Version{1 , 1 , 0 } && c.type != ChannelType::GROUP)
452+ {
453+ const bool isInternalChannel = c.type == ChannelType::PREVIEW || c.type == ChannelType::MASTER;
454+ const std::size_t targetIndex = isInternalChannel ? 0 : 1 ;
455+ patch.tracks [targetIndex].channels .push_back (c.id );
456+ }
457+ }
458+ }
459+
460+ /* -------------------------------------------------------------------------- */
450461
451- /* 0.16.3
452- Make sure that ChannelType is correct: ID 1, 2 are MASTER channels, ID 3
462+ void sanitize_ (Patch& patch)
463+ {
464+ for (Patch::Channel& c : patch.channels )
465+ {
466+ /* Make sure that ChannelType is correct: ID 1, 2 are MASTER channels, ID 3
453467 is PREVIEW channel. */
454468 if (c.id == MASTER_OUT_CHANNEL_ID || c.id == MASTER_IN_CHANNEL_ID)
455469 c.type = ChannelType::MASTER;
456470 else if (c.id == PREVIEW_CHANNEL_ID)
457471 c.type = ChannelType::PREVIEW;
458472
459- /* 0.16.4
460- Make sure internal channels are never armed. */
473+ /* Make sure internal channels are never armed. */
474+ const bool isInternalChannel = c. type == ChannelType::PREVIEW || c. type == ChannelType::MASTER;
461475 if (isInternalChannel)
462476 c.armed = false ;
463477
464- /* 0.16.3
465- Set waveId to 0 for non-Sample Channels. */
478+ /* Set waveId to 0 for non-Sample Channels. */
466479 if (c.type != ChannelType::SAMPLE)
467480 c.waveId = 0 ;
468-
469- /* 1.1.0
470- Let's put non-group channels into the relevant tracks. */
471- if (patch.version < Version{1 , 1 , 0 } && c.type != ChannelType::GROUP)
472- {
473- const std::size_t targetIndex = isInternalChannel ? 0 : 1 ;
474- patch.tracks [targetIndex].channels .push_back (c.id );
475- }
476481 }
477482}
478483} // namespace
@@ -540,6 +545,7 @@ Patch deserialize(const std::string& filePath)
540545 readActions_ (patch, j);
541546 readChannels_ (patch, j);
542547 modernize_ (patch);
548+ sanitize_ (patch);
543549 }
544550 catch (nlohmann::json::exception& e)
545551 {
0 commit comments