1. Rock Band Clone - Update
- Posted by Lone_EverGreen_Ranger Nov 28, 2011
- 1446 views
Hello All,
I am in the process of writing a rock band/guitar hero type clone in Euphoria. I was wondering if there was any audio libraries that supported 3D sound. I see many that support 2D. I'm also looking to see if anyone else would be interested in developing a project like this. I have a design document written out, containing most of the info and what I want. I know I don't really have anything to show, except a DD, but I'm not a artist, so I can't really draw any logos or anything. I can code, though.
Update: Below I have started on a database. I am posting a rough draft here to see if I am doing it right. Any help, I'd appeircate.
without warning without type_check include std/graphics.e include std/image.e include std/io.e include std/os.e include std/eds.e include std/wildcard.e include std/filesys.e include std/datetime.e include std/rand.e include std/get.e include std/task.e include std/text.e constant FORMAT = {"EubandSong *.eusong"} constant SONG_TITLE = 1, SONG_ARTIST = 2, SONG_ALBUM = 3, SONG_YEAR = 4, SONG_IMAGE = 5 constant SONG_DIFF_EASY = 1, SONG_DIFF_MEDIUM = 2, SONG_DIFF_HARD = 3, SONG_DIFF_EXPERT = 4, SONG_DIFF_NOFAIL = 5, SONG_DIFF_REAL = 6, SONG_DIFF_REAL_EASY = 7, SONG_DIFF_REAL_MEDIUM = 8, SONG_DIFF_REAL_HARD = 9, SONG_DIFF_REAL_EXPERT = 10 constant SONG_TRACK = 1, SONG_BPM = 2, SONG_TRACK = 3, SONG_MASTER = 4, SONG_COVER = 5 constant SONG_GENRE = 1 constant SONG_TRACKS = 1, SONG_TRACK_GUITAR = 2, SONG_TRACK_DRUMS = 3, SONG_TRACK_BASS = 4, SONG_TRACK_KEYBOARDS = 5, SONG_TRACK_VOCALS = 6 sequence song_title = "noname" sequence SongDB = "SongDatabase" sequence SongTable = "SongTable" if db_create(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Database could not be created") abort(1) else if db_open(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Could not open database") abort(1) end if else if db_select(SongDB) != DB_OK then puts(1,"Could select database") abort(1) end if else if db_create_table(SongTable) != DB_OK then puts(1,"Could not create table") abort(1) end if else if db_insert(song_title,{SONG_TITLE}) != DB_OK then puts(1,"Failed to insert song title data") abort(1) end if db_close(SongDB) end if
2. Re: Rock Band Clone - Update
- Posted by petelomax Nov 29, 2011
- 1406 views
Below I have started on a database. I am posting a rough draft here to see if I am doing it right. Any help, I'd appeircate.
Yeah, that needs rewriting. Get into the habit of saving the result codes from db_open etc so you can perform >1 test on them and optionally display the error code in a message.
You want to try and open the database, and if it does not exist, then try and create it, not the other way round. Below is an unaltered copy of the Edita db routine. (As an example only, there is code here that you certainly won't need.)
procedure initEditaEdb() -- -- open/create the edita database -- sequence tlist object exh integer errCode sequence Fkey errCode = db_open(initialcurrentdir&editaEDB,DB_LOCK_EXCLUSIVE) if errCode!=DB_OK then if errCode = DB_LOCK_FAIL then void = proemh("Error","edita.edb locked, aborting",0) abort(0) elsif db_create(initialcurrentdir&editaEDB,DB_LOCK_EXCLUSIVE)!=DB_OK then void = proemh("Error","error creating edita.edb",0) ?9/0 end if end if isOpen = 1 tlist = db_table_list() for i=1 to length(Tset) do if not find(Tset[i],tlist) then if i=1 then --"version" not present; delete the lot. (pre 0.2.0) for j=1 to length(tlist) do db_delete_table(tlist[j]) end for tlist = {} end if if db_create_table(Tset[i])!=DB_OK then DBfatal("error creating "&Tset[i]&" table",CRASHALWAYS) elsif i=1 then -- if db_insert(1,{0,2,0})!=DB_OK then if db_insert(1,{0,3,3})!=DB_OK then DBfatal("error inserting version record",CRASHALWAYS) end if end if end if end for -- -- get the version -- SelectTable(Tversion) dbversion = db_record_data(1) if compare(dbversion,{0,3,3})<0 then -- 0.2.0 (pre 0.3.3/usegpp) needVedb = 1 -- (Tversion is [eventually] set to {0,3,3} by vedb.exw) end if -- -- Plug in the elng_xxx.exh file for automatic builtin load... -- exh = getexhname() if sequence(exh) then void = logFile(exh[1],exh[2],0) -- ie add to background task list ) end if -- -- Load the default macros now -- (A macro saved as eg "F7default" [by editing the top box] will load as -- the default for F7, whereas "F7" is "this session only". Note that it -- handles multiple macros starting F7 alphabetically, so if you defined -- both "F7default" and "F7zzz", the latter would override the former. -- Of course macros can hold something named eg "paste and find next", -- which will only be available after manually assigning it to a key.) -- MacroKeys = repeat({},4) SelectTable(Tmacros) for i=1 to db_table_size() do Fkey = db_record_key(i) if length(Fkey)>2 then if Fkey[1]>'F' then exit end if if Fkey[1]='F' then if Fkey[2]>'9' then exit end if if Fkey[2]>='6' then MacroKeys[Fkey[2]-'5'] = db_record_data(i) end if end if end if end for DBclose() end procedure
HTH, Pete
3. Re: Rock Band Clone - Update
- Posted by Lone_EverGreen_Ranger Nov 29, 2011
- 1405 views
Thanks, I knew I was doing something a little off.
4. Re: Rock Band Clone - Update
- Posted by ghaberek (admin) Nov 29, 2011
- 1414 views
To extend Pete's comments, here are the typical wrapper functions I use all the time. I especially like db_auto_insert() which auto-numbers the key field for quick-and-dirty insert operations. Also, you may want to consider Matt's EuSQL on a project of this size.
global function db_load( sequence name, integer mode = DB_LOCK_EXCLUSIVE ) integer retval retval = db_select( name ) if retval = DB_OK then return retval end if retval = db_open( name, mode ) if retval = DB_OK or retval = DB_LOCK_FAIL then return retval end if return db_create( name, mode ) end function global function db_load_table( sequence name ) integer retval retval = db_select_table( name ) if retval = DB_OK then return retval end if return db_create_table( name ) end function global function db_auto_insert( object data ) integer count, key count = db_table_size() if count > 0 then key = db_record_key( count ) else key = 0 end if return db_insert( key + 1, data ) end function
-Greg
5. Re: Rock Band Clone - Update
- Posted by Lone_EverGreen_Ranger Nov 29, 2011
- 1379 views
I appericate the help, but I am still having trouble getting the database created. I've tried multiple things. Would it be possible that anyone could use my code and apply it, so that it is done correctly? I'd greatly appericate it. I did this before, but its been so long, I've forget how to do it.
6. Re: Rock Band Clone - Update
- Posted by ghaberek (admin) Nov 29, 2011
- 1277 views
How's this?
if db_select(SongDB) != DB_OK then puts(1,"Could not select database\n") if db_open(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Could not open database\n") if db_create(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Database could not be created\n") abort(1) end if end if end if if db_select_table(SongTable) != DB_OK then puts(1,"Could not select table\n") if db_create_table(SongTable) != DB_OK then puts(1,"Could not create table\n") abort(1) end if end if if db_insert(song_title,{SONG_TITLE}) != DB_OK then puts(1,"Could not insert song table\n") abort(1) end if db_close(SongDB)
-Greg
7. Re: Rock Band Clone - Update
- Posted by Lone_EverGreen_Ranger Nov 29, 2011
- 1352 views
How's this?
if db_select(SongDB) != DB_OK then puts(1,"Could not select database\n") if db_open(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Could not open database\n") if db_create(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Database could not be created\n") abort(1) end if end if end if if db_select_table(SongTable) != DB_OK then puts(1,"Could not select table\n") if db_create_table(SongTable) != DB_OK then puts(1,"Could not create table\n") abort(1) end if end if if db_insert(song_title,{SONG_TITLE}) != DB_OK then puts(1,"Could not insert song table\n") abort(1) end if db_close(SongDB)
-Greg
Thanks, but it still didn't work, I copied it word for word. All the errors that say could not select database, table, etc all appeared when I tried to run the program.
8. Re: Rock Band Clone - Update
- Posted by DerekParnell (admin) Nov 30, 2011
- 1354 views
I appericate the help, but I am still having trouble getting the database created. I've tried multiple things. Would it be possible that anyone could use my code and apply it, so that it is done correctly? I'd greatly appericate it. I did this before, but its been so long, I've forget how to do it.
This might help...
include std/eds.e sequence SongDB = "songs.edb" sequence SongTable = "song" atom song_id sequence song_data integer idkey if db_select(SongDB) != DB_OK then if db_open(SongDB, DB_LOCK_NO) != DB_OK then if db_create(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Database could not be created\n") abort(1) end if end if db_select(SongDB) -- Select the database after open/create end if if db_select_table(SongTable) != DB_OK then if db_create_table(SongTable) != DB_OK then puts(1,"Could not create table\n") abort(1) end if db_select_table(SongTable) -- Select the table after create. end if -- example data song_data = {"I Wanna Hold Your Hand", "The Beatles", {1963,10,17}, {"rock","pop"},"Lennon/McCartney"} -- Generate a unique ID for this song. song_id = hash(song_data[1..3], SongTable) idkey = db_find_key( song_id ) if idkey < 0 then if db_insert(song_id,{song_data}) != DB_OK then puts(1,"Could not insert song table\n") abort(1) else printf(1, " Song ID: %d added.\n", song_id) end if else song_data = db_record_data(idkey) printf(1, " Song ID: %d\n", song_id) if length(song_data) = 1 then song_data = song_data[1] printf(1, " Title: %s\n", {song_data[1]}) printf(1, " Artist: %s\n", {song_data[2]}) printf(1, "Recorded: %02dd%02dm%4d\n", {song_data[3][3],song_data[3][2],song_data[3][1]}) printf(1, "Composer: %s\n", {song_data[5]}) if length(song_data[4]) > 0 then puts(1, " Genre: ") for i = 1 to length(song_data[4]) do printf(1, "%s ", {song_data[4][i]}) end for puts(1, "\n") end if else puts(1, "data no longer exists\n") end if end if db_close()
9. Re: Rock Band Clone - Update
- Posted by ChrisB (moderator) Nov 30, 2011
- 1339 views
Hi
Or you could use sqlite, which is the industry standard small compact, ultrafast standalone databse system, in use by thousands of applications world wide, including, phones, web sites etc etc, making your application eminently upscalable should you need to transfer to another operating system or platform, and uses a large subset of standard sql query language.
I find it a lot easier to use than eudb, but its actually not a great deal faster (surprisingly), and I am biased.
Chris
10. Re: Rock Band Clone - Update
- Posted by Lone_EverGreen_Ranger Nov 30, 2011
- 1271 views
I appericate the help, but I am still having trouble getting the database created. I've tried multiple things. Would it be possible that anyone could use my code and apply it, so that it is done correctly? I'd greatly appericate it. I did this before, but its been so long, I've forget how to do it.
This might help...
include std/eds.e sequence SongDB = "songs.edb" sequence SongTable = "song" atom song_id sequence song_data integer idkey if db_select(SongDB) != DB_OK then if db_open(SongDB, DB_LOCK_NO) != DB_OK then if db_create(SongDB, DB_LOCK_NO) != DB_OK then puts(1,"Database could not be created\n") abort(1) end if end if db_select(SongDB) -- Select the database after open/create end if if db_select_table(SongTable) != DB_OK then if db_create_table(SongTable) != DB_OK then puts(1,"Could not create table\n") abort(1) end if db_select_table(SongTable) -- Select the table after create. end if -- example data song_data = {"I Wanna Hold Your Hand", "The Beatles", {1963,10,17}, {"rock","pop"},"Lennon/McCartney"} -- Generate a unique ID for this song. song_id = hash(song_data[1..3], SongTable) idkey = db_find_key( song_id ) if idkey < 0 then if db_insert(song_id,{song_data}) != DB_OK then puts(1,"Could not insert song table\n") abort(1) else printf(1, " Song ID: %d added.\n", song_id) end if else song_data = db_record_data(idkey) printf(1, " Song ID: %d\n", song_id) if length(song_data) = 1 then song_data = song_data[1] printf(1, " Title: %s\n", {song_data[1]}) printf(1, " Artist: %s\n", {song_data[2]}) printf(1, "Recorded: %02dd%02dm%4d\n", {song_data[3][3],song_data[3][2],song_data[3][1]}) printf(1, "Composer: %s\n", {song_data[5]}) if length(song_data[4]) > 0 then puts(1, " Genre: ") for i = 1 to length(song_data[4]) do printf(1, "%s ", {song_data[4][i]}) end for puts(1, "\n") end if else puts(1, "data no longer exists\n") end if end if db_close()
Thanks Derek, this looks really useful. The only thing is how would I make it so that you can add custom songs?
11. Re: Rock Band Clone - Update
- Posted by DerekParnell (admin) Nov 30, 2011
- 1323 views
The only thing is how would I make it so that you can add custom songs?
I just made up some data to show as an example. You would have to work out what fields you need in a SONG record and get the data to populate those fields from some external place, such as someone typing them into the application.
You could then make the 'insert' code into a function that you passed the SONG record to. The unique record key that I used is just generated from some fields whose data will both uniquely identify a particular song and will never change for that song. For this example I just used a simple atom to hold the hash value (record key) and that should be adequate for songs but to make sure you could change the generation function to ...
function add_new_record(sequence TableName, sequence RecordFields, integer IDFldLow, integer IDFldHigh) object record_key integer record_id integer dbres dbres = db_select_table(TableName) if dbres != DB_OK then return {1, "Table not found", dbres} end if record_key = RecordFields[IDFldLow..IDFldHigh] record_key = hash(record_key, TableName) & hash(record_key, record_key) record_id = db_find_key(record_key) if record_id < 0 then dbres = db_insert(record_key, RecordFields) if dbres != DB_OK then return {2, "DB Insert failed", dbres} else return {0, -record_id} -- insert success, return new record's id. end if else return {3, record_id} -- already in db, return record's id. end if end function object SongData sequence res while 1 do SongData = Get_Song_Details() if atom(SongData) then exit end if res = add_new_record(SongTable, SongData, 1, 3) if res[1] != 0 then Handle_Error(res, SongTable, SongData) end if end while
12. Re: Rock Band Clone - Update
- Posted by Lone_EverGreen_Ranger Nov 30, 2011
- 1245 views
The only thing is how would I make it so that you can add custom songs?
I just made up some data to show as an example. You would have to work out what fields you need in a SONG record and get the data to populate those fields from some external place, such as someone typing them into the application.
You could then make the 'insert' code into a function that you passed the SONG record to. The unique record key that I used is just generated from some fields whose data will both uniquely identify a particular song and will never change for that song. For this example I just used a simple atom to hold the hash value (record key) and that should be adequate for songs but to make sure you could change the generation function to ...
function add_new_record(sequence TableName, sequence RecordFields, integer IDFldLow, integer IDFldHigh) object record_key integer record_id integer dbres dbres = db_select_table(TableName) if dbres != DB_OK then return {1, "Table not found", dbres} end if record_key = RecordFields[IDFldLow..IDFldHigh] record_key = hash(record_key, TableName) & hash(record_key, record_key) record_id = db_find_key(record_key) if record_id < 0 then dbres = db_insert(record_key, RecordFields) if dbres != DB_OK then return {2, "DB Insert failed", dbres} else return {0, -record_id} -- insert success, return new record's id. end if else return {3, record_id} -- already in db, return record's id. end if end function object SongData sequence res while 1 do SongData = Get_Song_Details() if atom(SongData) then exit end if res = add_new_record(SongTable, SongData, 1, 3) if res[1] != 0 then Handle_Error(res, SongTable, SongData) end if end while
Thanks. I'll work with it tonight.