r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Sound] discussion about sound and audio implementation in REBOL

Rebolek
15-Sep-2005
[108x8]
print "Play a ping sound..." ; (init event system too)

    ; Generate a ping waveform as a binary value:
    ping: #{}
    for amplitude 500 1 -1 [
        for phase 1 360 16 [
            val: 128 + to-integer 127 * sine phase
            val: amplitude * val / 500
            append ping to-char val
            ;append ping to-char 256 - val
        ]
    ]

    ; Set up the sound sample parameters:
    sample: make sound [
        rate: 44100 / 2
        channels: 1
        bits: 8
        volume: 0.5
        data: #{}
    ]

    ; Make the ping sound 10 times:
    loop 10 [append sample/data ping]

    ; Play the sound now:
    sound-port: open sound://
    insert sound-port sample
    wait sound-port
    close sound-port
this is mono example - plays ping sound
print "Play a ping sound..." ; (init event system too)

    ; Generate a ping waveform as a binary value:
    ping: #{}
    for amplitude 500 1 -1 [
        for phase 1 360 16 [
            val: 128 + to-integer 127 * sine phase
            val: amplitude * val / 500
            append ping to-char val
            append ping to-char 256 - val
        ]
    ]

    ; Set up the sound sample parameters:
    sample: make sound [
        rate: 44100 / 2
        channels: 2
        bits: 8
        volume: 0.5
        data: #{}
    ]

    ; Make the ping sound 10 times:
    loop 10 [append sample/data ping]

    ; Play the sound now:
    sound-port: open sound://
    insert sound-port sample
    wait sound-port
    close sound-port
This is stereo example - plays nothing
if you look at sample/data after inserting sample to sound:// they're 
changed
>> sample/data
== #{
827EA55BC53BDF21F30DFD03FE02F40CE21EC838A957867A649C43BD27D911EF
05FB02FE08F818E831CF4FB1718F817EA45BC43BDE21F20DFC03FD02F30C...
>> insert sound-port sample
== 115000
>> sample/data
== #{
80808080808080808080808080808080808080808080807F7F7F7F7F7F7F7F7F
7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F7F...
Another thing - REBOL sounds different compared to other players. 
It's noisy and dull. I've got 44100Hz/16bit sound and it sound's 
more like 22050/8bit to my ear.
Pekr
15-Sep-2005
[116x2]
simply put, rebol sound quality and buggy behavior deserves to be 
put into trashcan ;-)
now let's convince Carl, that as AGG was good choice for vectors, 
we should find another library for sound. Maybe fmod?
Rebolek
15-Sep-2005
[118]
fmod? why not. but who's going to pay the license?
Pekr
15-Sep-2005
[119x2]
RT's investor? :-) First I would try to talk to those folks, then 
to speculate about how much it will be. Maybe there is some amigan 
inside the group :-)
the question is - AGG for vectors, is one of two best free libraries 
- Cairo and AGG ... so - how is fmod quality wise? Is there any better, 
smaller library to have?
Ingo
15-Sep-2005
[121x2]
It seems sound data is only changed on first insert, though.
Btw, I get different values, and the stereo version plays a sound 
for me
Rebolek
15-Sep-2005
[123x2]
Probably depends on sound hardware, because I've testing this previously 
and I was getting different results on my home computer and my work 
computer
Anyway, I think it's bad behaviour. The data should remain same (the 
can be changed internaly when playing but users must see same data).
Ingo
15-Sep-2005
[125x2]
Yes, that may be the case.
Well, whatever, sound in Rebol seems to be more or less unusable.
Romano
15-Sep-2005
[127]
Here under XP and REBOL/View 1.3.1.3.1, both example (mono and stereo) 
work, 2 sample/data is not changed after insert.
Rebolek
15-Sep-2005
[128x6]
Romano I think it does not depend on system version but on soundcard 
(or drivers probably)
REBOL does definitely play sounds in 22kHz/8bit. You can hear the 
quantisation noise in low volume and everything sounds so filtered.
I've got some Intel chipset soundcard in work, but here at home I've 
got M-Audio Delta 1010LT and the results are same (sound results, 
sample/data looks different).
It's really problem, but on the other hand, I can hear that Sintezar 
is much much better with sound than I thought on listening test done 
in REBOL :)
BTW, WAV saver is ready, so I'll do some demo-sounds and fixes and 
release it ASAP ;)
http://krutek.info/pix/PM101.png(work in progress)
Volker
15-Sep-2005
[134]
seems you could post some sounds now? :)
Rebolek
17-Sep-2005
[135x2]
I said that REBOL plays sound in 22kHz/8bit, but that's not true. 
At least here, after some tests I'm pretty sure that it's 11kHz/8bit.
I've got some demo-sounds ready, I'll post them today or tomorrow.
Rebolek
18-Sep-2005
[137x2]
14 demo sounds - http://krutek.info/rebol/sounds1.zip
(don't expect that 'bell' sounds like bell, 'violin' like violin 
and so on. it's just a name :-)
Kaj
18-Sep-2005
[139]
That which we call a siren, by any other name would sound as sweet?
Rebolek
18-Sep-2005
[140]
:)
Rebolek
2-Feb-2006
[141x7]
I said I'll release Sintezar after Competition. Compo is over, so, 
I'm releasing it :) Download it from http://krutek.info/rebol/SintezarPM101.ZIP
. Unpack it somewhere and run %sintezar_pm-101.r I hope it should 
work.
It's pretty sub-alpha version. Some buttons do not work, some buttons 
crash the application. I know that so you do not have to report bugs, 
it's full of them.
Anyway, it works. In the bottom row, there are six buttons. Press 
second button (load sound) and go to %sounds/ directory. Select a 
sound and open it.
Then press fifth button (compute sound) and wait. Press last button 
(play sound, looks like triangle) and it should play a sound.
You can change waves, adjust modulation, filter, envelopes, wave 
shaper, bit crusher and so on...
There's also some unfinished documentation included. Things that 
does not work: init sound (first button), LFO (black square button 
right to envelope button) and playing empty sound. That's what I 
remember for sure. But editing sound, creating, saving to own format 
and exporting to WAV works. Have fun.
Oh, and the Melody button does not work too.
Thør
4-Apr-2006
[148]
.
Josh
23-Jun-2006
[149]
There isn't a way to do sound input directly from rebol is there?
james_nak
23-Jun-2006
[150]
Nice Rebolek!
Anton
24-Jun-2006
[151]
Josh, recording ? There are only OS specific ways so far.
Sunanda
17-Jun-2008
[152]
Can any one help me reply to this question (received via REBOL.org's 
feedback form)?
Thanks!
<<
Where can I find more Hex Code like in psg-ay-3-8910-study.r

Please point me to a tool that I can use for development of  Sound 
Code for the AY-3-8910 where I end up with Hex Code that I can then 
load into EPROMs which would drive the AY-3-8910. Thanks for any 
help.

http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=psg-ay-3-8910-study.r
>>
Steeve
17-Jun-2008
[153]
I got the data using a free MSX emulator (openMSX). The music come 
from the game "Auf wiedersehen Monty".

You can use a "dump PSG" functionality in openMSX to get the raw 
data (values of the registers of the PSG).

You can find lot of roms (games) for the msx wich contain cool musics 
and effects for the AY PSG on www.planetemu.net

Beware, these roms are not freeware even if you can download them 
freely.


Another way (i have not tried), is to use VortexTracker at http://bulba.at.kz/
(see http://www.youtube.com/watch?v=lYdIqcqgkPMfor a demo)

wich is well designed to compose an manipulate raw data for the AY-* 
PSG.
I think many samples are given too.
amacleod
15-Mar-2009
[154x3]
Any reason I can play pre-recorded .wav files but if try to make 
my own they do not work:

** Access Error: Bad image data
** Where: narrate
** Near: insert sound-port load talk
i've tried several .wav recording/converting software...no change.
Tried changing the sample rates, channels etc...no difference. 

I know you should not use compression but I'm pretty sure I'm not.
Gregg
16-Mar-2009
[157]
How are you creating them Alan, and what specs? Try generic 44.1Khz 
stereo.