sdl_output

package
v0.0.0-...-09ec4ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

GoSpeccy SDL interface (audio&video output, keyboard input)

Index

Constants

View Source
const (
	HIDE = iota
	SHOW
)
View Source
const BUFSIZE_IDEAL = 3

Ideal number of buffered 'AudioData' objects, in order to prevent [SDL buffer underruns] and [Go channel overruns].

View Source
const DEFAULT_JOYSTICK_ID = 0
View Source
const FREQUENCY_CHANGE_RATE = 1.0002
View Source
const MIN_PLAYBACK_FREQUENCY = 10000

The function 'bufferRemove' requires a sufficiently high frequency so that FREQUENCY_CHANGE_RATE has an actual impact on the frequency. In other words: ((FREQUENCY_CHANGE_RATE-1) * MIN_PLAYBACK_FREQUENCY) has to be greater than 1.

View Source
const PLAYBACK_FREQUENCY = 48000

The default SDL-audio playback frequency

View Source
const RESPONSE_FREQUENCY = 12000

The ZX Spectrum beeper has only two levels: 0 and 1. However, the beeper can produce multi-channel sound if it changes so quickly that the speaker (speaker = the physical object that the TV uses to produce the sound) is unable to keep up with the rate of changes between the levels. This effectively puts the speaker into a position somewhere *between* 0 and 1 (e.g: 0.25, 0.7)

The RESPONSE_FREQUENCY is a frequency at which the multi-channel music in certain ZX Spectrum games and demos sounds "good-enough" to the human ear.

It is used only when 'hqAudio' is enabled.

Variables

View Source
var (
	Scale2x            = flag.Bool("2x", false, "2x display scaler")
	Fullscreen         = flag.Bool("fullscreen", false, "Fullscreen (enable 2x scaler by default)")
	Audio              = flag.Bool("audio", true, "Enable or disable audio")
	AudioFreq          = flag.Uint("audio-freq", PLAYBACK_FREQUENCY, "Audio playback frequency (units: Hz)")
	HQAudio            = flag.Bool("audio-hq", true, "Enable or disable higher-quality audio")
	ShowPaintedRegions = flag.Bool("show-paint", false, "Show painted display regions")
)

Functions

func Main

func Main()

func SDL_updateRects

func SDL_updateRects(surface *sdl.Surface, surfaceChanges *ListOfRects, scale uint, updatedRectsCh chan []sdl.Rect)

Types

type InitialSettings

type InitialSettings struct {
	// contains filtered or unexported fields
}

func (*InitialSettings) EnableAudio

func (s *InitialSettings) EnableAudio(enable bool)

func (*InitialSettings) ResizeVideo

func (s *InitialSettings) ResizeVideo(scale2x, fullscreen bool)

func (*InitialSettings) SetAudioFreq

func (s *InitialSettings) SetAudioFreq(freq uint)

func (*InitialSettings) SetAudioQuality

func (s *InitialSettings) SetAudioQuality(hqAudio bool)

func (*InitialSettings) ShowPaintedRegions

func (s *InitialSettings) ShowPaintedRegions(enable bool)

func (*InitialSettings) Terminated

func (s *InitialSettings) Terminated() bool

type ListOfRects

type ListOfRects []sdl.Rect

type SDLAudio

type SDLAudio struct {
	// contains filtered or unexported fields
}

func NewSDLAudio

func NewSDLAudio(app *spectrum.Application, playbackFrequency uint, hqAudio bool) (*SDLAudio, error)

Opens SDL audio. If 'playbackFrequency' is 0, the frequency will be equivalent to PLAYBACK_FREQUENCY.

func (*SDLAudio) Close

func (audio *SDLAudio) Close()

func (*SDLAudio) GetAudioDataChannel

func (audio *SDLAudio) GetAudioDataChannel() chan<- *spectrum.AudioData

Implement AudioReceiver

type SDLRenderer

type SDLRenderer struct {
	// contains filtered or unexported fields
}

func NewSDLRenderer

func NewSDLRenderer(app *spectrum.Application, speccy *spectrum.Spectrum48k, scale2x, fullscreen bool, audio, hqAudio bool, audioFreq uint) *SDLRenderer

func (*SDLRenderer) EnableAudio

func (r *SDLRenderer) EnableAudio(enable bool)

func (*SDLRenderer) ResizeVideo

func (r *SDLRenderer) ResizeVideo(scale2x, fullscreen bool)

func (*SDLRenderer) SetAudioFreq

func (r *SDLRenderer) SetAudioFreq(freq uint)

func (*SDLRenderer) SetAudioQuality

func (r *SDLRenderer) SetAudioQuality(hqAudio bool)

func (*SDLRenderer) ShowPaintedRegions

func (r *SDLRenderer) ShowPaintedRegions(enable bool)

func (*SDLRenderer) Terminated

func (r *SDLRenderer) Terminated() bool

type SDLScreen

type SDLScreen struct {
	// contains filtered or unexported fields
}

func NewSDLScreen

func NewSDLScreen(app *spectrum.Application) *SDLScreen

func (*SDLScreen) Close

func (display *SDLScreen) Close()

func (*SDLScreen) GetDisplayDataChannel

func (display *SDLScreen) GetDisplayDataChannel() chan<- *spectrum.DisplayData

Implement DisplayReceiver

func (*SDLScreen) GetSurface

func (display *SDLScreen) GetSurface() *sdl.Surface

func (*SDLScreen) UpdatedRectsCh

func (display *SDLScreen) UpdatedRectsCh() <-chan []sdl.Rect

type SDLScreen2x

type SDLScreen2x struct {
	// contains filtered or unexported fields
}

func NewSDLScreen2x

func NewSDLScreen2x(app *spectrum.Application) *SDLScreen2x

func (*SDLScreen2x) Close

func (display *SDLScreen2x) Close()

func (*SDLScreen2x) GetDisplayDataChannel

func (display *SDLScreen2x) GetDisplayDataChannel() chan<- *spectrum.DisplayData

Implement DisplayReceiver

func (*SDLScreen2x) GetSurface

func (display *SDLScreen2x) GetSurface() *sdl.Surface

func (*SDLScreen2x) UpdatedRectsCh

func (display *SDLScreen2x) UpdatedRectsCh() <-chan []sdl.Rect

type SDLSurface

type SDLSurface struct {
	// contains filtered or unexported fields
}

func NewSDLSurface

func NewSDLSurface(app *spectrum.Application) *SDLSurface

Create an SDL surface suitable for an unscaled screen

func NewSDLSurface2x

func NewSDLSurface2x(app *spectrum.Application) *SDLSurface

Create an SDL surface suitable for a 2x scaled screen

func (SDLSurface) Bpp

func (s SDLSurface) Bpp() uint

func (SDLSurface) Height

func (s SDLSurface) Height() uint

func (SDLSurface) Pitch

func (s SDLSurface) Pitch() uint

func (SDLSurface) Width

func (s SDLSurface) Width() uint

type SDLSurfaceAccessor

type SDLSurfaceAccessor interface {
	UpdatedRectsCh() <-chan []sdl.Rect
	GetSurface() *sdl.Surface
}

type SDLSurfaceComposer

type SDLSurfaceComposer struct {
	// contains filtered or unexported fields
}

Composes multiple SDL surfaces into a single surface

func NewSDLSurfaceComposer

func NewSDLSurfaceComposer(app *spectrum.Application) *SDLSurfaceComposer

Creates a new composer, and starts its command-loop in a goroutine

func (*SDLSurfaceComposer) AddInputSurface

func (composer *SDLSurfaceComposer) AddInputSurface(surface *sdl.Surface, x, y int, updatedRectsCh <-chan []sdl.Rect)

Enqueues a command that will append the specified surface to the end of [the list of input surfaces of 'composer'].

The order of surfaces in the mentioned list defines the compositing order. The first surface will visually appear at the bottom, while the last surface will visually appear at the top.

func (*SDLSurfaceComposer) RemoveAllInputSurfaces

func (composer *SDLSurfaceComposer) RemoveAllInputSurfaces() <-chan byte

Enqueues a command that will clear [the list of input surfaces of 'composer']. The returned channel will receive a single value when the command completes.

func (*SDLSurfaceComposer) RemoveInputSurface

func (composer *SDLSurfaceComposer) RemoveInputSurface(surface *sdl.Surface) <-chan byte

Enqueues a command that will remove the specified surface from [the list of input surfaces of 'composer']. The returned channel will receive a single value when the command completes.

func (*SDLSurfaceComposer) ReplaceOutputSurface

func (composer *SDLSurfaceComposer) ReplaceOutputSurface(surface_orNil *sdl.Surface) <-chan byte

Enqueues a command that will replace the output surface. The returned channel will receive a single value when the command completes.

func (*SDLSurfaceComposer) SetPosition

func (composer *SDLSurfaceComposer) SetPosition(surface *sdl.Surface, x, y int)

Enqueues a command that will move the specified surface to a new position

func (*SDLSurfaceComposer) ShowPaintedRegions

func (composer *SDLSurfaceComposer) ShowPaintedRegions(enable bool)

Enqueues a command that will set the "show painted regions" flag. If the flag is set to true, then each paint operation is covered by a semi-transparent randomly colored rectangle.

type UnscaledDisplay

type UnscaledDisplay struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL