[Solved] Sound advise
Posted
#1
(In Topic #1100)
Enthusiast

so I need someone who is smarter then me (so that is everyone lol)
I have a slight issue that I am not sure how to sort out
I can run this command with in Gambas
and it works fine but when I run
Code (gambas)
- shell "play -n synth 0.1 sine 880 vol 5"
i get nothing but when run the play command with in a terminal i get a nice loud beep
SO am I doing something wrong here or am i missing a command that i need to use?
Any ideas are MOST welcomed
Posted
Guru

Posted
Regular

You need to activate <COLOR color="#800000">gb.openal</COLOR> Component:
Code (gambas)
- ' Configures the device and the audio context with the "Alc" Class:
- cont = Alc.CreateContext(disp)
- err = cont.MakeCurrent()
- src = Al.GenSources(1)
- ' Configures the audio buffer:
- buffer = Al.GenBuffers(1)
- Wave(data)
- ' The audio data is loaded into the audio buffer:
- Al.BufferData(buffer[0], 4352, data.Data, data.Count, DIGIT)
- ' Connects the audio buffer to the audio source:
- Al.Sourcei(src[0], Al.BUFFER, buffer[0])
- ' Play the audio source:
- Al.SourcePlay(src[0])
- ' Allows performance for the entire duration of the sound wave:
- Wait TEMPUS
- ' Releases the memory:
- Al.DeleteBuffers(buffer)
- Al.DeleteSources(src)
- Alc.DestroyContext(cont)
- Alc.CloseDevice(disp)
or by using <COLOR color="#800000">gb.media</COLOR> resources:
Code (gambas)
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

There is no need for = Null, you could have just followed the equal sign with "speaker - test -t…..". Better still: -
Code (gambas)
- Shell "speaker-test -t sine -f 1000 -l 1 & sleep .2 && kill -9 $!"
************************************
Code (gambas)
shell "play -n synth 0.1 sine 880 vol 5"
You are correct, it doesn't work, and I have no idea why.
If you want to make sounds in Gambas, I suggest you make a recoding of what you want or get one from the internet, there are plenty of sites with free sounds you can download. You can then use code as below: -
Posted
Enthusiast

cogier said
There is no need for = Null, you could have just followed the equal sign with "speaker - test -t…..". Better still: -Which works for meCode (gambas)
Shell "speaker-test -t sine -f 1000 -l 1 & sleep .2 && kill -9 $!"
************************************
Code (gambas)
shell "play -n synth 0.1 sine 880 vol 5"
You are correct, it doesn't work, and I have no idea why.
If you want to make sounds in Gambas, I suggest you make a recoding of what you want or get one from the internet, there are plenty of sites with free sounds you can download. You can then use code as below: -
The problem with the above is the systems I am using do not have any sound cards on them they only have the PC speaker.
Posted
Regular

play -V3 -n synth 0.1 sine 880 vol 0.4
vol 5 means 5 times the normal volume which clips to a DC voltage.
Posted
Regular

Have you tried the :? old ways…AndyGable said
…do not have any sound cards on them they only have the PC speaker.
Code (gambas)
- Print "\x07"
Code (gambas)
- Shell "printf '\x07'"
Code (gambas)
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Enthusiast

thatbruce said
Try:
play -V3 -n synth 0.1 sine 880 vol 0.4
vol 5 means 5 times the normal volume which clips to a DC voltage.
I tried this one and I got the following show up in the console of the Gambas enveroment.
Code (gambas)
- play WARN alsa: can't encode 0-bit Unknown or not applicable
- play: SoX v14.4.2
- play INFO nulfile: sample rate not specified; using 48000
- Channels : 1
- Sample Rate : 48000
- Precision : 32-bit
- Channels : 1
- Sample Rate : 48000
- Precision : 32-bit
- Endian Type : little
- Reverse Nibbles: no
- Reverse Bits : no
- play INFO sox: effects chain: input 48000Hz 1 channels
- play INFO sox: effects chain: synth 48000Hz 1 channels
- play INFO sox: effects chain: vol 48000Hz 1 channels
- play INFO sox: effects chain: output 48000Hz 1 channels
and no sound
Posted
Enthusiast

vuott said
Yes I did try the above the \x07 just flashed the screen at me and no sound and the other asked for my password and then errored out at Error !
Posted
Regular

Posted
Enthusiast

vuott said
I have tried your recommendation but I kept getting a error
ERROR: #63: '&1.&2' is incorrectly overridden in class '&3'|Screen|Height|Screen
If I remove the gb.ncurses the application runs with no issues.
Posted
Regular

You have to use "gb.ncurses" with a command line interface project (no graphics Components):AndyGable said
ERROR: #63: '&1.&2' is incorrectly overridden in class '&3'|Screen|Height|Screen
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Enthusiast

Posted
Regular

Does it work ?
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Regular

AndyGable said
thatbruce said
Try:
play -V3 -n synth 0.1 sine 880 vol 0.4
vol 5 means 5 times the normal volume which clips to a DC voltage.
I tried this one and I got the following show up in the console of the Gambas enveroment.Code (gambas)
play WARN alsa: can't encode 0-bit Unknown or not applicable play: SoX v14.4.2 play INFO nulfile: sample rate not specified; using 48000 Channels : 1 Sample Rate : 48000 Precision : 32-bit Channels : 1 Sample Rate : 48000 Precision : 32-bit Endian Type : little Reverse Nibbles: no Reverse Bits : no play INFO sox: effects chain: input 48000Hz 1 channels play INFO sox: effects chain: synth 48000Hz 1 channels play INFO sox: effects chain: vol 48000Hz 1 channels play INFO sox: effects chain: output 48000Hz 1 channels
and no sound
OK, That's almost exactly what I get, with the beep very audible. The only difference is
Output File : 'default' (pulseaudio)
Do you have pulseaudio installed. (I have no idea why it should be needed, btw)
tb
OOPS! I also get this at the end:
In:0.00% 00:00:00.17 [00:00:00.00] Out:4.80k [ -===‡===- ] Clip:0
Done.
Posted
Regular

Try C3 523.25Hz
Posted
Guru

sudo apt install beep
beep
Posted
Enthusiast

BruceSteers said
How about installing beep?
sudo apt install beep
beep
Yea I did that and and it worked but it was the quietest beep ever lol
I need to work out how to beep the Dynakey built in speaker and not the one on the motherboard now I can make the beep sound.
Posted
Guru

AndyGable said
cogier said
There is no need for = Null, you could have just followed the equal sign with "speaker - test -t…..". Better still: -Which works for meCode (gambas)
Shell "speaker-test -t sine -f 1000 -l 1 & sleep .2 && kill -9 $!"
************************************
Code (gambas)
shell "play -n synth 0.1 sine 880 vol 5"
You are correct, it doesn't work, and I have no idea why.
The problem with the above is the systems I am using do not have any sound cards on them they only have the PC speaker.
Did you miss my post? It requires stdout or the play command does not exit so use "&" or "For Output" when using gambas Shell process then it can continue
Code (gambas)
- Shell "play -n synth 0.1 sine 880 &"
They both work fine here
Code (gambas)
- Shell "play -n synth 0.1 sine 880 2>/dev/null &"
Posted
Enthusiast

BruceSteers said
AndyGable said
cogier said
There is no need for = Null, you could have just followed the equal sign with "speaker - test -t…..". Better still: -Which works for meCode (gambas)
Shell "speaker-test -t sine -f 1000 -l 1 & sleep .2 && kill -9 $!"
************************************
You are correct, it doesn't work, and I have no idea why.
The problem with the above is the systems I am using do not have any sound cards on them they only have the PC speaker.
Did you miss my post? It requires stdout or the play command does not exit so use "&" or "For Output" when using gambas Shell process then it can continueorCode (gambas)
Shell "play -n synth 0.1 sine 880 &"
They both work fine hereif you want to divert the text output (stderr) to nullCode (gambas)
Shell "play -n synth 0.1 sine 880 2>/dev/null &"
Sorry Bruce I did miss your post
and it works perfectly
NOW If I am reading this information right
Speaker
The 5953 includes a built‐in speaker. By default, it sounds key clicks, but it can
be programmed to sound tones under control of the application program.
The speaker is tied to the speaker control of the host terminal so that whenever the
terminal speaker sounds, so does the 5953 speaker
I should not have to worry about the DynaKey Speaker it should work with the current Shell "play -n synth 0.1 sine 880" For Output. I will have to test this in the morning when I am near my NCR machine again and I will let you all know.
this is the NCR Dynakey Manual (https://manualzz.com/d…b-dynakey-user-manual#p15)
Posted
Regular

AndyGable said
Yea I did that and and it worked but it was the quietest beep ever lol
Fortunately not if you run this through a VT131 data terminal.
I implemented this code when I was trying to port a quick test program I wrote in Commodore Basic on my VIC-20 to modern Linux using Gambas (and Lazarus).
Code
Exec ["play", "-n", "synth", "1", "sine", Rnd(1, 500)]This will play a different tone each time.
1 guest and 0 members have just viewed this.


