<commit_before>#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdio.h>
#include <locale.h>

#include <iostream>
#include <string>
#include <sstream>

#include "PA.h"

//////////////////////////////////////////////////////////////////
class PA_initializer_ {
public:
	PA_initializer_() {
		setlocale(LC_ALL, "");

		int err = Pa_Initialize();
		if (err != paNoError)
		{
			printf("ERROR: Pa_Initialize returned 0x%x\n", err);
		}
	};
	virtual ~PA_initializer_() {
		Pa_Terminate();
	};
};

PA_initializer_ pa_initializer_;

//////////////////////////////////////////////////////////////////
PADeviceInfo::PADeviceInfo() : idx_(-1), info_(NULL)
{

}

void PADeviceInfo::set_device_idx_(const int &idx)
{
	const PaDeviceInfo *p = Pa_GetDeviceInfo(idx);
	if (p == NULL) {
		printf("error : PADeviceInfo::set_device_idx() : Pa_GetDeviceInfo() error...idx=", idx);
		return;
	}

	this->idx_ = idx;
	this->info_ = p;
}

bool PADeviceInfo::is_valid_() const
{
	if (this->idx_ == -1 || this->info_ == NULL) return false;
	return true;
}

bool PADeviceInfo::is_asio() const
{
	if (Pa_GetHostApiInfo(info_->hostApi)->type == paASIO) return true;
	return false;
}

int PADeviceInfo::idx() const
{
	return this->idx_;
}

std::string PADeviceInfo::name() const
{
	if (!is_valid_()) return "";

#ifdef WIN32
	return std::string(info_->name);
#else
	return std::string(info_->name);
#endif
}

std::string PADeviceInfo::host_ap() const
{
	if (!is_valid_()) return "none";
	return std::string(Pa_GetHostApiInfo(info_->hostApi)->name);
}

int PADeviceInfo::max_input() const
{
	if (!is_valid_()) return 0;
	return info_->maxInputChannels;
}

int PADeviceInfo::max_output() const
{
	if (!is_valid_()) return 0;
	return info_->maxOutputChannels;
}

PaTime PADeviceInfo::default_low_input_latency() const
{
	if (!is_valid_()) return 0;
	return info_->defaultLowInputLatency;
}<commit_msg>UTF-8→UCS2→MB<commit_after>#ifdef WIN32
#include <SDKDDKVer.h>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif

#include <stdio.h>
#include <locale.h>

#include <iostream>
#include <string>
#include <sstream>

#include "PA.h"

//////////////////////////////////////////////////////////////////
class PA_initializer_ {
public:
	PA_initializer_() {
		setlocale(LC_ALL, "");

		int err = Pa_Initialize();
		if (err != paNoError)
		{
			printf("ERROR: Pa_Initialize returned 0x%x\n", err);
		}
	};
	virtual ~PA_initializer_() {
		Pa_Terminate();
	};
};

PA_initializer_ pa_initializer_;

//////////////////////////////////////////////////////////////////
PADeviceInfo::PADeviceInfo() : idx_(-1), info_(NULL)
{

}

void PADeviceInfo::set_device_idx_(const int &idx)
{
	const PaDeviceInfo *p = Pa_GetDeviceInfo(idx);
	if (p == NULL) {
		printf("error : PADeviceInfo::set_device_idx() : Pa_GetDeviceInfo() error...idx=", idx);
		return;
	}

	this->idx_ = idx;
	this->info_ = p;
}

bool PADeviceInfo::is_valid_() const
{
	if (this->idx_ == -1 || this->info_ == NULL) return false;
	return true;
}

bool PADeviceInfo::is_asio() const
{
	if (Pa_GetHostApiInfo(info_->hostApi)->type == paASIO) return true;
	return false;
}

int PADeviceInfo::idx() const
{
	return this->idx_;
}

std::string PADeviceInfo::name() const
{
	if (!is_valid_()) return "";

#ifdef WIN32
	wchar_t name_w[MAX_PATH];
	char name_mb[MAX_PATH];
	MultiByteToWideChar(CP_UTF8, 0, info_->name, -1, name_w, MAX_PATH - 1);
	WideCharToMultiByte(CP_THREAD_ACP, 0, name_w, -1, name_mb, MAX_PATH - 1, NULL, NULL);
	return std::string(name_mb);
#else
	return std::string(info_->name);
#endif
}

std::string PADeviceInfo::host_ap() const
{
	if (!is_valid_()) return "none";
	return std::string(Pa_GetHostApiInfo(info_->hostApi)->name);
}

int PADeviceInfo::max_input() const
{
	if (!is_valid_()) return 0;
	return info_->maxInputChannels;
}

int PADeviceInfo::max_output() const
{
	if (!is_valid_()) return 0;
	return info_->maxOutputChannels;
}

PaTime PADeviceInfo::default_low_input_latency() const
{
	if (!is_valid_()) return 0;
	return info_->defaultLowInputLatency;
}
{'fraction_non_alphanumeric': 0.21646417059261097, 'fraction_numerical': 0.007686585668237045, 'mean_word_length': 3.768321513002364, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 45, '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': '1257102', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1512, 'n_words': 303}