English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 19 January 2016, 15:50   #1
LuMan
Amigan - an' lovin' it!!
 
LuMan's Avatar
 
Join Date: Nov 2010
Location: Nottingham, UK
Age: 55
Posts: 557
Question SetPeriod Sound Issues

I'm getting an odd error when trying to use the SetPeriod command in Blitz Basic to alter the pitch of a defined sound.

Here's the code, which creates a simple square wave and then tries to alter the pitch:

Code:
InitSound 0,128,450,0

For a=0 to 63
  SoundData 0,a,100
Next a

For a=64 to 128
  SoundData 0,a,-100
Next a

LoopSound 0,1
VWait 200

SetPeriod 0,250

LoopSound 0,1
VWait 200

Sound 0,1
End
It's dead simple, just a square wave, which sounds for 4 seconds (VWait 200)

However, when running the code all is well until the SetPeriod command is encountered. At this point I get an error saying "Illegal Chanel Mask". Bizarrely complete with mis-spelling of "Channel"... unless it is really something to do with perfume...

According to the Blitz manual, the SetPeriod command does not take a parameter for the audio channel, but purely a value for the pre-defined Period parameter of the Sound.

Any ideas?
LuMan is offline  
Old 20 January 2016, 06:26   #2
ReadOnlyCat
Code Kitten
 
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
First rule of debugging:
- strip the code to the bare minimum still exhibiting the bug

Do you still get the issue if you do:
Code:
InitSound 0, 128, 450, 0
For a=0 to 128
  SoundData 0, a, 100
Next a
LoopSound 0,1
SetPeriod 0, 250
If so, then try putting "127" in the loop instead of "128".
ReadOnlyCat is offline  
Old 20 January 2016, 10:48   #3
LuMan
Amigan - an' lovin' it!!
 
LuMan's Avatar
 
Join Date: Nov 2010
Location: Nottingham, UK
Age: 55
Posts: 557
The code works fine for the first part - although I did see a typo in my original post... The loop does go from 64 to 127, not 128

I've tried a number of different wave types - square, sine, saw, as well as loaded samples - and I always get the error when I try to amend the period....
LuMan is offline  
Old 20 January 2016, 12:27   #4
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
BUM7 says:
Syntax : SetPeriod Sound#,Period
Library : audiolib

Description:
Hmmm, not sure why we never included this command in the original
audiolib, SetPeriod simply allows the user to override the frequence
information (period) of the sound object after it has been loaded.

To alter a sound's pitch while playing programmers should hit the audio
hardware direct (hardware locations are listed at the back of the
reference manual).
idrougge is offline  
Old 20 January 2016, 14:58   #5
LuMan
Amigan - an' lovin' it!!
 
LuMan's Avatar
 
Join Date: Nov 2010
Location: Nottingham, UK
Age: 55
Posts: 557
Hehe. OK, so the command isn't working properly, then. That's OK, so long as I know. Saves me hours of flogging a dead horse!!

Thanks for the heads-up, idrougge. Taking a look at the reference manual now...

UPDATE:
WOW! There's a lot of useful stuff in the reference section at the end of the Blitz Manual!
So, the following bit of code resets the period to 256, thus making the pitch of the note higher:
Code:
Move.w #$00ff, $dff0a6
Sorted

Last edited by LuMan; 20 January 2016 at 15:51.
LuMan is offline  
Old 21 January 2016, 00:10   #6
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
I think the command you're looking for is Freq.
idrougge is offline  
Old 21 January 2016, 21:15   #7
LuMan
Amigan - an' lovin' it!!
 
LuMan's Avatar
 
Join Date: Nov 2010
Location: Nottingham, UK
Age: 55
Posts: 557
Quote:
Originally Posted by idrougge View Post
I think the command you're looking for is Freq.
Hmm.. This may be in later updates of BB2 for that Amiga, but it's certainly not a command in the version I have. There's no reference in the Manual, and, while I can find a reference to it on the internet, the command throws an error when I try to compile.
LuMan is offline  
Old 22 January 2016, 01:46   #8
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
There's no reason not to run the Ultimate Blitz CD version unless you have a floppy-only system.
idrougge is offline  
Old 22 January 2016, 20:56   #9
LuMan
Amigan - an' lovin' it!!
 
LuMan's Avatar
 
Join Date: Nov 2010
Location: Nottingham, UK
Age: 55
Posts: 557
Y'know, that's a good idea. I ought to dig it out, but I actually bought Blitz Basic 2 when if first came out and nostalgia sort of led me back to my original disk set.

I'll upgrade to the Ultimate version and make use of all those extra commands!!
LuMan is offline  
Old 22 January 2016, 21:12   #10
Mrs Beanbag
Glastonbridge Software
 
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
Quote:
Originally Posted by LuMan View Post
So, the following bit of code resets the period to 256, thus making the pitch of the note higher:
Code:
Move.w #$00ff, $dff0a6
no, it sets it to 255...
Mrs Beanbag is offline  
Old 23 January 2016, 20:51   #11
LuMan
Amigan - an' lovin' it!!
 
LuMan's Avatar
 
Join Date: Nov 2010
Location: Nottingham, UK
Age: 55
Posts: 557
Quote:
Originally Posted by Mrs Beanbag View Post
no, it sets it to 255...
Ha! Er.. Deliberate mistake, to see if anyone was reading it... <ahem>..
LuMan is offline  
Old 21 February 2016, 04:49   #12
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Found this in alt.sys.amiga.blitz…
Quote:
>BUG2:
> SetPeriod
>
> SetPeriod Generates a false debugger error: Illegal Channel Mask.
> The strange thing is that the message persist even when your#
> sound number happens to be a legal channel mask.
> Also, if you specify a number not corresponding to an existing
> sound, you get an Uninitialized sound error.
> The only workaround is to set errors off and on before and after
> the command,
Fixed on BUM9 sort of, I think... a replacement library called XBaudiolib
was in Blitzlibs:Testlibs which fixes/updates many of the Acid sound
commands. It uses exactly the same command syntax as the Acid lib but has
XB before it e.g. XBSound...
idrougge is offline  
Old 28 January 2017, 02:55   #13
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
There's a fix to SetPeriod in http://aminet.net/package/dev/basic/BlitzLstJan02
idrougge is offline  
Old 28 January 2017, 04:42   #14
Anakirob
Unregistered User
 
Anakirob's Avatar
 
Join Date: Nov 2005
Location: Tasmania
Age: 42
Posts: 893
This would be great, it's been a while since I coded in Blitz, but I recall telling my computer to get ****** every time I forgot to disable/re-enable the debugger around the Sound function. I'm curious as to which file contains the patch, is it this one:
Code:
BlitzLstJan02/attachments/mail_110/bugs2.2.bb2
I assume I just need to compile and run it.
Anakirob is offline  
Old 28 January 2017, 11:15   #15
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
It's attachments/mail_56/libfixes.lha. It claims to fix exactly the problem of SetPeriod not working in debug mode.
idrougge is offline  
Old 15 January 2021, 22:07   #16
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
OK this was driving me insane.
How exactly do I patch this, then? I have the libfixes.lha file but no idea how to patch the program.
I have the Blitz Ultimate CD but installing from there using the installer gives me an error about some file being write protected. I never was able to use that installer. Do I have a bad CD?

[edit] as soon as I use setperiod, I hear noise in my audio channel. Must not be using it right.

Last edited by Amiga1992; 15 January 2021 at 22:33.
Amiga1992 is offline  
Old 16 January 2021, 16:30   #17
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
There is a fixed installer on Aminet. http://aminet.net/package/dev/blitz/ubbinstall
idrougge is offline  
Old 18 January 2021, 17:08   #18
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Holy shit did they do nothing right? Thanks idrougge I'll have to try that.
Amiga1992 is offline  
Old 19 January 2021, 11:21   #19
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Also, there's the http://ubb.plus version of the CD that might be worth looking at. It's a relatively recent update to the Blitz CD that includes all the major updates, a fixed installer and an updated manual.

As for changing the pitch of a sample, back in the '90s I used SetPeriod and it worked fine, so that bug probably crept in later on in a certain version of the libraries. But it was limited in that it only took effect the next time the sample was played, since it simply alters the period value associated with the sample. If that's all you need, you can easily modify the sound object's parameters directly using something like this:

Code:
*MySound.sound = Addr Sound(1)
*MySound\_period = 500
You'll need the bb2objtypes.res added to the compiler settings for the sound Newtype to be available.

If changing the pitch during the sample being played is the intended result, then the Freq command should do the job instead, or you can poke the desired period values directly into the chipset registers for the desired channels.
Daedalus is offline  
Old 19 January 2021, 15:16   #20
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by Daedalus View Post
But it was limited in that it only took effect the next time the sample was played, since it simply alters the period value associated with the sample. If that's all you need, you can easily modify the sound object's parameters directly using something like this:

[...]
If changing the pitch during the sample being played is the intended result, then the Freq command should do the job instead, or you can poke the desired period values directly into the chipset registers for the desired channels.
Are you referring to this other thread I created? Because I tried to do this and I didn't get it to work. I'm gonna update that thread with the code I am using, maybe you can shed some light.
Amiga1992 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
WHDLoad IK+ Sound issues lurch support.Games 3 27 March 2015 18:48
Roadkill sound issues Steve support.WinUAE 0 11 May 2014 19:41
Sound issues? thermalthong support.Hardware 18 02 November 2012 18:14
A1200 sound issues arnljot support.Hardware 5 06 February 2008 13:16
Even more sound timing issues... andreas support.WinUAE 11 30 November 2005 11:23

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:38.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.21558 seconds with 15 queries