Jump to content

Python Music/Sound Code record for killing piece in favor or against the computer


zak100

Recommended Posts

Hi,

Kindly guide me some code for producing sound or music which I can use for indicating that a computer piece has been killed or the computer has killed the piece. Small file just executable for 2 or 3 secs. I am working in text mode.

 

Zulfi.

Link to comment
Share on other sites

55 minutes ago, zak100 said:

Kindly guide me some code for producing sound or music which I can use for indicating that a computer piece has been killed or the computer has killed the piece. Small file just executable for 2 or 3 secs. I am working in text mode.

print("\a")

The line of code plays the bell sound, which differ from environment to environment.
It fulfils the requirements stated in OP: It is some code, producing sound or music. It is a small file (one line) and these type of sound files (where files are used) in the OS are usually small and contains a few seconds of sound. It works in text mode*; there will be a visible bell if audio is disabled in the terminal.

 

*) I made a guess what "I am working in text mode" means.

Edited by Ghideon
explanation added and improved
Link to comment
Share on other sites

Hi,

Thanks all, I had a very short time but appreciate your efforts. Any other would definitely benefit from it. However, I used only : print("\a"). This was a great experience. I have once developed cross and zero game but 8-board game proved very lengthy for me and I did it using Python. Definitely this experience woul help me if I learn some ML skills also in Python.

 

God blesses you all.

 

Zulfi.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.