Author Topic: Convert WAV to CPC sound effects  (Read 660 times)

0 Members and 1 Guest are viewing this topic.

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 3.023
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 1189
  • Likes Given: 2414
Convert WAV to CPC sound effects
« on: 20:10, 01 January 20 »
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:

Code: [Select]
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.  :)

Offline SkulleateR

  • CPC6128
  • ****
  • Posts: 163
  • Country: de
  • Liked: 81
  • Likes Given: 52
Re: Convert WAV to CPC sound effects
« Reply #1 on: 10:40, 02 January 20 »
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:

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.768
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1016
  • Likes Given: 1725
Re: Convert WAV to CPC sound effects
« Reply #2 on: 12:28, 02 January 20 »
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

Offline VincentGR

  • 6128 Plus
  • ******
  • Posts: 1.197
  • Country: gr
    • Parts from the past.
  • Liked: 677
  • Likes Given: 1716
Re: Convert WAV to CPC sound effects
« Reply #3 on: 19:26, 02 January 20 »
Holy crap!!!
I imagine that a human voice can sound like vocoder?  :o

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.034
  • Country: fr
  • Liked: 983
  • Likes Given: 144
Re: Convert WAV to CPC sound effects
« Reply #4 on: 20: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.
Targhan/Arkos

Arkos Tracker 2 - alpha 8 now released! - Follow the news on Twitter!
Disark A cross-platform Z80 disassembler/source converter

Imperial Mahjong
Orion Prime

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 3.023
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 1189
  • Likes Given: 2414
Re: Convert WAV to CPC sound effects
« Reply #5 on: 20:40, 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.

Offline Token

  • 464 Plus
  • *****
  • Posts: 387
  • Country: fr
  • Liked: 144
  • Likes Given: 372
Re: Convert WAV to CPC sound effects
« Reply #6 on: 20:52, 04 January 20 »
I like that anyway.
Maybe with more voices :)
https://www.youtube.com/watch?v=-6e2c0v4sBM


Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 3.023
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 1189
  • Likes Given: 2414
Re: Convert WAV to CPC sound effects
« Reply #7 on: 21:34, 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.

Offline Singaja

  • CPC6128
  • ****
  • Posts: 169
  • Country: pl
  • Liked: 113
  • Likes Given: 525
Re: Convert WAV to CPC sound effects
« Reply #8 on: 17:48, 22 January 20 »
Isn't finding the square wave approximation conceptually something like this?

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

Offline jaymanu

  • CPC464
  • **
  • Posts: 38
  • Country: fr
  • Liked: 35
  • Likes Given: 1
Re: Convert WAV to CPC sound effects
« Reply #9 on: 16:00, 29 January 20 »
you could use DATA for code compacity :
for t=1 to 95 : read a,b : sound 1,a,1,b : next