Considering to start programming with PureBasic

Everything else that doesn't fall into one of the other PB categories.
Rudy
New User
New User
Posts: 3
Joined: Sun Jan 28, 2018 4:00 pm

Considering to start programming with PureBasic

Post by Rudy »

My first post on this forum, hello to everybody here. :)

It has been a while I did some programming, but I have an idea for a project and I need to do some coding. For this, I'm considering PureBasic. It involves audio synthesis, for now not in realtime. I also looked at things like SuperCollider, but I think writing it in a language like PureBasic makes it easier for other people who might be interested to use my software. Correct me if I'm wrong, but I'm especially drawn to PureBasic because I've read it produces small executables with little to no dependencies, with good execution speeds. So it should work on almost all computers?

Basically what I want to do: reading WAV-files, perform a whole lot of calculations on the data, writing the results as a WAV-file. I hope it's not too complicated to read and write WAV-files? Another question, if it's possible to say anything about it in general, is PureBasic faster with calculations on integers or floats?

Of course I've looked at some topics here on the forum and examples of code, to be honest it all looks a bit overwhelming. I do have some experience with programming, but that's a long time ago. Examples are: GWBasic, TurboBasic and TurboPascal. All of them in the DOS-era. So it has been ages. I just hope the learning curve is not too steep for an old dinosaur like me... :wink:
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Considering to start programming with PureBasic

Post by Mijikai »

Since PB is not a interpreted language and even allows inline ASM - speed wont be a problem.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Considering to start programming with PureBasic

Post by wilbert »

Rudy wrote:Basically what I want to do: reading WAV-files, perform a whole lot of calculations on the data, writing the results as a WAV-file. I hope it's not too complicated to read and write WAV-files? Another question, if it's possible to say anything about it in general, is PureBasic faster with calculations on integers or floats?
PureBasic is a really nice language.

The wav format is not that difficult to handle but you will have to parse the files yourself if you want to access the sample data.
Myself together with J. Baker created an application with PureBasic called Macrotune which can output the audio it generates to a wav file.
http://www.posemotion.com/macrotune/
There are other examples on the forum as well of users who created an application using PureBasic which works with audio samples.

When it comes to floats vs integers, both are pretty fast and you can speed up time critical parts with ASM when needed.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Considering to start programming with PureBasic

Post by J. Baker »

If you used TurboBasic (PowerBasic) then you will be fine picking up PureBasic. Instead of CALL and SUB, you can write a Procedure() in PureBasic and call it by its procedural name that you have given it. This, of course, can be used multiple times throughout your code. Everything else is kind of similar, basic-wise, and shouldn't be hard to pick up on. ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
Rudy
New User
New User
Posts: 3
Joined: Sun Jan 28, 2018 4:00 pm

Re: Considering to start programming with PureBasic

Post by Rudy »

Thank you all for your reply. Right now I'm going through the documentation, there are a lot of commands in PureBasic, some 1400 or so? :shock: On one hand, that's good, on the other hand, maybe there a risk you code something and many lines later you discover there is a simple command for that? :)
J. Baker wrote:If you used TurboBasic ...
Yes, although it has been a while. But if it's all somewhat similar, that helps.
I'm seriously considering to give it a shot, so in that case, expect a lot more questions from me in the near-future. :wink:
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Considering to start programming with PureBasic

Post by Dude »

Rudy wrote:I'm seriously considering to give it a shot
There's a demo version that you can try. Since you came from GWBasic, you'll find PureBasic easy enough to pick up. And we're all here to help if you need it. :)
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Considering to start programming with PureBasic

Post by Bitblazer »

Welcome to PureBasic. I guess you already noiced two major important points by your posting.
  • the community exists and is active
    the community is helpful
Both crucial points if you want to get things done with a new language :)

Let me maybe add another crucial point: compatibility / extensibility
When i try to work with audio data like wav for a free project, i include the latest BASS library first. A few lines later, your project has always the same kind of audio buffer you work with and its suddenly able to process lots of audio formats with plenty of options and check the licensing in case your software goes commercial. Its quite fair IMHO.

Code: Select all

XIncludeFile "DShowMedia.pbi"
XIncludeFile "Bass/PB/bass.pbi"

If (BASS_Init(0, 128000, 0, 0, 0) <> 1)
  MessageRequester("Error", "BASS initialisation failed", #PB_MessageRequester_Ok)
  End 999
EndIf
I rarely work with audio files, so these lines are from an old tool done 2008, so i am hesitating to post the include files it uses, but if you have any problems, just send me a private message. You should get more current ones from the web though at the BASS website or forum. Welcome to PureBasic again :)

A tiny snippet how (stone old) software works with BASS and PureBasic

Code: Select all

  BassHSTREAM = BASS_StreamCreateFile(#False, @DataName$, 0, 0, #BASS_STREAM_DECODE)

  If (BassHSTREAM = 0)
;    BassErrorCode = BASS_ErrorGetCode()
    Result = -3
    Goto GetAudioFileInfo_CleanUp
  EndIf
  
  ChannelLength.q = BASS_ChannelGetLength(BassHSTREAM, #BASS_POS_BYTE)
  BTime.f = BASS_ChannelBytes2Seconds(BassHSTREAM, ChannelLength)
pretty easy imho.

ps: you can clearly see how old and unprofessional this snippet is - i even used GOTO :D
webpage - discord chat links -> purebasic GPT4All
Rudy
New User
New User
Posts: 3
Joined: Sun Jan 28, 2018 4:00 pm

Re: Considering to start programming with PureBasic

Post by Rudy »

Thanks to everybody for your comments and suggestions. It felt like a very warm welcome to this forum, and an invitation to join the PB club! :)
Post Reply