Всем привет,
думаю выкладывать здесь всё, что связано с музыкальными инструментами.
Первое, что удалось найти - это пример с системным динамиком (автор неизвестен).
Музыкальные инструменты
-
- Attachments
-
-
PIANO4.zip (6.31 KiB)
- New version
Downloaded 315 times
-
piano1.ZIP (7.4 KiB)Downloaded 331 times
-
Last edited by Antonio on Fri Mar 29, 2019 8:33 am, edited 2 times in total.
I'm glad you are trying something.
Playing audio files in kolibri is not as easy as calling a system function. I attached a very basic example for you, put all the files to /hd0/1/.
To generate sounds I used sox:
Playing audio files in kolibri is not as easy as calling a system function. I attached a very basic example for you, put all the files to /hd0/1/.
To generate sounds I used sox:
Code: Select all
$ sox -n -L -c 1 -b 16 -r 48000 g392.raw synth 1 sine 392
- Attachments
-
-
demo_for_antonio.tar.7z (79.86 KiB)Downloaded 326 times
-
Thanks a lot, Dunkaist.
Пока мало что понятно. Буду разбираться.
Программа SoX уже есть в демо, или её нужно скачать?
Наверное лучше использовать RAM-диск для файлов, скорость чтения/записи там выше (imho).
И у меня конфигурация без /HD.
Пока мало что понятно. Буду разбираться.
Программа SoX уже есть в демо, или её нужно скачать?
Наверное лучше использовать RAM-диск для файлов, скорость чтения/записи там выше (imho).
И у меня конфигурация без /HD.
Feel free to ask.Antonio wrote:Пока мало что понятно. Буду разбираться.
File paths are hardcoded as /hd0/1/... currently, you can change them to ramsisk, of course.Antonio wrote:Наверное лучше использовать RAM-диск для файлов, скорость чтения/записи там выше (imho).
И у меня конфигурация без /HD.
Есть вопрос: на каких звуковых картах это будет работать?dunkaist wrote: To generate sounds I used sox:Code: Select all
$ sox -n -L -c 1 -b 16 -r 48000 g392.raw synth 1 sine 392
У меня пока что работает только графическая часть demo Forte.
К слову, в плейере Pixie тоже звука нет.
Частоту 48000, указанную в примере, поддерживают не все аудиокарты, есть смысл её понизить до стандартной 44100 для большей совместимости.
Формат файлов raw мне раньше не встречался, какие у него преимущества перед более распространенным wav?
Ну и последнее замечание - это отсутствие поддержки клавиатуры.
Так что, мы всё ещё далеко от цели.
А в остальном - всё ОК, только не мешало бы побольше комментариев в коде.
Для начинающих.
Спасибо
I tested on Qemu with HDA codec (-soundhw hda). All applications use a common audio driver, therefore first try to set up the sound in any of them, e.g. Pixie. Then all the other apps should produce sounds too.Antonio wrote:Есть вопрос: на каких звуковых картах это будет работать?
У меня пока что работает только графическая часть demo Forte.
К слову, в плейере Pixie тоже звука нет.
I'm not sure how Infinity driver does resampling. May be Serge, its author, will address your question.Antonio wrote:Частоту 48000, указанную в примере, поддерживают не все аудиокарты, есть смысл её понизить до стандартной 44100 для большей совместимости.
Raw is not actually a file format, it's just a file extension / filename suffix suggesting that there is no internal structure in the file and samples are written as is. I.e. you don't have to decode this file. Read it into memory and play, that's it.Antonio wrote:Формат файлов raw мне раньше не встречался, какие у него преимущества перед более распространенным wav?
Keyboard support is far more simpler to implement in kolibri than dealing with audio. I helped you with the harder part. Consider it as an example or a skeleton.Antonio wrote:Ну и последнее замечание - это отсутствие поддержки клавиатуры.
Так что, мы всё ещё далеко от цели.
You are right, documentation is the real issue in the project. This is not an excuse even though I did the demo late at night. That's why I encourage you to not be shy and ask any related questions.Antonio wrote:А в остальном - всё ОК, только не мешало бы побольше комментариев в коде.
Для начинающих.
Good luck with your project.Antonio wrote:Спасибо
Hello Dunkaist, how did you write raw files?dunkaist wrote:Raw is not actually a file format, it's just a file extension / filename suffix suggesting that there is no internal structure in the file and samples are written as is. I.e. you don't have to decode this file. Read it into memory and play, that's it.
Antonio wrote:Hello Dunkaist, how did you write raw files?dunkaist wrote:Raw is not actually a file format, it's just a file extension / filename suffix suggesting that there is no internal structure in the file and samples are written as is. I.e. you don't have to decode this file. Read it into memory and play, that's it.
dunkaist wrote:To generate sounds I used sox:Code: Select all
$ sox -n -L -c 1 -b 16 -r 48000 g392.raw synth 1 sine 392
Спасибо Dunkaist.
Благодаря Вам вышла новая программа, которой мне не хватало.
Качество звука не идеальное и работает только с мышкой.
Будет время - доделаю клавиатуру, если получится.
Хотел сделать более длительные звуки, но при их наложении появляется треск.
Поэтому оставил короткие.
Благодаря Вам вышла новая программа, которой мне не хватало.
Качество звука не идеальное и работает только с мышкой.
Будет время - доделаю клавиатуру, если получится.
Хотел сделать более длительные звуки, но при их наложении появляется треск.
Поэтому оставил короткие.
- Attachments
-
-
pls unpack to tmp01.zip (1.66 MiB)Downloaded 314 times
-
Antonio,
good job, keep going!
Ways to make your program even better:After:
Good news is that there is an example. This is not an easy task at all. May be you need to look for some theory on audio mixing to better understand what is going on in the code.
good job, keep going!
Ways to make your program even better:
- Initialize sound driver (_InitSound@4) only once, just after the call to sysfn 68.11;
- Create buffer for each file and copy samples to it only once. Store buffer handles into array;
- Copy _SetBufferPos@8 to your sound.asm from here and set buffer position to 0 just before each call to _PlayBuffer@8.
Code: Select all
for each button press, begin:
Init driver
Create buffer
Set buffer
Play buffer
end
Code: Select all
Init driver
Create buffers
Set buffers
for each button press, begin:
Set buffer position to 0
Play buffer
end
Bad news is that your program has to mix sounds itself.Antonio wrote:Хотел сделать более длительные звуки, но при их наложении появляется треск.
Good news is that there is an example. This is not an easy task at all. May be you need to look for some theory on audio mixing to better understand what is going on in the code.
I'm sorry, but I don't know how to do steps 2 and 3. If you can - pls help.
First I declared two arrays: files and audio_bufs that contain pointers to file names and created buffers.
Then I added a loop just after start: that loads files into memory one by one, creates audio buffers and sets the buffers with the loaded data (raw samples).
Then I separated procedures load_file and play_file. The former is called once per file, the latter each time corresponding button is pressed and
Finally I subtract lowest chime button id (0xabc1) from pressed button id to know which buffer to play.
Then I added a loop just after start: that loads files into memory one by one, creates audio buffers and sets the buffers with the loaded data (raw samples).
Then I separated procedures load_file and play_file. The former is called once per file, the latter each time corresponding button is pressed and
Finally I subtract lowest chime button id (0xabc1) from pressed button id to know which buffer to play.
Thank you. However, the sound quality has become poor. When you press any button, the first sound is good, and again - it is already bad (crackling is appeared).
Добавил клавиатуру: 4-0, Е-Р.
Если интенсивно играть на клавиатуре или мышкой, то минуты через 3 звук пропадает.
Не знаю с чем это связано.
Если интенсивно играть на клавиатуре или мышкой, то минуты через 3 звук пропадает.
Не знаю с чем это связано.
- Attachments
-
-
pls_unpack to tmp01.zip (1.66 MiB)Downloaded 312 times
-
Новая версия
- Attachments
-
-
PIANO2 (2.8 KiB)Downloaded 299 times
-
PIANO2.ASM (14.44 KiB)Downloaded 284 times
-
Who is online
Users browsing this forum: No registered users and 7 guests