PancakeNESEmu
A homebrewed NES Emulator written in C
Loading...
Searching...
No Matches
apu.h File Reference
#include "core/types.h"
#include "macros.h"
#include <pulse/pulseaudio.h>
#include <pulse/simple.h>
Include dependency graph for apu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wave_settings_t
 

Functions

wave_settings_tgenerate_wave_settings (float frequency, float sample_rate, unsigned int volume, duty_cycle_t duty_cycle, wave_t wave_type)
 Allocate a wave settings structure and return its pointers.
 
void free_wave_settings (wave_settings_t *wave_ss)
 Free the wave_settings structure.
 
errcode_t generate_wave (sbuffer_t *buf, size_t size, wave_settings_t *wave_ss)
 Generate a waveform inside of a buffer based on a frequency, rate, wave type and duty_cycle.
 
errcode_t play_sound (sbuffer_t *buf, pa_simple *s, size_t size)
 Play a sound based on a sound buffer, a sound interface and a the buffer size.
 

Function Documentation

◆ free_wave_settings()

void free_wave_settings ( wave_settings_t * wave_ss)

Free the wave_settings structure.

Parameters
[in,out]wave_ssThe pointer to the wave_settings

◆ generate_wave()

errcode_t generate_wave ( sbuffer_t * buf,
size_t size,
wave_settings_t * wave_ss )

Generate a waveform inside of a buffer based on a frequency, rate, wave type and duty_cycle.

Parameters
[in,out]bufA pointer to the sound buffer
[in]sizeThe size of the buffer
[in]wave_ssThe sound settings of the wave
Returns
0 if no error

◆ generate_wave_settings()

wave_settings_t * generate_wave_settings ( float frequency,
float sample_rate,
unsigned int volume,
duty_cycle_t duty_cycle,
wave_t wave_type )

Allocate a wave settings structure and return its pointers.

Parameters
[in]frequencyThe frequency of the wave
[in]sample_rateThe sample rate of the wave
[in]volumeThe volume of the sound wave (also called amplitude)
[in]duty_cycleThe duty_cycle of the wave (only used for Rectangle waveforms)
[in]wave_typeThe type of the wave
Returns
The pointer to the allocated settings

◆ play_sound()

errcode_t play_sound ( sbuffer_t * buf,
pa_simple * s,
size_t size )

Play a sound based on a sound buffer, a sound interface and a the buffer size.

Parameters
[in]bufA pointer to the sound buffer
[in]sA pointer to the sound interface
[in]sizeThe size of the sound buffer
Returns
0 if no error, 1 if pa_simple_write failed