<commit_before>// Copyright © 2011 <NAME> and <NAME>
// Licensed under the MIT License. See LICENSE for details.
#include "../../include/mid.h"
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <stdbool.h>

_Bool mute;

enum { NCHAN = 64 };

bool sndinit(void)
{
	if(mute)
		return true;

	if (SDL_WasInit(0) == 0) {
		if (SDL_Init(SDL_INIT_AUDIO) < 0)
			return false;
	} else {
		if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
			return false;
	}

	if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
		return false;
	Mix_AllocateChannels(NCHAN);

	sndvol(SndVolDefault);

	return true;
}

void sndfree(void)
{
	if(mute)
		return;

	Mix_CloseAudio();
}

int sndvol(int v)
{
	return Mix_Volume(-1, v);
}

struct Music {
	Mix_Music *m;
};

Music *musicnew(const char *path)
{
	Music *m = xalloc(1, sizeof(*m));

	if(mute)
		return m;

	m->m = Mix_LoadMUS(path);
	if (!m->m) {
		xfree(m);<commit_msg>Include music in the volume setting.<commit_after>// Copyright © 2011 <NAME> and <NAME>
// Licensed under the MIT License. See LICENSE for details.
#include "../../include/mid.h"
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <stdbool.h>

_Bool mute;

enum { NCHAN = 64 };

bool sndinit(void)
{
	if(mute)
		return true;

	if (SDL_WasInit(0) == 0) {
		if (SDL_Init(SDL_INIT_AUDIO) < 0)
			return false;
	} else {
		if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
			return false;
	}

	if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) < 0)
		return false;
	Mix_AllocateChannels(NCHAN);

	sndvol(SndVolDefault);

	return true;
}

void sndfree(void)
{
	if(mute)
		return;

	Mix_CloseAudio();
}

int sndvol(int v)
{
	Mix_VolumeMusic(v);
	return Mix_Volume(-1, v);
}

struct Music {
	Mix_Music *m;
};

Music *musicnew(const char *path)
{
	Music *m = xalloc(1, sizeof(*m));

	if(mute)
		return m;

	m->m = Mix_LoadMUS(path);
	if (!m->m) {
		xfree(m);
{'fraction_non_alphanumeric': 0.1553911205073996, 'fraction_numerical': 0.019027484143763214, 'mean_word_length': 3.994722955145119, 'pattern_counts': {'":': 0, '<': 19, '<?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': '2677577', 'n_tokens_mistral': 883, 'n_tokens_neox': 800, 'n_words': 185}