Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Hot_Dog on August 18, 2010, 12:32:28 am

Title: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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.
Title: Re: Frequency and Channels of a Custom Sound
Post by: DJ Omnimaga 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)
Title: Re: Frequency and Channels of a Custom Sound
Post by: calc84maniac on August 18, 2010, 06:52:23 pm
So are you wanting some sort of WAV playback, or do you want beeps?
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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.
Title: Re: Frequency and Channels of a Custom Sound
Post by: Runer112 on August 18, 2010, 10:00:39 pm
Your routine is built to play how many bits per sample, and at what sample rate?
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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
Title: Re: Frequency and Channels of a Custom Sound
Post by: calc84maniac on August 18, 2010, 10:19:40 pm
It's actually 4-bit, I believe.
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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
Title: Re: Frequency and Channels of a Custom Sound
Post by: ztrumpet 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
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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
Title: Re: Frequency and Channels of a Custom Sound
Post by: calc84maniac 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.
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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...

/me runs off to experiment

EDIT:  I'll keep up on this post as to what I find out, for those of you curious
Title: Re: Frequency and Channels of a Custom Sound
Post by: calc84maniac 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.
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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.
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog 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
Title: Re: Frequency and Channels of a Custom Sound
Post by: Quigibo on August 19, 2010, 05:29:56 pm
You can synthesize your own instruments you know without having to record anything.  Its basically just like a regular solid square wave, but you have a list of pitch shifts like +1,0,-1,-2,-1,0,+1 or something and you can create some really cool effects at very high quality.  I've never tried this, but its definitely possible.
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog on August 19, 2010, 06:03:05 pm
You can synthesize your own instruments you know without having to record anything.  Its basically just like a regular solid square wave, but you have a list of pitch shifts like +1,0,-1,-2,-1,0,+1 or something and you can create some really cool effects at very high quality.  I've never tried this, but its definitely possible.

Interesting, I'll have to look up how to do that.  (+1 respect, because I didn't think about that)  Since the game should run somewhat well (if not very well) at 6 MHz, I don't think speed is going to be an issue.
Title: Re: Frequency and Channels of a Custom Sound
Post by: Hot_Dog on August 20, 2010, 12:04:09 am
Calc84maniac, how did you make your "New Project M" noise generator?  Perhaps some code?