PureBoard
https://www.purebasic.fr/german/

OpenAL oder 5.1 ??
https://www.purebasic.fr/german/viewtopic.php?f=4&t=30797
Seite 1 von 1

Autor:  Then [ 02.05.2018 17:44 ]
Betreff des Beitrags:  OpenAL oder 5.1 ??

Hat schonmal jemand mit OpenAL was programmiert oder sonst irgendwie ne Möglichkeit gefunden die 5 Lautsprecher am PC einzeln anzusteuern ? Ich würde gerne die hinteren beiden mal direkt ansteuern...

recht einfach versteht sich.... :lol:

Autor:  ccode_new [ 02.05.2018 18:29 ]
Betreff des Beitrags:  Re: OpenAL oder 5.1 ??

Bei OpenAL muss ich im Moment noch passen, aber ich werde mich mal Schlau machen.

Mit der bass.dll ist es aber recht einfach.

Code:
;...
BASS_StreamCreateFile(0, *BASS_Filename, 0, 0, #BASS_SPEAKER_REARLEFT | #BASS_SAMPLE_MONO)
;....


Zur Überbrückung kann ich dir aber erst einmal diesen Link empfehlen:

https://www.pplusplus.lima-city.de/surround.html

Autor:  ccode_new [ 02.05.2018 19:23 ]
Betreff des Beitrags:  Re: OpenAL oder 5.1 ??

OpenAL ist Matrix basierend.

Code:
;...
Dim SourcePos.f(2)
SourcePos(0) = 1 ; 1 = FRONT-RIGHT / -1 = FRONT-LEFT
SourcePos(1) = 0
SourcePos(2) = 0 ;Hier müsste hinten sein ?!

Dim SourceVel.f(2)
SourceVel(0) = 0
SourceVel(0) = 0
SourceVel(0) = 0

alSourcei(source, #AL_BUFFER, buffer)
alSourcef(source, #AL_PITCH, 1.0)
alSourcef(source, #AL_GAIN, 1.0)
alSourcei(source, #AL_SOURCE_RELATIVE, #AL_TRUE)
alSourcefv(source, #AL_POSITION, @SourcePos())
alSourcefv(source, #AL_VELOCITY, @SourceVel())
;....

Autor:  ccode_new [ 02.05.2018 22:53 ]
Betreff des Beitrags:  Re: OpenAL oder 5.1 ??

Kann das bitte mal jemand unter echtem 5.1 testen.
(Bitte die korrekten Positionen nennen.)

Code:
;AL-Test!!! (Kann das bitte mal jemand unter echtem 5.1 testen und die korrekten Positionen angeben)

ImportC "-lalut"
  alutInit(p1.i, *p2)
  alutGetError()
  alutCreateBufferFromFile(*p)
  alutExit()
EndImport

ImportC "-lopenal"
  alGenSources(p1, *p2)
  alSourcei(p1, p2, p3)
  alSourcef(p1, p2, p3.f)
  alSourcefv(p1, p2, *p3)
  alListenerfv(p1, *p2)
  alSourcePlay(p)
  alSourcePause(p)
  alSourceStop(p)
  alDeleteBuffers(p1, *p2)
  alDeleteSources(p1, *p2)
EndImport

#AL_NONE = 0
#AL_FALSE = 0
#AL_TRUE = 1
#AL_SOURCE_RELATIVE = $202
#AL_CONE_INNER_ANGLE = $1001
#AL_CONE_OUTER_ANGLE = $1002
#AL_PITCH = $1003
#AL_POSITION = $1004
#AL_DIRECTION = $1005
#AL_VELOCITY = $1006
#AL_LOOPING = $1007
#AL_BUFFER = $1009
#AL_GAIN = $100A
#AL_MIN_GAIN = $100D
#AL_MAX_GAIN = $100E
#AL_ORIENTATION = $100F
#AL_SOURCE_STATE = $1010
#AL_INITIAL = $1011
#AL_PLAYING = $1012
#AL_PAUSED = $1013
#AL_STOPPED = $1014
#AL_BUFFERS_QUEUED = $1015
#AL_BUFFERS_PROCESSED = $1016
#AL_REFERENCE_DISTANCE = $1020
#AL_ROLLOFF_FACTOR = $1021
#AL_CONE_OUTER_GAIN = $1022
#AL_MAX_DISTANCE = $1023
#AL_SEC_OFFSET = $1024
#AL_SAMPLE_OFFSET = $1025
#AL_BYTE_OFFSET = $1026
#AL_SOURCE_TYPE = $1027
#AL_STATIC = $1028
#AL_STREAMING = $1029
#AL_UNDETERMINED = $1030
#AL_FORMAT_MONO8 = $1100
#AL_FORMAT_MONO16 = $1101
#AL_FORMAT_STEREO8 = $1102
#AL_FORMAT_STEREO16 = $1103
#AL_FREQUENCY = $2001
#AL_BITS = $2002
#AL_CHANNELS = $2003
#AL_SIZE = $2004
#AL_UNUSED = $2010
#AL_PENDING = $2011
#AL_PROCESSED = $2012
#AL_NO_ERROR = 0
#AL_INVALID_NAME = $A001
#AL_INVALID_ENUM = $A002
#AL_ILLEGAL_ENUM = #AL_INVALID_ENUM
#AL_INVALID_VALUE = $A003
#AL_INVALID_OPERATION = $A004
#AL_ILLEGAL_COMMAND = #AL_INVALID_OPERATION
#AL_OUT_OF_MEMORY = $A005
#AL_VENDOR = $B001
#AL_VERSION = $B002
#AL_RENDERER = $B003
#AL_EXTENSIONS = $B004
#AL_DOPPLER_FACTOR = $C000
#AL_DOPPLER_VELOCITY = $C001
#AL_SPEED_OF_SOUND = $C003
#AL_DISTANCE_MODEL = $D000
#AL_INVERSE_DISTANCE = $D001
#AL_INVERSE_DISTANCE_CLAMPED = $D002
#AL_LINEAR_DISTANCE = $D003
#AL_LINEAR_DISTANCE_CLAMPED = $D004
#AL_EXPONENT_DISTANCE = $D005
#AL_EXPONENT_DISTANCE_CLAMPED = $D006

#ALUT_API_MAJOR_VERSION = 1
#ALUT_API_MINOR_VERSION = 1
#ALUT_ERROR_NO_ERROR = 0
#ALUT_ERROR_OUT_OF_MEMORY = $200
#ALUT_ERROR_INVALID_ENUM = $201
#ALUT_ERROR_INVALID_VALUE = $202
#ALUT_ERROR_INVALID_OPERATION = $203
#ALUT_ERROR_NO_CURRENT_CONTEXT = $204
#ALUT_ERROR_AL_ERROR_ON_ENTRY = $205
#ALUT_ERROR_ALC_ERROR_ON_ENTRY = $206
#ALUT_ERROR_OPEN_DEVICE = $207
#ALUT_ERROR_CLOSE_DEVICE = $208
#ALUT_ERROR_CREATE_CONTEXT = $209
#ALUT_ERROR_MAKE_CONTEXT_CURRENT = $20A
#ALUT_ERROR_DESTROY_CONTEXT = $20B
#ALUT_ERROR_GEN_BUFFERS = $20C
#ALUT_ERROR_BUFFER_DATA = $20D
#ALUT_ERROR_IO_ERROR = $20E
#ALUT_ERROR_UNSUPPORTED_FILE_TYPE = $20F
#ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE = $210
#ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA = $211
#ALUT_WAVEFORM_SINE = $100
#ALUT_WAVEFORM_SQUARE = $101
#ALUT_WAVEFORM_SAWTOOTH = $102
#ALUT_WAVEFORM_WHITENOISE = $103
#ALUT_WAVEFORM_IMPULSE = $104
#ALUT_LOADER_BUFFER = $300
#ALUT_LOADER_MEMORY = $301

Global key.s
Global active.b = #False
Global stereo.b = #True
Global ende.b = #False

alutInit(0, 0)

Soundpath.s = GetCurrentDirectory()+"test.wav" ;Irgend eine Wav-Datei wählen !

Global buffer
buffer = alutCreateBufferFromFile(UTF8(Soundpath))

If( alutGetError() <> #ALUT_ERROR_NO_ERROR )
  Debug "Error!!!" : End
EndIf

Global source
alGenSources(1, @source)

Dim SourcePos.f(2)
SourcePos(0) = 0 ; 1 = FRONT-RIGHT / -1 = FRONT-LEFT
SourcePos(1) = 0
SourcePos(2) = 0

Dim SourceVel.f(2)
SourceVel(0) = 0
SourceVel(0) = 0
SourceVel(0) = 0

alSourcei(source, #AL_BUFFER, buffer)
alSourcef(source, #AL_PITCH, 1.0)
alSourcef(source, #AL_GAIN, 1.0)
alSourcei(source, #AL_SOURCE_RELATIVE, #AL_TRUE)
alSourcefv(source, #AL_POSITION, @SourcePos())
alSourcefv(source, #AL_VELOCITY, @SourceVel())

Dim listener_position.f(2)
listener_position(0) = 0
listener_position(1) = 0
listener_position(2) = 0

Dim listener_velocity.f(2)
listener_velocity(0) = 0
listener_velocity(1) = 0
listener_velocity(2) = 0

Dim listener_orientation.f(5)
listener_orientation(0) = 0
listener_orientation(1) = 0
listener_orientation(2) = -1
listener_orientation(3) = 0
listener_orientation(4) = 0
listener_orientation(5) = 1
                                               
alListenerfv(#AL_POSITION, @listener_position())
alListenerfv(#AL_VELOCITY, @listener_velocity())
alListenerfv(#AL_ORIENTATION, @listener_orientation())

alSourcei(source, #AL_LOOPING, #AL_TRUE)

OpenConsole()
PrintN("Wähle ein Soundprofil:")
PrintN("1 = Stereo")
PrintN("2 = 5.1 Sound (muss aktiviert sein)")
Repeat
  key = Inkey()
  If key = Chr(49)
    stereo = #True
    active = #True
    PrintN("Wähle eine Soundposition:")
    PrintN("1 = FRONT-LEFT")
    PrintN("2 = FRONT-RIGHT")
  ElseIf key = Chr(50)
    stereo = #False
    active = #True
    PrintN("Wähle eine Soundposition:")
    PrintN("1 = FRONT-LEFT")
    PrintN("2 = FRONT-RIGHT")
    PrintN("3 = CENTER")
    PrintN("4 = BACK-LEFT")
    PrintN("5 = BACK-RIGHT")
  EndIf
Until active = #True And Len(key) > 0

If active = #True
  Repeat
    key = Inkey()
    If Len(key) > 0
      If key = Chr(27)
        ende = #True
      ElseIf key = Chr(49) And stereo = #True
        SourcePos(0) = -1 : SourcePos(1) = 0 : SourcePos(2) = 0 ;FRONT-LEFT
        alSourcefv(source, #AL_POSITION, @SourcePos())
        alSourcePlay(source)
      ElseIf key = Chr(50) And stereo = #True
        SourcePos(0) = 1 : SourcePos(1) = 0 : SourcePos(2) = 0 ;FRONT-RIGHT
        alSourcefv(source, #AL_POSITION, @SourcePos())
        alSourcePlay(source)
      ElseIf key = Chr(49) And stereo = #False
        ;....
      ElseIf key = Chr(50) And stereo = #False
        ;...
      ElseIf key = Chr(51) And stereo = #False
        ;...
      ElseIf key = Chr(52) And stereo = #False
        ;...
      ElseIf key = Chr(53) And stereo = #False
        ;...
      EndIf
    EndIf
  Until ende = #True
EndIf

CloseConsole()

alSourceStop(source)

alDeleteBuffers(1, @buffer)
alDeleteSources(1, @source)
alutExit()

Autor:  STARGÅTE [ 03.05.2018 09:45 ]
Betreff des Beitrags:  Re: OpenAL oder 5.1 ??

@ccode_new
Zitat:
---------------------------
PureBasic - Linker error
---------------------------
POLINK: warning: Unrecognized option 'lalut'; ignored.
POLINK: warning: Unrecognized option 'lopenal'; ignored.
POLINK: error: Unresolved external symbol '_alutInit'.
POLINK: error: Unresolved external symbol '_alutCreateBufferFromFile'.
POLINK: error: Unresolved external symbol '_alutGetError'.
POLINK: error: Unresolved external symbol '_alGenSources'.
POLINK: error: Unresolved external symbol '_alSourcei'.
...
POLINK: fatal error: 13 unresolved external(s).
---------------------------
OK
---------------------------


Then hat geschrieben:
Hat schonmal jemand mit OpenAL was programmiert oder sonst irgendwie ne Möglichkeit gefunden die 5 Lautsprecher am PC einzeln anzusteuern ? Ich würde gerne die hinteren beiden mal direkt ansteuern...

Ich habe mir bereits eine Sound-Include geschrieben mit OpenAL, gerade aus dem Grund echtes 5.1 zu haben.
Allerdings bin ich der Meinung das du da die Einzelkanäle nicht ansprechen kannst.
Dein Lautsprechersystem wirkt immer als ganzes, und wird von OpenAL angesteuert, je nach Position, Ohren und Quelle.
Damit das aber überhaupt funktioniert, musst ich mir erst mal die passende DLL suchen, da OpenAL ja mit Version 1.1 von 2006 "eingeschlafen" ist. Allerdings gibts hier zumindest n neuere Version die auch mehr als Stereo kann.

Autor:  ccode_new [ 03.05.2018 16:51 ]
Betreff des Beitrags:  Re: OpenAL oder 5.1 ??

@STARGÅTE

Mitdenken!?

Diese Linkeraufrufe entstammen einem fernen Linux-Universum. Für Herrn Polink aus dem Windowsuniversum müsste es angepasst werden. (Dlls, Test-Mono-Wav-Datei vorausgesetzt.)
Der Aufwand sollte aber minimal sein.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/