News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_mr_lou

Convert WAV to CPC sound effects

Started by mr_lou, 19:10, 01 January 20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mr_lou

So I've had this idea for a long time, but only took a deeper look at it today.

The idea: Take a WAV file with the sound of a bird, and convert it to a CPC sound effect.

So I found this one: https://soundbible.com/grab.php?id=1240&type=wav
A baby chick.

Then wrote a simple Java app to read the file and find the periods. Extremely simple stuff.
Then turn each period into a SOUND command.
The result is pretty nice I think. Definitely sounds like a bird to me on the CPC:


10 SOUND 1,18,1,0
20 SOUND 1,18,1,0
30 SOUND 1,17,1,0
40 SOUND 1,18,1,0
50 SOUND 1,17,1,1
60 SOUND 1,18,1,1
70 SOUND 1,18,1,3
80 SOUND 1,17,1,4
90 SOUND 1,17,1,5
100 SOUND 1,17,1,6
110 SOUND 1,17,1,7
120 SOUND 1,18,1,7
130 SOUND 1,18,1,5
140 SOUND 1,18,1,8
150 SOUND 1,20,1,7
160 SOUND 1,20,1,4
170 SOUND 1,21,1,5
180 SOUND 1,20,1,3
190 SOUND 1,18,1,2
200 SOUND 1,19,1,2
210 SOUND 1,18,1,1
220 SOUND 1,19,1,1
230 SOUND 1,19,1,1
240 SOUND 1,19,1,0
250 SOUND 1,18,1,0
260 SOUND 1,19,1,0
270 SOUND 1,19,1,0
280 SOUND 1,20,1,0
290 SOUND 1,98,1,0
300 SOUND 1,16,1,0
310 SOUND 1,15,1,0
320 SOUND 1,17,1,0
330 SOUND 1,15,1,0
340 SOUND 1,15,1,0
350 SOUND 1,15,1,0
360 SOUND 1,15,1,1
370 SOUND 1,15,1,2
380 SOUND 1,16,1,5
390 SOUND 1,16,1,7
400 SOUND 1,16,1,7
410 SOUND 1,16,1,7
420 SOUND 1,17,1,9
430 SOUND 1,17,1,9
440 SOUND 1,17,1,8
450 SOUND 1,17,1,8
460 SOUND 1,18,1,11
470 SOUND 1,18,1,13
480 SOUND 1,18,1,13
490 SOUND 1,19,1,9
500 SOUND 1,19,1,8
510 SOUND 1,20,1,5
520 SOUND 1,17,1,4
530 SOUND 1,17,1,1
540 SOUND 1,30,1,1
550 SOUND 1,19,1,0
560 SOUND 1,17,1,0
570 SOUND 1,16,1,0
580 SOUND 1,19,1,0
590 SOUND 1,18,1,0
600 SOUND 1,20,1,0
610 SOUND 1,18,1,0
620 SOUND 1,17,1,0
630 SOUND 1,17,1,0
640 SOUND 1,56,1,0
650 SOUND 1,14,1,0
660 SOUND 1,12,1,0
670 SOUND 1,13,1,0
680 SOUND 1,12,1,0
690 SOUND 1,12,1,2
700 SOUND 1,12,1,2
710 SOUND 1,13,1,2
720 SOUND 1,13,1,2
730 SOUND 1,13,1,2
740 SOUND 1,14,1,2
750 SOUND 1,14,1,1
760 SOUND 1,14,1,2
770 SOUND 1,15,1,2
780 SOUND 1,14,1,2
790 SOUND 1,15,1,2
800 SOUND 1,15,1,5
810 SOUND 1,15,1,6
820 SOUND 1,16,1,6
830 SOUND 1,16,1,8
840 SOUND 1,16,1,11
850 SOUND 1,16,1,10
860 SOUND 1,17,1,14
870 SOUND 1,17,1,14
880 SOUND 1,18,1,9
890 SOUND 1,17,1,8
900 SOUND 1,22,1,7
910 SOUND 1,20,1,5
920 SOUND 1,21,1,4
930 SOUND 1,17,1,1
940 SOUND 1,17,1,1
950 SOUND 1,16,1,1


This is just a rough demonstration of the concept of course. But I'm fairly sure it could be use to generate all kinds of sound effects.
Obviously BASIC isn't quite fast enough. In the above example I'm only using every 15th period or so. Maybe @Targhan can help generate Arkos Tracker sound effects so these sound effects can become useful in games.  :)

SkulleateR

This is cool  8)


Would love to see that app for Basic, since I got NO clue how to use the sound command for anything useful  :laugh:

AMSDOS

Would the MC SND REGISTER (&BD34) offer better Sound Effects from SOUND? The whole formatting is different from SOUND command though, and I only know of it's existance from a small Sound RSX Utility Type-in which produced some typical game noises.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

VincentGR

Holy crap!!!
I imagine that a human voice can sound like vocoder?  :o

Targhan

@mr_lou Interesting. But the hardest part is extracting the period. What algorithm is used by your Java app?
Also, it may work all right for straightforward sound like your bird chip, but what about more complex sound? I'm not sure it will work so fine.

Once you have the periods, it's easy to create an instrument from that directly with AT2. But many sound effects are more the simple period change, so I'm not sure such raw conversion would work 'out of the box', so in most cases, you would need to do the sound by hand in AT2.
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

mr_lou

Quote from: Targhan on 19:24, 04 January 20
@mr_lou Interesting. But the hardest part is extracting the period. What algorithm is used by your Java app?
Also, it may work all right for straightforward sound like your bird chip, but what about more complex sound? I'm not sure it will work so fine.

Once you have the periods, it's easy to create an instrument from that directly with AT2. But many sound effects are more the simple period change, so I'm not sure such raw conversion would work 'out of the box', so in most cases, you would need to do the sound by hand in AT2.

Very simple algorithm. It just checks for values above 0, and then when values are below 0 it knows that upon next positive value, it's a period / cycle.
Yes it will only work for very simple sound effects that sounds somewhat square-synth'ish in real life, like various bird sounds.
I imagine it could give a great effect when mixed with noise sound effect resembling "wind in trees".  :)
Would be great for a Knytt-like game.

Token


mr_lou

Quote from: Token on 19:52, 04 January 20
I like that anyway.
Maybe with more voices :)
https://www.youtube.com/watch?v=-6e2c0v4sBM

Hah! That's pretty cool!

Theoretically, we could make slightly better sfx by using all 3 channels at the same time - but nothing grand.

Sound is basically "just" a bunch of waves - and smaller waves in bigger waves.

Using all 3 channels, we can produce smaller waves in bigger waves on the CPC just fine - except it'll always only be square waves.

But we should be able to produce something interesting. We "just" need an algorithm that can analyse a sound, and produce "the big wave sequence" and "the smaller wave sequence".
Then play the big wave sequence in channel 2, while the smaller wave sequence plays in channel 1 + 4.

Singaja

Isn't finding the square wave approximation conceptually something like this?

https://www.youtube.com/watch?v=WTD8jg8fXoE

jaymanu

you could use DATA for code compacity :
for t=1 to 95 : read a,b : sound 1,a,1,b : next

Powered by SMFPacks Menu Editor Mod