<commit_before># -*- encoding: utf-8 -*-
from supriya.tools import osctools


class CommandManager(object):

    ### PUBLIC METHODS ###

    @staticmethod
    def make_buffer_allocate_message(
        buffer_id=None,
        frame_count=None,
        channel_count=1,
        completion_message=None,
        ):
        r'''Makes a /b_alloc message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_allocate_message(
            ...    buffer_id=23,
            ...    frame_count=512,
            ...    channel_count=2,
            ...    )
            >>> message
            OscMessage(28, 23, 512, 2)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_ALLOCATE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_ALLOCATE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        frame_count = int(frame_count)
        channel_count = int(channel_count)
        contents = [
            command_number,
            buffer_id,
            frame_count,
            channel_count,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            completion_message = bytearray(completion_message.to_datagram())
            contents.append(completion_message)
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_allocate_read_message():
        r'''Makes a /b_allocRead message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_allocate_read_channel_message():
        r'''Makes a /b_allocReadChannel message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_close_message(buffer_id):
        r'''Makes a /b_close message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_close_message(
            ...     buffer_id=23,
            ...     )
            >>> message
            OscMessage(33, 23)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_CLOSE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_CLOSE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        message = osctools.OscMessage(
            command_number,
            buffer_id,
            )
        return message

    @staticmethod
    def make_buffer_fill_message(
        buffer_id=None,
        index_count_value_triples=None,
        ):
        r'''Makes a /b_fill message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_fill_message(
            ...     buffer_id=23,
            ...     index_count_value_triples=(
            ...         (0, 8, 0.1),
            ...         (11, 4, 0.2),
            ...         ),
            ...     )
            >>> message
            OscMessage(37, 23, 0, 8, 0.1, 11, 4, 0.2)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_FILL
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_FILL
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        for index, count, value in index_count_value_triples:
            contents.append(int(index))
            contents.append(int(count))
            contents.append(float(value))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_free_message(
        buffer_id,
        completion_message=None,
        ):
        r'''Makes a /b_free message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_free_message(23)
            >>> message
            OscMessage(32, 23)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_FREE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_FREE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            contents.append(bytearray(completion_message.to_datagram()))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_generate_message():
        r'''Makes a /b_gen message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_get_message(
        buffer_id=None,
        indices=None,
        ):
        r'''Makes a /b_get message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_get_message(
            ...     buffer_id=23,
            ...     indices=(0, 4, 8, 16),
            ...     )
            >>> message
            OscMessage(42, 23, 0, 4, 8, 16)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_GET
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_GET
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if indices:
            for index in indices:
                contents.append(int(index))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_get_contiguous_message(
        buffer_id=None,
        index_count_pairs=None
        ):
        r'''Makes a /b_getn message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_get_contiguous_message(
            ...     buffer_id=23,
            ...     index_count_pairs=[(0, 3), (8, 11)],
            ...     )
            >>> message
            OscMessage(43, 23, 0, 3, 8, 11)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.BUFFER_GET_CONTIGUOUS
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_GET_CONTIGUOUS
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if index_count_pairs:
            for index, count in index_count_pairs:
                contents.append(int(index))
                contents.append(int(count))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_query_message(
        *buffer_ids
        ):
        r'''Makes a /b_query message.

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_query_message(1, 23, 41)
            >>> message
            OscMessage(47, 1, 23, 41)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_QUERY
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_QUERY
        command_number = int(command_number)
        contents = [
            command_number,
            ]
        for buffer_id in buffer_ids:
            contents.append(int(buffer_id))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_read_message():
        r'''Makes a /b_read message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_read_channel_message():
        r'''Makes a /b_readChannel message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_set_message(
        buffer_id=None,
        index_value_pairs=None,
        ):
        r'''Makes a /b_set message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_set_message(
            ...     buffer_id=23,
            ...     index_value_pairs=(
            ...         (0, 1.0),
            ...         (10, 13.2),
            ...         (17, 19.3),
            ...         ),
            ...     )
            >>> message
            OscMessage(35, 23, 0, 1.0, 10, 13.2, 17, 19.3)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_SET
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_SET
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if index_value_pairs:
            for index, value in index_value_pairs:
                contents.append(int(index))
                contents.append(float(value))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_set_contiguous_message(
        buffer_id=None,
        index_values_pairs=None,
        ):
        r'''Makes a /b_setn message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_set_contiguous_message(
            ...     buffer_id=23,
            ...     index_values_pairs=(
            ...         (0, (1, 2, 3)),
            ...         (10, (17.1, 18.2))
            ...         ),
            ...     )
            >>> message
            OscMessage(36, 23, 0, 3, 1.0, 2.0, 3.0, 10, 2, 17.1, 18.2)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.BUFFER_SET_CONTIGUOUS
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_SET_CONTIGUOUS
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if index_values_pairs:
            for index, values in index_values_pairs:
                if not values:
                    continue
                contents.append(int(index))
                contents.append(len(values))
                for value in values:
                    contents.append(float(value))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_write_message(
        buffer_id=None,
        file_path=None,
        header_format='aiff',
        sample_format='int24',
        frame_count=None,
        starting_frame=None,
        leave_open=False,
        completion_message=None,
        ):
        r'''Makes a /b_write message.

        ::

            >>> from supriya.tools import servertools
            >>> from supriya.tools import soundfiletools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_write_message(
            ...     buffer_id=23,
            ...     file_path='test.aiff',
            ...     header_format=soundfiletools.HeaderFormat.AIFF,
            ...     sample_format=soundfiletools.SampleFormat.INT24,
            ...     )
            >>> message
            OscMessage(31, 23, 'test.aiff', 'aiff', 'int24', -1, 0)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_WRITE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        from supriya.tools import soundfiletools
        command_number = servertools.CommandNumber.BUFFER_WRITE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        file_path = str(file_path)
        header_format = soundfiletools.HeaderFormat.from_expr(header_format)
        header_format = header_format.name.lower()
        sample_format = soundfiletools.SampleFormat.from_expr(sample_format)
        sample_format = sample_format.name.lower()
        if frame_count is None:
            frame_count = -1
        frame_count = int(frame_count)
        assert -1 <= frame_count
        if starting_frame is None:
            starting_frame = 0
        starting_frame = int(starting_frame)
        assert 0 <= starting_frame
        leave_open = int(bool(leave_open))
        contents = [
            command_number,
            buffer_id,
            file_path,
            header_format,
            sample_format,
            frame_count,
            leave_open,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            contents.append(bytearray(completion_message.to_datagram()))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_zero_message(
        buffer_id=None,
        completion_message=None,
        ):
        r'''Makes a /b_zero message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_zero_message(23)
            >>> message
            OscMessage(34, 23)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_ZERO
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_ZERO
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            contents.append(bytearray(completion_message.to_datagram()))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_dump_osc_message(osc_status):
        r'''Makes a /dumpOSC message.

        ::

            >>> from supriya.tools import servertools<commit_msg>Implemented control bus message API in CommandManager.<commit_after># -*- encoding: utf-8 -*-
from supriya.tools import osctools


class CommandManager(object):

    ### PUBLIC METHODS ###

    @staticmethod
    def make_buffer_allocate_message(
        buffer_id=None,
        frame_count=None,
        channel_count=1,
        completion_message=None,
        ):
        r'''Makes a /b_alloc message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_allocate_message(
            ...    buffer_id=23,
            ...    frame_count=512,
            ...    channel_count=2,
            ...    )
            >>> message
            OscMessage(28, 23, 512, 2)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_ALLOCATE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_ALLOCATE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        frame_count = int(frame_count)
        channel_count = int(channel_count)
        contents = [
            command_number,
            buffer_id,
            frame_count,
            channel_count,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            completion_message = bytearray(completion_message.to_datagram())
            contents.append(completion_message)
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_allocate_read_message():
        r'''Makes a /b_allocRead message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_allocate_read_channel_message():
        r'''Makes a /b_allocReadChannel message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_close_message(buffer_id):
        r'''Makes a /b_close message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_close_message(
            ...     buffer_id=23,
            ...     )
            >>> message
            OscMessage(33, 23)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_CLOSE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_CLOSE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        message = osctools.OscMessage(
            command_number,
            buffer_id,
            )
        return message

    @staticmethod
    def make_buffer_fill_message(
        buffer_id=None,
        index_count_value_triples=None,
        ):
        r'''Makes a /b_fill message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_fill_message(
            ...     buffer_id=23,
            ...     index_count_value_triples=(
            ...         (0, 8, 0.1),
            ...         (11, 4, 0.2),
            ...         ),
            ...     )
            >>> message
            OscMessage(37, 23, 0, 8, 0.1, 11, 4, 0.2)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_FILL
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_FILL
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        for index, count, value in index_count_value_triples:
            contents.append(int(index))
            contents.append(int(count))
            contents.append(float(value))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_free_message(
        buffer_id,
        completion_message=None,
        ):
        r'''Makes a /b_free message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_free_message(23)
            >>> message
            OscMessage(32, 23)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_FREE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_FREE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            contents.append(bytearray(completion_message.to_datagram()))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_generate_message():
        r'''Makes a /b_gen message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_get_message(
        buffer_id=None,
        indices=None,
        ):
        r'''Makes a /b_get message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_get_message(
            ...     buffer_id=23,
            ...     indices=(0, 4, 8, 16),
            ...     )
            >>> message
            OscMessage(42, 23, 0, 4, 8, 16)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_GET
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_GET
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if indices:
            for index in indices:
                contents.append(int(index))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_get_contiguous_message(
        buffer_id=None,
        index_count_pairs=None
        ):
        r'''Makes a /b_getn message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_get_contiguous_message(
            ...     buffer_id=23,
            ...     index_count_pairs=[(0, 3), (8, 11)],
            ...     )
            >>> message
            OscMessage(43, 23, 0, 3, 8, 11)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.BUFFER_GET_CONTIGUOUS
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_GET_CONTIGUOUS
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if index_count_pairs:
            for index, count in index_count_pairs:
                contents.append(int(index))
                contents.append(int(count))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_query_message(
        *buffer_ids
        ):
        r'''Makes a /b_query message.

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_query_message(1, 23, 41)
            >>> message
            OscMessage(47, 1, 23, 41)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_QUERY
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_QUERY
        command_number = int(command_number)
        contents = [
            command_number,
            ]
        for buffer_id in buffer_ids:
            contents.append(int(buffer_id))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_read_message():
        r'''Makes a /b_read message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_read_channel_message():
        r'''Makes a /b_readChannel message.

        Returns OSC message.
        '''
        raise NotImplementedError

    @staticmethod
    def make_buffer_set_message(
        buffer_id=None,
        index_value_pairs=None,
        ):
        r'''Makes a /b_set message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_set_message(
            ...     buffer_id=23,
            ...     index_value_pairs=(
            ...         (0, 1.0),
            ...         (10, 13.2),
            ...         (17, 19.3),
            ...         ),
            ...     )
            >>> message
            OscMessage(35, 23, 0, 1.0, 10, 13.2, 17, 19.3)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_SET
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_SET
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if index_value_pairs:
            for index, value in index_value_pairs:
                contents.append(int(index))
                contents.append(float(value))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_set_contiguous_message(
        buffer_id=None,
        index_values_pairs=None,
        ):
        r'''Makes a /b_setn message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_set_contiguous_message(
            ...     buffer_id=23,
            ...     index_values_pairs=(
            ...         (0, (1, 2, 3)),
            ...         (10, (17.1, 18.2))
            ...         ),
            ...     )
            >>> message
            OscMessage(36, 23, 0, 3, 1.0, 2.0, 3.0, 10, 2, 17.1, 18.2)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.BUFFER_SET_CONTIGUOUS
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_SET_CONTIGUOUS
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if index_values_pairs:
            for index, values in index_values_pairs:
                if not values:
                    continue
                contents.append(int(index))
                contents.append(len(values))
                for value in values:
                    contents.append(float(value))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_write_message(
        buffer_id=None,
        file_path=None,
        header_format='aiff',
        sample_format='int24',
        frame_count=None,
        starting_frame=None,
        leave_open=False,
        completion_message=None,
        ):
        r'''Makes a /b_write message.

        ::

            >>> from supriya.tools import servertools
            >>> from supriya.tools import soundfiletools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_write_message(
            ...     buffer_id=23,
            ...     file_path='test.aiff',
            ...     header_format=soundfiletools.HeaderFormat.AIFF,
            ...     sample_format=soundfiletools.SampleFormat.INT24,
            ...     )
            >>> message
            OscMessage(31, 23, 'test.aiff', 'aiff', 'int24', -1, 0)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_WRITE
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        from supriya.tools import soundfiletools
        command_number = servertools.CommandNumber.BUFFER_WRITE
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        file_path = str(file_path)
        header_format = soundfiletools.HeaderFormat.from_expr(header_format)
        header_format = header_format.name.lower()
        sample_format = soundfiletools.SampleFormat.from_expr(sample_format)
        sample_format = sample_format.name.lower()
        if frame_count is None:
            frame_count = -1
        frame_count = int(frame_count)
        assert -1 <= frame_count
        if starting_frame is None:
            starting_frame = 0
        starting_frame = int(starting_frame)
        assert 0 <= starting_frame
        leave_open = int(bool(leave_open))
        contents = [
            command_number,
            buffer_id,
            file_path,
            header_format,
            sample_format,
            frame_count,
            leave_open,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            contents.append(bytearray(completion_message.to_datagram()))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_buffer_zero_message(
        buffer_id=None,
        completion_message=None,
        ):
        r'''Makes a /b_zero message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_buffer_zero_message(23)
            >>> message
            OscMessage(34, 23)

        ::

            >>> message.address == servertools.CommandNumber.BUFFER_ZERO
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.BUFFER_ZERO
        command_number = int(command_number)
        buffer_id = int(buffer_id)
        contents = [
            command_number,
            buffer_id,
            ]
        if completion_message is not None:
            prototype = (osctools.OscBundle, osctools.OscMessage)
            assert isinstance(completion_message, prototype)
            contents.append(bytearray(completion_message.to_datagram()))
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_control_bus_fill_message(
        index_count_value_triples=None,
        ):
        r'''Makes a /c_fill message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_control_bus_fill_message(
            ...     index_count_value_triples=[
            ...         (0, 8, 0.5),
            ...         (8, 8, 0.25),
            ...         ],
            ...     )
            >>> message
            OscMessage(27, 0, 8, 0.5, 8, 8, 0.25)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.CONTROL_BUS_FILL
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.CONTROL_BUS_FILL
        command_number = int(command_number)
        contents = [command_number]
        if index_count_value_triples:
            for index, count, value in index_count_value_triples:
                index = int(index)
                count = int(count)
                value = float(value)
                assert 0 <= index
                assert 0 < count
                contents.append(index)
                contents.append(count)
                contents.append(value)
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_control_bus_get_message(
        bus_indices=None,
        ):
        r'''Makes a /c_get message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_control_bus_get_message(
            ...     bus_indices=(0, 4, 8, 12),
            ...     )
            >>> message
            OscMessage(40, 0, 4, 8, 12)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.CONTROL_BUS_GET
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.CONTROL_BUS_GET
        command_number = int(command_number)
        contents = [command_number]
        if bus_indices:
            for bus_index in bus_indices:
                bus_index = int(bus_index)
                assert 0 <= bus_index
                contents.append(bus_index)
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_control_bus_get_contiguous_message(
        index_count_pairs=None,
        ):
        r'''Makes a /c_getn message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_control_bus_get_contiguous_message(
            ...     index_count_pairs=[
            ...         (0, 2),
            ...         (4, 2),
            ...         (8, 2),
            ...         (12, 2),
            ...         ],
            ...     )
            >>> message
            OscMessage(41, 0, 2, 4, 2, 8, 2, 12, 2)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.CONTROL_BUS_GET_CONTIGUOUS
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.CONTROL_BUS_GET_CONTIGUOUS
        command_number = int(command_number)
        contents = [command_number]
        if index_count_pairs:
            for index, count in index_count_pairs:
                index = int(index)
                count = int(count)
                contents.append(index)
                contents.append(count)
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_control_bus_set_message(
        index_value_pairs=None,
        ):
        r'''Makes a /c_set message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_control_bus_set_message(
            ...     index_value_pairs=[
            ...         (0, 0.1),
            ...         (1, 0.2),
            ...         (1, 0.3),
            ...         (1, 0.4),
            ...         ],
            ...     )
            >>> message
            OscMessage(25, 0, 0.1, 1, 0.2, 1, 0.3, 1, 0.4)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.CONTROL_BUS_SET
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.CONTROL_BUS_SET
        command_number = int(command_number)
        contents = [command_number]
        if index_value_pairs:
            for index, value in index_value_pairs:
                index = int(index)
                assert 0 <= index
                value = float(value)
                contents.append(index)
                contents.append(value)
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_control_bus_set_contiguous_message(
        index_values_pairs=None,
        ):
        r'''Makes a /c_setn message.

        ::

            >>> from supriya.tools import servertools
            >>> manager = servertools.CommandManager
            >>> message = manager.make_control_bus_set_contiguous_message(
            ...     index_values_pairs=[
            ...         (0, (0.1, 0.2, 0.3)),
            ...         (4, (0.4, 0.5, 0.6)),
            ...         ],
            ...     )
            >>> message
            OscMessage(26, 0, 3, 0.1, 0.2, 0.3, 4, 3, 0.4, 0.5, 0.6)

        ::

            >>> message.address == \
            ...     servertools.CommandNumber.CONTROL_BUS_SET_CONTIGUOUS
            True

        Returns OSC message.
        '''
        from supriya.tools import servertools
        command_number = servertools.CommandNumber.CONTROL_BUS_SET_CONTIGUOUS
        command_number = int(command_number)
        contents = [command_number]
        if index_values_pairs:
            for index, values in index_values_pairs:
                index = int(index)
                assert 0 <= index
                count = len(values)
                if not count:
                    continue
                contents.append(index)
                contents.append(count)
                for value in values:
                    value = float(value)
                    contents.append(value)
        message = osctools.OscMessage(*contents)
        return message

    @staticmethod
    def make_dump_osc_message(osc_status):
        r'''Makes a /dumpOSC message.

        ::

            >>> from supriya.tools import servertools
{'fraction_non_alphanumeric': 0.0897212543554007, 'fraction_numerical': 0.01290782388343364, 'mean_word_length': 1.5920224411603723, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 420, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '664138', 'n_tokens_mistral': 10571, 'n_tokens_neox': 9920, 'n_words': 1958}