Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht Das deutsche QBasic- und FreeBASIC-Forum
Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
 
FAQFAQ   SuchenSuchen   MitgliederlisteMitgliederliste   BenutzergruppenBenutzergruppen  RegistrierenRegistrieren
ProfilProfil   Einloggen, um private Nachrichten zu lesenEinloggen, um private Nachrichten zu lesen   LoginLogin
Zur Begleitseite des Forums / Chat / Impressum
Aktueller Forenpartner:

Kan bitte mal jemand mit Linux den ALSA Code Testen?

 
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Linux-spezifische Fragen
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen  
Autor Nachricht
d.j.peters
Gast





BeitragVerfasst am: 22.01.2006, 13:30    Titel: Kan bitte mal jemand mit Linux den ALSA Code Testen? Antworten mit Zitat

Wenn jemand mit Linux und ALSA Lib mal bitte den kurzen Code Testen könnte wäre mir das eine grosse Hilfe.

Mit Windows ist alles klar für eine FBSound Lib nur mit ALSA scheint es so das ich etwas übersehe oder noch nicht geblickt habe.

Danke Joshy

Code:
option explicit

const EAGAIN                       = 11 ' Try again
const EPIPE                        = 32 ' Broken pipe
const ESTRPIPE                     = 86 ' Streams pipe error

const BLOCK                        = 0
const NONBLOCK                     = 1
const ASYNC                        = 2
const SND_PCM_STREAM_PLAYBACK      = 0
const SND_PCM_STREAM_CAPTURE       = 1
const SND_PCM_FORMAT_S16_LE        = 2
const SND_PCM_ACCESS_RW_INTERLEAVED= 3

type snd_pcm_t           as _snd_pcm
type snd_pcm_hw_params_t as _snd_pcm_hw_params

' PCM
declare function snd_pcm_open cdecl alias "snd_pcm_open" ( _
byval pcm          as snd_pcm_t ptr ptr, _
byval device       as string, _
byval direction    as integer, _
byval mode         as integer) as integer

declare function snd_pcm_close cdecl alias "snd_pcm_close" ( _
byval pcm          as snd_pcm_t ptr) as integer

declare function snd_pcm_hw_free cdecl alias "snd_pcm_hw_free" ( _
byval pcm          as snd_pcm_t ptr) as integer

declare function snd_pcm_nonblock cdecl alias "snd_pcm_nonblock" ( _
byval pcm          as snd_pcm_t ptr, _
byval nonblock     as integer) as integer

declare function snd_pcm_prepare cdecl alias "snd_pcm_prepare" ( _
byval pcm as snd_pcm_t ptr) as integer

declare function snd_pcm_writei cdecl alias "snd_pcm_writei" ( _
byval pcm          as snd_pcm_t ptr, _
byval buffer       as any ptr, _
byval size         as integer) as integer

declare function snd_pcm_resume cdecl alias "snd_pcm_resume" ( _
byval pcm as snd_pcm_t ptr) as integer

'hardware
declare function snd_pcm_hw_params_malloc cdecl alias "snd_pcm_hw_params_malloc" ( _
byval hw           as snd_pcm_hw_params_t ptr ptr) as integer

declare function snd_pcm_hw_params_any cdecl alias "snd_pcm_hw_params_any" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr) as integer

declare function snd_pcm_hw_params_set_access cdecl alias "snd_pcm_hw_params_set_access" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval mode         as integer) as integer

declare function snd_pcm_hw_params_set_format cdecl alias "snd_pcm_hw_params_set_format" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval fmt          as integer) as integer

declare function snd_pcm_hw_params_set_channels cdecl alias "snd_pcm_hw_params_set_channels" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval Channels     as integer) as integer

declare function snd_pcm_hw_params_get_channels cdecl alias "snd_pcm_hw_params_get_channels" ( _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpChannels   as integer ptr) as integer

declare function snd_pcm_hw_params_set_rate_near cdecl alias "snd_pcm_hw_params_set_rate_near" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpRate         as integer ptr, _
byval lpDir        as integer ptr) as integer

declare function snd_pcm_hw_params_set_periods_near cdecl alias "snd_pcm_hw_params_set_periods_near" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpValue      as integer ptr, _
byval lpDir        as integer ptr) as integer

declare function snd_pcm_hw_params_get_period_size cdecl alias "snd_pcm_hw_params_get_period_size" ( _
byval params       as snd_pcm_hw_params_t ptr, _
byval lpFrames     as integer ptr, _
byval lpDir        as integer ptr) as integer

declare function snd_pcm_hw_params_set_buffer_size_near cdecl alias "snd_pcm_hw_params_set_buffer_size_near" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpFrames     as integer ptr) as integer

declare function snd_pcm_hw_params_get_buffer_size cdecl alias "snd_pcm_hw_params_get_buffer_size" ( _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpFrames     as integer ptr) as integer

declare function snd_pcm_hw_params cdecl alias "snd_pcm_hw_params" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr) as integer

declare sub snd_pcm_hw_params_free cdecl alias "snd_pcm_hw_params_free" ( _
byval hw as snd_pcm_hw_params_t ptr)

#inclib "asound"


'#define device "plughw:0,0"
#define device "hw:0,0"

type player_driver_t
  handle     as snd_pcm_t ptr 'NULL = Error
  Speed      as integer  ' 11025 22050 44100
  nChannels  as integer  ' 1 or 2
  nBits      as integer  ' 8 or 16
  SampleSize as integer  ' (nBits\8) * nChannels
  Buffer     as short ptr ' curently 16Bit
  BufferSize as integer  ' SampleSize * 8192
  nChunks    as integer  ' 2
  ChunkSize  as integer  ' BufferSize / nChunks
end type

function Alsa_Init(byval strDevice as string,byval Speed as integer) as player_driver_t ptr
  dim as snd_pcm_t ptr           htmp
  dim as snd_pcm_hw_params_t ptr hw
  dim as integer                 ret, direction
  dim as player_driver_t ptr     tmp
  dim as zstring ptr             strRet
  ' open device in non blocking mode
  ret = snd_pcm_open(@htmp, strDevice, SND_PCM_STREAM_PLAYBACK, NONBLOCK)
  if (ret < 0) then ? "failed open":goto Alsa_Init_Error

  ' switch to blocking mode
  ret=snd_pcm_nonblock(htmp,BLOCK)
  if (ret < 0) then ? "failed block":goto Alsa_Init_Error

  'alloc the player
  tmp=callocate(sizeof(player_driver_t))
  tmp->Speed=Speed
  tmp->nChannels  = 2
  tmp->nBits      = 16
  tmp->SampleSize = tmp->nBits\8 * tmp->nChannels
  tmp->BufferSize = 8192 * tmp->SampleSize
  tmp->nChunks    = 2
  tmp->ChunkSize  = tmp->BufferSize \ tmp->nChunks

  ' qwery param
  snd_pcm_hw_params_malloc(@hw)
  ret = snd_pcm_hw_params_any(htmp,hw)
  if (ret < 0) then ? "failed hw_param_any":goto Alsa_Init_Error

  ' set read write access
  ret = snd_pcm_hw_params_set_access(htmp, hw, SND_PCM_ACCESS_RW_INTERLEAVED)
  if (ret < 0) then ? "failed set_access":goto Alsa_Init_Error

  ' set 16bit signed
  ret = snd_pcm_hw_params_set_format(htmp,hw,2)
  if (ret < 0) then ? "failed set_format":goto Alsa_Init_Error

  'set stero
  ret = snd_pcm_hw_params_set_channels(htmp,hw, tmp->nChannels)
  if (ret < 0) then
    snd_pcm_hw_params_get_channels(hw, @ret)
    if (ret<>tmp->nChannels) then ? "failed set_channels":goto Alsa_Init_Error
  end if

  'set speed
  ret = snd_pcm_hw_params_set_rate_near(htmp,hw,@tmp->Speed,0)
  if (ret < 0) then
    ? "failed set_rate_near":goto Alsa_Init_Error
  elseif (ret > 0) then
    tmp->Speed=ret
  end if
  if tmp->Speed<>Speed then ? "warning: use speed";tmp->Speed

  ' number of Chunks
  ret = snd_pcm_hw_params_set_periods_near(htmp, hw,@tmp->nChunks, 0)
  if (ret < 0) then ? "failed set_periods_near":goto Alsa_Init_Error

  ' set ChunkSize
  ret = snd_pcm_hw_params_set_buffer_size_near(htmp, hw, @tmp->BufferSize)
  if (ret < 0) then ? "failed set_buffer_size_near":goto Alsa_Init_Error

  ' set the config
  ret = snd_pcm_hw_params(htmp,hw)
  if (ret < 0) then ? "failed hw_params":goto Alsa_Init_Error

  ret = snd_pcm_prepare(htmp)
  if (ret < 0) then ? "failed prepare":goto Alsa_Init_Error

Alsa_Init_Ok:
  tmp->Handle=htmp
  snd_pcm_hw_params_free hw

  return tmp

Alsa_Init_Error:
    if hw  <>0 then snd_pcm_hw_params_free hw
    if htmp<>0 then snd_pcm_close          htmp
    if tmp <>0 then deallocate             tmp
    return 0

end function

sub Alsa_Exit(byval pcm as snd_pcm_t ptr)
  if pcm=0 then exit sub
  ? snd_pcm_close(pcm)
end sub

sub Alsa_Send(byval player as player_driver_t ptr,byval nBytes as integer)

  dim as integer ret,nFrames
  dim as any ptr lpStart,lpEnd

  if player        =0 then exit sub
  if player->Handle=0 then exit sub
  if player->Buffer=0 then exit sub
  if nBytes        <1 then exit sub

  nFrames  = nBytes \ Player->SampleSize
  lpStart=Player->Buffer
  lpEnd  =Player->Buffer+nBytes

  while(lpStart<lpEnd)
    ret = snd_pcm_writei(Player->Handle,lpStart,nFrames)

    if (ret=-EAGAIN) then
      ' device busy
    elseif (ret=-ESTRPIPE) then
      ret=-EAGAIN
      while ret=-EAGAIN:ret=snd_pcm_resume(Player->Handle):wend
    elseif (ret=-EPIPE) then

    else
      if (ret<0) then  ? "failed send audiodata"
      if snd_pcm_prepare(Player->Handle) < 0 then exit sub
      nFrames-=ret:lpStart+=ret*Player->SampleSize
    endif
  wend
end sub


'
' main
'
dim as player_driver_t ptr player
dim as integer i,l,r
player=Alsa_Init(device,44100)

if player=0 then goto test_exist

player->Buffer=allocate(8192*player->SampleSize)

for i=0 to 8192*player->nChannels-1 step 2
  player->Buffer[i]=l:l+=100:if l>5000 then l=-5000
  player->Buffer[i+1]=r:r+=30:if r>5000 then r=-5000
next

for i=1 to 10
  Alsa_Send player,8192*player->SampleSize
next



test_exist:
sleep

end
Nach oben
d.j.peters
Gast





BeitragVerfasst am: 22.01.2006, 15:42    Titel: Antworten mit Zitat

Der Windows Teil der fbsound lib ist fertig.
Ich benötige aber noch ALSA Treiber Tests.

Der Code funktioniert in mono/stereo 8/16bits 10000-48000 kHz auf 3 Linux PC mit verschiedenen Soundkarten aber ich kann es nur mit SLACKWARE testen.

Was ist mit anderen Distros?

Danke für Eure Bemühungen.

Joshy
Code:
option explicit

const EAGAIN                       = 11 ' Try again
const EPIPE                        = 32 ' Broken pipe
const ESTRPIPE                     = 86 ' Streams pipe error

const BLOCK                        = 0
const NONBLOCK                     = 1
const ASYNC                        = 2
const SND_PCM_STREAM_PLAYBACK      = 0
const SND_PCM_STREAM_CAPTURE       = 1
const SND_PCM_FORMAT_S16_LE        = 2
const SND_PCM_ACCESS_RW_INTERLEAVED= 3

type snd_pcm_t           as _snd_pcm
type snd_pcm_hw_params_t as _snd_pcm_hw_params

' PCM
declare function snd_pcm_open cdecl alias "snd_pcm_open" ( _
byval pcm          as snd_pcm_t ptr ptr, _
byval device       as string, _
byval direction    as integer, _
byval mode         as integer) as integer

declare function snd_pcm_close cdecl alias "snd_pcm_close" ( _
byval pcm          as snd_pcm_t ptr) as integer

declare function snd_pcm_hw_free cdecl alias "snd_pcm_hw_free" ( _
byval pcm          as snd_pcm_t ptr) as integer

declare function snd_pcm_nonblock cdecl alias "snd_pcm_nonblock" ( _
byval pcm          as snd_pcm_t ptr, _
byval nonblock     as integer) as integer

declare function snd_pcm_prepare cdecl alias "snd_pcm_prepare" ( _
byval pcm as snd_pcm_t ptr) as integer

declare function snd_pcm_writei cdecl alias "snd_pcm_writei" ( _
byval pcm          as snd_pcm_t ptr, _
byval buffer       as any ptr, _
byval size         as integer) as integer

declare function snd_pcm_resume cdecl alias "snd_pcm_resume" ( _
byval pcm as snd_pcm_t ptr) as integer

'hardware
declare function snd_pcm_hw_params_malloc cdecl alias "snd_pcm_hw_params_malloc" ( _
byval hw           as snd_pcm_hw_params_t ptr ptr) as integer

declare function snd_pcm_hw_params_any cdecl alias "snd_pcm_hw_params_any" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr) as integer

declare function snd_pcm_hw_params_set_access cdecl alias "snd_pcm_hw_params_set_access" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval mode         as integer) as integer

declare function snd_pcm_hw_params_set_format cdecl alias "snd_pcm_hw_params_set_format" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval fmt          as integer) as integer

declare function snd_pcm_hw_params_set_channels cdecl alias "snd_pcm_hw_params_set_channels" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval Channels     as integer) as integer

declare function snd_pcm_hw_params_get_channels cdecl alias "snd_pcm_hw_params_get_channels" ( _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpChannels   as integer ptr) as integer

declare function snd_pcm_hw_params_set_rate_near cdecl alias "snd_pcm_hw_params_set_rate_near" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpRate         as integer ptr, _
byval lpDir        as integer ptr) as integer

declare function snd_pcm_hw_params_set_periods_near cdecl alias "snd_pcm_hw_params_set_periods_near" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpValue      as integer ptr, _
byval lpDir        as integer ptr) as integer

declare function snd_pcm_hw_params_get_period_size cdecl alias "snd_pcm_hw_params_get_period_size" ( _
byval params       as snd_pcm_hw_params_t ptr, _
byval lpFrames     as integer ptr, _
byval lpDir        as integer ptr) as integer

declare function snd_pcm_hw_params_set_buffer_size_near cdecl alias "snd_pcm_hw_params_set_buffer_size_near" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpFrames     as integer ptr) as integer

declare function snd_pcm_hw_params_get_buffer_size cdecl alias "snd_pcm_hw_params_get_buffer_size" ( _
byval hw           as snd_pcm_hw_params_t ptr, _
byval lpFrames     as integer ptr) as integer

declare function snd_pcm_hw_params cdecl alias "snd_pcm_hw_params" ( _
byval pcm          as snd_pcm_t ptr, _
byval hw           as snd_pcm_hw_params_t ptr) as integer

declare sub snd_pcm_hw_params_free cdecl alias "snd_pcm_hw_params_free" ( _
byval hw as snd_pcm_hw_params_t ptr)

#inclib "asound"


'#define device "plughw:0,0"
#define device "hw:0,0"

union uniptr
  ptr8       as byte  ptr '  -128 to   +127
  ptr16      as short ptr '-32768 to +32767
end union
type player_driver_t
  handle     as snd_pcm_t ptr 'NULL = Error
  Speed      as integer  ' 11025 22050 44100
  nChannels  as integer  ' 1 or 2
  nBits      as integer  ' 8 or 16
  nFrames    as integer  ' 512,1024,2048,4096 and so on
  FrameSize  as integer  ' (nBits\8) * nChannels
  nPeriods   as integer  ' try 2
  PeriodSize as integer  ' BufferSize / FrameSize
  Buffer     as uniptr
end type

function Alsa_Init(byval strDevice as string, _
                   byval Speed    as integer, _
                   byval Bits     as integer, _
                   byval Channels as integer, _
                   byval Frames   as integer=4096) as player_driver_t ptr
  Bits \=8
  Frames\=256

  ' range of Speed
  if Speed < 11025 then
    Speed = 11025
  elseif Speed>48000 then
    Speed = 48000
  end if
  ' range of Bits
  if Bits<1 then
    Bits=1
  elseif Bits>2 then
    Bits=2
  end if
  ' range of Channels
  if Channels<1 then
    Channels=1
  elseif Channels>2 then
    Channels=2
  end if
  ' range of frames
  if Frames<2 then
    Frames=2
  elseif Frames>32 then
    Frames=32
  end if
  Bits   = Bits   shl 3  ' *   8
  Frames = Frames shl 7  ' * 256

  dim as snd_pcm_t ptr           htmp
  dim as snd_pcm_hw_params_t ptr hw
  dim as integer                 ret, direction,PeriodSize
  dim as player_driver_t ptr     tmp
  dim as zstring ptr             strRet
  ' open device in non blocking mode
  ret = snd_pcm_open(@htmp, strDevice, SND_PCM_STREAM_PLAYBACK, NONBLOCK)
  if (ret < 0) then ? "failed open":goto Alsa_Init_Error

  ' switch to blocking mode
  ret=snd_pcm_nonblock(htmp,BLOCK)
  if (ret < 0) then ? "failed block":goto Alsa_Init_Error

  'alloc the player
  tmp=callocate(sizeof(player_driver_t))
  tmp->Speed      = Speed
  tmp->nChannels  = Channels
  tmp->nBits      = Bits
  tmp->FrameSize  = (Bits \ 8) * Channels
  tmp->nFrames    = Frames
  tmp->nPeriods   = 2
  tmp->PeriodSize = 0

  ' qwery param
  snd_pcm_hw_params_malloc(@hw)
  ret = snd_pcm_hw_params_any(htmp,hw)
  if (ret < 0) then ? "failed hw_param_any":goto Alsa_Init_Error

  ' set read write access
  ret = snd_pcm_hw_params_set_access(htmp, hw, SND_PCM_ACCESS_RW_INTERLEAVED)
  if (ret < 0) then ? "failed set_access":goto Alsa_Init_Error

  if tmp->nBits=8 then
     ret = snd_pcm_hw_params_set_format(htmp,hw,0) 'set 8bit signed
  else
     ret = snd_pcm_hw_params_set_format(htmp,hw,2) ' set 16bit signed
  end if
  if (ret < 0) then ? "failed set_format":goto Alsa_Init_Error

  'set mono or stero
  ret = snd_pcm_hw_params_set_channels(htmp,hw, tmp->nChannels)
  if (ret < 0) then
    snd_pcm_hw_params_get_channels(hw,@tmp->nChannels)
    if (tmp->nChannels<>Channels) then ? "warning: use channels=";tmp->nChannels
  end if

  'set speed
  ret = snd_pcm_hw_params_set_rate_near(htmp,hw,@tmp->Speed,0)
  if (ret < 0) then
    ? "failed set_rate_near":goto Alsa_Init_Error
  elseif (ret > 0) then
    tmp->Speed=ret
  end if
  if tmp->Speed<>Speed then ? "warning: use speed";tmp->Speed

  ' set number of Frames
  ret = snd_pcm_hw_params_set_buffer_size_near(htmp, hw, @tmp->nFrames)
  if (ret < 0) then ? "failed set_buffer_size_near":goto Alsa_Init_Error

  ' Chunks of Frames
  ret = snd_pcm_hw_params_set_periods_near(htmp, hw,@tmp->nPeriods, 0)
  if (ret < 0) then ? "failed set_periods_near":goto Alsa_Init_Error
  snd_pcm_hw_params_get_period_size(hw,@tmp->PeriodSize,@Direction)

  ' set the config
  ret = snd_pcm_hw_params(htmp,hw)
  if (ret < 0) then ? "failed hw_params":goto Alsa_Init_Error

  ret = snd_pcm_prepare(htmp)
  if (ret < 0) then ? "failed prepare":goto Alsa_Init_Error

Alsa_Init_Ok:
  tmp->Handle=htmp
  snd_pcm_hw_params_free hw
  return tmp

Alsa_Init_Error:
  if hw  <>0 then snd_pcm_hw_params_free hw
  if htmp<>0 then snd_pcm_close          htmp
  if tmp <>0 then deallocate             tmp
  return 0

end function

sub Alsa_Exit(byval pcm as snd_pcm_t ptr)
  if pcm=0 then exit sub
  ? snd_pcm_close(pcm)
end sub

sub Alsa_Info(byval player  as player_driver_t ptr)
  ? "Alsa_Info"
  ? "-------------------"
  if player=0 then ? "not init":exit sub
  ? "speed     :" ; player->Speed
  ? "bits      :" ; player->nBits
  ? "channels  :" ; player->nChannels
  ? "frames    :" ; player->nFrames
  ? "framesize :" ; player->FrameSize
  ? "chunks    :" ; player->nPeriods
  ? "chunksize :" ; player->PeriodSize
end sub

sub Alsa_Send(byval player as player_driver_t ptr,byval nBytes as integer)

  dim as integer ret,nFrames
  dim as any ptr lpStart,lpEnd

  if player             =0 then exit sub
  if player->Handle     =0 then exit sub
  if player->Buffer.ptr8=0 then exit sub
  if nBytes             <1 then exit sub

  nFrames  = nBytes \ Player->FrameSize
  lpStart=Player->Buffer.ptr8
  lpEnd  =Player->Buffer.ptr8+nBytes

  while(lpStart<lpEnd)
    ret = snd_pcm_writei(Player->Handle,lpStart,nFrames)

    if (ret=-EAGAIN) then
      ' device busy
    elseif (ret=-ESTRPIPE) then
      ret=-EAGAIN
      while ret=-EAGAIN:ret=snd_pcm_resume(Player->Handle):wend
    elseif (ret=-EPIPE) then

    else
      if (ret<0) then  ? "failed send audiodata"
      if snd_pcm_prepare(Player->Handle) < 0 then exit sub
      nFrames-=ret:lpStart+=ret*Player->FrameSize
    endif
  wend
end sub


'
' main
'
dim as player_driver_t ptr player
dim as integer i,l,r



' !!!! please test all this configs !!!!

'Player=Alsa_Init(device,12000, 8,1,2048)
'Player=Alsa_Init(device,24000, 8,2,2048)
'Player=Alsa_Init(device,44100,16,1,2048)
Player=Alsa_Init(device,44100,16,2,2048)



if Player=0 then goto test_exist

Alsa_Info Player

player->Buffer.ptr8=allocate(Player->nFrames*Player->FrameSize)

? "Buffer_Init"
if Player->nBits=8 then
  ? "8Bit"
  if Player->nChannels=1 then
    ? "mono"
    for i=0 to Player->nFrames-1
      player->Buffer.ptr8[i  ]=l:l+=1:if l>64 then l=-64
    next
  else
    ? "stereo"
    for i=0 to Player->nFrames*Player->nChannels - 1 step 2
      player->Buffer.ptr8[i  ]=l:l+=1:if l>64 then l=-64
      player->Buffer.ptr8[i+1]=r:r+=3:if r>64 then r=-64
    next
  end if
else
  ? "16Bit"
  if Player->nChannels=1 then
    ? "mono"
    for i=0 to Player->nFrames - 1
      player->Buffer.ptr16[i  ]=l:l+=100:if l>5000 then l=-5000
    next
  else
    ? "stereo"
    for i=0 to Player->nFrames*Player->nChannels - 1 step 2
      player->Buffer.ptr16[i  ]=l:l+=100:if l>5000 then l=-5000
      player->Buffer.ptr16[i+1]=r:r+=30:if r>5000 then r=-5000
    next
  end if
end if

? "Alsa_Send"
for i=1 to 10
  Alsa_Send player,Player->nFrames*Player->FrameSize
next



test_exist:
sleep

end
Nach oben
Michael Frey



Anmeldungsdatum: 18.12.2004
Beiträge: 2577
Wohnort: Schweiz

BeitragVerfasst am: 22.01.2006, 18:44    Titel: Antworten mit Zitat

peinlich
Post solche sachen bitte das nächste mal bei http://fb.exp-soft.de/fbnp/ ...
_________________
http://de.wikibooks.org/wiki/FreeBasic Jede Hilfe für dieses Buch ist Willkommen!
http://de.wikibooks.org/wiki/FreeBasic:_FAQ FAQ zu Freebasic (im Aufbau, hilfe Willkommen)
Neu mit Syntax Highlight
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden E-Mail senden Website dieses Benutzers besuchen
MisterD



Anmeldungsdatum: 10.09.2004
Beiträge: 3071
Wohnort: bei Darmstadt

BeitragVerfasst am: 22.01.2006, 19:51    Titel: Antworten mit Zitat

nä das nimmter da nich, das is zu groß. NoPaste is für Codesnippets, nicht für gigantische programmcodes. So teile gehören einfach als bas gespeichert auf nen server und dann verlinkt..
_________________
"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
Edsger W. Dijkstra
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
Michael Frey



Anmeldungsdatum: 18.12.2004
Beiträge: 2577
Wohnort: Schweiz

BeitragVerfasst am: 22.01.2006, 19:57    Titel: Antworten mit Zitat

Oder in ein anderes Forum grinsen
Dort hat der Admin sicher nichts dagegen.
_________________
http://de.wikibooks.org/wiki/FreeBasic Jede Hilfe für dieses Buch ist Willkommen!
http://de.wikibooks.org/wiki/FreeBasic:_FAQ FAQ zu Freebasic (im Aufbau, hilfe Willkommen)
Neu mit Syntax Highlight
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden E-Mail senden Website dieses Benutzers besuchen
Pille



Anmeldungsdatum: 27.09.2004
Beiträge: 248
Wohnort: BW/ Deuschland

BeitragVerfasst am: 22.01.2006, 21:00    Titel: Antworten mit Zitat

kanns leider net compilen irgendwas mit sound not found, aber wenn du mir die .out datei schickst kann ichs testen...
_________________
Skilltronic hat Folgendes geschrieben:
Schliesslich hat sich schon die Steinzeitfrau zu hause in der Höle um Kinder, Küche und Kulthandlungen gekümmert, während der Mann draussen in der Wildnis Software entwickelte.
Nach oben
Benutzer-Profile anzeigen Private Nachricht senden
d.j.peters
Gast





BeitragVerfasst am: 23.01.2006, 07:43    Titel: Antworten mit Zitat

Hallo Pille,
ich hoffe nun das Problem gefunden zu haben aber danke das Du es versucht hast zu testen.

Grüsse Joshy

PS. Wenn Du statische Libs unter Linux mit FB linken/benutzen möchtest dann benötigst du immer die dev (developer) Pakete. zB. inclib "asound" ist nicht libasound.so sondern libasound.a of ist das schon alles mit installiert aber FB kann die lib nicht finden. Dann hilft fbc -p /path/zurlib dasprogramm.bas
Nach oben
Beiträge der letzten Zeit anzeigen:   
Neues Thema eröffnen   Neue Antwort erstellen    Das deutsche QBasic- und FreeBASIC-Forum Foren-Übersicht -> Linux-spezifische Fragen Alle Zeiten sind GMT + 1 Stunde
Seite 1 von 1

 
Gehe zu:  
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.

 Impressum :: Datenschutz