News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Ygdrazil

Where to find conversion tool sound!

Started by Ygdrazil, 22:30, 16 December 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ygdrazil

Hi friends


I am exploring the sound capabilities of the CPC. A topic that I have neglected for so many years. Especially the ability to playback samples on the CPC.


There is a code example on how to playback a WAV file on http://www.cpctech.org.uk/


In the comments is stated that a need a tool to convert the WAV file into a format the can be processed be the example.


Where do i find this tool?... The source states that it is made by Marcus(!)


Hope someone can help!


Regards,
Ygdrazil


From the comments of the example:

;; This code demonstrates how to do sample playback;; on the Amstrad CPC. ;;
;; It has "drivers" for Digiblaster/Soundplayer, Amdrum and the internal
;; AY-3-8912 soundchip of the CPC.
;;
;; The samples are stored as 8-bit mono signed, suitable for playing direct
;; to digiblaster. (Note the printer hardware inverts bit 7, so the digiblaster actually ends
;; up playing unsigned mono samples).
;;
;; The CPC doesn't have an interrupt that can be reprogrammed to any rate,
;; so to playback samples we have to use software loops to control the playback
;; rate. This also means the CPU is effectively 100% used.
;; The timing of each instruction is therefore important. You will see the timings
;; for each instruction written between these brackets []. e.g. [3]
;;
;; It is possible to use the delay time between writing data to each "device" to
;; perform other operations, but this is not shown in this example.
;;
;; This code initialises some RSX commands that can be used direct from
;; BASIC.
;;
;; You are advised to use the tools from Devilmarkus for converting samples
;; from the PC or other system to a form that this player can use.
;; Use Markus's tools for conversion and ensure "invert sample" is checked.
;; Process:
;; Take an 8-bit unsigned mono WAV.
;; Convert to 8-bit signed mono raw data.
;; When played to digiblaster, the printer port hardware will invert bit 7
;; automatically making the sample unsigned again and then the digiblaster will convert this to analogue.
;; firmware function KL LOG EXT to register RSX commands kl_log_ext: equ &bcd1 
;; this can be any address in the range &0040-&a7ff.



roudoudou

The thing to do is to translate 8bits unsigned values to 4bits
And remove the wav header.
You may work with raw 8bits sound file to avoid wav shit
Pay attention that 4bits levels are not linear
There is a conversion formula on cpctech too
In the end you may also pack two values in one byte to gain space

Ygdrazil


[size=78%]Many thanks..[/size]


Regards,
/Ygdrazil

Quote from: roudoudou on 09:19, 17 December 16
The thing to do is to translate 8bits unsigned values to 4bits
And remove the wav header.
You may work with raw 8bits sound file to avoid wav shit
Pay attention that 4bits levels are not linear
There is a conversion formula on cpctech too
In the end you may also pack two values in one byte to gain space

roudoudou

this is the 256 table values for converting output levels according to theorical formula
please note that this is ONE of the possibilities
i heard some people do not use values greater than 12 to avoid the huge precision gap with low values

anyway you have to test differents conversions and keep the best audio result!



ConversionFromRAW8
defs 3,1
defb 2,3,4,4,5,5,6,6,6
defs 5,7defs 6,8
defs 10,9defs 13,10
defs 19,11
defs 26,12
defs 37,13
defs 53,14
defs 75,15

fgbrain


The MSX guys have made it 10 years ago...
Crystal clean PCM 8bit samples on our poor old PSG are possible!!
Problem was that the encoding required was possible using PC only.


Anyway, the encoder exists and it converts a wave file to optimal PSG channel transitions using a Viterbi algorithm.
Still, nobody made a player on CPC or plus using this yet..

Is it not possible?? 
_____

6128 (UK keyboard, Crtc type 0/2), 6128+ (UK keyboard), 3.5" and 5.25" drives, Reset switch and Digiblaster (selfmade), Inicron Romram box, Bryce Megaflash, SVideo & PS/2 mouse, , Magnum Lightgun, X-MEM, X4 Board, C4CPC, Multiface2 X4, RTC X4 and Gotek USB Floppy emulator.

TotO

Quote from: fgbrain on 18:50, 17 December 16
The MSX guys have made it 10 years ago...
Crystal clean PCM 8bit samples on our poor old PSG are possible!!
Problem was that the encoding required was possible using PC only.


Anyway, the encoder exists and it converts a wave file to optimal PSG channel transitions using a Viterbi algorithm.
Still, nobody made a player on CPC or plus using this yet..

Is it not possible??
Sure, it is the best way to do that and it work fine on CPC and great with the PlayCity.
I have expected that SF2 remake will use that... It is not too late.  ;)
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

roudoudou

Didn't know


Is the algo explained anywhere?


It would be veeeeery interresting!

roudoudou

Quote from: fgbrain on 18:50, 17 December 16
Anyway, the encoder exists and it converts a wave file to optimal PSG channel transitions using a Viterbi algorithm.
Still, nobody made a player on CPC or plus using this yet..

Is it not possible??


I found the MSX crystal clear encoder source here: https://github.com/maxim-zhao/pcmenc/blob/master/encoder/pcmenc.cpp


So i take a look at the method


We talk a long time ago of using more than one channel in order to gain precision but using PSG on CPC is very slow, on the CPC+ too


It may be possible to achieve cool results on the CPC+ with nasty tricks (make an extra HBL in the middle of the screen and force DMA to run at 30Khz instead of 15Khz)




Shining

Little bit played around with pcmenc today.


Needs Parados and 512kB 8Sould run with 256kB,too but was not tested).


run"disk
TGS is back

Download my productions at:
cpc.scifinet.org

Powered by SMFPacks Menu Editor Mod