Files
kolibrios/programs/media/midamp/playnote.txt
T
ace-dent 33acd57c58 programs/media: Post-SVN tidy (#417)
- Move source code from `trunk` into root directory for each program.
- Update build files and ASM include paths. Add SPDX license header where appropriate.
- Note: Line endings standardised from `CRLF` > `LF`, so best to view diffs with whitespace changes hidden.

(Work towards #75, point 3)

Reviewed-on: KolibriOS/kolibrios#417
Reviewed-by: Mikhail Frolov <mixa.frolov2003@gmail.com>
Reviewed-by: Burer <burer@noreply.localhost>
Co-authored-by: Andrew <dent.ace@gmail.com>
Co-committed-by: Andrew <dent.ace@gmail.com>
2026-04-11 09:21:42 +00:00

294 lines
13 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2003 VaStaNi *
* vastani@ukr.net *
* >>>- SIMPLY - QUICKLY - SHORTLY -<<< *
* *
* About Player Notes for Speaker PC. *
* ( PLAYNOTE.INC v.1.1 for MENUET OS ) *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--- ATTACH ---
>>> Insert string: include "PLAYNOTE.INC" in list file KERNEL32.INC
.........
......... ......... .............................
......... ......... .............................
......... ......... .............................
; sound
include "SB16.INC" ; playback for Sound Blaster 16
include "PLAYNOTE.INC" ; player Note for Speaker PC
.........
......... ......... .............................
......... ......... .............................
>>> Insert line --->>> call playNote --->>> in procedure irq0
( listing file SYS32.INC for KERNEL.ASM )
.... ....
.... ....
.... ....
no_error_in_previous_process:
mov edi,[0x3000]
imul edi,8
mov [edi+gdts+ tss0 +5], word 01010000b *256 +11101001b
inc dword [0xfdf0]
mov eax,[0xfdf0]
call playNote ; <<<--- INSERT THIS LINE !!!!!!!!!!
cmp eax,[next_usage_update]
jb nocounter
add eax,100
mov [next_usage_update],eax
call updatecputimes
nocounter:
.... ....
.... ....
.... ....
>>> file SB16.INC have this label...
.... ....
.... ....
.... ....
no_SB16_data_format:
ret
>>> I suggest add this code for subfunction #55 function #55 OS (player notes)
.... ....
.... ....
.... ....
no_SB16_data_format:
cmp eax, edi ; this is subfunction #55 ?
jne retFunc55 ; if no then return.
movzx eax, byte [countDelayNote]
or al, al ; player is busy ?
jnz retFunc55 ; return counter delay Note
mov eax, [0x3010]
mov eax, [eax+0x10] ; address application im memory
add eax, edx ; add offset Delay-Note string
mov [memAdrNote], eax
xor eax, eax ; Ok! EAX = 0
retFunc55:
mov [esp+36], eax ; return value EAX for application
ret
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--- USE ---
>>> Example use in your programs:
.... ....
.... ....
.... ....
mov eax, 55 ; OS function #55
mov ebx, eax ; EBX = 55 for subfunction Play Note
mov esi, MyMusic_1 ; ESI = head string Delay-Note code
int 0x40 ; start play
.... ....
.... ....
.... ....
>>> Very simply OS use. Only put dword adress head string in [memAdrNote]
.... ....
mov [memAdrNote], dword MyMusic_1 ; IRQ0 -> start play!!!
.... ....
!!! Example OS use for send: error tone, ring signal, disconnect hardware...
!!! Saund Card may be OFF, but Speaker PC always IS ON !!!
..... .. ..
..... .. ..
MyMusic_1 db .., .., .., .., .., 0 ; string Delay-Note code for MUSIC
... .. ..
...... .. ..
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--- CODE DELAY & NOTEs ---
>>> Format Delay-Note string:
1. Free style play Tone
db 1..0x80 ; !!! only (1..0x80) byte for Delay Tone
db 1..0xFF ; lower byte (counter for period oscillate)
db 1..0xFF ; upper byte (counter for period oscillate)
.. .. \
.. .. > 3 bytes for 1 TONE !!!
.. .. /
db 0 ; THE END Play!
2. Musical style play Note
db 0x81..0xFE ; !!! 0x80 + byte (1..0x7E) for Delay Note
db 1..0xFF ; PACK CODE (number Note & number Octave)
.. .. \
.. .. / 2 bytes for 1 Note in 1 Octave !!!
db 0 ; THE END Play!
-= DELAY CODE =-
┌────────────┬────────────┬───────╔══ 1 ═╗╔══ 2 ═╗
│длительности│ DELAY NOTE │ DELAY ║ DELAY ║║ DELAY ║
│ НОТ │ mSec │ IRQ 0 ║ CODE ║║ CODE ║
├────────────┼────────────┼───────╠════════╣╠════════╣
│ целая │ 2000 │ ║ 0xC8 ║║ absent ║
├────────────┼────────────┤ ╟────────╢╟────────╢
│ 1/2 │ 1000 │ ║ 0x64 ║║ 0xE4 ║
├────────────┼────────────┤ ╟────────╢╟────────╢
│ 1/4 │ 500 │ ║ 0x32 ║║ 0xB2 ║
├────────────┼────────────┤ 10 ║────────╢║────────╢
│ 1/8 │ 250 │ mSec ║ 0x19 ║║ 0x99 ║
├────────────┼────────────┤ ╟────────╢╟────────╢
│ 1/16 │ 125 │ ║ 0xC ║║ 0x8C ║
├────────────┼────────────┤ ║────────╢║────────╢
│ 1/32 │ 62.5 │ ║ 6 ║║ 0x86 ║
├────────────┼────────────┤ ╟────────╢╟────────╢
│ 1/64 │ 31.25 │ ║ 3 ║║ 0x83 ║
└────────────┴────────────┴───────╚════════╝╚════════╝
-= PACK CODE =-
!!!!! IF PACK CODE = 0xFF THEN PAUSE = DELAY CODE !!!!!
┌───────────┬──────┬──────╔══════════╗ ┌───────────┬────┬──────╔══════════╗
│ ТИПЫ │number│ code ║upper CODE║ │ НОТЫ │type│number║lower CODE║
│ ОКТАВ │OCTAVE│number║Bit7..Bit4║ │ ОКТАВЫ │NOTE│ NOTE ║Bit3..Bit0║
├───────────┼──────┼──────╠══════════╣ ├───────────┼────┼──────╠══════════╣
│контроктава│ -3 │ 0 ║ 0000 ║ │ ДО │ C │ 1 ║ 0001 ║
├───────────┼──────┼──────╠──────────╢ ├───────────┼────┼──────╫──────────╢
│ большая │ -2 │ 1 ║ 0001 ║ │ ДО бемоль │ C# │ 2 ║ 0010 ║
├───────────┼──────┼──────╟──────────╢ ├───────────┼────┼──────╫──────────╢
│ малая │ -1 │ 2 ║ 0010 ║ │ РЕ │ D │ 3 ║ 0011 ║
├───────────┼──────┼──────║──────────╢ ├───────────┼────┼──────╫──────────╢
│ первая │ 1 │ 3 ║ 0011 ║ │ РЕ бемоль │ D# │ 4 ║ 0100 ║
├───────────┼──────┼──────╟──────────╢ ├───────────┼────┼──────╫──────────╢
│ вторая │ 2 │ 4 ║ 0100 ║ │ МИ │ E │ 5 ║ 0101 ║
├───────────┼──────┼──────║──────────╢ ├───────────┼────┼──────╫──────────╢
│ третья │ 3 │ 5 ║ 0101 ║ │ ФА │ F │ 6 ║ 0110 ║
├───────────┼──────┼──────╟──────────╢ ├───────────┼────┼──────╫──────────╢
│ четвертая │ 4 │ 6 ║ 0110 ║ │ ФА бемоль │ F# │ 7 ║ 0111 ║
└───────────┴──────┴──────╚══════════╝ ├───────────┼────┼──────╫──────────╢
│ СОЛЬ │ G │ 8 ║ 1000 ║
├───────────┼────┼──────╫──────────╢
│СОЛЬ бемоль│ G# │ 9 ║ 1001 ║
├───────────┼────┼──────╫──────────╢
│ ЛЯ │ A │ 10 ║ 1010 ║
├───────────┼────┼──────╫──────────╢
│ ЛЯ бемоль │ A# │ 11 ║ 1011 ║
├───────────┼────┼──────╫──────────╢
│ СИ │ B │ 12 ║ 1100 ║
└───────────┴────┴──────╚══════════╝
PACK CODE = (number Note) AND ((code number Octave) SHL 4)
or
PACK CODE = (number Note) AND ((code number Octave) * 16)
-= PERIOD OSCILLATE =-
counter = 1193180 / FREQUENCY;
(WORD) (sound Hz)
┌───────────┬──────┬──────┬───────────┬────┬──────╔═════════ ══════╗
│ ТИП │number│ code │ НОТЫ │type│number║frequency PACK ║
│ ОКТАВЫ │OCTAVE│number│ 1й ОСТАВЫ │NOTE│ NOTE ║sound Hz CODE ║
├───────────┼──────┼──────┼───────────┼────┼──────╠═════════ ══════╣
│ │ │ │ ДО │ C │ 1 ║ 523,251 -- 0x31 ║
│ │ │ ├───────────┼────┼──────╫───────── | ──────╢
│ │ │ │ ДО бемоль │ C# │ 2 ║ 554,365 --|-- 0x32 ║
│ │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ РЕ │ D │ 3 ║ 587,33 | | 0x33 ║
│ │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ РЕ бемоль │ D# │ 4 ║ 622,254 | | 0x34 ║
│ │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ МИ │ E │ 5 ║ 659,255 | | 0x35 ║
│ │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ ФА │ F │ 6 ║ 698,456 | | 0x36 ║
│ первая │ 1 │ 3 ├───────────┼────┼──────╫───────── | | ──────╢
│ ( first │ │ │ ФА бемоль │ F# │ 7 ║ 739,989 | | 0x37 ║
│ octave ) │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ СОЛЬ │ G │ 8 ║ 783,991 0x38 ║
│ │ │ ├───────────┼────┼──────╫───────── x 2 ──────╢
│ │ │ │СОЛЬ бемоль│ G# │ 9 ║ 830,609 0x39 ║
│ │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ ЛЯ │ A │ 10 ║ 880 | | 0x3A ║
│ │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ ЛЯ бемоль │ A# │ 11 ║ 932,328 | | 0x3B ║
│ │ │ ├───────────┼────┼──────╫───────── | | ──────╢
│ │ │ │ СИ │ B │ 12 ║ 987,767 | | 0x3C ║
├───────────┼──────┼──────┼───────────┼────┼──────╠═════════ | | ══════╣
│ вторая │ 2 │ 4 │ ДО │ С │ 1 ║1046,502 <- | 0x41 ║
...... .. .. ... .. .. .... ... <----
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
--- EXAMPLE MUSIC ---
Пример музицирования по нотам мелодии И.Карнелюка "Горит очаг..."
к фильму "Бандитский Петербург"
MyMusic_1:
db 0xe4,0x35, 0x99,0x33, 0x99,0x31, 0x99,0x33, 0xe4,0x35, 0x99,0x35, 0x99,0x36
db 0x99,0x38, 0x99,0x3a, 0xe4,0x36, 0xe4,0x36, 0xb2,0xff, 0xe4,0x33, 0x99,0x31
db 0x99,0x2c, 0x99,0x31, 0xe4,0x33, 0xb2,0x33, 0x99,0x35, 0x99,0x36, 0xe4,0x35
db 0xe4,0x35, 0xb2,0xff, 0x99,0x35, 0x99,0x36, 0xe4,0x33, 0x99,0x35, 0x99,0x36
db 0xb2,0x33, 0x99,0x35, 0x99,0x36, 0xb2,0x33, 0x99,0x35, 0x99,0x36, 0xe4,0x39
db 0xe4,0x39, 0xb2,0xff, 0x99,0x35, 0x99,0x36, 0xe4,0x33, 0x99,0x35, 0x99,0x36
db 0xb2,0x33, 0x99,0x35, 0x99,0x36, 0xb2,0x33, 0x99,0x35, 0x99,0x36, 0xe4,0x35
db 0xe4,0x35, 0
MyMusic_2:
db 0x90,0x31, 0x90,0x33, 0x90,0x35, 0x90,0x36, 0xA0,0xFF, 0xA0,0x06, 0x90,0xFF
db 0xA0,0x06, 0x90,0xFF, 0x90,0x33, 0x90,0x35, 0x90,0x37, 0x90,0x38, 0xA0,0xFF
db 0xA0,0x18, 0x90,0xFF, 0xA0,0x18, 0x90,0xFF, 0x90,0x33, 0x90,0x35, 0x90,0x37
db 0x90,0x38, 0xA0,0xFF, 0x90,0x33, 0x90,0x35, 0x90,0x37, 0x90,0x38, 0xA0,0xFF
db 0x90,0x31, 0x90,0x33, 0x90,0x35, 0x90,0x36, 0xA0,0xFF, 0xA0,0x16, 0x90,0xFF
db 0xA0,0x16, 0
MyMusic_3:
db 0x99,0x31, 0xB2,0x36, 0x99,0x3A, 0xB2,0x36, 0x99,0x33, 0xB2,0x28, 0xBC,0x38
db 0
<<<<<<< >>>>>>>
|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> !GOOD LUCK! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
<<<<<<< >>>>>>>