mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
internal/cbackend: add AudioBufferSizeInSeconds
This commit is contained in:
parent
1799ed0b28
commit
e6131894a7
@ -71,8 +71,7 @@ func (c *Context) Err() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) oneBufferSize() int {
|
func (c *Context) oneBufferSize() int {
|
||||||
// TODO: This must be audio.oneBufferSize(p.context.sampleRate). Avoid the duplication.
|
return int(float64(c.sampleRate*c.channelNum*c.bitDepthInBytes) * cbackend.AudioBufferSizeInSeconds())
|
||||||
return c.sampleRate * c.channelNum * c.bitDepthInBytes / 4
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) MaxBufferSize() int {
|
func (c *Context) MaxBufferSize() int {
|
||||||
|
@ -51,6 +51,7 @@ package cbackend
|
|||||||
// void EbitenGetTouches(struct Touch* touches);
|
// void EbitenGetTouches(struct Touch* touches);
|
||||||
//
|
//
|
||||||
// // Audio
|
// // Audio
|
||||||
|
// // TODO: Implement mixing on Go side and reduce the API.
|
||||||
// typedef void (*OnWrittenCallback)(int id);
|
// typedef void (*OnWrittenCallback)(int id);
|
||||||
// void EbitenOpenAudio(int sample_rate, int channel_num, int bit_depth_in_bytes);
|
// void EbitenOpenAudio(int sample_rate, int channel_num, int bit_depth_in_bytes);
|
||||||
// void EbitenCloseAudio();
|
// void EbitenCloseAudio();
|
||||||
@ -62,6 +63,7 @@ package cbackend
|
|||||||
// double EbitenAudioPlayerGetVolume(int id);
|
// double EbitenAudioPlayerGetVolume(int id);
|
||||||
// void EbitenAudioPlayerSetVolume(int id, double volume);
|
// void EbitenAudioPlayerSetVolume(int id, double volume);
|
||||||
// int EbitenAudioPlayerGetUnplayedBufferSize(int id);
|
// int EbitenAudioPlayerGetUnplayedBufferSize(int id);
|
||||||
|
// float EbitenAudioBufferSizeInSeconds();
|
||||||
//
|
//
|
||||||
// void EbitenAudioPlayerOnWrittenCallback(int id);
|
// void EbitenAudioPlayerOnWrittenCallback(int id);
|
||||||
// static int EbitenCreateAudioPlayerProxy() {
|
// static int EbitenCreateAudioPlayerProxy() {
|
||||||
@ -187,6 +189,10 @@ func CreateAudioPlayer(onWritten func()) *AudioPlayer {
|
|||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AudioBufferSizeInSeconds() float64 {
|
||||||
|
return float64(C.EbitenAudioBufferSizeInSeconds())
|
||||||
|
}
|
||||||
|
|
||||||
type AudioPlayer struct {
|
type AudioPlayer struct {
|
||||||
id C.int
|
id C.int
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user