Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CarlLawl · Sep 11, 2011 at 05:03 PM · soundmusicrhythm

Guitar Hero style game?

After browsing through unity answers and having a quick look on google there doesn't seem to be much info on the subject (that i could see)

I wondered what sort of things I should look at if I wanted to make something like Guitar Hero or Flash Flash Revolution (a music rhythm game)

I guess the first thing would probably taking the BPM and dividing it by 60 to get the beats per second but I'm pretty stuck from there, I've never really touched on this side of things before

I did notice there was a package in the asset store but im skint :(

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sacredgeometry · Sep 11, 2011 at 05:10 PM 0
Share

$$anonymous$$aybe being more specific about the problem would be a good idea.

avatar image CarlLawl · Sep 11, 2011 at 05:20 PM 0
Share

How do you mean be specific? I'm just curious and wanted to learn how to make something similar

so making events happen in time to music?

avatar image sacredgeometry · Sep 11, 2011 at 05:31 PM 0
Share

By specific i mean ask specific questions about specific problems. If you havent even started or attempted to tackle anything then how can you know what problems you have with it. If you honestly dont know what to do next then you might be tackling something to far out of your current abilities.

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bovine · Sep 11, 2011 at 06:54 PM

I agree with @Brian 2, your question is too vague. If you're asking "How do I take any piece of music and turn that into game input requirements" then I would suggest that you probably don't, but that you should do some of:

  • Create some simple gameplay elements for the player to achieve - i.e. tap this now, tap this twice, tao and hold.

  • Make these elements generic so that they can be required anywhere

  • Create an Editor or EditorWindow that allows you to:
    • Create some meta data for each track for when elements should appear for a given track

    • Display a waveform representation of the track in question

    • Add some controls to insert these elements

  • Some playback object will read these elements

  • Present them to the player so they know what inputs to do when

  • Determine the success of each of the elements, plus any combos where multiple elements succeed within a given timeframe

You should then be able to associate meta data with any track and on playing that track the input elements would be displayed and the user should be able to attempt to meet that criteria.

That is the game side of things, or at least a starting point for an approach.

If you wish to render something dynamic to music then you want some sort of audio/music visualisation - you should look at examples for programs like WinAmp for inspiration, but basically these all work by creating some visualisation that takes things like the amplitude and rate of change and any other parameter of a waveform you can take as inputs and render something visual.

There is a question on a 'similar' site here on this branch of the question:

http://stackoverflow.com/questions/153712/creating-music-visualizer

From a Unity perspective this would be rendering pixels, which might be tough, so you would want to create a plugin that modifies an area of RAM representing the background area which you can then dump this into a texture. if you're a pro user you can probably access the rendering pipeline and do this with a texture you can write to and update efficiently. This is a whole other set of questions of course...

Hopefully there are some ideas. Clearly this is off the top of my head thinking, but hopefully it'll be a starting point. I suggest you make the question much clearer.

Thanks Bovine

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image A-man tuna · Nov 17, 2012 at 05:07 PM 0
Share

i know this may seem like i am asking of 2 much but i am really new to unity and i am making something like guitar hero for my I.T project, do you think you could post scripts for each of these, or provide some links for these things in javascript. thanks i would really appreciate it.

avatar image Bovine · Nov 17, 2012 at 05:24 PM 0
Share

This is a potentially ambitious project if you are new to Unity.

$$anonymous$$y strong suggestion would be to pick some very simple game type as the full set of features of any game, however small, is already a lot, aside from the complexity of this kind of app.

I cannot recommend this enough, especially if you've never created a game before now.

Some suggestions are:

  • Two-player tick tack toe - no AI

  • One or two player of same (+AI)

  • A packman type game, could be 2D, 3D or 2.5D

  • A space invader type game

If music has to be involved, how about a simple keyboard layout and having to copy some pre-defined short sequences of music, maybe starting with three notes and building up to more and to including longer notes. Even this, simplification is starting to get complex however...

Software development is a very difficult thing to plan or to estimate, as, by its nature, you create something new every time, even if you have components to help with. It is a common failing of both new-comers and professionals to underestimate the work involved. Hence there are all sorts of Agile methodologie that have spring up, such as Scrum.

I cannot stress enough that you should make your scope very simple, at least to begin with, and concentrate on functionality, rather than either things that make the game look cool, or are fun.

Apologies for the sermon, but I hear this question a lot, and it's taken me oooh, over twenty-five years to fully appreciate the $$anonymous$$ISS principal. And even now, I am over two-years into my second iOS project because I failed to do just that!

Good Luck.

avatar image A-man tuna · Nov 18, 2012 at 09:20 AM 0
Share

=P my mom said the same thing, thanks for your help and suggestion but i don't think i can change my project now,i know quite a lot of stuff just no scripting =( but thank you for your suggestion and i will be sure to use it for next time

avatar image
4

Answer by aldonaletto · Sep 12, 2011 at 12:40 PM

If you want to create something based on an arbitrary music file (mp3, wav, ogg) you must analyse the sound spectrum with GetSpectrumData and check the volume of certain frequency ranges. Usually, the rhythm is marked by the bass guitar and the bass drum - both in a lower frequency range, about 20 to 200 Hz. You can detect peaks in this frequency range to sync something with the rhythm, for instance. You can also monitor other frequency ranges to add other events - as in the game you've linked at http://www.youtube.com/watch?v=EbHO1ZYhtLk
In some cases you must analyse the music with some anticipation in order to create objects ahead of the player that will be in sync when it reaches them (like in GuitarHero or in the referenced game). To do that, you should play and analyse the song in an object located far away from the listener, and play the music in a near object with the required delay: if you need 0.5 seconds of anticipation, for instance, start the music in the far object and 0.5 seconds after start it in the near object.
The function BandVol below calculates the volume of a given frequency range. You must call GetSpectrum to get a snapshot of the sound currently being played in the object's AudioSource, then you can analyse several different frequency bands. This script must be attached to an object with AudioSource, and you must drag three objects (cubes, spheres, whatever) to bass, mid and treb in the Inspector. When the song is playing, the Y coordinate of each object will be proportional to the frequency range it monitors. You can extend this script to several bands, until you find the ones you want.

private var freqData: float[]; private var nSamples: int = 1024; private var fMax: float;

function GetSpectrum(){ // get spectrum: freqData[n] = vol of frequency n * fMax / nSamples audio.GetSpectrumData(freqData, 0, FFTWindow.BlackmanHarris); }

function BandVol(fLow:float, fHigh:float): float { fLow = Mathf.Clamp(fLow, 20, fMax); // limit low... fHigh = Mathf.Clamp(fHigh, fLow, fMax); // and high frequencies var n1: int = Mathf.Floor(fLow nSamples / fMax); var n2: int = Mathf.Floor(fHigh nSamples / fMax); var sum: float = 0; // average the volumes of frequencies fLow to fHigh for (var i=n1; i]

var bass: Transform; var mid: Transform; var treb: Transform; var volume: float = 20; private var yBass: float; private var yMid: float; private var yTreb: float;

function Start(){ // GetSpectrumData initialization fMax = AudioSettings.outputSampleRate/2; freqData = new float[nSamples]; // example initialization yBass = bass.position.y; yMid = mid.position.y; yTreb = treb.position.y; }

function Update(){ GetSpectrum(); bass.position.y = yBass+volume*BandVol(20, 200); mid.position.y = yMid+volume*BandVol(300, 1800); treb.position.y = yTreb+volume*BandVol(5000, 20000); } Don't expect to get too much precision - like detecting exactly which note is playing, for instance. Songs generally have lots of instruments and voices sounding together, which makes a precise pitch evaluation very hard - if not impossible at all.
NOTE: I didn't test this whole script, so please let me know if you get any errors.
EDITED: Fixed some typo errors, and included a compensation for the typical "equal energy per octave" distribution of frequencies in most sounds - the harmonics are more spaced at higher frequencies, so the average value returned by BandVol is reduced at higher frequencies.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sacredgeometry · Sep 12, 2011 at 12:50 PM 0
Share

This is exactly why i didnt bother going over this route, its completely hit and miss and getting precise note evaluation or even precise rhythmic evaluation is very hard if impossible to do in realtime.

Its much better to have some system of event notation. And what better way than using an established standard :) regardless I hope he has the information he needs.

avatar image Bovine · Sep 12, 2011 at 01:16 PM 0
Share

I don't think this would be something you'd want to do in-game but might be useful for adding some default/marker notation to some editor view of a given piece of music.

avatar image aldonaletto · Sep 12, 2011 at 05:38 PM 0
Share

You both are right: there's no way to get precise pitch evaluation from complex sounds like CD songs. I'm sure that Guitar Hero uses some form of sync - a parallel file, like @Bovine proposed, or via midi events, like @$$anonymous$$ 2 said (they don't synthesize the instruments, but there's a "wave" mode in midi which allows reproduction of recorded sounds, while other midi events can run in other channels).
But the game linked by @CarlLawl extracts some info from an arbitrary music file to create the character path with sync'ed events - they appear ahead of it, but are in sync when the character reach them.

avatar image sacredgeometry · Sep 13, 2011 at 11:38 AM 0
Share

Are you sure it does? the only way to know for sure is if the game lets you stick in any music you want, to be honest that would be the only reason i could see to attempt it that way. For "ease" of the users.

avatar image aldonaletto · Sep 14, 2011 at 02:01 AM 0
Share

Yes, it allows to choose an arbitrary audio file, and creates the path based on the music (kind of, at least). Watch this video: http://youtu.be/omk8uh89W$$anonymous$$4

avatar image
0

Answer by walleta · Mar 13, 2012 at 02:54 AM

ammm hi just come to give an idea works well guitar hero the song is divided in guitar, bass, drums and what we do not play the song bone background are all synchronized and analyzed together midi files containing the notes as it were a great example is frets on fire as well as working guitar hero 3

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Calculating rhythm of any music? 3 Answers

Setting menu music 1 Answer

Quick Questions about sounds for my game. 1 Answer

Theme music for approach to object question 1 Answer

Why can't I hear my audio? 5 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges