Example #1
0
    def convert(sm: SMMapSet, assertKeys=True) -> List[QuaMap]:
        """ Converts a SMMapset to possibly multiple quaver maps

        Note that a mapset contains maps, so a list would be expected.
        SMMap conversion is not possible due to lack of SMMapset Metadata

        :param sm:
        :param assertKeys: Adds an assertion to verify that Quaver can support this key mode
        :return:
        """
        quaMapSet: List[QuaMap] = []
        for smMap in sm.maps:
            assert isinstance(smMap, SMMap)
            if assertKeys:                assert QuaMapMode.getMode(int(SMMapChartTypes.getKeys(smMap.chartType))) != "",\
     f"Current Chart Type, Keys:{int(SMMapChartTypes.getKeys(smMap.chartType))} is not supported"

            hits: List[QuaHit] = []
            holds: List[QuaHold] = []

            # Note Conversion
            for hit in smMap.notes.hits():
                hits.append(QuaHit(offset=hit.offset, column=hit.column))
            for hold in smMap.notes.holds():
                holds.append(
                    QuaHold(offset=hold.offset,
                            column=hold.column,
                            _length=hold.length))

            bpms: List[Bpm] = []

            # Timing Point Conversion
            for bpm in smMap.bpms:
                bpms.append(QuaBpm(offset=bpm.offset, bpm=bpm.bpm))

            # Extract Metadata
            quaMap = QuaMap(
                backgroundFile=sm.background,
                title=sm.title,
                artist=sm.artist,
                mode=QuaMapMode.getMode(
                    int(SMMapChartTypes.getKeys(smMap.chartType))),
                audioFile=sm.music,
                creator=sm.credit,
                difficultyName=f"{smMap.difficulty} {smMap.difficultyVal}",
                songPreviewTime=int(sm.sampleStart),
                bpms=QuaBpmList(bpms),
                notes=QuaNotePkg(hits=QuaHitList(hits),
                                 holds=QuaHoldList(holds)))
            quaMapSet.append(quaMap)
        return quaMapSet
Example #2
0
    def convert(o2j: O2JMapSet) -> List[QuaMap]:
        """ Converts a Mapset to multiple Quaver maps

        Note that a mapset contains maps, so a list would be expected.
        O2JMap conversion is not possible due to lack of O2JMapset Metadata

        :param o2j:
        :return:
        """
        quaMapSet: List[QuaMap] = []
        for o2jMap in o2j.maps:
            assert isinstance(o2jMap, O2JMap)
            hits: List[QuaHit] = []
            holds: List[QuaHold] = []

            # Note Conversion
            for hit in o2jMap.notes.hits():
                hits.append(QuaHit(offset=hit.offset, column=hit.column))
            for hold in o2jMap.notes.holds():
                holds.append(
                    QuaHold(offset=hold.offset,
                            column=hold.column,
                            _length=hold.length))

            bpms: List[Bpm] = []

            # Timing Point Conversion
            for bpm in o2jMap.bpms:
                bpms.append(QuaBpm(offset=bpm.offset, bpm=bpm.bpm))

            # Extract Metadata
            quaMap = QuaMap(
                title=o2j.title,
                artist=o2j.artist,
                creator=o2j.creator,
                mode=QuaMapMode.KEYS_7,
                difficultyName=f"Level {o2j.level[o2j.maps.index(o2jMap)]}",
                bpms=QuaBpmList(bpms),
                notes=QuaNotePkg(hits=QuaHitList(hits),
                                 holds=QuaHoldList(holds)))
            quaMapSet.append(quaMap)
        return quaMapSet
Example #3
0
    def convert(bms: BMSMap, assertKeys=True) -> QuaMap:
        """ Converts a BMS to a Qua Map

        :param bms:
        :param assertKeys: Adds an assertion to verify that Quaver can support this key mode
        :return:
        """

        if assertKeys:            assert QuaMapMode.getMode(int(bms.notes.maxColumn() + 1)) != "",\
 f"Current Keys {bms.notes.maxColumn() + 1} is not supported"

        hits: List[QuaHit] = []
        holds: List[QuaHold] = []

        for hit in bms.notes.hits():
            hits.append(QuaHit(offset=hit.offset, column=hit.column))
        for hold in bms.notes.holds():
            holds.append(
                QuaHold(offset=hold.offset,
                        column=hold.column,
                        _length=hold.length))

        bpms: List[Bpm] = []

        for bpm in bms.bpms:
            bpms.append(QuaBpm(offset=bpm.offset, bpm=bpm.bpm))

        qua: QuaMap = QuaMap(title=str(bms.title, 'ascii', errors='ignore'),
                             mode=QuaMapMode.getMode(
                                 int(bms.notes.maxColumn() + 1)),
                             artist=str(bms.artist, 'ascii', errors='ignore'),
                             notes=QuaNotePkg(hits=QuaHitList(hits),
                                              holds=QuaHoldList(holds)),
                             bpms=QuaBpmList(bpms))

        return qua
Example #4
0
    def test(self):
        # Complex BPM Points
        qua = QuaMap.readFile(QUA_NEURO_CLOUD)

        osu = QuaToOsu.convert(qua)
Example #5
0
    def test(self):
        # Complex BPM Points
        qua = QuaMap.readFile(QUA_CARRY_ME_AWAY)

        bms = QuaToBMS.convert(qua, moveRightBy=1)
        bms.writeFile('out.bme', BMSChannel.BME)
Example #6
0
 def test_qua(self):
     m = QuaMap.readFile(QUA_NEURO_CLOUD)
     m.describe()
Example #7
0
 def test_qua(self):
     m = QuaMap.readFile(QUA_NEURO_CLOUD)
     offset = m.notes.offsets(flatten=True)[:10]
     m.rate(2.0, inplace=True)
     for i, j in zip(offset, m.notes.offsets(flatten=True)[:10]):
         self.assertAlmostEqual(i / 2, j)