News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_mr_lou

Can the CPC do this?

Started by mr_lou, 18:43, 30 September 11

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


TFM

Quote from: mr_lou on 18:43, 30 September 11
Can the CPC do this?


Yes, the CPC can do that, suggested help is the CPC-Booster+.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

norecess

I don't care actually if CPC can or can not do this.


But the real thing is : wow, this is awesome! The guys who thought about generating PCM such a way (and finding the right algorithm sounding good) are just pure geniouses !


Thanks for sharing this link.

Devilmarkus

Hmmm tried this in BASIC:
10 a=((t OR (t/512 OR t/128))*t AND (t/2048 OR t/512))
20 OUT &FF10,a
30 t=t+1
40 GOTO 10


But after a while I get an Overflow in 10
Whats wrong here?
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Cosi

Maybe the problem is that in BASIC t is represented as a long real number, while C "clears the counter" every time t reaches 65536.

(I'm not into Amstrad's BASIC, so please don't kill me if I'm wrong :) )

Devilmarkus

Quote from: Cosi on 10:37, 01 October 11
Maybe the problem is that in BASIC t is represented as a long real number, while C "clears the counter" every time t reaches 65536.

(I'm not into Amstrad's BASIC, so please don't kill me if I'm wrong :) )

Sure right,
but the Overflow happens when t=182  :'(
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Cosi

Well... :(

Could you please try to replace those divisions with integer divisions (int(x/y) or something)?

Devilmarkus

Sure, this makes no difference  ???
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

tastefulmrship

BASIC will not complete a logical expression with a number over 32767.

Devilmarkus

Quote from: tastefulmrship on 13:07, 01 October 11
BASIC will not complete a logical expression with a number over 32767.

I see... But why? This makes no sense :(
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

tastefulmrship

#10
Quote from: Devilmarkus on 13:34, 01 October 11
I see... But why? This makes no sense :(

PRINT 32768 AND 1 fails, but
PRINT &8000 AND 1 works fine.

Is this because BASIC treats numbers over 7FFF as negative; ie &8000 (-32768) to &FFFF (-1).

If you view this program in DEBUG, you'll see where I'm coming from... but why it refuses to complete logical expressions beyond my technical knowledge.

10 a=65535
20 b=&FFFF



EDIT: Here's a slightly updated version of Devilmarkus's BASIC program. This brings the value of t% to 255 before failing (due to numbers beyond FFFF).

10 WHILE t%<256
20 a$=HEX$((t% OR (t%/512 OR t%/128))*t%)
30 b$=HEX$(t% OR (t%/2048 OR t%/512))
40 c$=HEX$(VAL("&"+a$) AND VAL("&"+b$))
50 OUT &FF10,VAL("&"+c$)
60 t%=t%+1
70 WEND

And, of course, you can always add a PRINT statement in the routine to see what a$, b$, c$ and t% are doing as you require.

EDIT2: Is there a non-CPCBooster OUT command direct to the chip? WinAPE loves silence, but I don't.

Devilmarkus

Thankyou.
Tried it, also poked the values into RAM, and then played it through Amdrum / Digiblaster.
But sounds strange :D
10 adr=&1000
20 WHILE t%<256
30 a$=HEX$((t% OR (t%/512 OR t%/128))*t%)
40 b$=HEX$(t% OR (t%/2048 OR t%/512))
50 c$=HEX$(VAL("&"+a$) AND VAL("&"+b$))
60 POKE adr,VAL("&"+c$):adr=adr+1
70 t%=t%+1
80 WEND
90 FOR t=0 TO 255:OUT &FF10,PEEK(&1000+t):NEXT:GOTO 90

Amdrum! Digiblaster needs port &EF10

http://cpc-live.com/bastest

Perhaps an ASM playback routine would be clearer?

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

tastefulmrship

Yes, it needs a lot more samples than 256 to sound like those in the original one-liner, but it's surely getting there!
Maybe if someone could run a C program on PC that creates more samples, then take those results and play them through Amdrum or Digiblaster... but that's kinda missing the point!

If you amend the program with these lines
60 SOUND 1,VAL("&"+c$),10,15:SOUND 2,VAL("&"+c$)*10,10,15:SOUND 4,VAL("&"+c$),10,15
90 t%=0:GOTO 20
you get a pretty weird tune... which actually sounds quite good further in.

Devilmarkus

#13
Indeed...
Well I "tried" the routines shown in the video and combined 3 loops to a stereo sound.
Result: (Don't regard the "Ready", I quickly tweaked the audio routine, so no CPC was really used for!)
http://cpc-live.com/craptest

Code was like this:
        ppo++;
        if (ppo == 6) {
            r = ((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7));
            q = (t | (t >> 9 | t >> 7)) * t & (t >> 11 | t >> 9);
            p = ((t & 4096) != 0) ? ((t * (t ^ t % 255) | (t >> 4)) >> 1)
                    : (t >> 3) | (((t & 8192) != 0) ? t << 2 : t);
            t++;
            ppo = 0;
        }
        leftO = ((r & 0x07f) + (q & 0x07f));
        rightO = ((q & 0x07f) + (p & 0x07f));
        player.writeStereo(leftO ^ 0x80, rightO ^ 0x80);
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Goal should be a oneliner ;)
So in BASIC:
10 FOR t%=0 TO 255:a$=HEX$((t% OR (t%/512 OR t%/128))*t%):b$=HEX$(t% OR (t%/2048 OR t%/512)):c$=HEX$(VAL("&"+a$) AND VAL("&"+b$)):SOUND 3,VAL("&"+c$)*10,10,15:t%=t%+1:NEXT:GOTO 10

But it's really completely different :D
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

tastefulmrship

Quote from: Devilmarkus on 21:41, 01 October 11
        ppo++;
        if (ppo == 6) {
            r = ((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7));
            q = (t | (t >> 9 | t >> 7)) * t & (t >> 11 | t >> 9);
            p = ((t & 4096) != 0) ? ((t * (t ^ t % 255) | (t >> 4)) >> 1)
                    : (t >> 3) | (((t & 8192) != 0) ? t << 2 : t);
            t++;
            ppo = 0;
        }
        leftO = ((r & 0x07f) + (q & 0x07f));
        rightO = ((q & 0x07f) + (p & 0x07f));
        player.writeStereo(leftO ^ 0x80, rightO ^ 0x80);

Ok, what happens if you collate a number of results (I dunno, 1000? Maybe even 1000 per channel) from the above code on PC and copy them into CPC memory (as long as they are 8bit, of course), then play them through external audio hardware (Amdrum, Digiblaster)? Does it sound similar to the original? If so, all we need is assem code that can deal with numbers over &FFFF (possible?) and run it through PSG/external hardware.

Devilmarkus

Well, this could work...
Dunno... Who can code it?
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

tastefulmrship

Can you get get C code to send results to screen/file rather than to PCM?
I don't mind converting the results to CPC and seeing what happens...

If someone could get this programmed in assem, we could send it back to the 32/64 bit community before the C64 lot get their mitts on it! One-up for the Amstrad posse!

Devilmarkus

Well I did this:
A little routine in Java:
    public void doSong(){
        for (int t=0; t< 0x4000;t++){
            POKE(0x4000+t,((t >> 6 | t | t >> (t >> 16)) * 10 + ((t >> 11) & 7)));
        }


This produced a 16k samplefile.
This DATA I played via digiblaster with 8khz.
Result:
http://cpc-live.com/sampletest

now we need someone who does ALL in realtime in ASM ;)

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

My DSK:
RUN"64" -> 32k sample to AY
RUN"64D" -> 32k sample to digiblaster
(both use screen ram!)

RUN"128" / RUN"128D" same but using 2 BANKs
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

tastefulmrship

Isn't that the same principle as this;

Renault F1 Car playing God Save The Queen


I tried to get some "tonal music" from the TAPE loading noise, but it only produces 10 or so original tones and so I had to quit!

SyX

#22
Hi ;)

I have cheated because i'm using the expansion ram how storage for the datas generated by the equation (t>>7|t|t>>6)*10+4*(t&t>>13|t>>6)  (t = 0 - 65535) , mainly because i'm lazy today :P , but for a fast testing you only have to replace the datas in the expansion ram, by the new datas generated for other equation ;)

Of course, the source code for the player:    ORG  $2000

start
    DI

replay
    LD   BC,$7FC4
    OUT  (C),C
    CALL play
    LD   BC,$7FC5
    OUT  (C),C
    CALL play
    LD   BC,$7FC6
    OUT  (C),C
    CALL play
    LD   BC,$7FC7
    OUT  (C),C
    CALL play
    JR   replay

play
    LD   HL,$4000
    LD   B,$EF
loop_play
    DEFS 64 - 14
    LD   A,(HL)
    OUT  (C),A

    INC  HL
    LD   A,H
    CP   $80
    JP   NZ,loop_play
    RET

    END
PD: digi2 replay signed bytes and digi3 unsigned bytes (an extra XOR $80 between LD A,(HL) and OUT (C),A ).

Devilmarkus

#23
Something seem to be weird with your asm source...
Compiled it many times but only 1x I was able to hear the sound?!?

Hummmm... Edit:
I see: you did not generate the data! That was just the playback :D
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

SyX

Yes, Markus, it's only the playback, sorry, jejeje... but i generated the datas using Protext, PhrozenC and Maxam, that it must be a +1 cpc geek point  ;D

Powered by SMFPacks Menu Editor Mod