Author Topic: Frequency and Channels of a Custom Sound  (Read 8372 times)

0 Members and 1 Guest are viewing this topic.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Frequency and Channels of a Custom Sound
« on: August 18, 2010, 12:32:28 am »
For those of you who think you will laugh and point at me for asking a reasonable question, please leave immediately.

So, this is part of the code for PlayWav:

Code: [Select]
di           
 ld   a, 0FDh
 out  (01h), a 

main:
 ld   a, (hl)
 and  0Fh
 ld   c, a   
 call Label15
 ld   a, (hl)
 srl  a       
 srl  a       
 srl  a       
 srl  a       
 and  0Fh
 ld   c, a
 push iy
 pop  iy ;slow this down a little
 call Label15
 inc  hl     
 dec  de     
 ld   a, d   
 push iy ;slow this down a little
 pop  iy
 or   e       
 jr   nz,main
 ei         
 ret
         
quit:
 pop af
 pop af ;fix the stack
 pop af
 ret

Label15:
 ld   b, c   
 inc  b       
 ld   a, 0D3h

Label18:
 out  (00h), a 
 djnz Label18
 ld   a, 10h
 sub  c       
 ld   b, a   
 ld   a, 0D0h

Label19:
 out  (00h), a 
 djnz Label19
 ret

1. If I were to use a custom sound, one single recorded note, would it be possible to adjust the frequency and duration of that sound to allow more notes?
2. Would it be possible to have 2--or even 4--channels of said single recorded notes at said frequencies and durations?

I'm not asking for code (cause I have an idea of what I want to do), I'm just asking if it's reasonably possible.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Frequency and Channels of a Custom Sound
« Reply #1 on: August 18, 2010, 01:14:42 pm »
For those of you who think you will laugh and point at me for asking a reasonable question, please leave immediately.
Don't worry that won't happen here (if someone does, he won't be able to do it more than twice)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Frequency and Channels of a Custom Sound
« Reply #2 on: August 18, 2010, 06:52:23 pm »
So are you wanting some sort of WAV playback, or do you want beeps?
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #3 on: August 18, 2010, 07:03:17 pm »
So are you wanting some sort of WAV playback, or do you want beeps?

WAV.  What I'm looking at is a recorded note (such as .1 seconds of violin, like they do with midi), and since the code above can play waves, I'm wondering if that note can be adjusted for length and pitch, and played in two or 4 channels.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #4 on: August 18, 2010, 10:00:39 pm »
Your routine is built to play how many bits per sample, and at what sample rate?

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #5 on: August 18, 2010, 10:17:17 pm »
Your routine is built to play how many bits per sample, and at what sample rate?

Well, it's not actually my routine.  But it is 11 Khz, 8-bit mono

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Frequency and Channels of a Custom Sound
« Reply #6 on: August 18, 2010, 10:19:40 pm »
It's actually 4-bit, I believe.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #7 on: August 18, 2010, 10:23:41 pm »
It's actually 4-bit, I believe.

Alright, granted, but that still doesn't answer my questions 8)

EDIT:  At least the file sent and converted to a program is 8-bit
« Last Edit: August 18, 2010, 10:24:57 pm by Hot_Dog »

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #8 on: August 18, 2010, 10:24:52 pm »
This also looks like an interesting topic.  I'm curious as well.  Thanks for asking a great question Hot Dog. ;D

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #9 on: August 18, 2010, 10:26:02 pm »
This also looks like an interesting topic.  I'm curious as well.  Thanks for asking a great question Hot Dog. ;D

Well, I'm tossing around the idea with having about 16 "midi" instruments and making music for S.A.D. for 15 Mhz calculators.  If I can't get enough channels and can't change single notes, however, it ain't going to happen

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Frequency and Channels of a Custom Sound
« Reply #10 on: August 18, 2010, 10:28:19 pm »
This also looks like an interesting topic.  I'm curious as well.  Thanks for asking a great question Hot Dog. ;D

Well, I'm tossing around the idea with having about 16 "midi" instruments and making music for S.A.D. for 15 Mhz calculators.  If I can't get enough channels and can't change single notes, however, it ain't going to happen

So you're planning to run this on top of a game? :O I'm not sure how possible this is when using all of the processing time.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #11 on: August 18, 2010, 10:30:10 pm »
This also looks like an interesting topic.  I'm curious as well.  Thanks for asking a great question Hot Dog. ;D

Well, I'm tossing around the idea with having about 16 "midi" instruments and making music for S.A.D. for 15 Mhz calculators.  If I can't get enough channels and can't change single notes, however, it ain't going to happen

So you're planning to run this on top of a game? :O I'm not sure how possible this is when using all of the processing time.

Like I said, it's an idea I'm tossing around.  But if nobody knows if it's possible for many channels, as well as if it's possible to have a single recorded note and change pitch and duration...

* Hot Dog runs off to experiment

EDIT:  I'll keep up on this post as to what I find out, for those of you curious
« Last Edit: August 18, 2010, 10:32:41 pm by Hot_Dog »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Frequency and Channels of a Custom Sound
« Reply #12 on: August 18, 2010, 10:32:45 pm »
I believe that with WAV sound, the pitch/speed are linked. This is why typically when speeding up the sound goes higher and slowing down it goes lower. Apparently changing the speed without changing the pitch or vice versa is a problem even on PCs.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #13 on: August 18, 2010, 10:35:14 pm »
Well if it can be sped up or down, that's not an issue.  I don't care about the speed since most notes will repeat (in order to be held out) anyways.  After all, on computer midi, if you start with a single recorded note (like a piano note), the sound will run faster and faster the higher up you go.
« Last Edit: August 18, 2010, 10:35:56 pm by Hot_Dog »

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Frequency and Channels of a Custom Sound
« Reply #14 on: August 19, 2010, 04:38:12 pm »
Looks like I should leave the improbable to calc84maniac.  Using a short note to make a long note (such as a string orchestra) is almost impossible without hearing some clicks and pops, and if I have all short notes and no long background notes, it's not worth using recorded sounds instead of having all beeps (especially since beeps have no issues with long notes).

However, I'm still thinking about music for 15 Mhz S.A.D. if I can think of some decent beep-beep music.  It's likely I'll do some 4 channel stuff
« Last Edit: August 19, 2010, 04:43:54 pm by Hot_Dog »