Hi, does anyone have a best cpc 4 bit or near 4 bit sample playback function for both cpx and plus machines from 8bit data which incan incorporate into the streamer UniDOS node. I only know how to code 1bit sample playback and... I'd rather better. Thanks
https://www.cpcwiki.eu/forum/programming/(tool)-wav-melody-to-psg-conversion/msg196507/#msg196507 maybe this ::)
I'm planning on doing something like this. I get about 6 bits from dithering on 4 PSG bits, but if the resistors are of a different value than in the diagram, and they probably are on each CPC, the result will be different.
Also, you can directly use 8 Bit Sample PlayBack. The LambdaSpeak contains an Amdrum emulation - which is in effect an 8 bit sample play engine. :)
I assume you are looking for a pure software-based solution. If you have 8 bit unsigned sample data, you could use the routine by Gasman (attached to the post) to convert the values to 4 bit AY volumes. If the values are signed, you have to convert them before you can use this routine. If you already have 4 bit values, you could just as well send them to the AY as-is and don't need to convert. I think that the best sample playback on the CPC is based on 1) a stable (i.e. each sample is output at exactly the same interval) and 2) a as-high-as-possible playback-rate (to shift aliasing up the frequency band) and 3) using only one AY channel to avoid the cost of switching volume-registers during replay, which has a negative impact on 2). Don't know how the streamer UniDOS node plays into all of this, though.
Quote from: BSC on 18:28, 17 February 24you could use the routine by Gasman (attached to the post) to convert the values to 4 bit AY volumes.
Here is a shorter version (< 1/3 the size):
;### SMPCNV -> generates table for 8bit unsigned sample playback on a 4bit PSG volume register
;### Input DE=256byte aligned table
;### Destroyed AF,B,HL
smpcnvt db 2,3,2,3,4,5,10,11,16,24,23,28,30,36,39,20
smpcnv xor a
ld hl,smpcnvt
smpcnv1 ld b,(hl)
smpcnv2 ld (de),a
inc e
ret z
djnz smpcnv2
inc hl
inc a
jr smpcnv1
Quote from: BSC on 18:28, 17 February 24Don't know how the streamer UniDOS node plays into all of this, though.
Nothing :D
The streamer unidos node, the purpose is to expose some drivers jn a way that are easy to use through streams. The rom is now on github and is proven to work, but it is far from finished. Currently it has amdrum 8 bit sample playback, it is very basic with a hardcoded bit rate but I will change it to take a versioned header in the stream.
Different devices are grouped as virtual folders within the virtual devices, e.g. audio: device currently has ram music machine and amdrum folders. A simple copy of a sample file to a stream will play it. The good thing about this approach is that lots of devices can be added without reducing HIMEM and they will be inbthe case of the audio DAC playback, interchangeable. Ay3892, asic, amdrum, mmachine... whichever hardware the user has, a game for example can write it to the user configured stream. Likewise with speech, graphics (crtc and v9990 sprite and tile engines, vector graphics too).
I have head cpc sample playback on plus machines and cpcs way beyond the quality my coding has been able, so why not incorporate the best routines where possible in the streamer node.