<commit_before>package org.deviceconnect.android.deviceplugin.midi.profiles;

import android.content.Intent;
import android.media.midi.MidiDevice;
import android.media.midi.MidiInputPort;

import org.deviceconnect.android.deviceplugin.midi.MidiMessageSender;
import org.deviceconnect.android.deviceplugin.midi.NoteNameTable;
import org.deviceconnect.android.deviceplugin.midi.core.MidiMessage;
import org.deviceconnect.android.deviceplugin.midi.core.NoteOnMessage;
import org.deviceconnect.android.message.MessageUtils;
import org.deviceconnect.android.profile.api.DeleteApi;
import org.deviceconnect.android.profile.api.PostApi;
import org.deviceconnect.message.DConnectMessage;

import java.io.IOException;

public class MidiSoundModuleProfile extends BaseMidiProfile {

    private final MidiMessageSender mMessageSender;

    public MidiSoundModuleProfile(final MidiMessageSender messageSender) {
        mMessageSender = messageSender;

        // POST /gotapi/soundModule/note
        addApi(new PostApi() {
            @Override
            public String getAttribute() {
                return "note";
            }

            @Override
            public boolean onRequest(final Intent request, final Intent response) {
                String note = request.getStringExtra("note");
                Integer channel = parseInteger(request, "channel");

                Integer noteNumber = NoteNameTable.nameToNumber(note);
                if (noteNumber == null) {
                    MessageUtils.setInvalidRequestParameterError(response,
                            note + " is not supported as note name");
                    return true;
                }

                NoteOnMessage message = new NoteOnMessage.Builder()
                        .setChannelNumber(channel != null ? channel : 0)
                        .setNoteNumber(noteNumber)
                        .build();
                try {
                    mMessageSender.send(message);
                    setResult(response, DConnectMessage.RESULT_OK);
                } catch (IOException e) {
                    MessageUtils.setUnknownError(response, "Failed to send MIDI message: " + e.getMessage());
                }
                return true;
            }
        });

        // DELETE /gotapi/soundModule/note
        addApi(new DeleteApi() {
            @Override
            public String getAttribute() {
                return "note";
            }

            @Override
            public boolean onRequest(final Intent request, final Intent response) {
                String serviceId = (String) request.getExtras().get("serviceId");
                String note = (String) request.getExtras().get("note");
                Integer channel = parseInteger(request, "channel");

                // TODO ここでAPIを実装してください. 以下はサンプルのレスポンス作成処理です.
                setResult(response, DConnectMessage.RESULT_OK);
                return true;
            }
        });

    }

    @Override
    public String getProfileName() {
        return "soundModule";
    }
}<commit_msg>MIDI プラグインに DELETE /gotapi/soundModule/note を実装。<commit_after>package org.deviceconnect.android.deviceplugin.midi.profiles;

import android.content.Intent;
import android.media.midi.MidiDevice;
import android.media.midi.MidiInputPort;

import org.deviceconnect.android.deviceplugin.midi.MidiMessageSender;
import org.deviceconnect.android.deviceplugin.midi.NoteNameTable;
import org.deviceconnect.android.deviceplugin.midi.core.MidiMessage;
import org.deviceconnect.android.deviceplugin.midi.core.NoteOffMessage;
import org.deviceconnect.android.deviceplugin.midi.core.NoteOnMessage;
import org.deviceconnect.android.message.MessageUtils;
import org.deviceconnect.android.profile.api.DeleteApi;
import org.deviceconnect.android.profile.api.PostApi;
import org.deviceconnect.message.DConnectMessage;

import java.io.IOException;

public class MidiSoundModuleProfile extends BaseMidiProfile {

    private final MidiMessageSender mMessageSender;

    public MidiSoundModuleProfile(final MidiMessageSender messageSender) {
        mMessageSender = messageSender;

        // POST /gotapi/soundModule/note
        addApi(new PostApi() {
            @Override
            public String getAttribute() {
                return "note";
            }

            @Override
            public boolean onRequest(final Intent request, final Intent response) {
                String note = request.getStringExtra("note");
                Integer channel = parseInteger(request, "channel");

                Integer noteNumber = NoteNameTable.nameToNumber(note);
                if (noteNumber == null) {
                    MessageUtils.setInvalidRequestParameterError(response,
                            note + " is not supported as note name");
                    return true;
                }

                NoteOnMessage message = new NoteOnMessage.Builder()
                        .setChannelNumber(channel != null ? channel : 0)
                        .setNoteNumber(noteNumber)
                        .build();
                try {
                    mMessageSender.send(message);
                    setResult(response, DConnectMessage.RESULT_OK);
                } catch (IOException e) {
                    MessageUtils.setUnknownError(response, "Failed to send MIDI message: " + e.getMessage());
                }
                return true;
            }
        });

        // DELETE /gotapi/soundModule/note
        addApi(new DeleteApi() {
            @Override
            public String getAttribute() {
                return "note";
            }

            @Override
            public boolean onRequest(final Intent request, final Intent response) {
                String note = request.getStringExtra("note");
                Integer channel = parseInteger(request, "channel");

                Integer noteNumber = NoteNameTable.nameToNumber(note);
                if (noteNumber == null) {
                    MessageUtils.setInvalidRequestParameterError(response,
                            note + " is not supported as note name");
                    return true;
                }

                NoteOffMessage message = new NoteOffMessage.Builder()
                        .setChannelNumber(channel != null ? channel : 0)
                        .setNoteNumber(noteNumber)
                        .build();
                try {
                    mMessageSender.send(message);
                    setResult(response, DConnectMessage.RESULT_OK);
                } catch (IOException e) {
                    MessageUtils.setUnknownError(response, "Failed to send MIDI message: " + e.getMessage());
                }
                return true;
            }
        });

    }

    @Override
    public String getProfileName() {
        return "soundModule";
    }
}
{'fraction_non_alphanumeric': 0.0829090909090909, 'fraction_numerical': 0.00043636363636363637, 'mean_word_length': 1.9197452229299363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3027538', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1623, 'n_words': 342}