Пример #1
0
def  testSendNormalAndCMIXMessages()  -> None:
    """
    Test with Python OSC server.

    NB  REQUIRES QUALIFIED REFERENCE to (mosRTcmix.)cmixBuildEnablesOSC in MOSRTcmix.send().
        This is different than when send is used by scripts outside this module.
    """

    global cmixBuildEnablesOSC 

    #
    client = MOSRTcmix()
    client.createClient(port=cmixPort)

    cmixBuildEnablesOSC = False

    #
    print()
    testSendNormalOSCMessagesToScoreEnabledWithOSCData(client)
    time.sleep(1)

    print()
    testSendCMIXOSCMessagesToScoreEnabledWithOSCData(client)

    print()
    z.postAndExit("DONE.")
Пример #2
0
    def _validateHostnameAndPort(self,
                                 hostname: str = None,
                                 port: int = None,
                                 exitValue: int = 1) -> None:

        if not hostname: hostname = self._hostnameDefault
        if not port: port = self._portDefault

        #
        if not isinstance(hostname, str) or not isinstance(port, int):
            z.postDefUsage(log.className(), USAGE)
            return

        if (len(hostname) <= 0):
            z.postAndExit("%s(): hostname is EMPTY." % log.className(),
                          exitValue=exitValue)
            return

        if port < 1024:
            z.postAndExit("%s(): port MUST BE GREATER than 1024. (%s)" %
                          (log.className(), port),
                          exitValue=exitValue)
            return

        #
        self.hostname = hostname
        self.port = port
Пример #3
0
def testScaleSequencer():
    """
    Eyeball test.
    """
    log.mark()

    # kwargs for generateScaleSequence().
    #
    d: dict = {
        #"key"               : Key.C,                        #DEFAULT
        #"key"               : Key.D,
        #"key"               : Key.Gs,

        #"octave"            : MIDINote.C4,                  #DEFAULT
        "octave": MIDINote.C2,

        #"scaleForMode"      : ModeNames.ionian,             #DEFAULT
        "mode": ModeNames.locrian,

        #"octaveRange"       : 2,                            #DEFAULT
        "octaveRange": 3,

        #"direction"         : Direction.UP,                 #DEFAULT
        #"direction"         : Direction.DOWN,
        #"direction"         : Direction.DOWNUP,
        #"direction"         : Direction.UPDOWN,

        #"scaleEndBoundByRoot"  : True,                      #DEFAULT
        #"scaleEndBoundByRoot"  : False,
    }

    index = generateScaleSequence(**d)

    #
    log.info("Type any key.  'q' to quit.")

    while True:
        if z.readOneCharacter() == 'q': break
        nextNote: int = next(index)
        print(f"  {nextNote}", end="", flush=True)

    #
    print("\n\nDONE.", end="\n\r", flush=True)
    z.postAndExit("")
Пример #4
0
def testOrnaments():
    """
    Eyeball test.
    """
    log.mark()

    rval: list = []

    rval = _translateOrnamentScaleToMIDI("sixteenthLeadIn", 60, Key.C,
                                         ModeNames.ionian)
    log.info(f"01:  {rval}")
    rval = _translateOrnamentScaleToMIDI("sixteenthLeadIn", 69, Key.C,
                                         ModeNames.ionian)
    log.info(f"02:  {rval}")

    #_translateOrnamentScaleToMIDI("sixteenthLeadIn", 63, Key.C, ModeNames.ionianX)         #FAIL (system).
    #_translateOrnamentScaleToMIDI("sixteenthLeadIn", -1, Key.C, ModeNames.pentatonic)       #FAIL
    #_translateOrnamentScaleToMIDI("sixteenthLeadIn", 110, Key.C, ModeNames.pentatonic)       #FAIL

    rval = _translateOrnamentScaleToMIDI("sixteenthLeadIn", 66, Key.C,
                                         ModeNames.pentatonic)
    log.info(f"03:  {rval}")

    rval = _translateOrnamentScaleToMIDI("sixteenthTripletTurnaround", 52,
                                         Key.E, ModeNames.phrygian)
    log.info(f"04:  {rval}")
    rval = _translateOrnamentScaleToMIDI("sixteenthTripletTurnaround", 59,
                                         Key.E, ModeNames.phrygian)
    log.info(f"05:  {rval}")
    rval = _translateOrnamentScaleToMIDI("sixteenthTripletTurnaround", 67,
                                         Key.C, ModeNames.ionian)
    log.info(f"06:  {rval}")

    rval = _translateOrnamentScaleToMIDI("sixteenthPop", 60, Key.C,
                                         ModeNames.mixolydian)
    log.info(f"07:  {rval}")
    rval = _translateOrnamentScaleToMIDI("sixteenthPop", 64, Key.C,
                                         ModeNames.mixolydian)
    log.info(f"08:  {rval}")

    print()
    z.postAndExit("DONE.")
Пример #5
0
def testIvoryModesViaOSC() -> None:
    """
    Demonstrate sending ivory modes via OSC.
    Optionally, use RTcmix score MOSOSC-with-RTcmix/soundsAndSequences.sco to hear them.
    """
    log.mark()

    test1: bool = False
    test2: bool = True

    client = mosOSC.MOSOSC()
    client.createClient()

    # Send frequencies.
    #
    if test1:
        for r in range(200, 400, 25):
            client.messageSend("/lowSequence", [r])
            time.sleep(1)

    # Send MIDI.  Traverse all modes on ivory keys only.
    #
    if test2:
        ivoryKeys: list = ModesAdditional[ModeNames.major].copy()
        root: int = 60

        for name in Modes.keys():
            midiRoot = root + ivoryKeys.pop(0)
            log.info(name)

            scale: list = Modes[name].copy()
            scale.append(scale[0] + NOTES_PER_OCTAVE)

            for note in scale:
                client.messageSend("/lowSequence", [midiRoot + note])
                time.sleep(0.5)

            time.sleep(1)

    #
    print()
    z.postAndExit("DONE.")