<commit_before>#include <portmidi.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#define MAXBUFLEN 1024

typedef enum {INPUT, OUTPUT} DeviceType;
PmError findDevice(PmStream *stream, char *deviceName, DeviceType type);
const PmDeviceInfo ** listDevices(int);

PmError findDevice(PmStream *stream, char *deviceName, DeviceType type) {
  PmError result = pmInvalidDeviceId;
  const PmDeviceInfo *deviceInfo;


  int i = 0;
  while((deviceInfo = Pm_GetDeviceInfo(i)) != NULL) {
    int nameCompare = strcmp(deviceInfo->name, deviceName);

    if(nameCompare == 0 ) {
      if(type == INPUT && deviceInfo->input == 1) {
        result = Pm_OpenInput(stream, i, NULL, 0, NULL, NULL);
        break;
      }
      if(type == OUTPUT && deviceInfo->output == 1) {
        result = Pm_OpenOutput(stream, i, NULL, 0, NULL, NULL, 0);
        break;
      }
    }

    i++;
  }

  return result;
}

const PmDeviceInfo ** listDevices(int numOfDevices) {
  int i = 0;
  static const PmDeviceInfo * devices[MAXBUFLEN];

  for(i = 0; i < numOfDevices; i++) { devices[i] = Pm_GetDeviceInfo(i); }
  return devices;
}<commit_msg>add debug function to portmid_shared.c<commit_after>#include <portmidi.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#define MAXBUFLEN 1024

typedef enum {INPUT, OUTPUT} DeviceType;
PmError findDevice(PortMidiStream **stream, char *deviceName, DeviceType type);
const PmDeviceInfo ** listDevices(int);
void debug(char *str);

PmError findDevice(PortMidiStream **stream, char *deviceName, DeviceType type) {
  PmError result = pmInvalidDeviceId;
  const PmDeviceInfo *deviceInfo;

  int i = 0;
  while((deviceInfo = Pm_GetDeviceInfo(i)) != NULL) {
    int nameCompare = strcmp(deviceInfo->name, deviceName);

    if(nameCompare == 0 ) {
      if(type == INPUT && deviceInfo->input == 1) {
        result = Pm_OpenInput(stream, i, NULL, 0, NULL, NULL);
        break;
      }
      if(type == OUTPUT && deviceInfo->output == 1) {
        result = Pm_OpenOutput(stream, i, NULL, 0, NULL, NULL, 0);
        break;
      }
    }

    i++;
  }

  return result;
}

const PmDeviceInfo ** listDevices(int numOfDevices) {
  int i = 0;
  static const PmDeviceInfo * devices[MAXBUFLEN];

  for(i = 0; i < numOfDevices; i++) { devices[i] = Pm_GetDeviceInfo(i); }
  return devices;
}

void debug(char* str) {
  fprintf(stderr, str);
}
{'fraction_non_alphanumeric': 0.1353637901861252, 'fraction_numerical': 0.010998307952622674, 'mean_word_length': 3.6924603174603177, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '77316', 'n_tokens_mistral': 869, 'n_tokens_neox': 823, 'n_words': 210}