Jump to content



Photo
- - - - -

Sound For Afx


  • Please log in to reply
33 replies to this topic

#1 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 11 January 2005 - 05:53 PM

This is possible by misusing the calc's COM port.

You need no special hardware or controllers for it, what you need is nothing more than a 3.5mm to 2.5mm stereo jack adapter and a headphone. Plug the Phone into the adapter and the adapter into the calc - the COM signal is strong enough that you can hear it.

By writing defined data to the port then you can create every audio frequency you want :)

Try THIS, it's a simple demo program (screenshot below) that allows you to play all twelve notes of the scale over five octaves. It also supports a two channel mode, but this mode's quality isn't that good.

Posted Image

(Note: if it has a too low volume, take a headphone with a smaller resistor, or plug an amplifier between. I used an earphone, and it was loud enough. Btw I hope this won't demage the COM port? :unsure: Naturally it shouldn't I think...)

#2 Skalda

Skalda

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Czech Republic
  • Interests:Programming (C++ASM), Electronics, Math, Physics, Calculators, Motorbikes

  • Calculators:
    Algebra FX 2.0+ (rom 1.03)
    FX-991W

Posted 11 January 2005 - 06:23 PM

no, it shouldn't... i thought about such sounds over COM in the past, too. how do you generate the square over tx? do you use break-bit uart function (if there is one on afx) or do you just send null-bits when the edge should appear? what about stop-bits? which circuit is actually controling COM on afx?

#3 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 11 January 2005 - 06:39 PM

I gonna try it as soon as possible B)

#4 Bob Vila

Bob Vila

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 768 posts
  • Gender:Male
  • Location:USA

  • Calculators:
    FX 1.0+ : CFX-9850 GB Plus : TI-81

Posted 11 January 2005 - 07:25 PM

this is cool, now we can use music in the games :)

#5 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking & Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool & Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 11 January 2005 - 07:51 PM

but surely there is not much point, it is somthing you have to carry round with you, and that defeates the point of portable....

#6 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 11 January 2005 - 08:25 PM

True, it needs most os the CPU power, cause you have to write to the port in constant intervalls of time (according to the audio frequency you want). We can use it for games nevertheless :):

- background music for low performance games (you can innterrupt sound output by int 1C for example and use it for tasks necessarry for the game; if the int takes not a too long time, it doesn't disturb sound output much). For example, I could imagine a tetris version with background music :rolleyes: (think I'll try one)

- if it's a high performance game, you can use sound for intros or menus, and for sound effects (for example, halting the game for about 0.1s and playing a sound when shooting on the enemy or sth. like this)

how do you generate the square over tx? do you use break-bit uart function (if there is one on afx) or do you just send null-bits when the edge should appear? what about stop-bits? which circuit is actually controling COM on afx

Don't know about the circuit. Bits are putted out as square, I think, so an edge occurs when one bit is 1 and the next 0, or one 0 and the next 1. Additionally, a stop-bit seems always to cause an edge, no matter what the other bits are.

Another way we could use background music also for high performance games was, when we could prepare a buffer that is to be send through the port, not single bytes only. We could play (send) it then without having a care for it. But I think the port doesn't provide such a functionality?

#7 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 11 January 2005 - 09:52 PM

the 4nic8's soundsystem for an AFX: B)
Posted Image
http://www.casiopowe...oundsystem3.gif

@Marco: It sounds really good :lol:
btw. Could you give the source of the sound system library? Because then we could add simple sounds to MLC ;)

#8 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 11 January 2005 - 09:53 PM

eh, id advise against it...

#9 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 11 January 2005 - 10:06 PM

I can feel the bit... aha aha I like it :plol: B) ^_^ :lol2: :greengrin:
:rockband:

@Marco:
http://www.ticalc.or.../338/33890.html
this program would look cool on an AFX, wouldn't it?

#10 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

Posted 12 January 2005 - 05:52 AM

@4ni8:

does this speaker work? because I have the same fabric but I think it is not loud enough

#11 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 12 January 2005 - 09:27 AM

- if it's a high performance game, you can use sound for intros or menus, and for sound effects (for example, halting the game for about 0.1s and playing a sound when shooting on the enemy or sth. like this)
(...)
Another way we could use background music also for high performance games was, when we could prepare a buffer that is to be send through the port, not single bytes only. We could play (send) it then without having a care for it. But I think the port doesn't provide such a functionality?

<{POST_SNAPBACK}>

The problem is, that for high performance games a delay of even 0.1s is quite too long. And there is no known method to send such packs through the port while the game is still "running"...

What we could do is use the 0x1C or 0x53 interrupt, but not to interrupt the music:
We could run the game normally, and at each call of those int send a byte through the communication port to play a sound... so we could create music at a constant range of 50 Hz :)

Btw, i'm interested about the kind of data's that must be send to make such sounds ;)

#12 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 12 January 2005 - 10:01 AM

@huhn_m: surely it's not *very* loud but it wokrs fine for me B)

#13 Mohamed

Mohamed

    UCF Police

  • [Legends]
  • PipPipPipPipPipPipPip
  • 519 posts
  • Gender:Male
  • Location:Egypt, Cairo

  • Calculators:
    AFX 2.0, PV-S660, fx-570MS

Posted 12 January 2005 - 12:48 PM

@4ni8:

does this speaker work? because I have the same fabric but I think it is not loud enough

<{POST_SNAPBACK}>


I think you only need to connect it to an amplified speaker set, like your Hi-Fi or PC Speaker system, and you'll have loud enough system, beside not draining the calculator's battery.

#14 Skalda

Skalda

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Czech Republic
  • Interests:Programming (C++ASM), Electronics, Math, Physics, Calculators, Motorbikes

  • Calculators:
    Algebra FX 2.0+ (rom 1.03)
    FX-991W

Posted 12 January 2005 - 01:46 PM

but surely there is not much point, it is somthing you have to carry round with you, and that defeates the point of portable....

<{POST_SNAPBACK}>

what about piezo connected to COM, inbuilt in calculator (eg behind backup battery) with simple amplifier with one transistor supplied from main batteries (you can listen even common data transfers) B)

#15 Deimos

Deimos

    Casio Freak

  • Members
  • PipPipPipPip
  • 107 posts
  • Location:Poland
  • Interests:3d modelling, paper models, BASIC programming-AFX (just beginning)

  • Calculators:
    AFX 2.0+

Posted 12 January 2005 - 02:00 PM

I was thinking about the same thing - even a piezoelectric speaker WITH a plug would be small enough to put in the battery compartment.


EDIT:

Hehe, it works, it works really good. Sound scale is much better than i expected in fact.


#16 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 12 January 2005 - 07:09 PM

@Marco:
It sounds really good 
btw. Could you give the source of the sound system library? Because then we could add simple sounds to MLC

I'll put it to the file sharing as soon as possible (Pascal version is ready yet, currently I'm porting it to C as no one likes Pascal). Soundlib btw also has a function now for playing a kind of midi sequences.

@Marco:
http://www.ticalc.or.../338/33890.html
this program would look cool on an AFX, wouldn't it?

O yeah, it would! ==> midi tracker in progress yet :D (didn't know that there was a beat box for TI already- but what I read from the text I think it can play drum sounds only?)

does this speaker work? because I have the same fabric but I think it is not loud enough

I'm a bit surprised by the speaker, too - I'd not expect that you'd hear it even in a speaker loud enough, that's cool :) .
The thing with the piezo I also think is a good idea!

@huhn:
If your speaker is too quit, try one of these small earphones you get delivered with a discman, this should be loud enough then. :)

What we could do is use the 0x1C or 0x53 interrupt, but not to interrupt the music:
We could run the game normally, and at each call of those int send a byte through the communication port to play a sound... so we could create music at a constant range of 50 Hz  :)

Yeah, this was also the first I thought about before doing vice versa. But I guess we can't create a scale upon that (although a range from 25 to 50Hz was theoretically enough to do it) cause of the constant timer intervalls of 1/50s.

However, we could use it for 50, 25 and may be 37.5 Hz sounds, so it still will be applicable for some sound effects :)

#17 qwerty841

qwerty841

    Casio Freak

  • Members
  • PipPipPipPip
  • 198 posts
  • Gender:Male
  • Location:vernal

  • Calculators:
    ClassPad 300,TI 83 PSE,TI Voyage 200,Windows Calculator

Posted 12 January 2005 - 07:22 PM

for my ti calc, i just took one end of a unit to unit cable and attached a piezo buzzer.

#18 Deimos

Deimos

    Casio Freak

  • Members
  • PipPipPipPip
  • 107 posts
  • Location:Poland
  • Interests:3d modelling, paper models, BASIC programming-AFX (just beginning)

  • Calculators:
    AFX 2.0+

Posted 14 January 2005 - 10:52 AM

Piezo buzzer works fine - it's loud enough to be heard, but not too loud.

#19 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 15 January 2005 - 08:47 AM

AFXSound Library V. 0.9 is up in the File Sharing right now, providing a Pascal and a C version, a doc and two demo programs.

Note, that writing the doc took as long the lib itself did :huh: (I really hate writing docs...)

Btw, C version hasn't been tested yet, altough the compiler gives no errors for it. Especially for the MIDI track routines for C I don't know if they'll work, so just try out ^_^ (and tell me if or ifn't so)

#20 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 15 January 2005 - 01:02 PM

I've tried the C lib. :)

And made Sweet Sound v 0.1 (it's mostly port from snddemo.pas by you). I works almost fine. It generates sound very well. But I found no way to terminate the program (without using P button). It's really weird I guess it can be a bug in soundclose() (or in soundopen() or soundplay() ).

Posted Image
Sweet Sound v 0.1 (with source):
http://max.iem.pw.ed.../sweets_010.rar

btw. afxsound.c doesn't work with Digital Mars compiler :(

However, way to go Marco B)

#21 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 15 January 2005 - 03:02 PM

Well, it doesn't work with Digital Mars? :huh: Does the compiler give any errors or warnings or is the error in runtime only?

Ah and about the termination problem - it's a mistake I made in snddemo.pas: to leave soundplay() you should prefer setting soundstop variable to 1 instead of calling closesound(), else the port will be closed while soundplay() is running and soundplay() might hang thus (I haven't thought of this when writing the demo :banghead:).

So it should work when calling soundclose() only when soundplay() has returned already after setting soundstop.

Thx for testing it btw :) (would have been much efforts for me to do so as I never yet wrote a C prog running on AFX)

#22 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 15 January 2005 - 03:43 PM

Ok! Now it works fine.

Here is the Sweet Sound 0.2 + source:
http://max.iem.pw.ed.../sweets_020.rar

btw. Marco, you can add Sweet Sound to your lib package as a C example if you want ;).

#23 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 15 January 2005 - 03:46 PM

Digital Mars Compiler gives:
---------- DM ----------
  mov word [offset channels],0xFFFF
           ^
E:\CALCS\CASIO\PROG\sound\moje\afxsound.c(161) : Error: Expected assembler directive PTR to follow assembler cast
  mov word [offset channels+5],0xFFFF
           ^
E:\CALCS\CASIO\PROG\sound\moje\afxsound.c(162) : Error: Expected assembler directive PTR to follow assembler cast
  mov word [offset channels+2],1
           ^
E:\CALCS\CASIO\PROG\sound\moje\afxsound.c(163) : Error: Expected assembler directive PTR to follow assembler cast
  mov word [offset channels+7],1
           ^
E:\CALCS\CASIO\PROG\sound\moje\afxsound.c(164) : Error: Expected assembler directive PTR to follow assembler cast
    mov [offset channels+2],dx
                             ^
E:\CALCS\CASIO\PROG\sound\moje\afxsound.c(188) : Error: Illegal type/size of operands for the mov instruction
Fatal error: too many errors
--- errorlevel 1

Output completed (0 sec consumed) - Normal Termination


#24 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 15 January 2005 - 06:07 PM

btw. Marco, you can add Sweet Sound to your lib package as a C example if you want

That's fine, I'll add it :)

^^ Got a DM compiler meanwhile, hope I'll fix it soon...

#25 Skalda

Skalda

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Czech Republic
  • Interests:Programming (C++ASM), Electronics, Math, Physics, Calculators, Motorbikes

  • Calculators:
    Algebra FX 2.0+ (rom 1.03)
    FX-991W

Posted 15 January 2005 - 07:49 PM

Digital Mars Compiler gives:
[code=auto:0]---------- DM ----------
  mov word [offset channels],0xFFFF
          ^
E:\CALCS\CASIO\PROG\sound\moje\afxsound.c(161) : Error: Expected assembler directive PTR to follow assembler cast

<{POST_SNAPBACK}>

try mov word ptr ds:[&channels+xxx], yyy
ptr is here a keyword to accent pointer; word is necessary to determinate the length of second operand yyy which is immediate (sometimes required even if yyy isn't immediate, as in case of dx), xxx is shift from base adress; perhaps, offset of channels has not to be declared with offset keyword in DMC's assembler, try &

#26 4nic8

4nic8

    Casio Freak

  • Members
  • PipPipPipPip
  • 182 posts
  • Location:Warsaw, Poland

  • Calculators:
    Casio AFX 2.0 ROM 1.01, TI-89 (ASM 2.08 HW 2.00)

Posted 15 January 2005 - 08:04 PM

mov word ptr ds:[offset channels], 0xFFFF
DM error:
---------- DM ----------
  mov word ptr ds:[offset channels], 0xFFFF
                                          ^
E:\CALCS\CASIO\PROG\sound\moje\afxsound.c(161) : Error: Illegal type/size of operands for the mov instruction
  mov word [offset channels],0xFFFF


#27 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 15 January 2005 - 09:15 PM

Fixed right now: In DM inline Assembler effective addresses notation is the same as in NAsm:

dw myvar
mov ax,[myvar]
You have to do a type casting similar to C however:

mov (word) [(void) channels],0xFFFF
That works so far, but it's a really strange syntax for an assembler nevertheless (and it's also incompatible with borland inline assembler, so I'll make a third version afxsound_dm.c). They could have documented it anywhere at least <_<

#28 Skalda

Skalda

    Newbie

  • Members
  • Pip
  • 14 posts
  • Location:Czech Republic
  • Interests:Programming (C++ASM), Electronics, Math, Physics, Calculators, Motorbikes

  • Calculators:
    Algebra FX 2.0+ (rom 1.03)
    FX-991W

Posted 15 January 2005 - 09:58 PM

...but it's a really strange syntax for an assembler nevertheless (and it's also incompatible with borland inline assembler...

<{POST_SNAPBACK}>

most of programmers are used to intel asm syntax (tasm, masm, a86, nasm...) have you ever tried AT&T asm syntax, whichGCC gnu-compiler uses? :D my first mov was enough (you must declare all used variables, and operands are swapped and so on...)

now seriously: have you noticed (in DMC) any difference between
mov dx, myvar
mov dx, &myvar
mov dx, [myvar]
mov dx, [&myvar]
it seems that it work all the same (but logically, when brackets are used as dereference; & have to be used as reference and vice versa)

#29 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 15 January 2005 - 10:39 PM

That works so far, but it's a really strange syntax for an assembler nevertheless (and it's also incompatible with borland inline assembler, so I'll make a third version afxsound_dm.c). They could have documented it anywhere at least <_<

<{POST_SNAPBACK}>

Please do not make another file, just add some
#ifdef __DMC__
... // DM special code
#else
... // other compilers
#endif
stuff in your code ;)


But in this case, I see you don't use SI or DI... you could use it for that (of course there will be one instruction more, but its not big deal ;) )

If you have
void soundplay() {

  mloop:
  asm {

    mov ax,[offset channels+2]
    mov bx,[offset channels]
    cmp ax,bx
    jna m1
then write
void soundplay() {

  asm lea di, channels;
  mloop:
  asm {

    mov ax,[di+2]
    mov bx,[di]
    cmp ax,bx
    jna m1
etc ;)

#30 Marco

Marco

    Casio Freak

  • Members
  • PipPipPipPip
  • 185 posts
  • Location:Dresden, Germany

  • Calculators:
    Casio CFX 9850G (broken),
    Casio CFX 9850GB,
    Casio Algebra FX 2.0 Plus

Posted 17 January 2005 - 05:46 PM

AFXSound upgraded from V. 0.9 to 0.91 :):

- works also with Digital Mars compilers now
- contains 4nics C demo
- the closesound bug in the other two demos has been fixed

#31 Guest_Newbie_*

Guest_Newbie_*
  • Guests

Posted 18 February 2007 - 08:24 PM

Is it also possible for the 9860G? :unsure:

#32 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 18 February 2007 - 11:39 PM

It will be possible when CASIO adds serial communication functions to the SDK for the fx-9860.

#33 Guest_bengx_*

Guest_bengx_*
  • Guests

Posted 28 February 2007 - 04:47 PM

is it possible to one day have the calculator play mp3 files? haha.

#34 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 01 March 2007 - 01:04 AM

Yes maybe on the fx-9860SD. I asked CASIO for serial communications support. We will see what happens...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users